KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > versioning > system > cvss > options > CvsOptionsController


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.versioning.system.cvss.options;
20
21 import org.netbeans.spi.options.OptionsPanelController;
22 import org.netbeans.modules.versioning.system.cvss.CvsModuleConfig;
23 import org.openide.util.Lookup;
24 import org.openide.util.HelpCtx;
25
26 import javax.swing.*;
27 import java.beans.PropertyChangeListener JavaDoc;
28
29 /**
30  *
31  * @author Maros Sandor
32  */

33 class CvsOptionsController extends OptionsPanelController {
34
35     private CvsOptionsPanel panel;
36     
37     public void update() {
38         panel.getExcludeNewFiles().setSelected(CvsModuleConfig.getDefault().getPreferences().getBoolean(CvsModuleConfig.PROP_EXCLUDE_NEW_FILES, false));
39         panel.getStatusLabelFormat().setText(CvsModuleConfig.getDefault().getPreferences().get(CvsModuleConfig.PROP_ANNOTATIONS_FORMAT, CvsModuleConfig.DEFAULT_ANNOTATIONS_FORMAT));
40         int wrapLength = CvsModuleConfig.getDefault().getWrapCommitMessagelength();
41         panel.getWrapCommitMessages().setSelected(wrapLength > 0);
42         panel.getWrapCharCount().setText(wrapLength > 0 ? Integer.toString(wrapLength) : "");
43     }
44
45     public void applyChanges() {
46         if (!isValid()) return;
47         CvsModuleConfig.getDefault().getPreferences().putBoolean(CvsModuleConfig.PROP_EXCLUDE_NEW_FILES, panel.getExcludeNewFiles().isSelected());
48         CvsModuleConfig.getDefault().getPreferences().put(CvsModuleConfig.PROP_ANNOTATIONS_FORMAT, panel.getStatusLabelFormat().getText());
49         int wrapLength = panel.getWrapCommitMessages().isSelected() ? Integer.parseInt(panel.getWrapCharCount().getText().trim()) : 0;
50         CvsModuleConfig.getDefault().setWrapCommitMessagelength(wrapLength);
51     }
52
53     public void cancel() {
54         // nothing to do
55
}
56
57     public boolean isValid() {
58         try {
59             return !panel.getWrapCommitMessages().isSelected() || Integer.parseInt(panel.getWrapCharCount().getText().trim()) > 0;
60         } catch (Exception JavaDoc e) {
61             return false;
62         }
63     }
64
65     public boolean isChanged() {
66         return true;
67     }
68
69     public JComponent getComponent(Lookup masterLookup) {
70         if (panel == null) {
71             panel = new CvsOptionsPanel();
72         }
73         return panel;
74     }
75
76     public HelpCtx getHelpCtx() {
77         return new HelpCtx(CvsOptionsController.class);
78     }
79
80     public void addPropertyChangeListener(PropertyChangeListener JavaDoc l) {
81     }
82
83     public void removePropertyChangeListener(PropertyChangeListener JavaDoc l) {
84     }
85 }
86
Popular Tags