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]"
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
.netbeans
.modules
.git
.options
;
44 import javax
.swing
.event
.DocumentEvent
;
45 import javax
.swing
.event
.DocumentListener
;
46 import org
.netbeans
.modules
.git
.GitAnnotator
;
47 import org
.netbeans
.modules
.git
.GitModuleConfig
;
48 import org
.netbeans
.modules
.git
.util
.GitUtils
;
50 final class GitPanel
extends javax
.swing
.JPanel
{
52 private final GitOptionsPanelController controller
;
53 private final DocumentListener listener
;
55 GitPanel(GitOptionsPanelController controller
) {
56 this.controller
= controller
;
57 this.listener
= new DocumentListener() {
58 public void insertUpdate(DocumentEvent e
) { nameChange(); }
59 public void removeUpdate(DocumentEvent e
) { nameChange(); }
60 public void changedUpdate(DocumentEvent e
) { nameChange(); }
66 public void addNotify() {
68 emailTextField
.getDocument().addDocumentListener(listener
);
72 public void removeNotify() {
73 emailTextField
.getDocument().removeDocumentListener(listener
);
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.
84 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
85 private void initComponents() {
87 emailLabel
= new javax
.swing
.JLabel();
88 execPathLabel
= new javax
.swing
.JLabel();
89 jPanel1
= new javax
.swing
.JPanel();
90 jLabel3
= new javax
.swing
.JLabel();
91 jPanel2
= new javax
.swing
.JPanel();
92 jLabel4
= new javax
.swing
.JLabel();
93 exportFilename
= new javax
.swing
.JLabel();
94 backupOnRevertModifications
= new javax
.swing
.JCheckBox();
95 userNameTextField
= new javax
.swing
.JTextField();
96 userNameLabel
= new javax
.swing
.JLabel();
98 emailLabel
.setLabelFor(emailTextField
);
99 org
.openide
.awt
.Mnemonics
.setLocalizedText(emailLabel
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.jLabel1.text")); // NOI18N
101 execPathLabel
.setLabelFor(executablePathTextField
);
102 org
.openide
.awt
.Mnemonics
.setLocalizedText(execPathLabel
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.jLabel2.text")); // NOI18N
104 org
.openide
.awt
.Mnemonics
.setLocalizedText(execPathBrowseButton
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.browseButton.text")); // NOI18N
106 jPanel1
.setBorder(javax
.swing
.BorderFactory
.createTitledBorder(org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.jPanel1.border.title"))); // NOI18N
108 jLabel3
.setLabelFor(annotationTextField
);
109 org
.openide
.awt
.Mnemonics
.setLocalizedText(jLabel3
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.jLabel3.text")); // NOI18N
111 annotationTextField
.setText(org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.annotationTextField.text")); // NOI18N
113 org
.openide
.awt
.Mnemonics
.setLocalizedText(addButton
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.addButton.text")); // NOI18N
115 org
.jdesktop
.layout
.GroupLayout jPanel1Layout
= new org
.jdesktop
.layout
.GroupLayout(jPanel1
);
116 jPanel1
.setLayout(jPanel1Layout
);
117 jPanel1Layout
.setHorizontalGroup(
118 jPanel1Layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.LEADING
)
119 .add(jPanel1Layout
.createSequentialGroup()
122 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.UNRELATED
)
123 .add(annotationTextField
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
, 405, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
)
124 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.RELATED
, 13, Short
.MAX_VALUE
)
128 jPanel1Layout
.setVerticalGroup(
129 jPanel1Layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.LEADING
)
130 .add(jPanel1Layout
.createSequentialGroup()
132 .add(jPanel1Layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.BASELINE
)
135 .add(annotationTextField
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
))
136 .addContainerGap(20, Short
.MAX_VALUE
))
139 addButton
.getAccessibleContext().setAccessibleDescription(org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "ACSD_addButton")); // NOI18N
141 jPanel2
.setBorder(javax
.swing
.BorderFactory
.createTitledBorder(""));
143 org
.openide
.awt
.Mnemonics
.setLocalizedText(jLabel4
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.jLabel4.text")); // NOI18N
145 org
.openide
.awt
.Mnemonics
.setLocalizedText(manageButton
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.manageButton.text")); // NOI18N
147 org
.jdesktop
.layout
.GroupLayout jPanel2Layout
= new org
.jdesktop
.layout
.GroupLayout(jPanel2
);
148 jPanel2
.setLayout(jPanel2Layout
);
149 jPanel2Layout
.setHorizontalGroup(
150 jPanel2Layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.LEADING
)
151 .add(jPanel2Layout
.createSequentialGroup()
154 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.RELATED
, 67, Short
.MAX_VALUE
)
158 jPanel2Layout
.setVerticalGroup(
159 jPanel2Layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.LEADING
)
160 .add(jPanel2Layout
.createSequentialGroup()
162 .add(jPanel2Layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.BASELINE
)
165 .addContainerGap(24, Short
.MAX_VALUE
))
168 manageButton
.getAccessibleContext().setAccessibleDescription(org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "ACSD_manageButton")); // NOI18N
170 exportFilename
.setLabelFor(exportFilenameTextField
);
171 org
.openide
.awt
.Mnemonics
.setLocalizedText(exportFilename
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.ExportFilename.text")); // NOI18N
173 org
.openide
.awt
.Mnemonics
.setLocalizedText(exportFilenameBrowseButton
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.browseButton2.text")); // NOI18N
175 backupOnRevertModifications
.setSelected(true);
176 org
.openide
.awt
.Mnemonics
.setLocalizedText(backupOnRevertModifications
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.jCheckBox1.text")); // NOI18N
178 userNameLabel
.setLabelFor(userNameTextField
);
179 org
.openide
.awt
.Mnemonics
.setLocalizedText(userNameLabel
, org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "GitPanel.jLabel5.text")); // NOI18N
181 org
.jdesktop
.layout
.GroupLayout layout
= new org
.jdesktop
.layout
.GroupLayout(this);
182 this.setLayout(layout
);
183 layout
.setHorizontalGroup(
184 layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.LEADING
)
185 .add(layout
.createSequentialGroup()
187 .add(layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.LEADING
)
188 .add(layout
.createSequentialGroup()
189 .add(layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.LEADING
)
190 .add(backupOnRevertModifications
)
191 .add(jPanel2
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)
192 .add(jPanel1
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)
193 .add(layout
.createSequentialGroup()
194 .add(emailLabel
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
, 160, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
)
195 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.RELATED
)
196 .add(emailTextField
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, 490, Short
.MAX_VALUE
))
197 .add(layout
.createSequentialGroup()
198 .add(userNameLabel
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, 100, Short
.MAX_VALUE
)
200 .add(userNameTextField
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, 490, Short
.MAX_VALUE
)))
202 .add(layout
.createSequentialGroup()
203 .add(layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.TRAILING
)
204 .add(layout
.createSequentialGroup()
206 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.RELATED
))
207 .add(execPathLabel
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, 170, Short
.MAX_VALUE
))
208 .add(layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.TRAILING
)
209 .add(exportFilenameTextField
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, 385, Short
.MAX_VALUE
)
210 .add(executablePathTextField
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, 385, Short
.MAX_VALUE
))
211 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.RELATED
)
212 .add(layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.TRAILING
)
213 .add(execPathBrowseButton
)
214 .add(exportFilenameBrowseButton
))
217 layout
.setVerticalGroup(
218 layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.LEADING
)
219 .add(layout
.createSequentialGroup()
221 .add(layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.BASELINE
)
223 .add(emailTextField
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
))
224 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.RELATED
)
225 .add(layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.BASELINE
)
227 .add(userNameTextField
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
))
228 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.UNRELATED
)
229 .add(layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.BASELINE
)
230 .add(execPathBrowseButton
)
231 .add(executablePathTextField
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
)
234 .add(layout
.createParallelGroup(org
.jdesktop
.layout
.GroupLayout
.BASELINE
)
235 .add(exportFilenameTextField
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
)
236 .add(exportFilenameBrowseButton
)
237 .add(exportFilename
))
238 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.RELATED
, 26, Short
.MAX_VALUE
)
239 .add(jPanel1
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
)
240 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.RELATED
)
241 .add(jPanel2
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
, org
.jdesktop
.layout
.GroupLayout
.DEFAULT_SIZE
, org
.jdesktop
.layout
.GroupLayout
.PREFERRED_SIZE
)
242 .addPreferredGap(org
.jdesktop
.layout
.LayoutStyle
.RELATED
)
243 .add(backupOnRevertModifications
)
247 emailTextField
.getAccessibleContext().setAccessibleDescription(org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "ACSD_userNameTextField")); // NOI18N
248 executablePathTextField
.getAccessibleContext().setAccessibleDescription(org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "ACSD_executablePathTextField")); // NOI18N
249 execPathBrowseButton
.getAccessibleContext().setAccessibleDescription(org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "ACSD_execPathBrowseButton")); // NOI18N
250 jPanel2
.getAccessibleContext().setAccessibleName("<GitPanel.jPanel2.border.title>");
251 exportFilenameTextField
.getAccessibleContext().setAccessibleDescription(org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "ACSD_exportFileNameTextField")); // NOI18N
252 exportFilenameBrowseButton
.getAccessibleContext().setAccessibleDescription(org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "ACSD_exportFilenameBrowseButton")); // NOI18N
253 backupOnRevertModifications
.getAccessibleContext().setAccessibleDescription(org
.openide
.util
.NbBundle
.getMessage(GitPanel
.class, "ACSD_backupOnRevertModifications")); // NOI18N
254 }// </editor-fold>//GEN-END:initComponents
256 private void nameChange() {
257 controller
.changed();
261 // TODO read settings and initialize GUI
263 // someCheckBox.setSelected(Preferences.userNodeForPackage(GitPanel.class).getBoolean("someFlag", false)); // NOI18N
264 // or for org.openide.util with API spec. version >= 7.4:
265 // someCheckBox.setSelected(NbPreferences.forModule(GitPanel.class).getBoolean("someFlag", false)); // NOI18N
267 // someTextField.setText(SomeSystemOption.getDefault().getSomeStringProperty());
268 emailTextField
.setText(GitModuleConfig
.getDefault().getEmail());
269 userNameTextField
.setText(GitModuleConfig
.getDefault().getUserName());
270 executablePathTextField
.setText(GitModuleConfig
.getDefault().getExecutableBinaryPath());
271 exportFilenameTextField
.setText(GitModuleConfig
.getDefault().getExportFilename());
272 annotationTextField
.setText(GitModuleConfig
.getDefault().getAnnotationFormat());
273 backupOnRevertModifications
.setSelected(GitModuleConfig
.getDefault().getBackupOnRevertModifications());
277 // TODO store modified settings
279 // Preferences.userNodeForPackage(GitPanel.class).putBoolean("someFlag", someCheckBox.isSelected()); // NOI18N
280 // or for org.openide.util with API spec. version >= 7.4:
281 // NbPreferences.forModule(GitPanel.class).putBoolean("someFlag", someCheckBox.isSelected()); // NOI18N
283 // SomeSystemOption.getDefault().setSomeStringProperty(someTextField.getText());
284 GitModuleConfig
.getDefault().setEmail(emailTextField
.getText());
285 GitModuleConfig
.getDefault().setUserName(userNameTextField
.getText());
286 GitModuleConfig
.getDefault().setExecutableBinaryPath(executablePathTextField
.getText());
287 GitModuleConfig
.getDefault().setExportFilename(exportFilenameTextField
.getText());
288 GitModuleConfig
.getDefault().setAnnotationFormat(annotationTextField
.getText());
289 GitModuleConfig
.getDefault().setBackupOnRevertModifications(backupOnRevertModifications
.isSelected());
290 if (GitAnnotator
.isRevisionInAnnotationFormat(annotationTextField
.getText())){
291 GitUtils
.warningDialog(GitPanel
.class,
292 "MSG_STATUS_LABEL_WITH_REVSION_TITLE", "MSG_STATUS_LABEL_WITH_REVSION_MSG");// NOI18N
297 // TODO check whether form is consistent and complete
299 String username
= emailTextField
.getText();
301 valid
= GitModuleConfig
.getDefault().isUserNameValid(username
);
302 if (!valid
) return false;
303 String execpath
= executablePathTextField
.getText();
304 valid
= GitModuleConfig
.getDefault().isExecPathValid(execpath
);
308 // Variables declaration - do not modify//GEN-BEGIN:variables
309 final javax
.swing
.JButton addButton
= new javax
.swing
.JButton();
310 final javax
.swing
.JTextField annotationTextField
= new javax
.swing
.JTextField();
311 private javax
.swing
.JCheckBox backupOnRevertModifications
;
312 private javax
.swing
.JLabel emailLabel
;
313 final javax
.swing
.JTextField emailTextField
= new javax
.swing
.JTextField();
314 final javax
.swing
.JButton execPathBrowseButton
= new javax
.swing
.JButton();
315 private javax
.swing
.JLabel execPathLabel
;
316 final javax
.swing
.JTextField executablePathTextField
= new javax
.swing
.JTextField();
317 private javax
.swing
.JLabel exportFilename
;
318 final javax
.swing
.JButton exportFilenameBrowseButton
= new javax
.swing
.JButton();
319 final javax
.swing
.JTextField exportFilenameTextField
= new javax
.swing
.JTextField();
320 private javax
.swing
.JLabel jLabel3
;
321 private javax
.swing
.JLabel jLabel4
;
322 private javax
.swing
.JPanel jPanel1
;
323 private javax
.swing
.JPanel jPanel2
;
324 final javax
.swing
.JButton manageButton
= new javax
.swing
.JButton();
325 private javax
.swing
.JLabel userNameLabel
;
326 private javax
.swing
.JTextField userNameTextField
;
327 // End of variables declaration//GEN-END:variables