Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.coreplugin.app / org.gvsig.coreplugin.app.mainplugin / src / main / java / org / gvsig / coreplugin / preferences / general / NotificationsPage.java @ 41282

History | View | Annotate | Download (5.2 KB)

1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6

    
7
package org.gvsig.coreplugin.preferences.general;
8

    
9
import java.awt.GridBagConstraints;
10
import java.awt.GridBagLayout;
11
import javax.swing.ImageIcon;
12
import javax.swing.JCheckBox;
13
import javax.swing.JLabel;
14
import javax.swing.JPanel;
15
import javax.swing.SwingConstants;
16
import org.gvsig.andami.PluginServices;
17
import org.gvsig.andami.PluginsLocator;
18
import org.gvsig.andami.PluginsManager;
19
import org.gvsig.andami.preferences.AbstractPreferencePage;
20
import org.gvsig.andami.preferences.StoreException;
21
import org.gvsig.coreplugin.PreferencesExtension;
22
import org.gvsig.tools.dynobject.DynObject;
23

    
24
/**
25
 *
26
 * @author usuario
27
 */
28
public class NotificationsPage extends AbstractPreferencePage {
29

    
30
    /**
31
     * Creates new form NotificationsPage
32
     */
33
    public NotificationsPage() {
34
        initComponents();
35
    }
36

    
37
    /**
38
     * This method is called from within the constructor to
39
     * initialize the form.
40
     * WARNING: Do NOT modify this code. The content of this method is
41
     * always regenerated by the Form Editor.
42
     */
43
    @SuppressWarnings("unchecked")
44
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
45
    private void initComponents() {
46
        GridBagConstraints gridBagConstraints;
47

    
48
        jLabel1 = new JLabel();
49
        jchkShowInConsole = new JCheckBox();
50
        jchkShowInStatusbar = new JCheckBox();
51
        jLabel2 = new JLabel();
52

    
53
        GridBagLayout layout = new GridBagLayout();
54
        layout.columnWidths = new int[] {0, 5, 0};
55
        layout.rowHeights = new int[] {0, 5, 0, 5, 0, 5, 0};
56
        setLayout(layout);
57

    
58
        jLabel1.setText("Select the notification mode");
59
        jLabel1.setHorizontalTextPosition(SwingConstants.LEFT);
60
        gridBagConstraints = new GridBagConstraints();
61
        gridBagConstraints.gridx = 0;
62
        gridBagConstraints.gridy = 0;
63
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
64
        gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
65
        add(jLabel1, gridBagConstraints);
66

    
67
        jchkShowInConsole.setText("Show notificacion in console window");
68
        gridBagConstraints = new GridBagConstraints();
69
        gridBagConstraints.gridx = 0;
70
        gridBagConstraints.gridy = 4;
71
        gridBagConstraints.anchor = GridBagConstraints.WEST;
72
        add(jchkShowInConsole, gridBagConstraints);
73

    
74
        jchkShowInStatusbar.setText("Show notifications in statusbar");
75
        jchkShowInStatusbar.setHorizontalAlignment(SwingConstants.LEFT);
76
        gridBagConstraints = new GridBagConstraints();
77
        gridBagConstraints.gridx = 0;
78
        gridBagConstraints.gridy = 2;
79
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
80
        gridBagConstraints.anchor = GridBagConstraints.WEST;
81
        add(jchkShowInStatusbar, gridBagConstraints);
82

    
83
        jLabel2.setText("The changes take effect in next execution of the application");
84
        gridBagConstraints = new GridBagConstraints();
85
        gridBagConstraints.gridx = 0;
86
        gridBagConstraints.gridy = 6;
87
        add(jLabel2, gridBagConstraints);
88
    }// </editor-fold>//GEN-END:initComponents
89

    
90

    
91
    // Variables declaration - do not modify//GEN-BEGIN:variables
92
    protected JLabel jLabel1;
93
    protected JLabel jLabel2;
94
    protected JCheckBox jchkShowInConsole;
95
    protected JCheckBox jchkShowInStatusbar;
96
    // End of variables declaration//GEN-END:variables
97

    
98
    @Override
99
    public void storeValues() throws StoreException {
100
        PluginsManager pluginsManager = PluginsLocator.getManager();
101
        PluginServices plugin = pluginsManager.getPlugin(PreferencesExtension.class);
102
        
103
        DynObject pluginProperties = plugin.getPluginProperties();
104
        pluginProperties.setDynValue(
105
                "showNotificationsInConsole", 
106
                new Boolean(jchkShowInConsole.isSelected())
107
        );
108
        pluginProperties.setDynValue(
109
                "showNotificationsInStatusbar", 
110
                new Boolean(jchkShowInStatusbar.isSelected())
111
        );
112
        plugin.savePluginProperties();
113
    }
114

    
115
    @Override
116
    public void setChangesApplied() {
117

    
118
    }
119

    
120
    public String getID() {
121
        return this.getClass().getName();
122
    }
123

    
124
    public String getTitle() {
125
        return "Notificactions mode";
126
    }
127

    
128
    public JPanel getPanel() {
129
        return this;
130
    }
131

    
132
    public void initializeValues() {
133
        PluginsManager pluginsManager = PluginsLocator.getManager();
134
        PluginServices plugin = pluginsManager.getPlugin(PreferencesExtension.class);
135
        
136
        DynObject pluginProperties = plugin.getPluginProperties();
137
        jchkShowInStatusbar.setSelected(
138
                ((Boolean)pluginProperties.getDynValue("showNotificationsInStatusbar")).booleanValue());
139
        jchkShowInConsole.setSelected(
140
                ((Boolean)pluginProperties.getDynValue("showNotificationsInConsole")).booleanValue());
141
    }
142

    
143
    public void initializeDefaults() {
144
        jchkShowInStatusbar.setSelected(true);
145
        jchkShowInConsole.setSelected(false);
146
    }
147

    
148
    public ImageIcon getIcon() {
149
        return null;
150
    }
151

    
152
    public boolean isValueChanged() {
153
        return true;
154
    }
155
}