Cleanup code whitespace
[nbgit.git] / src / org / nbgit / options / PropertiesPanel.java
blob58fd422511f23e92e0412392c23fa52e57d55390
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
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]"
24 * Contributor(s):
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 * Portions Copyright 2008 Alexander Coles (Ikonoklastik Productions).
31 * If you wish your version of this file to be governed by only the CDDL
32 * or only the GPL Version 2, indicate your decision by adding
33 * "[Contributor] elects to include this software in this distribution
34 * under the [CDDL or GPL Version 2] license." If you do not indicate a
35 * single choice of license, a recipient has the option to distribute
36 * your version of this file under either the CDDL, the GPL Version 2 or
37 * to extend the choice of license to its licensees as provided above.
38 * However, if you add GPL Version 2 code and therefore, elected the GPL
39 * Version 2 license, then the option applies only if the new code is
40 * made subject to such option by the copyright holder.
42 package org.nbgit.options;
44 import java.util.prefs.PreferenceChangeEvent;
45 import java.util.prefs.PreferenceChangeListener;
46 import javax.swing.event.TableModelEvent;
47 import javax.swing.event.TableModelListener;
48 import org.nbgit.GitModuleConfig;
49 import org.netbeans.modules.versioning.util.ListenersSupport;
51 /**
53 * @author Peter Pis
55 public class PropertiesPanel extends javax.swing.JPanel implements PreferenceChangeListener, TableModelListener {
57 private static final Object EVENT_SETTINGS_CHANGED = new Object();
58 private PropertiesTable propertiesTable;
59 private ListenersSupport listenerSupport = new ListenersSupport(this);
61 /** Creates new form PropertiesPanel */
62 public PropertiesPanel() {
63 initComponents();
66 public javax.swing.JTextArea getTxtAreaValue() {
67 return txtAreaValue;
70 public javax.swing.JComboBox getComboName() {
71 return comboName;
74 public javax.swing.JButton getBtnAdd() {
75 return btnAdd;
78 public javax.swing.JButton getBtnRemove() {
79 return btnRemove;
82 public void setPropertiesTable(PropertiesTable propertiesTable){
83 this.propertiesTable = propertiesTable;
86 @Override
87 public void addNotify() {
88 super.addNotify();
89 GitModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(this);
90 propertiesTable.getTableModel().addTableModelListener(this);
91 listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
92 txtAreaValue.selectAll();
95 @Override
96 public void removeNotify() {
97 propertiesTable.getTableModel().removeTableModelListener(this);
98 GitModuleConfig.getDefault().getPreferences().removePreferenceChangeListener(this);
99 super.removeNotify();
102 public void preferenceChange(PreferenceChangeEvent evt) {
103 if (evt.getKey().startsWith(GitModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
104 propertiesTable.dataChanged();
105 listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
109 public void tableChanged(TableModelEvent e) {
110 listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
113 /** This method is called from within the constructor to
114 * initialize the form.
115 * WARNING: Do NOT modify this code. The content of this method is
116 * always regenerated by the Form Editor.
118 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
119 private void initComponents() {
121 jLabel2 = new javax.swing.JLabel();
122 jLabel1 = new javax.swing.JLabel();
123 propsPanel = new javax.swing.JPanel();
124 jScrollPane1 = new javax.swing.JScrollPane();
125 labelForTable = new javax.swing.JLabel();
127 jLabel2.setLabelFor(comboName);
128 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel2.text")); // NOI18N
130 jLabel1.setLabelFor(txtAreaValue);
131 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel1.text")); // NOI18N
133 org.jdesktop.layout.GroupLayout propsPanelLayout = new org.jdesktop.layout.GroupLayout(propsPanel);
134 propsPanel.setLayout(propsPanelLayout);
135 propsPanelLayout.setHorizontalGroup(
136 propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
137 .add(0, 566, Short.MAX_VALUE)
139 propsPanelLayout.setVerticalGroup(
140 propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
141 .add(0, 99, Short.MAX_VALUE)
144 txtAreaValue.setColumns(20);
145 txtAreaValue.setRows(5);
146 jScrollPane1.setViewportView(txtAreaValue);
147 txtAreaValue.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "ACSD_txtAreaValue")); // NOI18N
149 org.openide.awt.Mnemonics.setLocalizedText(btnRemove, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnRemove.text")); // NOI18N
151 org.openide.awt.Mnemonics.setLocalizedText(btnAdd, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnAdd.text")); // NOI18N
152 btnAdd.setMaximumSize(new java.awt.Dimension(75, 23));
153 btnAdd.setMinimumSize(new java.awt.Dimension(75, 23));
155 org.openide.awt.Mnemonics.setLocalizedText(labelForTable, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "jLabel3.txt")); // NOI18N
157 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
158 this.setLayout(layout);
159 layout.setHorizontalGroup(
160 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
161 .add(layout.createSequentialGroup()
162 .addContainerGap()
163 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
164 .add(propsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
165 .add(layout.createSequentialGroup()
166 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
167 .add(jLabel2)
168 .add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
169 .add(labelForTable)
170 .add(jLabel1))
171 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
172 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
173 .add(org.jdesktop.layout.GroupLayout.LEADING, comboName, 0, 470, Short.MAX_VALUE)
174 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE))
175 .add(layout.createSequentialGroup()
176 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
177 .add(btnRemove)))))
178 .addContainerGap())
181 layout.linkSize(new java.awt.Component[] {btnAdd, btnRemove}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
183 layout.setVerticalGroup(
184 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
185 .add(layout.createSequentialGroup()
186 .addContainerGap()
187 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
188 .add(jLabel2)
189 .add(comboName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
190 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
191 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
192 .add(layout.createSequentialGroup()
193 .add(jLabel1)
194 .add(99, 99, 99)
195 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
196 .add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
197 .add(btnRemove))
198 .add(26, 26, 26)
199 .add(labelForTable))
200 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
201 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 25, Short.MAX_VALUE)
202 .add(propsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
205 btnRemove.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "ACSD_btnRemove")); // NOI18N
206 btnAdd.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "ACSD_btnAdd")); // NOI18N
207 }// </editor-fold>//GEN-END:initComponents
210 // Variables declaration - do not modify//GEN-BEGIN:variables
211 final javax.swing.JButton btnAdd = new javax.swing.JButton();
212 final javax.swing.JButton btnRemove = new javax.swing.JButton();
213 final javax.swing.JComboBox comboName = new javax.swing.JComboBox();
214 private javax.swing.JLabel jLabel1;
215 private javax.swing.JLabel jLabel2;
216 private javax.swing.JScrollPane jScrollPane1;
217 public javax.swing.JLabel labelForTable;
218 public javax.swing.JPanel propsPanel;
219 final javax.swing.JTextArea txtAreaValue = new javax.swing.JTextArea();
220 // End of variables declaration//GEN-END:variables