Added
Link Here
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. |
5 |
* |
6 |
* The contents of this file are subject to the terms of either the GNU |
7 |
* General Public License Version 2 only ("GPL") or the Common |
8 |
* Development and Distribution License("CDDL") (collectively, the |
9 |
* "License"). You may not use this file except in compliance with the |
10 |
* License. You can obtain a copy of the License at |
11 |
* http://www.netbeans.org/cddl-gplv2.html |
12 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
13 |
* specific language governing permissions and limitations under the |
14 |
* License. When distributing the software, include this License Header |
15 |
* Notice in each file and include the License file at |
16 |
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this |
17 |
* particular file as subject to the "Classpath" exception as provided |
18 |
* by Sun in the GPL Version 2 section of the License file that |
19 |
* accompanied this code. If applicable, add the following below the |
20 |
* License Header, with the fields enclosed by brackets [] replaced by |
21 |
* your own identifying information: |
22 |
* "Portions Copyrighted [year] [name of copyright owner]" |
23 |
* |
24 |
* Contributor(s): |
25 |
* |
26 |
* The Original Software is NetBeans. The Initial Developer of the Original |
27 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun |
28 |
* Microsystems, Inc. All Rights Reserved. |
29 |
* |
30 |
* If you wish your version of this file to be governed by only the CDDL |
31 |
* or only the GPL Version 2, indicate your decision by adding |
32 |
* "[Contributor] elects to include this software in this distribution |
33 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
34 |
* single choice of license, a recipient has the option to distribute |
35 |
* your version of this file under either the CDDL, the GPL Version 2 or |
36 |
* to extend the choice of license to its licensees as provided above. |
37 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
38 |
* Version 2 license, then the option applies only if the new code is |
39 |
* made subject to such option by the copyright holder. |
40 |
*/ |
41 |
package org.netbeans.modules.mercurial.options; |
42 |
|
43 |
import java.util.prefs.PreferenceChangeEvent; |
44 |
import java.util.prefs.PreferenceChangeListener; |
45 |
import javax.swing.event.TableModelEvent; |
46 |
import javax.swing.event.TableModelListener; |
47 |
import org.netbeans.modules.mercurial.HgModuleConfig; |
48 |
import org.netbeans.modules.mercurial.options.PropertiesTable; |
49 |
import org.netbeans.modules.versioning.util.ListenersSupport; |
50 |
|
51 |
/** |
52 |
* |
53 |
* @author Peter Pis |
54 |
*/ |
55 |
public class PropertiesPanel extends javax.swing.JPanel implements PreferenceChangeListener, TableModelListener { |
56 |
|
57 |
private static final Object EVENT_SETTINGS_CHANGED = new Object(); |
58 |
private PropertiesTable propertiesTable; |
59 |
private ListenersSupport listenerSupport = new ListenersSupport(this); |
60 |
|
61 |
/** Creates new form PropertiesPanel */ |
62 |
public PropertiesPanel() { |
63 |
initComponents(); |
64 |
} |
65 |
|
66 |
public javax.swing.JTextArea getTxtAreaValue() { |
67 |
return txtAreaValue; |
68 |
} |
69 |
|
70 |
public javax.swing.JComboBox getComboName() { |
71 |
return comboName; |
72 |
} |
73 |
|
74 |
public javax.swing.JButton getBtnAdd() { |
75 |
return btnAdd; |
76 |
} |
77 |
|
78 |
public javax.swing.JButton getBtnRemove() { |
79 |
return btnRemove; |
80 |
} |
81 |
|
82 |
public void setPropertiesTable(PropertiesTable propertiesTable){ |
83 |
this.propertiesTable = propertiesTable; |
84 |
} |
85 |
|
86 |
public void addNotify() { |
87 |
super.addNotify(); |
88 |
HgModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(this); |
89 |
propertiesTable.getTableModel().addTableModelListener(this); |
90 |
listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED); |
91 |
txtAreaValue.selectAll(); |
92 |
} |
93 |
|
94 |
public void removeNotify() { |
95 |
propertiesTable.getTableModel().removeTableModelListener(this); |
96 |
HgModuleConfig.getDefault().getPreferences().removePreferenceChangeListener(this); |
97 |
super.removeNotify(); |
98 |
} |
99 |
|
100 |
public void preferenceChange(PreferenceChangeEvent evt) { |
101 |
if (evt.getKey().startsWith(HgModuleConfig.PROP_COMMIT_EXCLUSIONS)) { |
102 |
propertiesTable.dataChanged(); |
103 |
listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED); |
104 |
} |
105 |
} |
106 |
|
107 |
public void tableChanged(TableModelEvent e) { |
108 |
listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED); |
109 |
} |
110 |
|
111 |
/** This method is called from within the constructor to |
112 |
* initialize the form. |
113 |
* WARNING: Do NOT modify this code. The content of this method is |
114 |
* always regenerated by the Form Editor. |
115 |
*/ |
116 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
117 |
private void initComponents() { |
118 |
|
119 |
jLabel2 = new javax.swing.JLabel(); |
120 |
jLabel1 = new javax.swing.JLabel(); |
121 |
propsPanel = new javax.swing.JPanel(); |
122 |
jScrollPane1 = new javax.swing.JScrollPane(); |
123 |
jLabel3 = new javax.swing.JLabel(); |
124 |
|
125 |
jLabel2.setLabelFor(comboName); |
126 |
org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel2.text")); // NOI18N |
127 |
|
128 |
jLabel1.setLabelFor(txtAreaValue); |
129 |
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel1.text")); // NOI18N |
130 |
|
131 |
org.jdesktop.layout.GroupLayout propsPanelLayout = new org.jdesktop.layout.GroupLayout(propsPanel); |
132 |
propsPanel.setLayout(propsPanelLayout); |
133 |
propsPanelLayout.setHorizontalGroup( |
134 |
propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
135 |
.add(0, 420, Short.MAX_VALUE) |
136 |
); |
137 |
propsPanelLayout.setVerticalGroup( |
138 |
propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
139 |
.add(0, 99, Short.MAX_VALUE) |
140 |
); |
141 |
|
142 |
txtAreaValue.setColumns(20); |
143 |
txtAreaValue.setRows(5); |
144 |
jScrollPane1.setViewportView(txtAreaValue); |
145 |
|
146 |
org.openide.awt.Mnemonics.setLocalizedText(btnRemove, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnRemove.text")); // NOI18N |
147 |
|
148 |
org.openide.awt.Mnemonics.setLocalizedText(btnAdd, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnAdd.text")); // NOI18N |
149 |
btnAdd.setMaximumSize(new java.awt.Dimension(75, 23)); |
150 |
btnAdd.setMinimumSize(new java.awt.Dimension(75, 23)); |
151 |
|
152 |
org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "jLabel3.txt")); // NOI18N |
153 |
|
154 |
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); |
155 |
this.setLayout(layout); |
156 |
layout.setHorizontalGroup( |
157 |
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
158 |
.add(layout.createSequentialGroup() |
159 |
.addContainerGap() |
160 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
161 |
.add(propsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
162 |
.add(layout.createSequentialGroup() |
163 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
164 |
.add(jLabel2) |
165 |
.add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
166 |
.add(jLabel3) |
167 |
.add(jLabel1)) |
168 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) |
169 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) |
170 |
.add(org.jdesktop.layout.GroupLayout.LEADING, comboName, 0, 307, Short.MAX_VALUE) |
171 |
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE)) |
172 |
.add(layout.createSequentialGroup() |
173 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
174 |
.add(btnRemove))))) |
175 |
.addContainerGap()) |
176 |
); |
177 |
|
178 |
layout.linkSize(new java.awt.Component[] {btnAdd, btnRemove}, org.jdesktop.layout.GroupLayout.HORIZONTAL); |
179 |
|
180 |
layout.setVerticalGroup( |
181 |
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
182 |
.add(layout.createSequentialGroup() |
183 |
.addContainerGap() |
184 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
185 |
.add(jLabel2) |
186 |
.add(comboName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
187 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
188 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
189 |
.add(layout.createSequentialGroup() |
190 |
.add(jLabel1) |
191 |
.add(99, 99, 99) |
192 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
193 |
.add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
194 |
.add(btnRemove)) |
195 |
.add(26, 26, 26) |
196 |
.add(jLabel3) |
197 |
.add(12, 12, 12)) |
198 |
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
199 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 13, Short.MAX_VALUE) |
200 |
.add(propsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
201 |
); |
202 |
}// </editor-fold>//GEN-END:initComponents |
203 |
|
204 |
|
205 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
206 |
final javax.swing.JButton btnAdd = new javax.swing.JButton(); |
207 |
final javax.swing.JButton btnRemove = new javax.swing.JButton(); |
208 |
final javax.swing.JComboBox comboName = new javax.swing.JComboBox(); |
209 |
private javax.swing.JLabel jLabel1; |
210 |
private javax.swing.JLabel jLabel2; |
211 |
private javax.swing.JLabel jLabel3; |
212 |
private javax.swing.JScrollPane jScrollPane1; |
213 |
public javax.swing.JPanel propsPanel; |
214 |
final javax.swing.JTextArea txtAreaValue = new javax.swing.JTextArea(); |
215 |
// End of variables declaration//GEN-END:variables |
216 |
|
217 |
} |