Revision 693
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.131/src/test/java/org/gvsig/expressionfield/AllTests.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield; |
|
2 |
|
|
3 |
import junit.framework.Test; |
|
4 |
import junit.framework.TestSuite; |
|
5 |
|
|
6 |
public class AllTests { |
|
7 |
|
|
8 |
public static Test suite() { |
|
9 |
TestSuite suite = new TestSuite( |
|
10 |
"Test for com.iver.cit.gvsig.expressionField"); |
|
11 |
//$JUnit-BEGIN$ |
|
12 |
|
|
13 |
//$JUnit-END$ |
|
14 |
return suite; |
|
15 |
} |
|
16 |
|
|
17 |
} |
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.131/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<!-- |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
--> |
|
26 |
<assembly> |
|
27 |
<id>gvsig-plugin-package</id> |
|
28 |
<formats> |
|
29 |
<format>zip</format> |
|
30 |
</formats> |
|
31 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
32 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
33 |
<files> |
|
34 |
<file> |
|
35 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
36 |
<outputDirectory>lib</outputDirectory> |
|
37 |
</file> |
|
38 |
<file> |
|
39 |
<source>target/package.info</source> |
|
40 |
</file> |
|
41 |
</files> |
|
42 |
|
|
43 |
<fileSets> |
|
44 |
<fileSet> |
|
45 |
<directory>src/main/resources-plugin</directory> |
|
46 |
<outputDirectory>.</outputDirectory> |
|
47 |
</fileSet> |
|
48 |
</fileSets> |
|
49 |
|
|
50 |
<dependencySets> |
|
51 |
<dependencySet> |
|
52 |
<useProjectArtifact>false</useProjectArtifact> |
|
53 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
54 |
<outputDirectory>lib</outputDirectory> |
|
55 |
<includes> |
|
56 |
<include>bsf:bsf</include> |
|
57 |
<include>org.python:jython</include> |
|
58 |
<include>com.fifesoft:rsyntaxtextarea</include> |
|
59 |
</includes> |
|
60 |
</dependencySet> |
|
61 |
</dependencySets> |
|
62 |
|
|
63 |
</assembly> |
|
64 |
|
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.131/src/main/java/org/gvsig/expressionfield/project/documents/table/IOperator.java | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* |
|
3 |
* gvSIG. Desktop Geographic Information System. |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 3 |
|
10 |
* of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
21 |
* |
|
22 |
* For any additional information, do not hesitate to contact us |
|
23 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
* |
|
25 |
*******************************************************************************/ |
|
26 |
package org.gvsig.expressionfield.project.documents.table; |
|
27 |
|
|
28 |
import org.apache.bsf.BSFException; |
|
29 |
import org.apache.bsf.BSFManager; |
|
30 |
|
|
31 |
/** |
|
32 |
* @author Vicente Caballero Navarro |
|
33 |
*/ |
|
34 |
public interface IOperator { |
|
35 |
int NUMBER = 0; |
|
36 |
int STRING = 1; |
|
37 |
int DATE = 2; |
|
38 |
public String addText(String s); |
|
39 |
public String toString(); |
|
40 |
public void eval(BSFManager interpreter) throws BSFException ; |
|
41 |
public boolean isEnable(); |
|
42 |
public void setType(int fieldType); |
|
43 |
public String getTooltip(); |
|
44 |
} |
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.131/src/main/java/org/gvsig/expressionfield/project/documents/table/gui/AdvancedPanel.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.gui; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.event.ActionEvent; |
|
5 |
import java.awt.event.ActionListener; |
|
6 |
import java.io.File; |
|
7 |
import java.io.IOException; |
|
8 |
import javax.swing.JFileChooser; |
|
9 |
import javax.swing.JOptionPane; |
|
10 |
import org.apache.bsf.BSFException; |
|
11 |
import org.apache.bsf.BSFManager; |
|
12 |
import org.apache.commons.io.FileUtils; |
|
13 |
import org.apache.commons.lang.StringUtils; |
|
14 |
import org.gvsig.app.ApplicationLocator; |
|
15 |
import org.gvsig.app.ApplicationManager; |
|
16 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
17 |
import org.gvsig.tools.ToolsLocator; |
|
18 |
import org.gvsig.tools.i18n.I18nManager; |
|
19 |
import org.gvsig.utils.GenericFileFilter; |
|
20 |
import org.slf4j.Logger; |
|
21 |
import org.slf4j.LoggerFactory; |
|
22 |
import org.gvsig.expressionfield.project.documents.table.gui.syntaxhighlight.JRSyntaxTextArea; |
|
23 |
import org.gvsig.expressionfield.project.documents.table.gui.syntaxhighlight.SyntaxtHighlightTextComponent; |
|
24 |
|
|
25 |
public class AdvancedPanel extends AdvancedPanelLayout { |
|
26 |
|
|
27 |
private static Logger logger = LoggerFactory.getLogger(AdvancedPanel.class); |
|
28 |
|
|
29 |
private BSFManager interpreter = null; |
|
30 |
private SyntaxtHighlightTextComponent textArea = null; |
|
31 |
|
|
32 |
public AdvancedPanel(BSFManager interpreter) { |
|
33 |
super(); |
|
34 |
this.interpreter = interpreter; |
|
35 |
initComponents(); |
|
36 |
translate(); |
|
37 |
} |
|
38 |
|
|
39 |
private void translate() { |
|
40 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
41 |
this.butLoad.setToolTipText(i18nManager.getTranslation("_Load_script_from_file")); |
|
42 |
this.butSave.setToolTipText(i18nManager.getTranslation("_Save_script_to_file")); |
|
43 |
this.butTest.setToolTipText(i18nManager.getTranslation("_Run_script_for_testing")); |
|
44 |
} |
|
45 |
|
|
46 |
private void initComponents() { |
|
47 |
// this.butLoad.setIcon(...); |
|
48 |
// this.butSave.setIcon(...); |
|
49 |
// this.butTest.setIcon(...); |
|
50 |
this.editorContainer.setLayout(new BorderLayout()); |
|
51 |
this.textArea = new JRSyntaxTextArea(); |
|
52 |
this.editorContainer.add(textArea.getJTextComponent(), BorderLayout.CENTER); |
|
53 |
|
|
54 |
this.butLoad.addActionListener(new ActionListener() { |
|
55 |
public void actionPerformed(ActionEvent ae) { |
|
56 |
doLoad(); |
|
57 |
} |
|
58 |
}); |
|
59 |
this.butSave.addActionListener(new ActionListener() { |
|
60 |
public void actionPerformed(ActionEvent ae) { |
|
61 |
doSave(); |
|
62 |
} |
|
63 |
}); |
|
64 |
this.butTest.addActionListener(new ActionListener() { |
|
65 |
public void actionPerformed(ActionEvent ae) { |
|
66 |
doTest(); |
|
67 |
} |
|
68 |
}); |
|
69 |
} |
|
70 |
|
|
71 |
private void doLoad() { |
|
72 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
73 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
74 |
File files[] = application.showChooserDialog( |
|
75 |
i18nManager.getTranslation("_Seleccione_el_script_a_cargar"), |
|
76 |
JFileChooser.OPEN_DIALOG, |
|
77 |
JFileChooser.FILES_ONLY, |
|
78 |
false, |
|
79 |
null, |
|
80 |
new GenericFileFilter(new String[]{"py", "txt"}, i18nManager.getTranslation("python")), |
|
81 |
false |
|
82 |
); |
|
83 |
if (files != null && files.length >= 1) { |
|
84 |
String code; |
|
85 |
try { |
|
86 |
code = FileUtils.readFileToString(files[0]); |
|
87 |
} catch (IOException ex) { |
|
88 |
logger.warn("Can't read file '" + files[0].getAbsolutePath() + "'.", ex); |
|
89 |
application.messageDialog( |
|
90 |
i18nManager.getTranslation("_No_se_puede_cargar_el_fichero_seleccionado"), |
|
91 |
i18nManager.getTranslation("_Atencion"), |
|
92 |
JOptionPane.WARNING_MESSAGE); |
|
93 |
return; |
|
94 |
} |
|
95 |
this.textArea.setText(code); |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
private void doSave() { |
|
100 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
101 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
102 |
String code = this.getCode(); |
|
103 |
if (code == null) { |
|
104 |
application.messageDialog( |
|
105 |
i18nManager.getTranslation("_No_hay_ningun_script_cargado"), |
|
106 |
i18nManager.getTranslation("_Informacion"), |
|
107 |
JOptionPane.INFORMATION_MESSAGE); |
|
108 |
return; |
|
109 |
} |
|
110 |
File files[] = application.showChooserDialog( |
|
111 |
i18nManager.getTranslation("_Seleccione_el_script_a_cargar"), |
|
112 |
JFileChooser.SAVE_DIALOG, |
|
113 |
JFileChooser.FILES_ONLY, |
|
114 |
false, |
|
115 |
null, |
|
116 |
new GenericFileFilter(new String[]{"py", "txt"}, i18nManager.getTranslation("python")), |
|
117 |
false |
|
118 |
); |
|
119 |
if (files != null && files.length >= 1) { |
|
120 |
try { |
|
121 |
FileUtils.writeStringToFile(files[0], code); |
|
122 |
} catch (IOException ex) { |
|
123 |
logger.warn("Can't write file '" + files[0].getAbsolutePath() + "'.", ex); |
|
124 |
application.messageDialog( |
|
125 |
i18nManager.getTranslation("_No_se_puede_guardar_en_el_fichero_seleccionado"), |
|
126 |
i18nManager.getTranslation("_Atencion"), |
|
127 |
JOptionPane.WARNING_MESSAGE); |
|
128 |
return; |
|
129 |
} |
|
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
private void doTest() { |
|
134 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
135 |
final ApplicationManager application = ApplicationLocator.getManager(); |
|
136 |
String code = this.getCode(); |
|
137 |
if (code == null) { |
|
138 |
application.messageDialog( |
|
139 |
i18nManager.getTranslation("_No_hay_ningun_script_cargado"), |
|
140 |
i18nManager.getTranslation("_Informacion"), |
|
141 |
JOptionPane.INFORMATION_MESSAGE); |
|
142 |
return; |
|
143 |
} |
|
144 |
try { |
|
145 |
interpreter.exec(ExpressionFieldExtension.JYTHON, null, -1, -1, code); |
|
146 |
} catch (BSFException ex) { |
|
147 |
logger.warn("Can't execute script:\n" + code + "\n", ex); |
|
148 |
application.messageDialog( |
|
149 |
i18nManager.getTranslation("_Se_han_producido_errores") + "\n\n" + ex.getMessage(), |
|
150 |
i18nManager.getTranslation("_Atencion"), |
|
151 |
JOptionPane.WARNING_MESSAGE); |
|
152 |
return; |
|
153 |
} |
|
154 |
application.messageDialog( |
|
155 |
i18nManager.getTranslation("_Ejecucion_correcta"), |
|
156 |
i18nManager.getTranslation("_Informacion"), |
|
157 |
JOptionPane.INFORMATION_MESSAGE); |
|
158 |
} |
|
159 |
|
|
160 |
public String getCode() { |
|
161 |
String code = this.textArea.getText(); |
|
162 |
code = code.trim(); |
|
163 |
if (StringUtils.isBlank(code)) { |
|
164 |
return null; |
|
165 |
} |
|
166 |
return code; |
|
167 |
} |
|
168 |
|
|
169 |
} |
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.131/src/main/java/org/gvsig/expressionfield/project/documents/table/gui/AdvancedPanelLayout.form | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
|
|
3 |
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> |
|
4 |
<AuxValues> |
|
5 |
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> |
|
6 |
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> |
|
7 |
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> |
|
8 |
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> |
|
9 |
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> |
|
10 |
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> |
|
11 |
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> |
|
12 |
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> |
|
13 |
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="4"/> |
|
14 |
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> |
|
15 |
</AuxValues> |
|
16 |
<SubComponents> |
|
17 |
<Component class="javax.swing.Box$Filler" name="filler2"> |
|
18 |
<Properties> |
|
19 |
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> |
|
20 |
<Dimension value="[4, 4]"/> |
|
21 |
</Property> |
|
22 |
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> |
|
23 |
<Dimension value="[4, 4]"/> |
|
24 |
</Property> |
|
25 |
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> |
|
26 |
<Dimension value="[4, 4]"/> |
|
27 |
</Property> |
|
28 |
</Properties> |
|
29 |
<AuxValues> |
|
30 |
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.RigidArea"/> |
|
31 |
</AuxValues> |
|
32 |
<Constraints> |
|
33 |
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> |
|
34 |
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> |
|
35 |
</Constraint> |
|
36 |
</Constraints> |
|
37 |
</Component> |
|
38 |
<Component class="javax.swing.JButton" name="butLoad"> |
|
39 |
<Properties> |
|
40 |
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> |
|
41 |
<Image iconType="3" name="/org/gvsig/expressionfield/project/documents/table/gui/document-open.png"/> |
|
42 |
</Property> |
|
43 |
<Property name="toolTipText" type="java.lang.String" value="Load script from file" noResource="true"/> |
|
44 |
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> |
|
45 |
<Border info="null"/> |
|
46 |
</Property> |
|
47 |
</Properties> |
|
48 |
<Constraints> |
|
49 |
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> |
|
50 |
<GridBagConstraints gridX="2" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> |
|
51 |
</Constraint> |
|
52 |
</Constraints> |
|
53 |
</Component> |
|
54 |
<Component class="javax.swing.JButton" name="butSave"> |
|
55 |
<Properties> |
|
56 |
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> |
|
57 |
<Image iconType="3" name="/org/gvsig/expressionfield/project/documents/table/gui/document-save.png"/> |
|
58 |
</Property> |
|
59 |
<Property name="toolTipText" type="java.lang.String" value="Save script to file"/> |
|
60 |
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> |
|
61 |
<Border info="null"/> |
|
62 |
</Property> |
|
63 |
</Properties> |
|
64 |
<Constraints> |
|
65 |
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> |
|
66 |
<GridBagConstraints gridX="4" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> |
|
67 |
</Constraint> |
|
68 |
</Constraints> |
|
69 |
</Component> |
|
70 |
<Component class="javax.swing.JButton" name="butTest"> |
|
71 |
<Properties> |
|
72 |
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> |
|
73 |
<Image iconType="3" name="/org/gvsig/expressionfield/project/documents/table/gui/tools-scripting-launcher.png"/> |
|
74 |
</Property> |
|
75 |
<Property name="toolTipText" type="java.lang.String" value="Run script for testing"/> |
|
76 |
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> |
|
77 |
<Border info="null"/> |
|
78 |
</Property> |
|
79 |
</Properties> |
|
80 |
<Constraints> |
|
81 |
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> |
|
82 |
<GridBagConstraints gridX="6" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> |
|
83 |
</Constraint> |
|
84 |
</Constraints> |
|
85 |
</Component> |
|
86 |
<Component class="javax.swing.Box$Filler" name="filler3"> |
|
87 |
<Properties> |
|
88 |
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> |
|
89 |
<Dimension value="[32767, 0]"/> |
|
90 |
</Property> |
|
91 |
</Properties> |
|
92 |
<AuxValues> |
|
93 |
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalGlue"/> |
|
94 |
</AuxValues> |
|
95 |
<Constraints> |
|
96 |
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> |
|
97 |
<GridBagConstraints gridX="8" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.1" weightY="0.0"/> |
|
98 |
</Constraint> |
|
99 |
</Constraints> |
|
100 |
</Component> |
|
101 |
<Component class="javax.swing.Box$Filler" name="filler4"> |
|
102 |
<Properties> |
|
103 |
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> |
|
104 |
<Dimension value="[4, 4]"/> |
|
105 |
</Property> |
|
106 |
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> |
|
107 |
<Dimension value="[4, 4]"/> |
|
108 |
</Property> |
|
109 |
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> |
|
110 |
<Dimension value="[4, 4]"/> |
|
111 |
</Property> |
|
112 |
</Properties> |
|
113 |
<AuxValues> |
|
114 |
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.RigidArea"/> |
|
115 |
</AuxValues> |
|
116 |
<Constraints> |
|
117 |
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> |
|
118 |
<GridBagConstraints gridX="10" gridY="6" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> |
|
119 |
</Constraint> |
|
120 |
</Constraints> |
|
121 |
</Component> |
|
122 |
<Container class="javax.swing.JPanel" name="editorContainer"> |
|
123 |
<Properties> |
|
124 |
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> |
|
125 |
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> |
|
126 |
<LineBorder/> |
|
127 |
</Border> |
|
128 |
</Property> |
|
129 |
</Properties> |
|
130 |
<Constraints> |
|
131 |
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> |
|
132 |
<GridBagConstraints gridX="2" gridY="4" gridWidth="7" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.1" weightY="0.1"/> |
|
133 |
</Constraint> |
|
134 |
</Constraints> |
|
135 |
|
|
136 |
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> |
|
137 |
</Container> |
|
138 |
</SubComponents> |
|
139 |
<LayoutCode> |
|
140 |
<CodeStatement> |
|
141 |
<CodeExpression id="1_layout"> |
|
142 |
<CodeVariable name="layout" type="4096" declaredType="java.awt.GridBagLayout"/> |
|
143 |
<ExpressionOrigin> |
|
144 |
<ExpressionProvider type="CodeConstructor"> |
|
145 |
<CodeConstructor class="java.awt.GridBagLayout" parameterTypes=""/> |
|
146 |
</ExpressionProvider> |
|
147 |
</ExpressionOrigin> |
|
148 |
</CodeExpression> |
|
149 |
<StatementProvider type="CodeExpression"> |
|
150 |
<CodeExpression id="1_layout"/> |
|
151 |
</StatementProvider> |
|
152 |
</CodeStatement> |
|
153 |
<CodeStatement> |
|
154 |
<CodeExpression id="1_layout"/> |
|
155 |
<StatementProvider type="CodeField"> |
|
156 |
<CodeField name="columnWidths" class="java.awt.GridBagLayout"/> |
|
157 |
</StatementProvider> |
|
158 |
<Parameters> |
|
159 |
<CodeExpression id="2"> |
|
160 |
<ExpressionOrigin> |
|
161 |
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor"> |
|
162 |
<PropertyValue value="[0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]"/> |
|
163 |
</Value> |
|
164 |
</ExpressionOrigin> |
|
165 |
</CodeExpression> |
|
166 |
</Parameters> |
|
167 |
</CodeStatement> |
|
168 |
<CodeStatement> |
|
169 |
<CodeExpression id="1_layout"/> |
|
170 |
<StatementProvider type="CodeField"> |
|
171 |
<CodeField name="rowHeights" class="java.awt.GridBagLayout"/> |
|
172 |
</StatementProvider> |
|
173 |
<Parameters> |
|
174 |
<CodeExpression id="3"> |
|
175 |
<ExpressionOrigin> |
|
176 |
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor"> |
|
177 |
<PropertyValue value="[0, 5, 0, 5, 0, 5, 0]"/> |
|
178 |
</Value> |
|
179 |
</ExpressionOrigin> |
|
180 |
</CodeExpression> |
|
181 |
</Parameters> |
|
182 |
</CodeStatement> |
|
183 |
<CodeStatement> |
|
184 |
<CodeExpression id="4"> |
|
185 |
<ExpressionOrigin> |
|
186 |
<ExpressionProvider type="ComponentRef"> |
|
187 |
<ComponentRef name="."/> |
|
188 |
</ExpressionProvider> |
|
189 |
</ExpressionOrigin> |
|
190 |
</CodeExpression> |
|
191 |
<StatementProvider type="CodeMethod"> |
|
192 |
<CodeMethod name="setLayout" class="java.awt.Container" parameterTypes="java.awt.LayoutManager"/> |
|
193 |
</StatementProvider> |
|
194 |
<Parameters> |
|
195 |
<CodeExpression id="1_layout"/> |
|
196 |
</Parameters> |
|
197 |
</CodeStatement> |
|
198 |
<CodeStatement> |
|
199 |
<CodeExpression id="5_gridBagConstraints"> |
|
200 |
<CodeVariable name="gridBagConstraints" type="20480" declaredType="java.awt.GridBagConstraints"/> |
|
201 |
<ExpressionOrigin> |
|
202 |
<ExpressionProvider type="CodeConstructor"> |
|
203 |
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/> |
|
204 |
</ExpressionProvider> |
|
205 |
</ExpressionOrigin> |
|
206 |
</CodeExpression> |
|
207 |
<StatementProvider type="CodeExpression"> |
|
208 |
<CodeExpression id="5_gridBagConstraints"/> |
|
209 |
</StatementProvider> |
|
210 |
</CodeStatement> |
|
211 |
<CodeStatement> |
|
212 |
<CodeExpression id="5_gridBagConstraints"/> |
|
213 |
<StatementProvider type="CodeField"> |
|
214 |
<CodeField name="gridx" class="java.awt.GridBagConstraints"/> |
|
215 |
</StatementProvider> |
|
216 |
<Parameters> |
|
217 |
<CodeExpression id="6"> |
|
218 |
<ExpressionOrigin> |
|
219 |
<Value type="int" value="0"/> |
|
220 |
</ExpressionOrigin> |
|
221 |
</CodeExpression> |
|
222 |
</Parameters> |
|
223 |
</CodeStatement> |
|
224 |
<CodeStatement> |
|
225 |
<CodeExpression id="5_gridBagConstraints"/> |
|
226 |
<StatementProvider type="CodeField"> |
|
227 |
<CodeField name="gridy" class="java.awt.GridBagConstraints"/> |
|
228 |
</StatementProvider> |
|
229 |
<Parameters> |
|
230 |
<CodeExpression id="7"> |
|
231 |
<ExpressionOrigin> |
|
232 |
<Value type="int" value="0"/> |
|
233 |
</ExpressionOrigin> |
|
234 |
</CodeExpression> |
|
235 |
</Parameters> |
|
236 |
</CodeStatement> |
|
237 |
<CodeStatement> |
|
238 |
<CodeExpression id="4"/> |
|
239 |
<StatementProvider type="CodeMethod"> |
|
240 |
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/> |
|
241 |
</StatementProvider> |
|
242 |
<Parameters> |
|
243 |
<CodeExpression id="8_filler2"> |
|
244 |
<CodeVariable name="filler2" type="8196" declaredType="javax.swing.Box$Filler"/> |
|
245 |
<ExpressionOrigin> |
|
246 |
<ExpressionProvider type="ComponentRef"> |
|
247 |
<ComponentRef name="filler2"/> |
|
248 |
</ExpressionProvider> |
|
249 |
</ExpressionOrigin> |
|
250 |
</CodeExpression> |
|
251 |
<CodeExpression id="5_gridBagConstraints"/> |
|
252 |
</Parameters> |
|
253 |
</CodeStatement> |
|
254 |
<CodeStatement> |
|
255 |
<CodeExpression id="9_gridBagConstraints"> |
|
256 |
<CodeVariable name="gridBagConstraints"/> |
|
257 |
<ExpressionOrigin> |
|
258 |
<ExpressionProvider type="CodeConstructor"> |
|
259 |
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/> |
|
260 |
</ExpressionProvider> |
|
261 |
</ExpressionOrigin> |
|
262 |
</CodeExpression> |
|
263 |
<StatementProvider type="CodeExpression"> |
|
264 |
<CodeExpression id="9_gridBagConstraints"/> |
|
265 |
</StatementProvider> |
|
266 |
</CodeStatement> |
|
267 |
<CodeStatement> |
|
268 |
<CodeExpression id="9_gridBagConstraints"/> |
|
269 |
<StatementProvider type="CodeField"> |
|
270 |
<CodeField name="gridx" class="java.awt.GridBagConstraints"/> |
|
271 |
</StatementProvider> |
|
272 |
<Parameters> |
|
273 |
<CodeExpression id="10"> |
|
274 |
<ExpressionOrigin> |
|
275 |
<Value type="int" value="2"/> |
|
276 |
</ExpressionOrigin> |
|
277 |
</CodeExpression> |
|
278 |
</Parameters> |
|
279 |
</CodeStatement> |
|
280 |
<CodeStatement> |
|
281 |
<CodeExpression id="9_gridBagConstraints"/> |
|
282 |
<StatementProvider type="CodeField"> |
|
283 |
<CodeField name="gridy" class="java.awt.GridBagConstraints"/> |
|
284 |
</StatementProvider> |
|
285 |
<Parameters> |
|
286 |
<CodeExpression id="11"> |
|
287 |
<ExpressionOrigin> |
|
288 |
<Value type="int" value="2"/> |
|
289 |
</ExpressionOrigin> |
|
290 |
</CodeExpression> |
|
291 |
</Parameters> |
|
292 |
</CodeStatement> |
|
293 |
<CodeStatement> |
|
294 |
<CodeExpression id="4"/> |
|
295 |
<StatementProvider type="CodeMethod"> |
|
296 |
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/> |
|
297 |
</StatementProvider> |
|
298 |
<Parameters> |
|
299 |
<CodeExpression id="12_butLoad"> |
|
300 |
<CodeVariable name="butLoad" type="8196" declaredType="javax.swing.JButton"/> |
|
301 |
<ExpressionOrigin> |
|
302 |
<ExpressionProvider type="ComponentRef"> |
|
303 |
<ComponentRef name="butLoad"/> |
|
304 |
</ExpressionProvider> |
|
305 |
</ExpressionOrigin> |
|
306 |
</CodeExpression> |
|
307 |
<CodeExpression id="9_gridBagConstraints"/> |
|
308 |
</Parameters> |
|
309 |
</CodeStatement> |
|
310 |
<CodeStatement> |
|
311 |
<CodeExpression id="13_gridBagConstraints"> |
|
312 |
<CodeVariable name="gridBagConstraints"/> |
|
313 |
<ExpressionOrigin> |
|
314 |
<ExpressionProvider type="CodeConstructor"> |
|
315 |
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/> |
|
316 |
</ExpressionProvider> |
|
317 |
</ExpressionOrigin> |
|
318 |
</CodeExpression> |
|
319 |
<StatementProvider type="CodeExpression"> |
|
320 |
<CodeExpression id="13_gridBagConstraints"/> |
|
321 |
</StatementProvider> |
|
322 |
</CodeStatement> |
|
323 |
<CodeStatement> |
|
324 |
<CodeExpression id="13_gridBagConstraints"/> |
|
325 |
<StatementProvider type="CodeField"> |
|
326 |
<CodeField name="gridx" class="java.awt.GridBagConstraints"/> |
|
327 |
</StatementProvider> |
|
328 |
<Parameters> |
|
329 |
<CodeExpression id="14"> |
|
330 |
<ExpressionOrigin> |
|
331 |
<Value type="int" value="4"/> |
|
332 |
</ExpressionOrigin> |
|
333 |
</CodeExpression> |
|
334 |
</Parameters> |
|
335 |
</CodeStatement> |
|
336 |
<CodeStatement> |
|
337 |
<CodeExpression id="13_gridBagConstraints"/> |
|
338 |
<StatementProvider type="CodeField"> |
|
339 |
<CodeField name="gridy" class="java.awt.GridBagConstraints"/> |
|
340 |
</StatementProvider> |
|
341 |
<Parameters> |
|
342 |
<CodeExpression id="15"> |
|
343 |
<ExpressionOrigin> |
|
344 |
<Value type="int" value="2"/> |
|
345 |
</ExpressionOrigin> |
|
346 |
</CodeExpression> |
|
347 |
</Parameters> |
|
348 |
</CodeStatement> |
|
349 |
<CodeStatement> |
|
350 |
<CodeExpression id="4"/> |
|
351 |
<StatementProvider type="CodeMethod"> |
|
352 |
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/> |
|
353 |
</StatementProvider> |
|
354 |
<Parameters> |
|
355 |
<CodeExpression id="16_butSave"> |
|
356 |
<CodeVariable name="butSave" type="8196" declaredType="javax.swing.JButton"/> |
|
357 |
<ExpressionOrigin> |
|
358 |
<ExpressionProvider type="ComponentRef"> |
|
359 |
<ComponentRef name="butSave"/> |
|
360 |
</ExpressionProvider> |
|
361 |
</ExpressionOrigin> |
|
362 |
</CodeExpression> |
|
363 |
<CodeExpression id="13_gridBagConstraints"/> |
|
364 |
</Parameters> |
|
365 |
</CodeStatement> |
|
366 |
<CodeStatement> |
|
367 |
<CodeExpression id="17_gridBagConstraints"> |
|
368 |
<CodeVariable name="gridBagConstraints"/> |
|
369 |
<ExpressionOrigin> |
|
370 |
<ExpressionProvider type="CodeConstructor"> |
|
371 |
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/> |
|
372 |
</ExpressionProvider> |
|
373 |
</ExpressionOrigin> |
|
374 |
</CodeExpression> |
|
375 |
<StatementProvider type="CodeExpression"> |
|
376 |
<CodeExpression id="17_gridBagConstraints"/> |
|
377 |
</StatementProvider> |
|
378 |
</CodeStatement> |
|
379 |
<CodeStatement> |
|
380 |
<CodeExpression id="17_gridBagConstraints"/> |
|
381 |
<StatementProvider type="CodeField"> |
|
382 |
<CodeField name="gridx" class="java.awt.GridBagConstraints"/> |
|
383 |
</StatementProvider> |
|
384 |
<Parameters> |
|
385 |
<CodeExpression id="18"> |
|
386 |
<ExpressionOrigin> |
|
387 |
<Value type="int" value="6"/> |
|
388 |
</ExpressionOrigin> |
|
389 |
</CodeExpression> |
|
390 |
</Parameters> |
|
391 |
</CodeStatement> |
|
392 |
<CodeStatement> |
|
393 |
<CodeExpression id="17_gridBagConstraints"/> |
|
394 |
<StatementProvider type="CodeField"> |
|
395 |
<CodeField name="gridy" class="java.awt.GridBagConstraints"/> |
|
396 |
</StatementProvider> |
|
397 |
<Parameters> |
|
398 |
<CodeExpression id="19"> |
|
399 |
<ExpressionOrigin> |
|
400 |
<Value type="int" value="2"/> |
|
401 |
</ExpressionOrigin> |
|
402 |
</CodeExpression> |
|
403 |
</Parameters> |
|
404 |
</CodeStatement> |
|
405 |
<CodeStatement> |
|
406 |
<CodeExpression id="4"/> |
|
407 |
<StatementProvider type="CodeMethod"> |
|
408 |
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/> |
|
409 |
</StatementProvider> |
|
410 |
<Parameters> |
|
411 |
<CodeExpression id="20_butTest"> |
|
412 |
<CodeVariable name="butTest" type="8196" declaredType="javax.swing.JButton"/> |
|
413 |
<ExpressionOrigin> |
|
414 |
<ExpressionProvider type="ComponentRef"> |
|
415 |
<ComponentRef name="butTest"/> |
|
416 |
</ExpressionProvider> |
|
417 |
</ExpressionOrigin> |
|
418 |
</CodeExpression> |
|
419 |
<CodeExpression id="17_gridBagConstraints"/> |
|
420 |
</Parameters> |
|
421 |
</CodeStatement> |
|
422 |
<CodeStatement> |
|
423 |
<CodeExpression id="21_gridBagConstraints"> |
|
424 |
<CodeVariable name="gridBagConstraints"/> |
|
425 |
<ExpressionOrigin> |
|
426 |
<ExpressionProvider type="CodeConstructor"> |
|
427 |
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/> |
|
428 |
</ExpressionProvider> |
|
429 |
</ExpressionOrigin> |
|
430 |
</CodeExpression> |
|
431 |
<StatementProvider type="CodeExpression"> |
|
432 |
<CodeExpression id="21_gridBagConstraints"/> |
|
433 |
</StatementProvider> |
|
434 |
</CodeStatement> |
|
435 |
<CodeStatement> |
|
436 |
<CodeExpression id="21_gridBagConstraints"/> |
|
437 |
<StatementProvider type="CodeField"> |
|
438 |
<CodeField name="gridx" class="java.awt.GridBagConstraints"/> |
|
439 |
</StatementProvider> |
|
440 |
<Parameters> |
|
441 |
<CodeExpression id="22"> |
|
442 |
<ExpressionOrigin> |
|
443 |
<Value type="int" value="8"/> |
|
444 |
</ExpressionOrigin> |
|
445 |
</CodeExpression> |
|
446 |
</Parameters> |
|
447 |
</CodeStatement> |
|
448 |
<CodeStatement> |
|
449 |
<CodeExpression id="21_gridBagConstraints"/> |
|
450 |
<StatementProvider type="CodeField"> |
|
451 |
<CodeField name="gridy" class="java.awt.GridBagConstraints"/> |
|
452 |
</StatementProvider> |
|
453 |
<Parameters> |
|
454 |
<CodeExpression id="23"> |
|
455 |
<ExpressionOrigin> |
|
456 |
<Value type="int" value="2"/> |
|
457 |
</ExpressionOrigin> |
|
458 |
</CodeExpression> |
|
459 |
</Parameters> |
|
460 |
</CodeStatement> |
|
461 |
<CodeStatement> |
|
462 |
<CodeExpression id="21_gridBagConstraints"/> |
|
463 |
<StatementProvider type="CodeField"> |
|
464 |
<CodeField name="fill" class="java.awt.GridBagConstraints"/> |
|
465 |
</StatementProvider> |
|
466 |
<Parameters> |
|
467 |
<CodeExpression id="24"> |
|
468 |
<ExpressionOrigin> |
|
469 |
<Value type="int" value="2"/> |
|
470 |
</ExpressionOrigin> |
|
471 |
</CodeExpression> |
|
472 |
</Parameters> |
|
473 |
</CodeStatement> |
|
474 |
<CodeStatement> |
|
475 |
<CodeExpression id="21_gridBagConstraints"/> |
|
476 |
<StatementProvider type="CodeField"> |
|
477 |
<CodeField name="weightx" class="java.awt.GridBagConstraints"/> |
|
478 |
</StatementProvider> |
|
479 |
<Parameters> |
|
480 |
<CodeExpression id="25"> |
|
481 |
<ExpressionOrigin> |
|
482 |
<Value type="double" value="0.1"/> |
|
483 |
</ExpressionOrigin> |
|
484 |
</CodeExpression> |
|
485 |
</Parameters> |
|
486 |
</CodeStatement> |
|
487 |
<CodeStatement> |
|
488 |
<CodeExpression id="4"/> |
|
489 |
<StatementProvider type="CodeMethod"> |
|
490 |
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/> |
|
491 |
</StatementProvider> |
|
492 |
<Parameters> |
|
493 |
<CodeExpression id="26_filler3"> |
|
494 |
<CodeVariable name="filler3" type="8196" declaredType="javax.swing.Box$Filler"/> |
|
495 |
<ExpressionOrigin> |
|
496 |
<ExpressionProvider type="ComponentRef"> |
|
497 |
<ComponentRef name="filler3"/> |
|
498 |
</ExpressionProvider> |
|
499 |
</ExpressionOrigin> |
|
500 |
</CodeExpression> |
|
501 |
<CodeExpression id="21_gridBagConstraints"/> |
|
502 |
</Parameters> |
|
503 |
</CodeStatement> |
|
504 |
<CodeStatement> |
|
505 |
<CodeExpression id="27_gridBagConstraints"> |
|
506 |
<CodeVariable name="gridBagConstraints"/> |
|
507 |
<ExpressionOrigin> |
|
508 |
<ExpressionProvider type="CodeConstructor"> |
|
509 |
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/> |
|
510 |
</ExpressionProvider> |
|
511 |
</ExpressionOrigin> |
|
512 |
</CodeExpression> |
|
513 |
<StatementProvider type="CodeExpression"> |
|
514 |
<CodeExpression id="27_gridBagConstraints"/> |
|
515 |
</StatementProvider> |
|
516 |
</CodeStatement> |
|
517 |
<CodeStatement> |
|
518 |
<CodeExpression id="27_gridBagConstraints"/> |
|
519 |
<StatementProvider type="CodeField"> |
|
520 |
<CodeField name="gridx" class="java.awt.GridBagConstraints"/> |
|
521 |
</StatementProvider> |
|
522 |
<Parameters> |
|
523 |
<CodeExpression id="28"> |
|
524 |
<ExpressionOrigin> |
|
525 |
<Value type="int" value="10"/> |
|
526 |
</ExpressionOrigin> |
|
527 |
</CodeExpression> |
|
528 |
</Parameters> |
|
529 |
</CodeStatement> |
|
530 |
<CodeStatement> |
|
531 |
<CodeExpression id="27_gridBagConstraints"/> |
|
532 |
<StatementProvider type="CodeField"> |
|
533 |
<CodeField name="gridy" class="java.awt.GridBagConstraints"/> |
|
534 |
</StatementProvider> |
|
535 |
<Parameters> |
|
536 |
<CodeExpression id="29"> |
|
537 |
<ExpressionOrigin> |
|
538 |
<Value type="int" value="6"/> |
|
539 |
</ExpressionOrigin> |
|
540 |
</CodeExpression> |
|
541 |
</Parameters> |
|
542 |
</CodeStatement> |
|
543 |
<CodeStatement> |
|
544 |
<CodeExpression id="4"/> |
|
545 |
<StatementProvider type="CodeMethod"> |
|
546 |
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/> |
|
547 |
</StatementProvider> |
|
548 |
<Parameters> |
|
549 |
<CodeExpression id="30_filler4"> |
|
550 |
<CodeVariable name="filler4" type="8196" declaredType="javax.swing.Box$Filler"/> |
|
551 |
<ExpressionOrigin> |
|
552 |
<ExpressionProvider type="ComponentRef"> |
|
553 |
<ComponentRef name="filler4"/> |
|
554 |
</ExpressionProvider> |
|
555 |
</ExpressionOrigin> |
|
556 |
</CodeExpression> |
|
557 |
<CodeExpression id="27_gridBagConstraints"/> |
|
558 |
</Parameters> |
|
559 |
</CodeStatement> |
|
560 |
<CodeStatement> |
|
561 |
<CodeExpression id="31_gridBagConstraints"> |
|
562 |
<CodeVariable name="gridBagConstraints"/> |
|
563 |
<ExpressionOrigin> |
|
564 |
<ExpressionProvider type="CodeConstructor"> |
|
565 |
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/> |
|
566 |
</ExpressionProvider> |
|
567 |
</ExpressionOrigin> |
|
568 |
</CodeExpression> |
|
569 |
<StatementProvider type="CodeExpression"> |
|
570 |
<CodeExpression id="31_gridBagConstraints"/> |
|
571 |
</StatementProvider> |
|
572 |
</CodeStatement> |
|
573 |
<CodeStatement> |
|
574 |
<CodeExpression id="31_gridBagConstraints"/> |
|
575 |
<StatementProvider type="CodeField"> |
|
576 |
<CodeField name="gridx" class="java.awt.GridBagConstraints"/> |
|
577 |
</StatementProvider> |
|
578 |
<Parameters> |
|
579 |
<CodeExpression id="32"> |
|
580 |
<ExpressionOrigin> |
|
581 |
<Value type="int" value="2"/> |
|
582 |
</ExpressionOrigin> |
|
583 |
</CodeExpression> |
|
584 |
</Parameters> |
|
585 |
</CodeStatement> |
|
586 |
<CodeStatement> |
|
587 |
<CodeExpression id="31_gridBagConstraints"/> |
|
588 |
<StatementProvider type="CodeField"> |
|
589 |
<CodeField name="gridy" class="java.awt.GridBagConstraints"/> |
|
590 |
</StatementProvider> |
|
591 |
<Parameters> |
|
592 |
<CodeExpression id="33"> |
|
593 |
<ExpressionOrigin> |
|
594 |
<Value type="int" value="4"/> |
|
595 |
</ExpressionOrigin> |
|
596 |
</CodeExpression> |
|
597 |
</Parameters> |
|
598 |
</CodeStatement> |
|
599 |
<CodeStatement> |
|
600 |
<CodeExpression id="31_gridBagConstraints"/> |
|
601 |
<StatementProvider type="CodeField"> |
|
602 |
<CodeField name="gridwidth" class="java.awt.GridBagConstraints"/> |
|
603 |
</StatementProvider> |
|
604 |
<Parameters> |
|
605 |
<CodeExpression id="34"> |
|
606 |
<ExpressionOrigin> |
|
607 |
<Value type="int" value="7"/> |
|
608 |
</ExpressionOrigin> |
|
609 |
</CodeExpression> |
|
610 |
</Parameters> |
|
611 |
</CodeStatement> |
|
612 |
<CodeStatement> |
|
613 |
<CodeExpression id="31_gridBagConstraints"/> |
|
614 |
<StatementProvider type="CodeField"> |
|
615 |
<CodeField name="fill" class="java.awt.GridBagConstraints"/> |
|
616 |
</StatementProvider> |
|
617 |
<Parameters> |
|
618 |
<CodeExpression id="35"> |
|
619 |
<ExpressionOrigin> |
|
620 |
<Value type="int" value="1"/> |
|
621 |
</ExpressionOrigin> |
|
622 |
</CodeExpression> |
|
623 |
</Parameters> |
|
624 |
</CodeStatement> |
|
625 |
<CodeStatement> |
|
626 |
<CodeExpression id="31_gridBagConstraints"/> |
|
627 |
<StatementProvider type="CodeField"> |
|
628 |
<CodeField name="weightx" class="java.awt.GridBagConstraints"/> |
|
629 |
</StatementProvider> |
|
630 |
<Parameters> |
|
631 |
<CodeExpression id="36"> |
|
632 |
<ExpressionOrigin> |
|
633 |
<Value type="double" value="0.1"/> |
|
634 |
</ExpressionOrigin> |
|
635 |
</CodeExpression> |
|
636 |
</Parameters> |
|
637 |
</CodeStatement> |
|
638 |
<CodeStatement> |
|
639 |
<CodeExpression id="31_gridBagConstraints"/> |
|
640 |
<StatementProvider type="CodeField"> |
|
641 |
<CodeField name="weighty" class="java.awt.GridBagConstraints"/> |
|
642 |
</StatementProvider> |
|
643 |
<Parameters> |
|
644 |
<CodeExpression id="37"> |
|
645 |
<ExpressionOrigin> |
|
646 |
<Value type="double" value="0.1"/> |
|
647 |
</ExpressionOrigin> |
|
648 |
</CodeExpression> |
|
649 |
</Parameters> |
|
650 |
</CodeStatement> |
|
651 |
<CodeStatement> |
|
652 |
<CodeExpression id="4"/> |
|
653 |
<StatementProvider type="CodeMethod"> |
|
654 |
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/> |
|
655 |
</StatementProvider> |
|
656 |
<Parameters> |
|
657 |
<CodeExpression id="38_editorContainer"> |
|
658 |
<CodeVariable name="editorContainer" type="8196" declaredType="javax.swing.JPanel"/> |
|
659 |
<ExpressionOrigin> |
|
660 |
<ExpressionProvider type="ComponentRef"> |
|
661 |
<ComponentRef name="editorContainer"/> |
|
662 |
</ExpressionProvider> |
|
663 |
</ExpressionOrigin> |
|
664 |
</CodeExpression> |
|
665 |
<CodeExpression id="31_gridBagConstraints"/> |
|
666 |
</Parameters> |
|
667 |
</CodeStatement> |
|
668 |
</LayoutCode> |
|
669 |
</Form> |
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.131/src/main/java/org/gvsig/expressionfield/project/documents/table/gui/EvalExpression.java | ||
---|---|---|
1 |
/******************************************************************************* |
|
2 |
* |
|
3 |
* gvSIG. Desktop Geographic Information System. |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 3 |
|
10 |
* of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
21 |
* |
|
22 |
* For any additional information, do not hesitate to contact us |
|
23 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
* |
|
25 |
*******************************************************************************/ |
|
26 |
package org.gvsig.expressionfield.project.documents.table.gui; |
|
27 |
|
|
28 |
import java.util.Date; |
|
29 |
|
|
30 |
import org.apache.bsf.BSFException; |
|
31 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
32 |
import org.gvsig.fmap.dal.DataTypes; |
|
33 |
import org.gvsig.fmap.dal.exception.DataException; |
|
34 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
35 |
import org.gvsig.fmap.dal.feature.Feature; |
|
36 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
37 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
39 |
|
|
40 |
/** |
|
41 |
* @author Vicente Caballero Navarro |
|
42 |
*/ |
|
43 |
public class EvalExpression { |
|
44 |
private FeatureType featureType; |
|
45 |
private FeatureAttributeDescriptor selectedDescriptor; |
|
46 |
public EvalExpression() { |
|
47 |
} |
|
48 |
public void setTable(FeatureTableDocumentPanel table) { |
|
49 |
try { |
|
50 |
selectedDescriptor = table.getTablePanel().getTable().getSelectedColumnsAttributeDescriptor()[0]; |
|
51 |
featureType = table.getModel().getStore().getDefaultFeatureType(); |
|
52 |
} catch (DataException e) { |
|
53 |
e.printStackTrace(); |
|
54 |
} |
|
55 |
} |
|
56 |
|
|
57 |
public void setValue(FeatureSet featureSet,Feature feature,Object obj) { |
|
58 |
Object objBoolean=obj; |
|
59 |
EditableFeature eFeature=feature.getEditable(); |
|
60 |
int type=((FeatureAttributeDescriptor)featureSet.getDefaultFeatureType().get(selectedDescriptor.getName())).getType(); |
|
61 |
if (type==DataTypes.BOOLEAN){ |
|
62 |
Integer integer=((Integer)obj).intValue(); |
|
63 |
if (integer==0){ |
|
64 |
objBoolean=new Boolean(false); |
|
65 |
}else{ |
|
66 |
objBoolean=new Boolean(true); |
|
67 |
} |
|
68 |
} |
|
69 |
eFeature.set(selectedDescriptor.getName(), objBoolean); |
|
70 |
try { |
|
71 |
featureSet.update(eFeature); |
|
72 |
} catch (DataException e) { |
|
73 |
e.printStackTrace(); |
|
74 |
} |
|
75 |
} |
|
76 |
public void isCorrectValue(Object obj) throws BSFException { |
|
77 |
if (obj instanceof Number || obj instanceof Date || obj instanceof Boolean || obj instanceof String || obj == null ) { |
|
78 |
|
|
79 |
}else{ |
|
80 |
throw new BSFException("incorrect"); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
public FeatureAttributeDescriptor getFieldDescriptorSelected() { |
|
85 |
return selectedDescriptor; |
|
86 |
} |
|
87 |
public FeatureType getFieldDescriptors() { |
|
88 |
return featureType; |
|
89 |
} |
|
90 |
} |
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.131/src/main/java/org/gvsig/expressionfield/project/documents/table/gui/EvalExpressionDialog.java | ||
---|---|---|
1 |
/** |
|
2 |
* ***************************************************************************** |
|
3 |
* |
|
4 |
* gvSIG. Desktop Geographic Information System. |
|
5 |
* |
|
6 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 3 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
* For any additional information, do not hesitate to contact us |
|
24 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
* |
|
26 |
****************************************************************************** |
|
27 |
*/ |
|
28 |
package org.gvsig.expressionfield.project.documents.table.gui; |
|
29 |
|
|
30 |
import java.awt.BorderLayout; |
|
31 |
import java.awt.Component; |
|
32 |
import java.awt.GridBagConstraints; |
|
33 |
import java.awt.GridBagLayout; |
|
34 |
import java.awt.GridLayout; |
|
35 |
import java.awt.Insets; |
|
36 |
import java.awt.event.MouseEvent; |
|
37 |
import java.awt.event.MouseListener; |
|
38 |
import java.io.File; |
|
39 |
import java.io.FileReader; |
|
40 |
import java.io.IOException; |
|
41 |
import java.io.UnsupportedEncodingException; |
|
42 |
import java.util.ArrayList; |
|
43 |
import java.util.Iterator; |
|
44 |
import java.util.prefs.Preferences; |
|
45 |
|
|
46 |
import javax.swing.BoxLayout; |
|
47 |
import javax.swing.ButtonGroup; |
|
48 |
import javax.swing.JFileChooser; |
|
49 |
import javax.swing.JLabel; |
|
50 |
import javax.swing.JList; |
|
51 |
import javax.swing.JOptionPane; |
|
52 |
import javax.swing.JPanel; |
|
53 |
import javax.swing.JRadioButton; |
|
54 |
import javax.swing.JScrollPane; |
|
55 |
import javax.swing.JTabbedPane; |
|
56 |
import javax.swing.JTextArea; |
|
57 |
import javax.swing.JTextField; |
|
58 |
import javax.swing.UIManager; |
|
59 |
import javax.swing.event.CaretEvent; |
|
60 |
import javax.swing.event.CaretListener; |
|
61 |
|
|
62 |
import org.apache.bsf.BSFException; |
|
63 |
import org.apache.bsf.BSFManager; |
|
64 |
import org.gvsig.andami.PluginServices; |
|
65 |
import org.gvsig.andami.messages.NotificationManager; |
|
66 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
67 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
68 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
69 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
70 |
import org.gvsig.expressionfield.project.documents.table.FeatureIndex; |
|
71 |
import org.gvsig.expressionfield.project.documents.table.GraphicOperator; |
|
72 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
73 |
import org.gvsig.expressionfield.project.documents.table.operators.Field; |
|
74 |
import org.gvsig.fmap.dal.exception.DataException; |
|
75 |
import org.gvsig.fmap.dal.feature.Feature; |
|
76 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
77 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
78 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
79 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
80 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
81 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
|
82 |
import org.gvsig.gui.beans.swing.JButton; |
|
83 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
84 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
85 |
import org.gvsig.utils.GenericFileFilter; |
|
86 |
import org.slf4j.Logger; |
|
87 |
import org.slf4j.LoggerFactory; |
|
88 |
|
|
89 |
import bsh.EvalError; |
|
90 |
import org.apache.commons.lang3.StringUtils; |
|
91 |
import org.gvsig.app.ApplicationLocator; |
|
92 |
import org.gvsig.app.ApplicationManager; |
|
93 |
import org.gvsig.tools.ToolsLocator; |
|
94 |
import org.gvsig.tools.i18n.I18nManager; |
|
95 |
|
|
96 |
public class EvalExpressionDialog extends JPanel implements IWindow { |
|
97 |
|
|
98 |
private static Logger logger = LoggerFactory.getLogger(EvalExpressionDialog.class); |
|
99 |
private static Preferences prefs = Preferences.userRoot().node("fieldExpressionOptions"); |
|
100 |
|
|
101 |
private JPanel pNorth = null; |
|
102 |
private JPanel pCentral = null; |
|
103 |
private JScrollPane jScrollPane = null; |
|
104 |
private JTextArea txtExp = null; |
|
105 |
private AcceptCancelPanel acceptCancel; |
|
106 |
private FeatureTableDocumentPanel table; |
|
107 |
private FLyrVect lv; |
|
108 |
private JPanel pNorthEast = null; |
|
109 |
private JPanel pNorthCenter = null; |
|
110 |
private JPanel pNorthWest = null; |
|
111 |
private JScrollPane jScrollPane1 = null; |
|
112 |
private JList listFields = null; |
|
113 |
private JRadioButton rbNumber = null; |
|
114 |
private JRadioButton rbString = null; |
|
115 |
private JRadioButton rbDate = null; |
|
116 |
private JScrollPane jScrollPane2 = null; |
|
117 |
private JList listCommand = null; |
|
118 |
private BSFManager interpreter = null; // Construct an interpreter |
|
119 |
private Feature feature; |
|
120 |
private FeatureStore featureStore = null; |
|
121 |
private EvalExpression evalExpression = null; |
|
122 |
/* |
|
123 |
* Keeps index of row in feature set currently used. |
|
124 |
*/ |
|
125 |
private FeatureIndex fIndex = new FeatureIndex(); |
|
126 |
|
|
127 |
private JPanel pMessage; |
|
128 |
private FeatureContainer featureContainer; |
|
129 |
private static ArrayList<IOperator> operators = new ArrayList<IOperator>(); |
|
130 |
|
|
131 |
public EvalExpressionDialog(FeatureTableDocumentPanel table, BSFManager interpreter, ArrayList<IOperator> operators) { |
|
132 |
super(); |
|
133 |
this.operators = operators; |
|
134 |
this.interpreter = interpreter; |
|
135 |
this.table = table; |
|
136 |
initialize(); |
|
137 |
|
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* This method initializes this |
|
142 |
*/ |
|
143 |
private void initialize() { |
|
144 |
try { |
|
145 |
evalExpressions(); |
|
146 |
} catch (BSFException e) { |
|
147 |
NotificationManager.addError(e); |
|
148 |
} |
|
149 |
evalExpression = new EvalExpression(); |
|
150 |
evalExpression.setTable(table); |
|
151 |
/* |
|
152 |
* Keeps index of row in feature set currently used |
|
153 |
*/ |
|
154 |
try { |
|
155 |
interpreter.declareBean("featureIndex", fIndex, FeatureIndex.class); |
|
156 |
} catch (BSFException e) { |
|
157 |
logger.error("While declaring featureIndex (Long).", e); |
|
158 |
} |
|
159 |
|
|
160 |
lv = (FLyrVect) table.getModel().getAssociatedLayer(); |
|
161 |
ButtonGroup bg = new ButtonGroup(); |
|
162 |
bg.add(getRbNumber()); |
|
163 |
bg.add(getRbString()); |
|
164 |
bg.add(getRbDate()); |
|
165 |
this.setLayout(new GridBagLayout()); |
|
166 |
this.setSize(549, 480); |
|
167 |
GridBagConstraints constr = new GridBagConstraints(); |
|
168 |
constr.gridwidth = GridBagConstraints.REMAINDER; |
|
169 |
constr.gridheight = 1; |
|
170 |
constr.fill = GridBagConstraints.BOTH; |
|
171 |
constr.ipadx = 5; |
|
172 |
constr.ipady = 5; |
|
173 |
constr.weightx = 1; |
|
174 |
constr.weighty = 0.3; |
|
175 |
this.add(getPMessage(), constr); |
|
176 |
constr.gridheight = 5; |
|
177 |
constr.weighty = 1; |
|
178 |
this.add(getTabPrincipal(), constr); |
|
179 |
GridBagConstraints constr2 = new GridBagConstraints(); |
|
180 |
constr2.gridwidth = GridBagConstraints.REMAINDER; |
|
181 |
constr2.gridheight = 1; |
|
182 |
constr2.fill = GridBagConstraints.HORIZONTAL; |
|
183 |
constr2.anchor = GridBagConstraints.LAST_LINE_END; |
|
184 |
constr2.weightx = 1; |
|
185 |
constr2.weighty = 0; |
|
186 |
|
|
187 |
this.add(getAcceptCancel(), constr2); |
|
188 |
|
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* This method initializes pCentral |
|
193 |
* |
|
194 |
* @return javax.swing.JPanel |
|
195 |
*/ |
|
196 |
private JPanel getPNorth() { |
|
197 |
if ( pNorth == null ) { |
|
198 |
pNorth = new JPanel(); |
|
199 |
pNorth.setLayout(new GridBagLayout()); |
|
200 |
GridBagConstraints contr = new GridBagConstraints(); |
|
201 |
contr.ipadx = 5; |
|
202 |
contr.ipady = 5; |
|
203 |
contr.fill = GridBagConstraints.BOTH; |
|
204 |
contr.weightx = 1; |
|
205 |
contr.weighty = 1; |
|
206 |
pNorth.add(getPNorthWest(), contr); |
|
207 |
|
|
208 |
contr.fill = GridBagConstraints.VERTICAL; |
|
209 |
contr.weightx = 0; |
|
210 |
contr.weighty = 1; |
|
211 |
|
|
212 |
pNorth.add(getPNorthCenter(), contr); |
|
213 |
|
|
214 |
contr.fill = GridBagConstraints.BOTH; |
|
215 |
contr.weightx = 0.5; |
|
216 |
contr.weighty = 1; |
|
217 |
|
|
218 |
pNorth.add(getPNorthEast(), contr); |
|
219 |
} |
|
220 |
|
|
221 |
return pNorth; |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* This method initializes pNorth |
|
226 |
* |
|
227 |
* @return javax.swing.JPanel |
|
228 |
*/ |
|
229 |
private JPanel getPCentral() { |
|
230 |
if ( pCentral == null ) { |
|
231 |
StringBuilder tit = new StringBuilder(); |
|
232 |
tit.append(PluginServices.getText(this, "expression")); |
|
233 |
tit.append(" "); |
|
234 |
tit.append(PluginServices.getText(this, "column")); |
|
235 |
tit.append(" : "); |
|
236 |
tit.append(evalExpression.getFieldDescriptorSelected().getName()); |
|
237 |
pCentral = new JPanel(); |
|
238 |
pCentral.setLayout(new GridBagLayout()); |
|
239 |
pCentral.setBorder(javax.swing.BorderFactory.createTitledBorder( |
|
240 |
null, tit.toString(), |
|
241 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
|
242 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
243 |
GridBagConstraints contr = new GridBagConstraints(); |
|
244 |
contr.gridwidth = GridBagConstraints.REMAINDER; |
|
245 |
contr.gridheight = 1; |
|
246 |
contr.fill = GridBagConstraints.BOTH; |
|
247 |
contr.ipadx = 5; |
|
248 |
contr.ipady = 5; |
|
249 |
contr.weightx = 1; |
|
250 |
contr.weighty = 1; |
|
251 |
pCentral.add(getJScrollPane(), contr); |
|
252 |
GridBagConstraints contr1 = new GridBagConstraints(); |
|
253 |
contr1.gridwidth = 1; |
|
254 |
contr1.gridheight = 1; |
|
255 |
contr1.fill = GridBagConstraints.NONE; |
|
256 |
contr1.ipadx = 5; |
|
257 |
contr1.ipady = 5; |
|
258 |
contr1.anchor = GridBagConstraints.CENTER; |
|
259 |
pCentral.add(getBClear(), contr1); |
|
260 |
} |
|
261 |
|
|
262 |
return pCentral; |
|
263 |
} |
|
264 |
|
|
265 |
/** |
|
266 |
* This method initializes pSouth |
|
267 |
* |
|
268 |
* @return javax.swing.JPanel |
|
269 |
*/ |
|
270 |
private AcceptCancelPanel getAcceptCancel() { |
|
271 |
if ( this.acceptCancel == null ) { |
|
272 |
this.acceptCancel = new AcceptCancelPanel( |
|
273 |
new java.awt.event.ActionListener() { |
|
274 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
275 |
boolean isAccepted = true; |
|
276 |
Preferences prefs = Preferences.userRoot().node( |
|
277 |
"fieldExpressionOptions"); |
|
278 |
int limit; |
|
279 |
limit = prefs.getInt("limit_rows_in_memory", -1); |
|
280 |
if ( limit != -1 ) { |
|
281 |
int option = JOptionPane |
|
282 |
.showConfirmDialog( |
|
283 |
(Component) PluginServices |
|
284 |
.getMainFrame(), |
|
285 |
PluginServices |
|
286 |
.getText( |
|
287 |
this, |
|
288 |
"it_has_established_a_limit_of_rows_will_lose_the_possibility_to_undo_wants_to_continue")); |
|
289 |
if ( option != JOptionPane.OK_OPTION ) { |
|
290 |
return; |
|
291 |
} |
|
292 |
} |
|
293 |
try { |
|
294 |
long t1 = System.currentTimeMillis(); |
|
295 |
isAccepted = evalExpression(); |
|
296 |
long t2 = System.currentTimeMillis(); |
|
297 |
logger.info("Tiempo evaluar expresiones = " + (t2 - t1)); |
|
298 |
} catch (BSFException e1) { |
|
299 |
NotificationManager.addError(e1); |
|
300 |
} |
|
301 |
if ( isAccepted ) { |
|
302 |
PluginServices.getMDIManager().closeWindow( |
|
303 |
EvalExpressionDialog.this); |
|
304 |
} |
|
305 |
} |
|
306 |
}, new java.awt.event.ActionListener() { |
|
307 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
308 |
PluginServices.getMDIManager().closeWindow( |
|
309 |
EvalExpressionDialog.this); |
|
310 |
} |
|
311 |
}); |
|
312 |
acceptCancel.setOkButtonEnabled(false); |
|
313 |
} |
|
314 |
|
|
315 |
return this.acceptCancel; |
|
316 |
} |
|
317 |
|
|
318 |
private String replaceFields(String expression) { |
|
319 |
String s = expression; |
|
320 |
|
|
321 |
JList list = getListFields(); |
|
322 |
ListOperatorsModel model = (ListOperatorsModel) list.getModel(); |
|
323 |
for ( int i = 0; i < model.getSize(); i++ ) { |
|
324 |
Field f = (Field) model.getElementAt(i); |
|
325 |
s = StringUtils.replace(s, f.toString(), "field(\"" + f.getName() + "\")"); |
|
326 |
} |
|
327 |
return s; |
|
328 |
} |
|
329 |
|
|
330 |
/** |
|
331 |
* Evaluate the expression. |
|
332 |
* |
|
333 |
* @throws BSFException |
|
334 |
*/ |
|
335 |
private boolean evalExpression() throws BSFException { |
|
336 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
337 |
final ApplicationManager application = ApplicationLocator.getManager(); |
|
338 |
String expression = getTxtExp().getText(); |
|
339 |
byte[] expressionBytes; |
|
340 |
String encoding = System.getProperty("file.encoding"); |
|
341 |
try { |
|
342 |
expressionBytes = expression.getBytes(encoding); |
|
343 |
expression = new String(expressionBytes, "ISO-8859-1"); |
|
344 |
} catch (UnsupportedEncodingException e) { |
|
345 |
logger.warn("Can't apply enconding ("+encoding+").",e); |
|
346 |
} |
|
347 |
String advancedCode = advancedPanel.getCode(); |
|
348 |
if( advancedCode != null ) { |
|
349 |
try { |
|
350 |
interpreter.exec(ExpressionFieldExtension.JYTHON, null, -1, -1, advancedCode); |
|
351 |
} catch (BSFException ex) { |
|
352 |
logger.warn("Can't execute script from advanced tab:\n" + advancedCode + "\n", ex); |
|
353 |
application.messageDialog( |
|
354 |
i18nManager.getTranslation("_Se_han_producido_errores_ejecutando_el_codigo_de_la_pesta?a_avanzado") + "\n\n" + ex.getMessage(), |
|
355 |
i18nManager.getTranslation("_Atencion"), |
|
356 |
JOptionPane.WARNING_MESSAGE); |
|
357 |
} |
|
358 |
} |
|
359 |
expression = replaceFields(expression); |
|
360 |
|
|
361 |
interpreter.declareBean("evalExpression", evalExpression, EvalExpression.class); |
|
362 |
interpreter.exec(ExpressionFieldExtension.JYTHON, null, -1, -1, "def expression():\n" |
|
363 |
+ " return " + expression + ""); |
|
364 |
|
|
365 |
try { |
|
366 |
interpreter.exec(ExpressionFieldExtension.JYTHON, null, -1, -1, "def isCorrect():\n" |
|
367 |
+ " evalExpression.isCorrectValue(expression())\n"); |
|
368 |
interpreter.exec(ExpressionFieldExtension.JYTHON, null, -1, -1, "isCorrect()"); |
|
369 |
} catch (BSFException ee) { |
|
370 |
String message = ee.getMessage(); |
|
371 |
if ( message.length() > 200 ) { |
|
372 |
message = message.substring(0, 200); |
|
373 |
} |
|
374 |
int option = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(), |
|
375 |
PluginServices.getText(this, |
|
376 |
"error_expression") + "\n" + message + "\n" + PluginServices.getText(this, "continue?")); |
|
377 |
if ( option != JOptionPane.OK_OPTION ) { |
|
378 |
return false; |
|
379 |
} |
|
380 |
} |
|
381 |
try { |
|
382 |
boolean select = true; |
|
383 |
interpreter.declareBean("select", select, boolean.class); |
Also available in: Unified diff