Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / gui / preferences / FieldExpresionPage.java @ 40557

History | View | Annotate | Download (4.62 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

    
25
package org.gvsig.editing.gui.preferences;
26

    
27
import java.awt.event.MouseEvent;
28
import java.awt.event.MouseListener;
29
import java.util.prefs.Preferences;
30

    
31
import javax.swing.ImageIcon;
32
import javax.swing.JCheckBox;
33
import javax.swing.JPanel;
34
import javax.swing.JTextArea;
35
import javax.swing.JTextField;
36

    
37
import org.gvsig.andami.PluginServices;
38
import org.gvsig.andami.preferences.AbstractPreferencePage;
39
import org.gvsig.andami.preferences.StoreException;
40

    
41

    
42
/**
43
* @author Vicente Caballero Navarro
44
**/
45
public class FieldExpresionPage extends AbstractPreferencePage {
46
        private static Preferences prefs = Preferences.userRoot().node( "fieldExpresionOptions" );
47
        private JTextArea jTextArea = null;
48
        private JTextField txtLimit;
49
        private JCheckBox ckLimit=null;
50
        private ImageIcon icon;
51

    
52
        public FieldExpresionPage() {
53
                super();
54
                icon = PluginServices.getIconTheme().get("field-expresion");
55
                addComponent(getJTextArea());
56

    
57
                addComponent(PluginServices.getText(this, "limit_rows_in_memory") + ":",
58
                        txtLimit = new JTextField("", 15));
59
                addComponent(ckLimit = new JCheckBox(PluginServices.getText(this, "without_limit")));
60
                ckLimit.addMouseListener(new MouseListener() {
61
                        public void mouseClicked(MouseEvent e) {
62
                                if (ckLimit.isSelected()) {
63
                                        txtLimit.setText(PluginServices.getText(this, "without_limit"));
64
                                }else {
65
                                        if (txtLimit.getText().equals(PluginServices.getText(this, "without_limit")))
66
                                        txtLimit.setText("500000");
67
                                }
68

    
69
                        }
70
                        public void mouseEntered(MouseEvent e) {
71
                        }
72
                        public void mouseExited(MouseEvent e) {
73
                        }
74
                        public void mousePressed(MouseEvent e) {
75
                        }
76
                        public void mouseReleased(MouseEvent e) {
77
                        }
78

    
79
                });
80
        }
81

    
82
        public void initializeValues() {
83
                int limit = prefs.getInt("limit_rows_in_memory",-1);
84
                if (limit==-1) {
85
                        ckLimit.setSelected(true);
86
                        txtLimit.setText(PluginServices.getText(this,"without_limit"));
87
                }else {
88
                        ckLimit.setSelected(false);
89
                        txtLimit.setText(String.valueOf(limit));
90
                }
91
        }
92

    
93
        public String getID() {
94
                return this.getClass().getName();
95
        }
96

    
97
        public String getTitle() {
98
                return PluginServices.getText(this, "limit_rows_in_memory");
99
        }
100

    
101
        public JPanel getPanel() {
102
                return this;
103
        }
104

    
105
        public void storeValues() throws StoreException {
106
                int limit;
107
                try{
108
                        if (ckLimit.isSelected()) {
109
                                limit=-1;
110
                        }else {
111
//                        if (txtLimit.getText().equals(PluginServices.getText(this,"without_limit"))) {
112
//                                limit=-1;
113
//                        }else {
114
                                limit=Integer.parseInt(txtLimit.getText());
115
                        }
116
                }catch (Exception e) {
117
                        throw new StoreException(PluginServices.getText(this,"limit_rows_in_memory")+PluginServices.getText(this,"error"));
118
                }
119
                prefs.putInt("limit_rows_in_memory", limit);
120
        }
121

    
122
        public void initializeDefaults() {
123
                int limit=prefs.getInt("limit_rows_in_memory",-1);
124
                if (limit==-1) {
125
                        ckLimit.setSelected(true);
126
                        txtLimit.setText(PluginServices.getText(this,"without_limit"));
127
                }else {
128
                        ckLimit.setSelected(false);
129
                        txtLimit.setText(String.valueOf(limit));
130
                }
131
        }
132

    
133
        public ImageIcon getIcon() {
134
                return icon;
135
        }
136
        /**
137
         * This method initializes jTextArea
138
         *
139
         * @return javax.swing.JTextArea
140
         */
141
        private JTextArea getJTextArea() {
142
                if (jTextArea == null) {
143
                        jTextArea = new JTextArea();
144
                        jTextArea.setBounds(new java.awt.Rectangle(13,7,285,57));
145
                        jTextArea.setForeground(java.awt.Color.black);
146
                        jTextArea.setBackground(java.awt.SystemColor.control);
147
                        jTextArea.setRows(3);
148
                        jTextArea.setWrapStyleWord(true);
149
                        jTextArea.setLineWrap(true);
150
                        jTextArea.setEditable(false);
151
                        jTextArea.setText(PluginServices.getText(this,"specifies_the_limit_rows_in_memory_when_the_program_eval_the_expresion"));
152
                }
153
                return jTextArea;
154
        }
155

    
156
        public boolean isValueChanged() {
157
                return super.hasChanged();
158
        }
159

    
160
        public void setChangesApplied() {
161
                setChanged(false);
162
        }
163
}