/** * @param styleRule * The styleRule to set. */ public void setStyleRule(StyleRule styleRule) { if (styleRule == null) { unsetStyleRule(); } else { this.styleRule = styleRule; final boolean supress = styleRule.isSupress(); foregroundColorChooser.setEnabled(!supress); backgroundColorChooser.setEnabled(!supress); patternTextField.setEnabled(!supress); supressCheckBox.setEnabled(true); supressCheckBox.setSelected(supress); patternTextField.setText(styleRule.getPattern().toString()); } }
public StyleRuleEditPanel(LocalizedResources messages) throws ResourceNotFoundException { super(new BorderLayout()); ForegroundAction foregroundAction = new ForegroundAction(messages); BackgroundAction backgroundAction = new BackgroundAction(messages); foregroundColorChooser = new JButton(foregroundAction); backgroundColorChooser = new JButton(backgroundAction); JLabel patternLabel = new JLabel(messages.getMessage("nu.zoom.catonine.stylerule.pattern")); patternTextField = new StyleRulePatternField(patternLabel); patternTextField.setToolTipText(messages.getMessage("nu.zoom.catonine.stylerule.pattern.tt")); supressCheckBox = new JCheckBox(new SupressAction()); JPanel colorPanel = new JPanel(new FlowLayout()); colorPanel.add(foregroundColorChooser); colorPanel.add(backgroundColorChooser); VerticalPanel mainPanel = new VerticalPanel(); mainPanel.addRow(patternLabel, patternTextField); mainPanel.addRow(messages.getMessage("nu.zoom.catonine.stylerule.supress"), supressCheckBox); mainPanel.addRow(colorPanel); add(mainPanel, BorderLayout.CENTER); }
public void unsetStyleRule() { this.styleRule = null; patternTextField.setText(""); foregroundColorChooser.setEnabled(true); backgroundColorChooser.setEnabled(true); patternTextField.setEnabled(true); supressCheckBox.setEnabled(true); supressCheckBox.setSelected(false); }
@Override public void actionPerformed(ActionEvent e) { boolean supress = supressCheckBox.isSelected(); foregroundColorChooser.setEnabled(!supress); backgroundColorChooser.setEnabled(!supress); patternTextField.setEnabled(!supress); if (styleRule != null) { styleRule.setSupress(supress); } } }
@Override protected void validationPassed() { super.validationPassed(); // Is there a selected style rule? Document might change even if // there is no active style rule (for example from "unset". if (styleRule != null) { styleRule.setPattern(getText()); } } }