/** * Adds the given {@link ValidationResultModel} to this container's list * of children and registers the container to listen for changes in the child. * * @param resultModel the <code>ValidationResultModel</code> to be added * * @see #remove(ValidationResultModel) */ public void add(ValidationResultModel resultModel) { childResultModels.add(resultModel); resultModel.addPropertyChangeListener( ValidationResultModel.PROPERTYNAME_RESULT, childResultUpdateHandler); }
/** * Adds the given {@link ValidationResultModel} to this container's list * of children and registers the container to listen for changes in the child. * * @param resultModel the {@code ValidationResultModel} to be added * * @see #remove(ValidationResultModel) */ public void add(ValidationResultModel resultModel) { childResultModels.add(resultModel); resultModel.addPropertyChangeListener( ValidationResultModel.PROPERTY_RESULT, childResultUpdateHandler); }
/** * Registers a listener with the validation result model that updates the feedback components. */ private void initEventHandling() { model.addPropertyChangeListener(ValidationResultModel.PROPERTYNAME_RESULT, new ValidationResultChangeHandler()); }
public ToolTipFeedbackComponentValidationResultFocusListener(ValidationResultModel model) { super(); this.model = model; this.componentMap = new HashMap<Component, List<ValidationMessage>>(); this.model.addPropertyChangeListener(ValidationResultModel.PROPERTYNAME_RESULT, new ValidationResultChangeHandler()); }
/** * Creates and returns an icon label that indicates the validation severity. * A handler updates the label's visibility and icon each time the severity * of the given validation result model changes. * * @param model the model that provides the observable validation result * @return a label with an icon that presents the validation severity */ public static JLabel createReportIconLabel(ValidationResultModel model) { JLabel label = new JLabel(); LabelIconChangeHandler.updateVisibilityAndIcon(label, model.getSeverity()); model.addPropertyChangeListener( ValidationResultModel.PROPERTY_SEVERITY, new LabelIconChangeHandler(label)); return label; }
/** * Creates and returns an icon label that indicates the validation severity. * A handler updates the label's visibility and icon each time the severity * of the given validation result model changes. * * @param model the model that provides the observable validation result * @return a label with an icon that presents the validation severity */ public static JLabel createReportIconLabel(ValidationResultModel model) { JLabel label = new JLabel(); LabelIconChangeHandler.updateVisibilityAndIcon(label, model.getSeverity()); model.addPropertyChangeListener( ValidationResultModel.PROPERTYNAME_SEVERITY, new LabelIconChangeHandler(label)); return label; }
/** * Constructs a ValidationResultListAdapter that converts * the given model into a ListModel. Observes the given model * to update this adapter every time the validation result changes. * * @param model the model that provides the validation result */ public ValidationResultListAdapter(ValidationResultModel model) { this.model = model; this.oldSize = getSize(); model.addPropertyChangeListener( ValidationResultModel.PROPERTYNAME_RESULT, new ValidationResultHandler()); }
/** * Constructs a ValidationResultListAdapter that converts * the given model into a ListModel. Observes the given model * to update this adapter every time the validation result changes. * * @param model the model that provides the validation result */ public ValidationResultListAdapter(ValidationResultModel model) { this.model = model; this.oldSize = getSize(); model.addPropertyChangeListener( ValidationResultModel.PROPERTY_RESULT, new ValidationResultHandler()); }
/** * Creates and returns a text area that is intended to show validation * messages. The area is bound to the given {@link ValidationResultModel}: * the text content reflects the validation result message text, * and the component is visible if and only if the model has messages. * * @param model the model that provides the observable validation result * @param backgroundColor the color used to paint the area's background * @return a text area intended to show validation messages */ public static JTextArea createReportTextArea(ValidationResultModel model, Color backgroundColor) { JTextArea area = new JTextArea(); area.setEditable(false); area.setFocusable(false); area.setOpaque(true); area.setBackground(backgroundColor); MessageTextChangeHandler.updateText(area, model.getResult()); model.addPropertyChangeListener( ValidationResultModel.PROPERTY_RESULT, new MessageTextChangeHandler(area)); return area; }
/** * Creates and returns a text area that is intended to show validation * messages. The area is bound to the given {@link ValidationResultModel}: * the text content reflects the validation result message text, * and the component is visible if and only if the model has messages. * * @param model the model that provides the observable validation result * @param backgroundColor the color used to paint the area's background * @return a text area intended to show validation messages */ public static JTextArea createReportTextArea(ValidationResultModel model, Color backgroundColor) { JTextArea area = new JTextArea(); area.setEditable(false); area.setFocusable(false); area.setOpaque(true); area.setBackground(backgroundColor); MessageTextChangeHandler.updateText(area, model.getResult()); model.addPropertyChangeListener( ValidationResultModel.PROPERTYNAME_RESULT, new MessageTextChangeHandler(area)); return area; }
model.addPropertyChangeListener( ValidationResultModel.PROPERTYNAME_MESSAGES, new MessageStateChangeHandler(reportPane));
model.addPropertyChangeListener( ValidationResultModel.PROPERTY_MESSAGES, new MessageStateChangeHandler(reportPane));
/** * Creates and returns a label with icon and text that indicates * the validation state and displays the first message text * with the highest severity. * * @param model the model that provides the observable validation result * @return a label with text and icon that shows the validation severity * and the first validation message text */ public static JLabel createReportIconAndTextLabel(ValidationResultModel model) { JLabel label = createReportIconLabel(model); LabelTextChangeHandler.updateText(label, model.getResult()); model.addPropertyChangeListener( ValidationResultModel.PROPERTY_RESULT, new LabelTextChangeHandler(label)); return label; }
/** * Creates and returns a label with icon and text that indicates * the validation state and displays the first message text. * * @param model the model that provides the observable validation result * @return a label with text and icon that shows the validation severity * and the first validation message text */ public static JLabel createReportIconAndTextLabel(ValidationResultModel model) { JLabel label = createReportIconLabel(model); LabelTextChangeHandler.updateText(label, model.getResult()); model.addPropertyChangeListener( ValidationResultModel.PROPERTYNAME_RESULT, new LabelTextChangeHandler(label)); return label; }
/** * Creates and returns a list wrapped in a scroll pane that presents * validation messages. The list content is bound to the given * {@link ValidationResultModel} using a {@link ValidationResultListAdapter}. * * @param model the model that provides the observable validation result * @param backgroundColor the color used to paint the area's background * @return a {@code JList} that shows validation messages */ public static JComponent createReportList(ValidationResultModel model, Color backgroundColor) { JList list = new JList(); list.setFocusable(false); list.setBackground(backgroundColor); list.setCellRenderer(new BasicValidationMessageCellRenderer()); list.setModel(new ValidationResultListAdapter(model)); JScrollPane scrollPane = new JScrollPane(list); scrollPane.setVisible(model.hasMessages()); model.addPropertyChangeListener( ValidationResultModel.PROPERTY_MESSAGES, new MessageStateChangeHandler(scrollPane)); return scrollPane; }
/** * Creates and returns a text area wrapped by a scroll pane that is * intended to show validation messages. The component is bound to * the given {@link ValidationResultModel}: the text content reflects * the validation result message text and the component is visible * if and only if the model has messages. * * @param model the model that provides the observable validation result * @param backgroundColor the color used to paint the area's background * @return a scrollable text component intended to show validation messages */ public static JComponent createReportTextPane(ValidationResultModel model, Color backgroundColor) { JTextArea area = createReportTextArea(model, backgroundColor); JScrollPane scrollPane = new JScrollPane(area); scrollPane.setVisible(model.hasMessages()); model.addPropertyChangeListener( ValidationResultModel.PROPERTYNAME_MESSAGES, new MessageStateChangeHandler(scrollPane)); return scrollPane; }
/** * Creates and returns a text area wrapped by a scroll pane that is * intended to show validation messages. The component is bound to * the given {@link ValidationResultModel}: the text content reflects * the validation result message text and the component is visible * if and only if the model has messages. * * @param model the model that provides the observable validation result * @param backgroundColor the color used to paint the area's background * @return a scrollable text component intended to show validation messages */ public static JComponent createReportTextPane(ValidationResultModel model, Color backgroundColor) { JTextArea area = createReportTextArea(model, backgroundColor); JScrollPane scrollPane = new JScrollPane(area); scrollPane.setVisible(model.hasMessages()); model.addPropertyChangeListener( ValidationResultModel.PROPERTY_MESSAGES, new MessageStateChangeHandler(scrollPane)); return scrollPane; }
private void initEventHandling() { KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(new FocusChangeHandler()); validationResultModel.addPropertyChangeListener(ValidationResultModel.PROPERTYNAME_RESULT, new ValidationChangeHandler()); }
/** * Creates and returns a list wrapped in a scroll pane that presents * validation messages. The list content is bound to the given * {@link ValidationResultModel} using a {@link ValidationResultListAdapter}. * * @param model the model that provides the observable validation result * @param backgroundColor the color used to paint the area's background * @return a <code>JList</code> that shows validation messages */ public static JComponent createReportList(ValidationResultModel model, Color backgroundColor) { JList list = new JList(); list.setFocusable(false); list.setBackground(backgroundColor); list.setCellRenderer(new BasicValidationMessageCellRenderer()); list.setModel(new ValidationResultListAdapter(model)); JScrollPane scrollPane = new JScrollPane(list); scrollPane.setVisible(model.hasMessages()); model.addPropertyChangeListener( ValidationResultModel.PROPERTYNAME_MESSAGES, new MessageStateChangeHandler(scrollPane)); return scrollPane; }