1 package org.objectstyle.cayenne.modeler.dialog; 2 3 import java.awt.BorderLayout ; 4 import java.awt.Dimension ; 5 import java.awt.FlowLayout ; 6 7 import javax.swing.JButton ; 8 import javax.swing.JComponent ; 9 import javax.swing.JDialog ; 10 import javax.swing.JPanel ; 11 import javax.swing.JScrollPane ; 12 import javax.swing.JTextArea ; 13 14 import com.jgoodies.forms.builder.PanelBuilder; 15 import com.jgoodies.forms.layout.CellConstraints; 16 import com.jgoodies.forms.layout.FormLayout; 17 18 21 public class ValidationResultBrowserView extends JDialog { 22 23 protected JTextArea messageLabel; 24 protected JTextArea errorsDisplay; 25 protected JButton closeButton; 26 27 public ValidationResultBrowserView() { 28 this.closeButton = new JButton ("Close"); 29 30 this.messageLabel = new JTextArea (); 31 messageLabel.setEditable(false); 32 messageLabel.setLineWrap(true); 33 messageLabel.setWrapStyleWord(true); 34 35 this.errorsDisplay = new JTextArea (); 36 errorsDisplay.setEditable(false); 37 errorsDisplay.setLineWrap(true); 38 errorsDisplay.setWrapStyleWord(true); 39 40 CellConstraints cc = new CellConstraints(); 42 PanelBuilder builder = new PanelBuilder(new FormLayout( 43 "fill:min(50dlu;pref):grow", 44 "fill:20dlu, 9dlu, p, 3dlu, fill:40dlu:grow")); 45 builder.setDefaultDialogBorder(); 46 builder.add(new JScrollPane ( 47 messageLabel, 48 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 49 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), cc.xy(1, 1)); 50 builder.addSeparator("Details", cc.xy(1, 3)); 51 builder.add(new JScrollPane ( 52 errorsDisplay, 53 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 54 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), cc.xy(1, 5)); 55 56 JPanel buttons = new JPanel (new FlowLayout (FlowLayout.RIGHT)); 57 buttons.add(closeButton); 58 59 JComponent container = (JComponent ) getContentPane(); 60 container.setLayout(new BorderLayout ()); 61 container.add(builder.getPanel(), BorderLayout.CENTER); 62 container.add(buttons, BorderLayout.SOUTH); 63 64 messageLabel.setBackground(container.getBackground()); 66 67 container.setPreferredSize(new Dimension (450, 270)); 70 } 71 72 public JButton getCloseButton() { 73 return closeButton; 74 } 75 76 public JTextArea getErrorsDisplay() { 77 return errorsDisplay; 78 } 79 80 public JTextArea getMessageLabel() { 81 return messageLabel; 82 } 83 } | Popular Tags |