PropertyPatternMessageColorizer implements MessageColorizer { @Override public Collection<MessageFragmentStyle> colorize(String message) { Collection<MessageFragmentStyle> list = new ArrayList<>(); StyleContext styleContext = new StyleContext(); for (int i = 0; i <= groupCount; i++) { if (StyleProperties.isStyleForGroupDeclared(i, configuration)) { Style style = StyleProperties.getStyle(theme.themeType(), styleContext, configuration, "propStyle" + getName(), i); list.addAll(MessageColorizerUtils.colorizeRegex(style, message, pattern, i)); } } return list; } PropertyPatternMessageColorizer(Theme theme); void init(InputStream in); void store(OutputStream out); @Override boolean colorizingNeeded(String message); @Override Collection<MessageFragmentStyle> colorize(String message); @Override String getName(); @Override String getDescription(); @Override String getPluginableId(); @Override int getApiVersion(); String getFile(); void setFile(String file); String getTestMessage(); void setTestMessage(String testMessage); void setName(String name); static final String PROP_TYPE; static final String PROP_VERSION; static final String PROP_NAME; static final String PROP_DESCRIPTION; static final String PROP_PATTERN; static final String PROP_PATTERN_CANON_EQ; static final String PROP_PATTERN_CASE_INSENSITIVE; static final String PROP_PATTERN_COMMENTS; static final String PROP_PATTERN_DOTALL; static final String PROP_PATTERN_LITERAL; static final String PROP_PATTERN_MULTILINE; static final String PROP_PATTERN_UNICODE_CASE; static final String PROP_PATTERN_UNIX_LINES; static final String PROP_TEST_MESSAGE; }
@Test public void testColorize() throws BadLocationException { String message = "a55(a)a"; Collection<MessageFragmentStyle> colorize = colorizer.colorize(message); assertEquals(2, colorize.size()); ArrayList<MessageFragmentStyle> list = new ArrayList<>(colorize); MessageFragmentStyle messageFragmentStyle = list.get(0); MessageFragmentStyle messageFragmentStyle1 = list.get(1); assertEquals(messageFragmentStyle.isReplace(), false); assertEquals(messageFragmentStyle.getOffset(), 0); assertEquals(messageFragmentStyle.getLength(), message.length()); Style style = messageFragmentStyle.getStyle(); assertEquals(StyleConstants.getBackground(style), new Color(0, 255, 255)); assertEquals(StyleConstants.getForeground(style), new Color(255, 255, 0)); assertEquals((Boolean) StyleConstants.isBold(style), Boolean.FALSE); assertEquals((Boolean) StyleConstants.isItalic(style), Boolean.TRUE); assertEquals(messageFragmentStyle1.isReplace(), false); assertEquals(messageFragmentStyle1.getOffset(), 1); assertEquals(messageFragmentStyle1.getLength(), 5); Style style1 = messageFragmentStyle1.getStyle(); assertEquals(StyleConstants.getBackground(style1), new Color(0, 0, 255)); assertEquals(StyleConstants.getForeground(style1), new Color(255, 0, 0)); assertEquals((Boolean) StyleConstants.isBold(style1), Boolean.TRUE); assertEquals((Boolean) StyleConstants.isItalic(style1), Boolean.FALSE); }