root / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / preferences / FieldExpresionPage.java @ 10254
History | View | Annotate | Download (4.98 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 |
import javax.swing.event.ChangeEvent; |
55 |
import javax.swing.event.ChangeListener; |
56 |
|
57 |
import com.iver.andami.PluginServices; |
58 |
import com.iver.andami.preferences.AbstractPreferencePage; |
59 |
import com.iver.andami.preferences.StoreException; |
60 |
/**
|
61 |
* @author Vicente Caballero Navarro
|
62 |
**/
|
63 |
public class FieldExpresionPage extends AbstractPreferencePage { |
64 |
private static Preferences prefs = Preferences.userRoot().node( "fieldExpresionOptions" ); |
65 |
private JTextArea jTextArea = null; |
66 |
private JTextField txtLimit; |
67 |
private JCheckBox ckLimit=null; |
68 |
private ImageIcon icon; |
69 |
|
70 |
public FieldExpresionPage() {
|
71 |
super();
|
72 |
icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/FieldExpresion.png")); |
73 |
addComponent(getJTextArea()); |
74 |
|
75 |
addComponent(PluginServices.getText(this, "limit_rows_in_memory") + ":", |
76 |
txtLimit = new JTextField("", 15)); |
77 |
addComponent(ckLimit = new JCheckBox(PluginServices.getText(this, "without_limit"))); |
78 |
ckLimit.addMouseListener(new MouseListener() { |
79 |
public void mouseClicked(MouseEvent e) { |
80 |
if (ckLimit.isSelected()) {
|
81 |
txtLimit.setText(PluginServices.getText(this, "without_limit")); |
82 |
}else {
|
83 |
if (txtLimit.getText().equals(PluginServices.getText(this, "without_limit"))) |
84 |
txtLimit.setText("500000");
|
85 |
} |
86 |
|
87 |
} |
88 |
public void mouseEntered(MouseEvent e) { |
89 |
} |
90 |
public void mouseExited(MouseEvent e) { |
91 |
} |
92 |
public void mousePressed(MouseEvent e) { |
93 |
} |
94 |
public void mouseReleased(MouseEvent e) { |
95 |
} |
96 |
|
97 |
}); |
98 |
} |
99 |
|
100 |
public void initializeValues() { |
101 |
int limit = prefs.getInt("limit_rows_in_memory",-1); |
102 |
if (limit==-1) { |
103 |
ckLimit.setSelected(true);
|
104 |
txtLimit.setText(PluginServices.getText(this,"without_limit")); |
105 |
}else {
|
106 |
ckLimit.setSelected(false);
|
107 |
txtLimit.setText(String.valueOf(limit));
|
108 |
} |
109 |
} |
110 |
|
111 |
public String getID() { |
112 |
return this.getClass().getName(); |
113 |
} |
114 |
|
115 |
public String getTitle() { |
116 |
return PluginServices.getText(this, "limit_rows_in_memory"); |
117 |
} |
118 |
|
119 |
public JPanel getPanel() { |
120 |
return this; |
121 |
} |
122 |
|
123 |
public void storeValues() throws StoreException { |
124 |
int limit;
|
125 |
try{
|
126 |
if (ckLimit.isSelected()) {
|
127 |
limit=-1;
|
128 |
}else {
|
129 |
// if (txtLimit.getText().equals(PluginServices.getText(this,"without_limit"))) {
|
130 |
// limit=-1;
|
131 |
// }else {
|
132 |
limit=Integer.parseInt(txtLimit.getText());
|
133 |
} |
134 |
}catch (Exception e) { |
135 |
throw new StoreException(PluginServices.getText(this,"limit_rows_in_memory")+PluginServices.getText(this,"error")); |
136 |
} |
137 |
prefs.putInt("limit_rows_in_memory", limit);
|
138 |
} |
139 |
|
140 |
public void initializeDefaults() { |
141 |
int limit=prefs.getInt("limit_rows_in_memory",-1); |
142 |
if (limit==-1) { |
143 |
ckLimit.setSelected(true);
|
144 |
txtLimit.setText(PluginServices.getText(this,"without_limit")); |
145 |
}else {
|
146 |
ckLimit.setSelected(false);
|
147 |
txtLimit.setText(String.valueOf(limit));
|
148 |
} |
149 |
} |
150 |
|
151 |
public ImageIcon getIcon() { |
152 |
return icon;
|
153 |
} |
154 |
/**
|
155 |
* This method initializes jTextArea
|
156 |
*
|
157 |
* @return javax.swing.JTextArea
|
158 |
*/
|
159 |
private JTextArea getJTextArea() { |
160 |
if (jTextArea == null) { |
161 |
jTextArea = new JTextArea(); |
162 |
jTextArea.setBounds(new java.awt.Rectangle(13,7,285,57)); |
163 |
jTextArea.setForeground(java.awt.Color.black); |
164 |
jTextArea.setBackground(java.awt.SystemColor.control); |
165 |
jTextArea.setRows(3);
|
166 |
jTextArea.setWrapStyleWord(true);
|
167 |
jTextArea.setLineWrap(true);
|
168 |
jTextArea.setEditable(false);
|
169 |
jTextArea.setText(PluginServices.getText(this,"specifies_the_limit_rows_in_memory_when_the_program_eval_the_expresion")); |
170 |
} |
171 |
return jTextArea;
|
172 |
} |
173 |
|
174 |
public boolean isValueChanged() { |
175 |
return super.hasChanged(); |
176 |
} |
177 |
|
178 |
public void setChangesApplied() { |
179 |
setChanged(false);
|
180 |
} |
181 |
} |