private static String getMessagesToolTipText(ValidationResult result) { List<ValidationMessage> messages = result.getMessages(); StringBuilder buffer = new StringBuilder("<html>"); //$NON-NLS-1$ for (Iterator<ValidationMessage> it = messages.iterator(); it.hasNext();) { ValidationMessage message = it.next(); buffer.append(message.formattedText()); if (it.hasNext()) { buffer.append("<br/>"); //$NON-NLS-1$ } } buffer.append("</html>"); //$NON-NLS-1$ return buffer.toString(); }
/** * Returns a string representation of the given list of messages. * * @param messages the List of ValidationMessages to iterate * @return a string representation of the given list of messages */ private static String getMessagesText(List<ValidationMessage> messages) { if (messages.isEmpty()) { return "OK"; } StringBuilder builder = new StringBuilder(); for (ValidationMessage message : messages) { if (builder.length() > 0) { builder.append("\n"); } builder.append(message.formattedText()); } return builder.toString(); }
/** * Returns a string representation of the given list of messages. * * @param messages the List of ValidationMessages to iterate * @return a string representation of the given list of messages */ private static String getMessagesText(List<ValidationMessage> messages) { if (messages.isEmpty()) { return "OK"; } StringBuilder builder = new StringBuilder(); for (ValidationMessage message : messages) { if (builder.length() > 0) { builder.append('\n'); } builder.append(message.formattedText()); } return builder.toString(); }
private static void updateText(JLabel label, ValidationResult result) { label.setText(result.hasMessages() ? result.getMessages().get(0).formattedText() : ""); }
private JDefaultToolTip createToolTip(ValidationMessage vm) { JDefaultToolTip res = null; switch (vm.severity()) { case ERROR: res = new JRedToolTip(vm.formattedText()); break; case OK: res = new JGreenToolTip(vm.formattedText()); break; case WARNING: res = new JOrangeToolTip(vm.formattedText()); break; default: res = new JRedToolTip(vm.formattedText()); break; } res.setInsetsToolTip(new Insets(2, 5, 2, 5)); return res; }
private static void updateText(JLabel label, ValidationResult result) { if (result.isEmpty()) { label.setText(""); return; } Severity severity = result.getSeverity(); for (ValidationMessage message : result) { if (message.severity() == severity) { label.setText(message.formattedText()); return; } } }
/** * In addition to the superclass behavior, this method * assumes that the value is a ValidationMessage. * It sets the renderer's icon to the one associated with the * ValidationMessage's severity and sets the renderer's text * to the message's formatted text. */ @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent( list, value, index, false, // Ignore the selection state false); // Ignore the cell focus state ValidationMessage message = (ValidationMessage) value; this.setIcon(ValidationResultViewFactory.getIcon(message.severity())); this.setText(message.formattedText()); return this; } }
/** * In addition to the superclass behavior, this method * assumes that the value is a ValidationMessage. * It sets the renderer's icon to the one associated with the * ValidationMessage's severity and sets the renderer's text * to the message's formatted text. */ @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent( list, value, index, false, // Ignore the selection state false); // Ignore the cell focus state ValidationMessage message = (ValidationMessage) value; this.setIcon(ValidationResultViewFactory.getIcon(message.severity())); this.setText(message.formattedText()); return this; } }