KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > java > project > support > ui > IncludeExcludeVisualizerPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.spi.java.project.support.ui;
21
22 import java.awt.EventQueue JavaDoc;
23 import java.io.File JavaDoc;
24 import javax.swing.DefaultListModel JavaDoc;
25 import javax.swing.JPanel JavaDoc;
26 import javax.swing.event.DocumentEvent JavaDoc;
27 import javax.swing.event.DocumentListener JavaDoc;
28
29 class IncludeExcludeVisualizerPanel extends JPanel JavaDoc {
30
31     private final IncludeExcludeVisualizer handle;
32     private final DocumentListener JavaDoc listener = new DocumentListener JavaDoc() {
33         private void changes() {
34             handle.changedPatterns(includes.getText(), excludes.getText());
35         }
36         public void insertUpdate(DocumentEvent JavaDoc e) {
37             changes();
38         }
39         public void removeUpdate(DocumentEvent JavaDoc e) {
40             changes();
41         }
42         public void changedUpdate(DocumentEvent JavaDoc e) {}
43     };
44     private final DefaultListModel JavaDoc includedListModel = new DefaultListModel JavaDoc();
45     private final DefaultListModel JavaDoc excludedListModel = new DefaultListModel JavaDoc();
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 JavaDoc includes, String JavaDoc 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 JavaDoc[] included, File JavaDoc[] excluded, boolean busy) {
67         assert EventQueue.isDispatchThread();
68         includedListModel.clear();
69         for (File JavaDoc f : included) {
70             includedListModel.addElement(f);
71         }
72         excludedListModel.clear();
73         for (File JavaDoc f : excluded) {
74             excludedListModel.addElement(f);
75         }
76         scanningLabel.setVisible(busy);
77     }
78
79     /** This method is called from within the constructor to
80      * initialize the form.
81      * WARNING: Do NOT modify this code. The content of this method is
82      * always regenerated by the Form Editor.
83      */

84     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
85
private void initComponents() {
86
87         includedListLabel = new javax.swing.JLabel JavaDoc();
88         includedListPane = new javax.swing.JScrollPane JavaDoc();
89         includedList = new javax.swing.JList JavaDoc();
90         excludedListLabel = new javax.swing.JLabel JavaDoc();
91         excludedListPane = new javax.swing.JScrollPane JavaDoc();
92         excludedList = new javax.swing.JList JavaDoc();
93         scanningLabel = new javax.swing.JLabel JavaDoc();
94         includesLabel = new javax.swing.JLabel JavaDoc();
95         includes = new javax.swing.JTextField JavaDoc();
96         excludesLabel = new javax.swing.JLabel JavaDoc();
97         excludes = new javax.swing.JTextField JavaDoc();
98         explanation = new javax.swing.JLabel JavaDoc();
99
100         includedListLabel.setLabelFor(includedList);
101         org.openide.awt.Mnemonics.setLocalizedText(includedListLabel, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.includedListLabel.text")); // NOI18N
102

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")); // NOI18N
107

108         excludedListPane.setViewportView(excludedList);
109
110         org.openide.awt.Mnemonics.setLocalizedText(scanningLabel, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.scanningLabel.text")); // NOI18N
111

112         includesLabel.setLabelFor(includes);
113         org.openide.awt.Mnemonics.setLocalizedText(includesLabel, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.includesLabel.text")); // NOI18N
114

115         excludesLabel.setLabelFor(excludes);
116         org.openide.awt.Mnemonics.setLocalizedText(excludesLabel, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.excludesLabel.text")); // NOI18N
117

118         org.openide.awt.Mnemonics.setLocalizedText(explanation, org.openide.util.NbBundle.getMessage(IncludeExcludeVisualizerPanel.class, "IncludeExcludeVisualizerPanel.explanation.text")); // NOI18N
119

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     }// </editor-fold>//GEN-END:initComponents
178

179
180     // Variables declaration - do not modify//GEN-BEGIN:variables
181
private javax.swing.JList JavaDoc excludedList;
182     private javax.swing.JLabel JavaDoc excludedListLabel;
183     private javax.swing.JScrollPane JavaDoc excludedListPane;
184     private javax.swing.JTextField JavaDoc excludes;
185     private javax.swing.JLabel JavaDoc excludesLabel;
186     private javax.swing.JLabel JavaDoc explanation;
187     private javax.swing.JList JavaDoc includedList;
188     private javax.swing.JLabel JavaDoc includedListLabel;
189     private javax.swing.JScrollPane JavaDoc includedListPane;
190     private javax.swing.JTextField JavaDoc includes;
191     private javax.swing.JLabel JavaDoc includesLabel;
192     private javax.swing.JLabel JavaDoc scanningLabel;
193     // End of variables declaration//GEN-END:variables
194

195 }
196
Popular Tags