Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / preferences / FieldExpresionPage.java @ 15637

History | View | Annotate | Download (4.87 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

    
42

    
43
package com.iver.cit.gvsig.gui.preferences;
44

    
45
import java.awt.event.MouseEvent;
46
import java.awt.event.MouseListener;
47
import java.util.prefs.Preferences;
48

    
49
import javax.swing.ImageIcon;
50
import javax.swing.JCheckBox;
51
import javax.swing.JPanel;
52
import javax.swing.JTextArea;
53
import javax.swing.JTextField;
54

    
55
import com.iver.andami.PluginServices;
56
import com.iver.andami.preferences.AbstractPreferencePage;
57
import com.iver.andami.preferences.StoreException;
58
/**
59
* @author Vicente Caballero Navarro
60
**/
61
public class FieldExpresionPage extends AbstractPreferencePage {
62
        private static Preferences prefs = Preferences.userRoot().node( "fieldExpresionOptions" );
63
        private JTextArea jTextArea = null;
64
        private JTextField txtLimit;
65
        private JCheckBox ckLimit=null;
66
        private ImageIcon icon;
67

    
68
        public FieldExpresionPage() {
69
                super();
70
                icon = PluginServices.getIconTheme().get("field-expresion");
71
                addComponent(getJTextArea());
72

    
73
                addComponent(PluginServices.getText(this, "limit_rows_in_memory") + ":",
74
                        txtLimit = new JTextField("", 15));
75
                addComponent(ckLimit = new JCheckBox(PluginServices.getText(this, "without_limit")));
76
                ckLimit.addMouseListener(new MouseListener() {
77
                        public void mouseClicked(MouseEvent e) {
78
                                if (ckLimit.isSelected()) {
79
                                        txtLimit.setText(PluginServices.getText(this, "without_limit"));
80
                                }else {
81
                                        if (txtLimit.getText().equals(PluginServices.getText(this, "without_limit")))
82
                                        txtLimit.setText("500000");
83
                                }
84

    
85
                        }
86
                        public void mouseEntered(MouseEvent e) {
87
                        }
88
                        public void mouseExited(MouseEvent e) {
89
                        }
90
                        public void mousePressed(MouseEvent e) {
91
                        }
92
                        public void mouseReleased(MouseEvent e) {
93
                        }
94

    
95
                });
96
        }
97

    
98
        public void initializeValues() {
99
                int limit = prefs.getInt("limit_rows_in_memory",-1);
100
                if (limit==-1) {
101
                        ckLimit.setSelected(true);
102
                        txtLimit.setText(PluginServices.getText(this,"without_limit"));
103
                }else {
104
                        ckLimit.setSelected(false);
105
                        txtLimit.setText(String.valueOf(limit));
106
                }
107
        }
108

    
109
        public String getID() {
110
                return this.getClass().getName();
111
        }
112

    
113
        public String getTitle() {
114
                return PluginServices.getText(this, "limit_rows_in_memory");
115
        }
116

    
117
        public JPanel getPanel() {
118
                return this;
119
        }
120

    
121
        public void storeValues() throws StoreException {
122
                int limit;
123
                try{
124
                        if (ckLimit.isSelected()) {
125
                                limit=-1;
126
                        }else {
127
//                        if (txtLimit.getText().equals(PluginServices.getText(this,"without_limit"))) {
128
//                                limit=-1;
129
//                        }else {
130
                                limit=Integer.parseInt(txtLimit.getText());
131
                        }
132
                }catch (Exception e) {
133
                        throw new StoreException(PluginServices.getText(this,"limit_rows_in_memory")+PluginServices.getText(this,"error"));
134
                }
135
                prefs.putInt("limit_rows_in_memory", limit);
136
        }
137

    
138
        public void initializeDefaults() {
139
                int limit=prefs.getInt("limit_rows_in_memory",-1);
140
                if (limit==-1) {
141
                        ckLimit.setSelected(true);
142
                        txtLimit.setText(PluginServices.getText(this,"without_limit"));
143
                }else {
144
                        ckLimit.setSelected(false);
145
                        txtLimit.setText(String.valueOf(limit));
146
                }
147
        }
148

    
149
        public ImageIcon getIcon() {
150
                return icon;
151
        }
152
        /**
153
         * This method initializes jTextArea
154
         *
155
         * @return javax.swing.JTextArea
156
         */
157
        private JTextArea getJTextArea() {
158
                if (jTextArea == null) {
159
                        jTextArea = new JTextArea();
160
                        jTextArea.setBounds(new java.awt.Rectangle(13,7,285,57));
161
                        jTextArea.setForeground(java.awt.Color.black);
162
                        jTextArea.setBackground(java.awt.SystemColor.control);
163
                        jTextArea.setRows(3);
164
                        jTextArea.setWrapStyleWord(true);
165
                        jTextArea.setLineWrap(true);
166
                        jTextArea.setEditable(false);
167
                        jTextArea.setText(PluginServices.getText(this,"specifies_the_limit_rows_in_memory_when_the_program_eval_the_expresion"));
168
                }
169
                return jTextArea;
170
        }
171

    
172
        public boolean isValueChanged() {
173
                return super.hasChanged();
174
        }
175

    
176
        public void setChangesApplied() {
177
                setChanged(false);
178
        }
179
}