public synchronized void addRow(StyleRule config) { styleRules.add(config); }
public ConfigTableModel(Resources messages, StyleRules styleRules) { super(); this.messages = messages; this.styleRules = styleRules; styleRules.addListener(this); styleRules.addStyleRuleListener(this); }
public static StyleRules getSyslogStyleRules() { StyleRules rules = new StyleRules("Syslog"); rules.setLogBlockPatternBeginsBlock(false); rules.setLogBlockPattern(Pattern.compile("((\\n\\r?)|(\\r\\n?))")); StyleRule kernel = new StyleRule(); kernel.setPattern(".*kernel.*"); kernel.setBackground(new Color(204, 255, 204)); rules.add(kernel); StyleRule cron = new StyleRule(); cron.setPattern(".*CRON.*"); cron.setForeground(new Color(51, 0, 51)); rules.add(cron); return rules; } }
@Override public void listStructureChanged(StyleRules newStyleRules) { int oldRowCount = styleRules.getPatternStyles().size(); int newRowCount = newStyleRules.getPatternStyles().size(); styleRules.removeListener(this); styleRules = newStyleRules; styleRules.addListener(this); // Remove first since we do not want to be registered twice on old // rules. styleRules.removeStyleRuleListener(this); styleRules.addStyleRuleListener(this); // fireTableDataChanged() - Which would seem like the perfect event // messes up the selections in the table. TableRowsUpdated does not even // if we say that all rows are updated if (oldRowCount > newRowCount) { fireTableRowsDeleted(newRowCount, oldRowCount); } else { fireTableRowsInserted(oldRowCount, newRowCount); } int rowsToUpdate = Math.min(oldRowCount, newRowCount); fireTableRowsUpdated(0, rowsToUpdate); }
this.styleRules = styleRules; styleRulesName = new JTextField(styleRules.getName()); styleRulesName.getDocument().addDocumentListener(this); lbStartOrEnd.setSelectedItem((styleRules.isLogBlockPatternBeginsBlock() ? slbMessage : elbMessage)); LogBlockPatternField logBlockPatternField = new LogBlockPatternField(styleRules, lbLabelLabel); logBlockPatternField.setText(styleRules.getLogBlockPattern().toString()); styleRules.resetChangeStatus();
private synchronized void addMeToListeningToRules() { for (StyleRules rules : styleRules) { rules.addListener(this); } }
private synchronized void removeMeFromListeningToRules() { for (StyleRules rules : styleRules) { rules.removeListener(this); } }
@Override public synchronized void resetChangeStatus() { changed = false; log.trace("Resetting changed status"); for (StyleRules rules : styleRules) { rules.resetChangeStatus(); } } }
@Override public void actionPerformed(ActionEvent e) { String lbMessage = (String) lbStartOrEnd.getSelectedItem(); styleRules.setLogBlockPatternBeginsBlock(lbMessage.equals(slbMessage)); } });
@Override protected void validationPassed() { super.validationPassed(); list.setLogBlockPattern(Pattern.compile(getText())); }
private void newStyleRules() { try { StyleRules styleRules = new StyleRules( messages.getMessage("nu.zoom.catonine.configurations.new")); manager.add(styleRules); editStyleRules(styleRules); } catch (ResourceNotFoundException resourceNotFoundException) { // TODO: add logging } }
/** * @param logBlockPatternBeginsBlock * the logBlockPatternBeginsBlock to set */ public synchronized void setLogBlockPatternBeginsBlock(boolean logBlockPatternBeginsBlock) { if (this.logBlockPatternBeginsBlock != logBlockPatternBeginsBlock) { this.logBlockPatternBeginsBlock = logBlockPatternBeginsBlock; fireDataChanged(); } }
public static StyleRules getLog4JStyleRules() { StyleRules rules = new StyleRules("Log4J"); rules.setLogBlockPatternBeginsBlock(true); rules.setLogBlockPattern(Pattern.compile("\\d\\d\\d\\d-\\d\\d-\\d\\d")); StyleRule error = new StyleRule(); error.setPattern(".*ERROR.*"); error.setBackground(Color.RED); rules.add(error); StyleRule warn = new StyleRule(); warn.setPattern(".*WARN.*"); warn.setBackground(Color.YELLOW); rules.add(warn); StyleRule trace = new StyleRule(); trace.setPattern(".*TRACE.*"); trace.setForeground(Color.DARK_GRAY); rules.add(trace); return rules; }
/** * @param logBlockPattern * The logBlockPattern to set. */ public synchronized void setLogBlockPattern(Pattern linePattern) { if ((linePattern != null) && (!linePattern.equals(this.logBlockPattern))) { this.logBlockPattern = linePattern; fireDataChanged(); } }
@Override public void actionPerformed(ActionEvent e) { StyleRule newRule = new StyleRule(); newRule.setPattern(".*"); styleRules.add(newRule); setActiveRule(newRule); } }
synchronized void editStyleRules(final StyleRules styleRules) { WorkbenchFrame editFrame = editorFrames.get(styleRules); if (editFrame != null) { if (!editFrame.isVisible()) { editFrame.setVisible(true); } editFrame.moveToFront(); } else { try { configPanel = new ConfigPanel(workbench, fontChooserFactory, messages, errorReporter, styleRules, fontChooserFactory.getDefaultFont()); editFrame = workbench.createWorkbenchFrame( "catonine.configframe", configPanel, null, true, true); String title = messages.format( "nu.zoom.catonine.configurations.edit.frame", styleRules.getName()); editFrame.setTitle(title); } catch (ResourceNotFoundException resourceNotFoundException) { // TODO: add logging } editFrame.addFrameListener(this); editorFrames.put(styleRules, editFrame); editFrame.setVisible(true); } }
/** * @param fileEncoding * the fileEncoding to set */ public synchronized void setFileEncoding(String fileEncoding) { if (!this.fileEncoding.equals(fileEncoding)) { this.fileEncoding = fileEncoding; fireDataChanged(); } } }
public void createSimpleRule(StyleRules rules, String selectedText) { StyleRule rule = new StyleRule(); rule.setPattern(".*" + selectedText + ".*"); rules.add(rule); editStyleRules(rules); configPanel.setActiveRule(rule); } }