1 19 20 package org.netbeans.spi.java.project.support.ui; 21 22 import java.awt.EventQueue ; 23 import java.io.File ; 24 import javax.swing.DefaultListModel ; 25 import javax.swing.JPanel ; 26 import javax.swing.event.DocumentEvent ; 27 import javax.swing.event.DocumentListener ; 28 29 class IncludeExcludeVisualizerPanel extends JPanel { 30 31 private final IncludeExcludeVisualizer handle; 32 private final DocumentListener listener = new DocumentListener () { 33 private void changes() { 34 handle.changedPatterns(includes.getText(), excludes.getText()); 35 } 36 public void insertUpdate(DocumentEvent e) { 37 changes(); 38 } 39 public void removeUpdate(DocumentEvent e) { 40 changes(); 41 } 42 public void changedUpdate(DocumentEvent e) {} 43 }; 44 private final DefaultListModel includedListModel = new DefaultListModel (); 45 private final DefaultListModel excludedListModel = new DefaultListModel (); 46 47 public IncludeExcludeVisualizerPanel(IncludeExcludeVisualizer handle) { 48 this.handle = handle; 49 initComponents(); 50 includes.getDocument().addDocumentListener(listener); 51 excludes.getDocument().addDocumentListener(listener); 52 includedList.setModel(includedListModel); 53 excludedList.setModel(excludedListModel); 54 } 55 56 void setFields(String includes, String excludes) { 57 assert EventQueue.isDispatchThread(); 58 this.includes.getDocument().removeDocumentListener(listener); 59 this.includes.setText(includes); 60 this.includes.getDocument().addDocumentListener(listener); 61 this.excludes.getDocument().removeDocumentListener(listener); 62 this.excludes.setText(excludes); 63 this.excludes.getDocument().addDocumentListener(listener); 64 } 65 66 void setFiles(File [] included, File [] excluded, boolean busy) { 67 assert EventQueue.isDispatchThread(); 68 includedListModel.clear(); 69 for (File f : included) { 70 includedListModel.addElement(f); 71 } 72 excludedListModel.clear(); 73 for (File f : excluded) { 74 excludedListModel.addElement(f); 75 } 76 scanningLabel.setVisible(busy); 77 } 78 79 84 private void initComponents() { 86 87 includedListLabel = new javax.swing.JLabel (); 88 includedListPane = new javax.swing.JScrollPane (); 89 includedList = new javax.swing.JList (); 90 excludedListLabel = new javax.swing.JLabel (); 91 excludedListPane = new javax.swing.JScrollPane (); 92 excludedList = new javax.swing.JList (); 93 scanningLabel = new javax.swing.JLabel (); 94 includesLabel = new javax.swing.JLabel (); 95 includes = new javax.swing.JTextField (); 96 excludesLabel = new javax.swing.JLabel (); 97 excludes = new javax.swing.JTextField (); 98 explanation = new javax.swing.JLabel (); 99 100 includedListLabel.setLabelFor(includedList); 101 org.openide.awt.Mnemonics.setLocalizedText(includedListLabel, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.includedListLabel.text")); 103 includedListPane.setViewportView(includedList); 104 105 excludedListLabel.setLabelFor(excludedList); 106 org.openide.awt.Mnemonics.setLocalizedText(excludedListLabel, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.excludedListLabel.text")); 108 excludedListPane.setViewportView(excludedList); 109 110 org.openide.awt.Mnemonics.setLocalizedText(scanningLabel, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.scanningLabel.text")); 112 includesLabel.setLabelFor(includes); 113 org.openide.awt.Mnemonics.setLocalizedText(includesLabel, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.includesLabel.text")); 115 excludesLabel.setLabelFor(excludes); 116 org.openide.awt.Mnemonics.setLocalizedText(excludesLabel, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.excludesLabel.text")); 118 org.openide.awt.Mnemonics.setLocalizedText(explanation, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.explanation.text")); 120 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 121 this.setLayout(layout); 122 layout.setHorizontalGroup( 123 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 124 .add(layout.createSequentialGroup() 125 .addContainerGap() 126 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 127 .add(layout.createSequentialGroup() 128 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 129 .add(layout.createSequentialGroup() 130 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 131 .add(includesLabel) 132 .add(excludesLabel)) 133 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 134 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 135 .add(excludes, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE) 136 .add(includes, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE))) 137 .add(scanningLabel) 138 .add(includedListLabel)) 139 .addContainerGap()) 140 .add(layout.createSequentialGroup() 141 .add(excludedListLabel) 142 .addContainerGap(361, Short.MAX_VALUE)) 143 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() 144 .add(includedListPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) 145 .addContainerGap()) 146 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() 147 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) 148 .add(explanation, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) 149 .add(excludedListPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)) 150 .addContainerGap()))) 151 ); 152 layout.setVerticalGroup( 153 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 154 .add(layout.createSequentialGroup() 155 .addContainerGap() 156 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 157 .add(includesLabel) 158 .add(includes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 159 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 160 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 161 .add(excludesLabel) 162 .add(excludes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 163 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 164 .add(scanningLabel) 165 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 166 .add(includedListLabel) 167 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 168 .add(includedListPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 169 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 170 .add(excludedListLabel) 171 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 172 .add(excludedListPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 143, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 173 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 174 .add(explanation, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE) 175 .addContainerGap()) 176 ); 177 } 179 180 private javax.swing.JList excludedList; 182 private javax.swing.JLabel excludedListLabel; 183 private javax.swing.JScrollPane excludedListPane; 184 private javax.swing.JTextField excludes; 185 private javax.swing.JLabel excludesLabel; 186 private javax.swing.JLabel explanation; 187 private javax.swing.JList includedList; 188 private javax.swing.JLabel includedListLabel; 189 private javax.swing.JScrollPane includedListPane; 190 private javax.swing.JTextField includes; 191 private javax.swing.JLabel includesLabel; 192 private javax.swing.JLabel scanningLabel; 193 195 } 196 | Popular Tags |