001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.mercurial.options;
042:
043: import java.util.prefs.PreferenceChangeEvent;
044: import java.util.prefs.PreferenceChangeListener;
045: import javax.swing.event.TableModelEvent;
046: import javax.swing.event.TableModelListener;
047: import org.netbeans.modules.mercurial.HgModuleConfig;
048: import org.netbeans.modules.mercurial.options.PropertiesTable;
049: import org.netbeans.modules.versioning.util.ListenersSupport;
050:
051: /**
052: *
053: * @author Peter Pis
054: */
055: public class PropertiesPanel extends javax.swing.JPanel implements
056: PreferenceChangeListener, TableModelListener {
057:
058: private static final Object EVENT_SETTINGS_CHANGED = new Object();
059: private PropertiesTable propertiesTable;
060: private ListenersSupport listenerSupport = new ListenersSupport(
061: this );
062:
063: /** Creates new form PropertiesPanel */
064: public PropertiesPanel() {
065: initComponents();
066: }
067:
068: public javax.swing.JTextArea getTxtAreaValue() {
069: return txtAreaValue;
070: }
071:
072: public javax.swing.JComboBox getComboName() {
073: return comboName;
074: }
075:
076: public javax.swing.JButton getBtnAdd() {
077: return btnAdd;
078: }
079:
080: public javax.swing.JButton getBtnRemove() {
081: return btnRemove;
082: }
083:
084: public void setPropertiesTable(PropertiesTable propertiesTable) {
085: this .propertiesTable = propertiesTable;
086: }
087:
088: public void addNotify() {
089: super .addNotify();
090: HgModuleConfig.getDefault().getPreferences()
091: .addPreferenceChangeListener(this );
092: propertiesTable.getTableModel().addTableModelListener(this );
093: listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
094: txtAreaValue.selectAll();
095: }
096:
097: public void removeNotify() {
098: propertiesTable.getTableModel().removeTableModelListener(this );
099: HgModuleConfig.getDefault().getPreferences()
100: .removePreferenceChangeListener(this );
101: super .removeNotify();
102: }
103:
104: public void preferenceChange(PreferenceChangeEvent evt) {
105: if (evt.getKey().startsWith(
106: HgModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
107: propertiesTable.dataChanged();
108: listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
109: }
110: }
111:
112: public void tableChanged(TableModelEvent e) {
113: listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
114: }
115:
116: /** This method is called from within the constructor to
117: * initialize the form.
118: * WARNING: Do NOT modify this code. The content of this method is
119: * always regenerated by the Form Editor.
120: */
121: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
122: private void initComponents() {
123:
124: jLabel2 = new javax.swing.JLabel();
125: jLabel1 = new javax.swing.JLabel();
126: propsPanel = new javax.swing.JPanel();
127: jScrollPane1 = new javax.swing.JScrollPane();
128: labelForTable = new javax.swing.JLabel();
129:
130: jLabel2.setLabelFor(comboName);
131: org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
132: org.openide.util.NbBundle.getMessage(
133: PropertiesPanel.class,
134: "PropertiesPanel.jLabel2.text")); // NOI18N
135:
136: jLabel1.setLabelFor(txtAreaValue);
137: org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
138: org.openide.util.NbBundle.getMessage(
139: PropertiesPanel.class,
140: "PropertiesPanel.jLabel1.text")); // NOI18N
141:
142: org.jdesktop.layout.GroupLayout propsPanelLayout = new org.jdesktop.layout.GroupLayout(
143: propsPanel);
144: propsPanel.setLayout(propsPanelLayout);
145: propsPanelLayout.setHorizontalGroup(propsPanelLayout
146: .createParallelGroup(
147: org.jdesktop.layout.GroupLayout.LEADING).add(0,
148: 427, Short.MAX_VALUE));
149: propsPanelLayout.setVerticalGroup(propsPanelLayout
150: .createParallelGroup(
151: org.jdesktop.layout.GroupLayout.LEADING).add(0,
152: 99, Short.MAX_VALUE));
153:
154: txtAreaValue.setColumns(20);
155: txtAreaValue.setRows(5);
156: jScrollPane1.setViewportView(txtAreaValue);
157: txtAreaValue.getAccessibleContext().setAccessibleDescription(
158: org.openide.util.NbBundle.getMessage(
159: PropertiesPanel.class, "ACSD_txtAreaValue")); // NOI18N
160:
161: org.openide.awt.Mnemonics.setLocalizedText(btnRemove,
162: org.openide.util.NbBundle.getMessage(
163: PropertiesPanel.class,
164: "PropertiesPanel.btnRemove.text")); // NOI18N
165:
166: org.openide.awt.Mnemonics.setLocalizedText(btnAdd,
167: org.openide.util.NbBundle.getMessage(
168: PropertiesPanel.class,
169: "PropertiesPanel.btnAdd.text")); // NOI18N
170: btnAdd.setMaximumSize(new java.awt.Dimension(75, 23));
171: btnAdd.setMinimumSize(new java.awt.Dimension(75, 23));
172:
173: org.openide.awt.Mnemonics.setLocalizedText(labelForTable,
174: org.openide.util.NbBundle.getMessage(
175: PropertiesPanel.class, "jLabel3.txt")); // NOI18N
176:
177: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
178: this );
179: this .setLayout(layout);
180: layout
181: .setHorizontalGroup(layout
182: .createParallelGroup(
183: org.jdesktop.layout.GroupLayout.LEADING)
184: .add(
185: layout
186: .createSequentialGroup()
187: .addContainerGap()
188: .add(
189: layout
190: .createParallelGroup(
191: org.jdesktop.layout.GroupLayout.LEADING)
192: .add(
193: propsPanel,
194: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
195: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
196: Short.MAX_VALUE)
197: .add(
198: layout
199: .createSequentialGroup()
200: .add(
201: layout
202: .createParallelGroup(
203: org.jdesktop.layout.GroupLayout.LEADING)
204: .add(
205: jLabel2)
206: .add(
207: btnAdd,
208: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
209: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
210: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
211: .add(
212: labelForTable)
213: .add(
214: jLabel1))
215: .add(
216: layout
217: .createParallelGroup(
218: org.jdesktop.layout.GroupLayout.TRAILING)
219: .add(
220: layout
221: .createParallelGroup(
222: org.jdesktop.layout.GroupLayout.TRAILING)
223: .add(
224: org.jdesktop.layout.GroupLayout.LEADING,
225: comboName,
226: 0,
227: 307,
228: Short.MAX_VALUE)
229: .add(
230: jScrollPane1,
231: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
232: 307,
233: Short.MAX_VALUE))
234: .add(
235: layout
236: .createSequentialGroup()
237: .addPreferredGap(
238: org.jdesktop.layout.LayoutStyle.RELATED)
239: .add(
240: btnRemove)))))
241: .addContainerGap()));
242:
243: layout.linkSize(new java.awt.Component[] { btnAdd, btnRemove },
244: org.jdesktop.layout.GroupLayout.HORIZONTAL);
245:
246: layout
247: .setVerticalGroup(layout
248: .createParallelGroup(
249: org.jdesktop.layout.GroupLayout.LEADING)
250: .add(
251: layout
252: .createSequentialGroup()
253: .addContainerGap()
254: .add(
255: layout
256: .createParallelGroup(
257: org.jdesktop.layout.GroupLayout.BASELINE)
258: .add(jLabel2)
259: .add(
260: comboName,
261: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
262: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
263: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
264: .addPreferredGap(
265: org.jdesktop.layout.LayoutStyle.RELATED)
266: .add(
267: layout
268: .createParallelGroup(
269: org.jdesktop.layout.GroupLayout.LEADING)
270: .add(
271: layout
272: .createSequentialGroup()
273: .add(
274: jLabel1)
275: .add(
276: 99,
277: 99,
278: 99)
279: .add(
280: layout
281: .createParallelGroup(
282: org.jdesktop.layout.GroupLayout.BASELINE)
283: .add(
284: btnAdd,
285: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
286: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
287: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
288: .add(
289: btnRemove))
290: .add(
291: 26,
292: 26,
293: 26)
294: .add(
295: labelForTable))
296: .add(
297: jScrollPane1,
298: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
299: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
300: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
301: .addPreferredGap(
302: org.jdesktop.layout.LayoutStyle.RELATED,
303: 25, Short.MAX_VALUE)
304: .add(
305: propsPanel,
306: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
307: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
308: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)));
309:
310: btnRemove.getAccessibleContext().setAccessibleDescription(
311: org.openide.util.NbBundle.getMessage(
312: PropertiesPanel.class, "ACSD_btnRemove")); // NOI18N
313: btnAdd.getAccessibleContext().setAccessibleDescription(
314: org.openide.util.NbBundle.getMessage(
315: PropertiesPanel.class, "ACSD_btnAdd")); // NOI18N
316: }// </editor-fold>//GEN-END:initComponents
317:
318: // Variables declaration - do not modify//GEN-BEGIN:variables
319: final javax.swing.JButton btnAdd = new javax.swing.JButton();
320: final javax.swing.JButton btnRemove = new javax.swing.JButton();
321: final javax.swing.JComboBox comboName = new javax.swing.JComboBox();
322: private javax.swing.JLabel jLabel1;
323: private javax.swing.JLabel jLabel2;
324: private javax.swing.JScrollPane jScrollPane1;
325: public javax.swing.JLabel labelForTable;
326: public javax.swing.JPanel propsPanel;
327: final javax.swing.JTextArea txtAreaValue = new javax.swing.JTextArea();
328: // End of variables declaration//GEN-END:variables
329:
330: }
|