/** * Notifies all registered ListDataListeners that the ValidationResult * in this adapter's underlying ValidationResultModel has changed. */ public void propertyChange(PropertyChangeEvent evt) { int newSize = getSize(); int oldLastIndex = oldSize - 1; int newLastIndex = newSize - 1; oldSize = newSize; fireListChanged(oldLastIndex, newLastIndex); }
/** * 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 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; }
/** * Notifies all registered ListDataListeners that the ValidationResult * in this adapter's underlying ValidationResultModel has changed. */ @Override public void propertyChange(PropertyChangeEvent evt) { int newSize = getSize(); int oldLastIndex = oldSize - 1; int newLastIndex = newSize - 1; oldSize = newSize; fireListChanged(oldLastIndex, newLastIndex); }
/** * 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()); }