Revision 37362

View differences:

tags/v2_0_0_Build_2041/extensions/extGeoDB/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
6

  
7
    <modelVersion>4.0.0</modelVersion>
8
    <groupId>org.gvsig</groupId>
9
    <artifactId>org.gvsig.geodb</artifactId>
10
    <packaging>jar</packaging>
11
    <version>2.0-SNAPSHOT</version>
12
    <name>Database conectors</name>
13
    <description>Connection manager to spatial databases.
14
 - PostgreSQL
15
 - MySQL
16
 - H2</description>
17
    <url>http://maven.apache.org</url>
18
    <parent>
19
        <groupId>org.gvsig</groupId>
20
        <artifactId>gvsig-base-extension-pom</artifactId>
21
        <version>2.0-SNAPSHOT</version>
22
    </parent>
23
    <distributionManagement>
24
        <site>
25
            <id>gvsig-repository</id>
26
            <url>${site-repository}/</url>
27
        </site>
28
    </distributionManagement>
29

  
30
    <dependencies>
31
        <dependency>
32
            <groupId>org.gvsig</groupId>
33
            <artifactId>org.gvsig.fmap.dal</artifactId>
34
            <scope>compile</scope>
35
        </dependency>
36
        <dependency>
37
            <groupId>org.gvsig</groupId>
38
            <artifactId>org.gvsig.fmap.dal</artifactId>
39
            <classifier>spi</classifier>
40
            <scope>compile</scope>
41
        </dependency>
42
        <dependency>
43
            <groupId>org.gvsig</groupId>
44
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
45
            <scope>compile</scope>
46
        </dependency>
47
        <dependency>
48
            <groupId>org.gvsig</groupId>
49
            <artifactId>org.gvsig.fmap.dal.db</artifactId>
50
            <scope>compile</scope>
51
        </dependency>
52
        <dependency>
53
            <groupId>org.gvsig</groupId>
54
            <artifactId>org.gvsig.fmap.dal.db</artifactId>
55
            <classifier>store.jdbc</classifier>
56
            <scope>compile</scope>
57
        </dependency>
58
        <dependency>
59
            <groupId>org.gvsig</groupId>
60
            <artifactId>org.gvsig.fmap.dal.db</artifactId>
61
            <classifier>store.postgresql</classifier>
62
            <scope>compile</scope>
63
        </dependency>
64
        <dependency>
65
            <groupId>org.gvsig</groupId>
66
            <artifactId>org.gvsig.fmap.dal.db</artifactId>
67
            <classifier>store.mysql</classifier>
68
            <scope>compile</scope>
69
        </dependency>
70
        <dependency>
71
            <groupId>org.gvsig</groupId>
72
            <artifactId>org.gvsig.ui</artifactId>
73
            <scope>compile</scope>
74
        </dependency>
75
        <dependency>
76
            <groupId>org.gvsig</groupId>
77
            <artifactId>org.gvsig.app</artifactId>
78
            <version>2.0-SNAPSHOT</version>
79
            <scope>compile</scope>
80
        </dependency>
81
        <dependency>
82
            <groupId>org.gvsig</groupId>
83
            <artifactId>org.gvsig.app.document.table.app.mainplugin</artifactId>
84
            <version>2.0.0-SNAPSHOT</version>
85
            <scope>compile</scope>
86
        </dependency>
87
        <dependency>
88
            <groupId>org.gvsig</groupId>
89
            <artifactId>org.gvsig.about.api</artifactId>
90
            <scope>compile</scope>
91
        </dependency>
92
        <dependency>
93
            <groupId>org.gvsig</groupId>
94
            <artifactId>org.gvsig.andami</artifactId>
95
            <scope>compile</scope>
96
        </dependency>
97
        <dependency>
98
            <groupId>org.gvsig</groupId>
99
            <artifactId>org.gvsig.utils</artifactId>
100
            <scope>compile</scope>
101
        </dependency>
102
        <dependency>
103
            <groupId>org.gvsig</groupId>
104
            <artifactId>org.gvsig.fmap.mapcontext</artifactId>
105
            <scope>compile</scope>
106
        </dependency>
107
        <dependency>
108
            <groupId>org.gvsig</groupId>
109
            <artifactId>org.gvsig.fmap.geometry</artifactId>
110
            <scope>compile</scope>
111
        </dependency>
112
        <dependency>
113
            <groupId>org.gvsig</groupId>
114
            <artifactId>org.gvsig.tools.lib</artifactId>
115
            <scope>compile</scope>
116
        </dependency>
117
        <dependency>
118
            <groupId>org.gvsig</groupId>
119
            <artifactId>org.gvsig.projection</artifactId>
120
            <scope>compile</scope>
121
        </dependency>
122
        <dependency>
123
            <groupId>org.gvsig</groupId>
124
            <artifactId>org.gvsig.fmap.control</artifactId>
125
            <scope>compile</scope>
126
        </dependency>
127
        <dependency>
128
            <groupId>org.gvsig</groupId>
129
            <artifactId>org.gvsig.personaldb.lib.api</artifactId>
130
            <scope>compile</scope>
131
        </dependency>
132
        <dependency>
133
            <groupId>org.gvsig</groupId>
134
            <artifactId>org.gvsig.personaldb.lib.impl</artifactId>
135
            <scope>compile</scope>
136
        </dependency>    
137
        <dependency>
138
            <groupId>org.gvsig</groupId>
139
            <artifactId>org.gvsig.timesupport.lib.api</artifactId>
140
            <scope>compile</scope>
141
        </dependency>    
142
        <dependency>
143
            <groupId>org.slf4j</groupId>
144
            <artifactId>slf4j-api</artifactId>
145
            <scope>compile</scope>
146
        </dependency>
147
        <dependency>
148
            <groupId>commons-collections</groupId>
149
            <artifactId>commons-collections</artifactId>
150
            <scope>compile</scope>
151
        </dependency>	
152
    </dependencies>
153
    <properties>
154
        <build-dir>${basedir}/../build</build-dir>
155
        <eclipse.project.name>extGeoDB</eclipse.project.name>
156
        <package.info.dependencies>required: org.gvsig.app.document.table.app.mainplugin -ge 2</package.info.dependencies>
157
    </properties>
158
    <build>
159
        <sourceDirectory>src</sourceDirectory>
160
        <!-- <testSourceDirectory>src-test</testSourceDirectory> -->
161
        <plugins>
162
            <!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
163
            <plugin>
164
                <groupId>org.apache.maven.plugins</groupId>
165
                <artifactId>maven-surefire-plugin</artifactId>
166
                <configuration>
167
                    <skipTests>true</skipTests>
168
                </configuration>
169
            </plugin>
170
        </plugins>
171
    </build>
172
</project>
tags/v2_0_0_Build_2041/extensions/extGeoDB/resources/text.properties
1
#Translations for language [es]
2
more_provider_parameters_needed_message=El driver seleccionado necesita par?metros adicionales.\nA continuaci?n se abrir? el editor de propiedades avanzado.
3
more_provider_parameters_needed_title=Par?metros adicionales requeridos
tags/v2_0_0_Build_2041/extensions/extGeoDB/resources/text_en.properties
1
#Translations for language [en]
2
more_provider_parameters_needed_message=The selected driver requires more additional parameters.\nNext the advanced properties editor will be opened.
3
more_provider_parameters_needed_title=More parameters required
tags/v2_0_0_Build_2041/extensions/extGeoDB/distribution/distribution.xml
1
<assembly>
2
	<id>distribution</id>
3
	<formats>
4
		<format>dir</format>
5
	</formats>
6
	<fileSets>
7
	<!-- Extructure for the extension -->
8
		<fileSet>
9
			<directory>config</directory>
10
			<outputDirectory>${extension.install.dir.name}</outputDirectory>
11
		</fileSet>
12
		<fileSet>
13
			<directory>images</directory>
14
			<outputDirectory>/${extension.install.dir.name}/images
15
			</outputDirectory>
16
		</fileSet>
17
        <fileSet>
18
            <directory>resources</directory>
19
            <outputDirectory>${extension.install.dir.name}</outputDirectory>
20
        </fileSet>
21
	</fileSets>
22
    <files>
23
        <file>
24
            <source>package.info</source>
25
            <outputDirectory>${extension.install.dir.name}
26
            </outputDirectory>
27
        </file>
28
    </files>
29
	<!--
30
		***********************************************************************
31
	-->
32
  <!-- *													   *-->
33
	<!--
34
		***********************************************************************
35
	-->
36
	<dependencySets>
37
		<dependencySet>
38
			<outputDirectory>${extension.install.dir.name}/${library-dir}
39
			</outputDirectory>
40
			<includes>
41
				<include>org.gvsig:org.gvsig.geodb</include>
42
				<include>org.gvsig:org.gvsig.fmap.dal.db</include>
43
				<include>org.gvsig:org.gvsig.fmap.dal.db:jar:store.jdbc</include>
44
				<include>commons-dbcp:commons-dbcp</include>
45
				<include>commons-collections:commons-collections</include>
46
				<include>commons-pool:commons-pool</include>
47
				<include>org.gvsig:org.gvsig.fmap.dal.db:jar:store.postgresql</include>
48
				<include>postgresql:postgresql</include>
49
				<include>org.gvsig:org.gvsig.fmap.dal.db:jar:store.mysql</include>
50
				<include>mysql:mysql-connector-java</include>
51
				
52
				<!-- Personal DB support -->
53
                <include>org.gvsig:org.gvsig.personaldb*</include>
54
				<include>com.h2database:h2</include>
55

  
56
			</includes>
57
		</dependencySet>
58
	</dependencySets>
59
</assembly>
tags/v2_0_0_Build_2041/extensions/extGeoDB/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Fri Nov 18 13:16:56 CET 2011
3
buildNumber=2041
tags/v2_0_0_Build_2041/extensions/extGeoDB/config/plugin-persistence.def
1
<?xml version="1.0"?>
2
<!--
3
Definitions of plugin persistence org.gvsig.geodb.  
4
 -->
5
<definitions>
6
  <version>1.0.0</version>
7
  <classes>
8
    <class name="org.gvsig.geodb">
9
      <description>plugin persistence org.gvsig.geodb</description>
10
      <fields>
11
        <field name="db_connections" type="map" classOfItems="org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters" mandatory="false">
12
          <description>Connections</description>
13
        </field>
14
      </fields>
15
    </class>
16
  </classes>
17
</definitions>  
tags/v2_0_0_Build_2041/extensions/extGeoDB/config/prodevelop.html
1
<html>
2
<body>
3

  
4
<img src="prodevelop-logo.png"><br>
5

  
6
<h2>PRODEVELOP</h2>
7
<br>
8

  
9
<p>EN CONSTRUCCION</p>
10

  
11
</body>
12
</html>
tags/v2_0_0_Build_2041/extensions/extGeoDB/config/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<libraries library-dir="lib"/>
4
	<depends plugin-name="org.gvsig.app"/>
5
    <depends plugin-name="org.gvsig.app.document.table.app.mainplugin" />
6
	<resourceBundle name="text"/>
7
	<extensions>
8
		<extension class-name="org.gvsig.geodb.ExtDB_Spatial"
9
			description="Support to access Spatial databases"
10
			active="true">
11
		</extension>		
12
	</extensions>
13
</plugin-config>
0 14

  
tags/v2_0_0_Build_2041/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/ConnectionSettings.java
1
package org.gvsig.geodb.vectorialdb;
2

  
3
import org.gvsig.fmap.dal.DALLocator;
4
import org.gvsig.fmap.dal.DataManager;
5
import org.gvsig.fmap.dal.exception.InitializeException;
6
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
7
import org.gvsig.fmap.dal.resource.db.DBParameters;
8

  
9

  
10
/**
11
 * @author Fernando Gonz?lez Cort?s
12
 */
13
public class ConnectionSettings {
14
    private String host;
15
    private String port;
16
    private String db;
17
    private String schema;
18
    private String driver;
19
    private String user;
20
    private String name;
21
    private String passw;
22

  
23
    public String getDb() {
24
        return db;
25
    }
26
    public void setDb(String db) {
27
        this.db = db;
28
    }
29
    public String getDriver() {
30
        return driver;
31
    }
32
    public void setDriver(String driver) {
33
        this.driver = driver;
34
    }
35
    public String getHost() {
36
        return host;
37
    }
38
    public void setHost(String host) {
39
        this.host = host;
40
    }
41
    public String getPort() {
42
        return port;
43
    }
44
    public void setPort(String port) {
45
        this.port = port;
46
    }
47
    public String getUser() {
48
        return user;
49
    }
50
    public void setUser(String user) {
51
        this.user = user;
52
    }
53
    public void setName(String name) {
54
        this.name = name;
55
    }
56
    public String getName() {
57
        return name;
58
    }
59

  
60
    public String toString(){
61
        return host+","+port+","+db+","+driver+","+user+","+name;
62
    }
63

  
64
    public void setFromString(String str) {
65
        String[] values = str.split(",");
66
        host = values[0];
67
        port = values[1];
68
        db = values[2];
69
        driver = values[3];
70
        user = values[4];
71
        name = values[5];
72
        if (values.length == 7) {
73
			passw = values[6];
74
		}
75
    }
76
    public String getPassw() {
77
        return passw;
78
    }
79
    public void setPassw(String passw) {
80
        this.passw = passw;
81
    }
82
    public String getConnectionString(){
83
    	DataManager dm=DALLocator.getDataManager();
84
    	try {
85
			DBParameters dsp=(DBParameters)dm.createStoreParameters(getDriver());
86
		} catch (InitializeException e) {
87
			// TODO Auto-generated catch block
88
			e.printStackTrace();
89
		} catch (ProviderNotRegisteredException e) {
90
			// TODO Auto-generated catch block
91
			e.printStackTrace();
92
		}
93

  
94
        String connectionString = "";//vecDriver.getConnectionStringBeginning() + "//" + getHost();
95

  
96
        connectionString += (":" + getPort());
97

  
98
        connectionString += ("/" + getDb());
99

  
100
        return connectionString;
101
    }
102
	public String getSchema() {
103
		return schema;
104
	}
105
	public void setSchema(String schema) {
106
		this.schema = schema;
107
	}
108
}
0 109

  
tags/v2_0_0_Build_2041/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/UserTableSettingsPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Prodevelop 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
 *   Prodevelop Integraci?n de Tecnolog?as SL
34
 *   Conde Salvatierra de ?lava , 34-10
35
 *   46004 Valencia
36
 *   Spain
37
 *
38
 *   +34 963 510 612
39
 *   +34 963 510 968
40
 *   gis@prodevelop.es
41
 *   http://www.prodevelop.es
42
 */
43
package org.gvsig.geodb.vectorialdb.wizard;
44

  
45
import java.awt.Point;
46
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionListener;
48
import java.awt.event.KeyEvent;
49
import java.awt.event.KeyListener;
50
import java.text.DecimalFormat;
51
import java.text.DecimalFormatSymbols;
52
import java.util.ArrayList;
53
import java.util.List;
54

  
55
import javax.swing.JCheckBox;
56
import javax.swing.JComboBox;
57
import javax.swing.JLabel;
58
import javax.swing.JPanel;
59
import javax.swing.JScrollPane;
60
import javax.swing.JTextArea;
61
import javax.swing.JTextField;
62

  
63
import org.slf4j.Logger;
64
import org.slf4j.LoggerFactory;
65

  
66
import org.gvsig.andami.PluginServices;
67
import org.gvsig.fmap.dal.store.db.DBStoreParameters;
68
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor;
69
import org.gvsig.gui.beans.swing.JButton;
70
import org.gvsig.tools.service.ServiceException;
71

  
72

  
73

  
74
/**
75
 * Utility class that holds a single table settings controls.
76
 *
77
 * @author jldominguez
78
 *
79
 */
80
public class UserTableSettingsPanel extends JPanel implements ActionListener,
81
    KeyListener {
82

  
83
    private static final long serialVersionUID = -9205704982299200912L;
84

  
85
    private static Logger LOG = LoggerFactory
86
			.getLogger(UserTableSettingsPanel.class);
87
    
88
    private FieldComboItem[] ids;
89
    private String initLayerName = "";
90
    private JComboBox idComboBox = null;
91
    private JTextArea sqlTextArea = null;
92
    private JLabel idLabel = null;
93
    private JLabel sqlLabel = null;
94
    private JCheckBox activateSQLCheckBox = null;
95
    protected JLabel tableNamejLabel = null;
96
    private JTextField layerNameTextField = null;
97
    private JScrollPane sqlTextAreaScroll = null;
98
    protected WizardDB parent = null;
99
	private JButton advanzedButton;
100
	protected DBStoreParameters parameters;
101

  
102
    protected UserTableSettingsPanel() {
103
		super();
104
	}
105

  
106
	protected void setInitValues(FieldComboItem[] idComboItems,
107
			String initialLayerName, boolean empty, WizardDB _p,DBStoreParameters parameters) {
108
        parent = _p;
109

  
110
        initLayerName = initialLayerName;
111
		ids = idComboItems;
112
		this.parameters = parameters;
113

  
114
	}
115

  
116
    public UserTableSettingsPanel(FieldComboItem[] idComboItems,
117
        String initialLayerName, boolean empty, WizardDB _p,
118
			DBStoreParameters parameters) {
119
		setInitValues(idComboItems, initialLayerName, empty, _p, parameters);
120
        initialize(empty);
121
    }
122

  
123
    public boolean hasValidValues() {
124
        if (!combosHaveItems()) {
125
            return false;
126
        }
127

  
128
        if ((activateSQLCheckBox.isSelected()) &&
129
                (getSqlTextArea().getText().trim().length() == 0)) {
130
            return false;
131
        }
132

  
133
        if (getLayerNameTextField().getText().trim().length() == 0) {
134
            return false;
135
        }
136

  
137
        return true;
138
    }
139

  
140
    protected void initialize(boolean _empty) {
141
        tableNamejLabel = new JLabel();
142
        tableNamejLabel.setText(PluginServices.getText(this, "name"));
143
        tableNamejLabel.setSize(new java.awt.Dimension(86, 21));
144
        tableNamejLabel.setLocation(new java.awt.Point(5, 25));
145
        sqlLabel = new JLabel();
146
        // sqlLabel.setBounds(new java.awt.Rectangle(30, 90, 116, 21));
147
		sqlLabel.setBounds(new java.awt.Rectangle(30, 55, 116, 21));
148
        sqlLabel.setText(PluginServices.getText(this, "sql_restriction"));
149
        idLabel = new JLabel();
150
        // idLabel.setBounds(new java.awt.Rectangle(5, 55, 86, 21));
151
		idLabel.setBounds(new java.awt.Rectangle(260, 25, 86, 21));
152
        idLabel.setText(PluginServices.getText(this, "id_field"));
153

  
154
        setLayout(null);
155
        setBounds(new java.awt.Rectangle(3, 225, 501, 246));
156
        setBorder(javax.swing.BorderFactory.createTitledBorder(null,
157
                PluginServices.getText(this, "specify_table_settings"),
158
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
159
                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
160
        add(getIdComboBox(), null);
161
        add(getSqlTextAreaScroll(), null);
162
        add(idLabel, null);
163
        add(sqlLabel, null);
164
        add(getActivateSQLCheckBox(), null);
165
        add(getLayerNameTextField(), null);
166
        add(tableNamejLabel, null);
167
        add(getAdvancedButton(), null);
168

  
169
        loadValues(_empty);
170
    }
171

  
172
    public void enableAlphaControls(boolean enable) {
173
        getIdComboBox().setEnabled(enable);
174
        getLayerNameTextField().setEnabled(enable);
175
        getSqlTextArea().setEnabled(enable);
176
        getActivateSQLCheckBox().setEnabled(enable);
177
        getAdvancedButton().setEnabled(enable);
178
    }
179

  
180
    public void enableSpatialControls(boolean enable) {
181

  
182
    }
183

  
184
    public void loadValues() {
185
        loadValues(false);
186
    }
187

  
188
    protected void loadValues(boolean is_empty) {
189
        if (is_empty) {
190
            enableAlphaControls(false);
191
            enableSpatialControls(false);
192
            getLayerNameTextField().setText("");
193
            getActivateSQLCheckBox().setSelected(false);
194
        }
195
        else {
196
            enableAlphaControls(true);
197
			enableSpatialControls(true);
198
			getActivateSQLCheckBox().setEnabled(true);
199
            getIdComboBox().removeAllItems();
200

  
201
            for (int i = 0; i < ids.length; i++) {
202
                getIdComboBox().addItem(ids[i]);
203
            }
204

  
205

  
206
            getLayerNameTextField().setText(initLayerName);
207

  
208
        }
209
    }
210

  
211
    private JComboBox getIdComboBox() {
212
        if (idComboBox == null) {
213
            idComboBox = new JComboBox();
214

  
215
            // idComboBox.setBounds(new java.awt.Rectangle(105, 55, 126, 21));
216
			idComboBox.setBounds(new java.awt.Rectangle(351, 25, 134, 21));
217
        }
218

  
219
        return idComboBox;
220
    }
221

  
222
    private JButton getAdvancedButton() {
223
    	if (advanzedButton == null) {
224
			advanzedButton = new JButton();
225
			advanzedButton.setLocation(new Point(350, 110));
226
			advanzedButton.setText(PluginServices.getText(this,
227
					"advanced_properties"));
228
			advanzedButton.addActionListener(this);
229
		}
230
		return advanzedButton;
231
	}
232

  
233
    private JCheckBox getActivateSQLCheckBox() {
234
        if (activateSQLCheckBox == null) {
235
            activateSQLCheckBox = new JCheckBox();
236
            activateSQLCheckBox.addActionListener(this);
237
            //activateSQLCheckBox
238
					//.setBounds(new java.awt.Rectangle(5, 90, 21, 21));
239
			activateSQLCheckBox
240
					.setBounds(new java.awt.Rectangle(5, 55, 21, 21));
241
        }
242

  
243
        return activateSQLCheckBox;
244
    }
245

  
246
    private JTextField getLayerNameTextField() {
247
        if (layerNameTextField == null) {
248
            layerNameTextField = new JTextField();
249
            layerNameTextField.setSize(new java.awt.Dimension(118, 21));
250
			// layerNameTextField.setLocation(new java.awt.Point(105, 25));
251
			layerNameTextField.setLocation(new java.awt.Point(120, 25));
252
            layerNameTextField.addKeyListener(this);
253
        }
254

  
255
        return layerNameTextField;
256
    }
257

  
258
    private JTextArea getSqlTextArea() {
259
        if (sqlTextArea == null) {
260
            sqlTextArea = new JTextArea();
261
            sqlTextArea.setLineWrap(true);
262
            sqlTextArea.setWrapStyleWord(true);
263
            sqlTextArea.addKeyListener(this);
264

  
265
            // sqlTextArea.setBounds(new java.awt.Rectangle(160,90,326,41));
266
        }
267

  
268
        return sqlTextArea;
269
    }
270

  
271
    private JScrollPane getSqlTextAreaScroll() {
272
        if (sqlTextAreaScroll == null) {
273
            sqlTextAreaScroll = new JScrollPane();
274
            // sqlTextAreaScroll.setBounds(new java.awt.Rectangle(160, 90, 326,
275
			// 41));
276
			sqlTextAreaScroll
277
					.setBounds(new java.awt.Rectangle(160, 55, 326, 41));
278
            sqlTextAreaScroll.setViewportView(getSqlTextArea());
279
            sqlTextAreaScroll.updateUI();
280
        }
281

  
282
        return sqlTextAreaScroll;
283
    }
284

  
285
    public void actionPerformed(ActionEvent e) {
286
        Object src = e.getSource();
287

  
288
        if (src == activateSQLCheckBox) {
289
            enableSQLSettings(activateSQLCheckBox.isSelected());
290
            parent.checkFinishable();
291
        } else if (src == advanzedButton) {
292
        	List<String> toHide = new ArrayList<String>();
293
			toHide.add(DBStoreParameters.PASSWORD_PARAMTER_NAME);
294
			toHide.add(DBStoreParameters.HOST_PARAMTER_NAME);
295
			toHide.add(DBStoreParameters.PORT_PARAMTER_NAME);
296
			toHide.add(DBStoreParameters.USER_PARAMTER_NAME);
297
			toHide.add(DBStoreParameters.DBNAME_PARAMTER_NAME);
298
			toHide.add(DBStoreParameters.DEFAULTGEOMETRY_PARAMTER_NAME);
299
			toHide.add(DBStoreParameters.PKFIELDS_PARAMTER_NAME);
300
			toHide.add(DBStoreParameters.FIELDS_PARAMTER_NAME);
301
			toHide.add(DBStoreParameters.BASEFILTER_PARAMTER_NAME);
302
			toHide.add(DBStoreParameters.WORKINGAREA_PARAMTER_NAME);
303
			toHide.add(DBStoreParameters.TABLE_PARAMTER_NAME);
304
			toHide.add(DBStoreParameters.CRS_PARAMTER_NAME);
305
			try {
306
				parameters.validate();
307
			} catch (Exception ex) {
308
				// ignore... only for fill default values
309
			}
310
			try {
311
                DynObjectEditor editor = new DynObjectEditor(parameters);
312
                editor.editObject(true);
313
                } catch (ServiceException ex) {
314
                    LOG.error(
315
                        "Error creating a Swing component for the DynObject: "
316
                            + parameters, ex);
317
            }
318

  
319

  
320
			return;
321

  
322
        }
323

  
324
    }
325

  
326

  
327
    private void enableSQLSettings(boolean b) {
328
        sqlTextArea.setEnabled(b);
329
    }
330

  
331
    protected String getFormattedDouble(double d) {
332
        DecimalFormat df = new DecimalFormat("#.###");
333
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
334
        dfs.setDecimalSeparator('.');
335
        df.setDecimalFormatSymbols(dfs);
336
        return df.format(d);
337
    }
338

  
339
    public void keyPressed(KeyEvent e) {
340
    }
341

  
342
    public void keyReleased(KeyEvent e) {
343
        parent.checkFinishable();
344
    }
345

  
346
    public void keyTyped(KeyEvent e) {
347
    }
348

  
349

  
350
    public String getUserLayerName() {
351
        return getLayerNameTextField().getText();
352
    }
353

  
354
    public boolean combosHaveItems() {
355
        if (getIdComboBox().getItemCount() == 0) {
356
            return false;
357
        }
358

  
359
        return true;
360
    }
361

  
362
    public void repaint() {
363
        super.repaint();
364
        getIdComboBox().updateUI();
365
    }
366

  
367
    public String getIdFieldName() {
368
        return getIdComboBox().getSelectedItem().toString();
369
    }
370

  
371
    public String getWhereClause() {
372
        return getSqlTextArea().getText();
373
    }
374

  
375
    public boolean isSqlActive() {
376
        return getActivateSQLCheckBox().isSelected();
377
    }
378
}
0 379

  
tags/v2_0_0_Build_2041/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/AvailableFieldsCheckBoxList.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Prodevelop 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
 *   Prodevelop Integraci?n de Tecnolog?as SL
34
 *   Conde Salvatierra de ?lava , 34-10
35
 *   46004 Valencia
36
 *   Spain
37
 *
38
 *   +34 963 510 612
39
 *   +34 963 510 968
40
 *   gis@prodevelop.es
41
 *   http://www.prodevelop.es
42
 */
43
package org.gvsig.geodb.vectorialdb.wizard;
44

  
45
import java.awt.Component;
46
import java.awt.event.MouseAdapter;
47
import java.awt.event.MouseEvent;
48
import java.util.ArrayList;
49

  
50
import javax.swing.JList;
51
import javax.swing.ListCellRenderer;
52
import javax.swing.ListSelectionModel;
53
import javax.swing.UIManager;
54
import javax.swing.border.Border;
55
import javax.swing.border.EmptyBorder;
56

  
57

  
58
/**
59
 * Utility class to keep the list of available fields.
60
 *
61
 * @author jldominguez
62
 *
63
 */
64
public class AvailableFieldsCheckBoxList extends JList {
65
    protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
66

  
67
    public AvailableFieldsCheckBoxList() {
68
        setCellRenderer(new CellRenderer());
69

  
70
        addMouseListener(new MouseAdapter() {
71
                public void mousePressed(MouseEvent e) {
72
                    int index = locationToIndex(e.getPoint());
73

  
74
                    if (index == -1) {
75
                        return;
76
                    }
77

  
78
                    FieldsListItem sel = (FieldsListItem) getModel()
79
                                                              .getElementAt(index);
80

  
81
                    if ((e.getClickCount() == 2) || (e.getX() < 15)) {
82
                        sel.setSelected(!sel.isSelected());
83
                    }
84
                }
85
            });
86

  
87
        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
88
    }
89

  
90
    public Object[] getCheckedItems() {
91
        int size = getModel().getSize();
92
        ArrayList resp = new ArrayList();
93

  
94
        for (int i = 0; i < size; i++) {
95
            FieldsListItem item = (FieldsListItem) getModel().getElementAt(i);
96

  
97
            if (item.isSelected()) {
98
                resp.add(item);
99
            }
100
        }
101

  
102
        return resp.toArray();
103
    }
104

  
105
    public void checkAll(boolean b) {
106
        int size = getModel().getSize();
107

  
108
        for (int i = 0; i < size; i++) {
109
            FieldsListItem item = (FieldsListItem) getModel().getElementAt(i);
110
            item.setSelected(b);
111
        }
112

  
113
        updateUI();
114
    }
115

  
116
    protected class CellRenderer implements ListCellRenderer {
117
        public Component getListCellRendererComponent(JList list, Object value,
118
            int index, boolean isSelected, boolean cellHasFocus) {
119
            FieldsListItem checkbox = (FieldsListItem) value;
120
            checkbox.setBackground(isSelected ? getSelectionBackground()
121
                                              : getBackground());
122
            checkbox.setForeground(isSelected ? getSelectionForeground()
123
                                              : getForeground());
124
            checkbox.setEnabled(isEnabled());
125
            checkbox.setFont(getFont());
126
            checkbox.setFocusPainted(false);
127
            checkbox.setBorderPainted(true);
128
            checkbox.setBorder(isSelected
129
                ? UIManager.getBorder("List.focusCellHighlightBorder")
130
                : noFocusBorder);
131

  
132
            return checkbox;
133
        }
134
    }
135
}
0 136

  
tags/v2_0_0_Build_2041/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/AvailableTablesCheckBoxList.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Prodevelop 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
 *   Prodevelop Integraci?n de Tecnolog?as SL
34
 *   Conde Salvatierra de ?lava , 34-10
35
 *   46004 Valencia
36
 *   Spain
37
 *
38
 *   +34 963 510 612
39
 *   +34 963 510 968
40
 *   gis@prodevelop.es
41
 *   http://www.prodevelop.es
42
 */
43
package org.gvsig.geodb.vectorialdb.wizard;
44

  
45
import java.awt.Component;
46
import java.awt.event.MouseAdapter;
47
import java.awt.event.MouseEvent;
48

  
49
import javax.swing.JList;
50
import javax.swing.JOptionPane;
51
import javax.swing.ListCellRenderer;
52
import javax.swing.ListSelectionModel;
53
import javax.swing.UIManager;
54
import javax.swing.border.Border;
55
import javax.swing.border.EmptyBorder;
56

  
57
import org.slf4j.Logger;
58
import org.slf4j.LoggerFactory;
59

  
60
import org.gvsig.andami.PluginServices;
61

  
62

  
63

  
64
/**
65
 * Utility class to keep the list of available tables.
66
 *
67
 * @author jldominguez
68
 *
69
 */
70
public class AvailableTablesCheckBoxList extends JList {
71
    protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
72

  
73
    private static final Logger LOG = LoggerFactory
74
        .getLogger(AvailableTablesCheckBoxList.class);
75
    private WizardDB parent = null;
76
    private TablesListItem actingTable = null;
77

  
78
    public AvailableTablesCheckBoxList(WizardDB p) {
79
        parent = p;
80

  
81
        setCellRenderer(new CellRenderer());
82

  
83
        addMouseListener(new MouseAdapter() {
84
                public void mousePressed(MouseEvent e) {
85
                    int index = locationToIndex(e.getPoint());
86

  
87
                    if (index == -1) {
88
                        return;
89
                    }
90

  
91
                    actingTable = (TablesListItem) getModel().getElementAt(index);
92

  
93
                    if ((e.getClickCount() == 2) || (e.getX() < 15)) {
94
                        if (!actingTable.isActivated()) {
95
                            actingTable.activate();
96
                        }
97

  
98
                        actingTable.setSelected(!actingTable.isSelected());
99

  
100
                        if (actingTable.isSelected()) {
101
                            actingTable.setEnabledPanels(true);
102
                        }
103
                        else {
104
                            actingTable.setEnabledPanels(false);
105
                        }
106

  
107
                        repaint();
108
                    }
109

  
110
                    try {
111
                        parent.setSettingsPanels(actingTable);
112
                        parent.checkFinishable();
113
                    }
114
                    catch (Exception e1) {
115
                        actingTable.setEnabledPanels(false);
116
                        actingTable.setSelected(false);
117
                    LOG.error(
118
                        "While setting selected table: " +
119
                            e1.getMessage(), e1);
120
                        showConnectionErrorMessage(e1.getMessage());
121
                    }
122
                }
123
            });
124

  
125
        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
126
    }
127

  
128
    private void showConnectionErrorMessage(String _msg) {
129
    	if (_msg==null) {
130
			_msg="";
131
		}
132
        String msg = (_msg.length() > 300) ? "" : (": " + _msg);
133
        String title = PluginServices.getText(this, "connection_error");
134
        JOptionPane.showMessageDialog(this, title + msg, title,
135
            JOptionPane.ERROR_MESSAGE);
136
    }
137

  
138
    protected class CellRenderer implements ListCellRenderer {
139
        public Component getListCellRendererComponent(JList list, Object value,
140
            int index, boolean isSelected, boolean cellHasFocus) {
141
            TablesListItem checkbox = (TablesListItem) value;
142
            checkbox.setBackground(isSelected ? getSelectionBackground()
143
                                              : getBackground());
144
            checkbox.setForeground(isSelected ? getSelectionForeground()
145
                                              : getForeground());
146
            checkbox.setEnabled(isEnabled());
147
            checkbox.setFont(getFont());
148
            checkbox.setFocusPainted(false);
149
            checkbox.setBorderPainted(true);
150
            checkbox.setBorder(isSelected
151
                ? UIManager.getBorder("List.focusCellHighlightBorder")
152
                : noFocusBorder);
153

  
154
            return checkbox;
155
        }
156
    }
157
}
0 158

  
tags/v2_0_0_Build_2041/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/TablesListItemVectorial.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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 2
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
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
package org.gvsig.geodb.vectorialdb.wizard;
29

  
30
import java.util.ArrayList;
31
import java.util.Iterator;
32

  
33
import org.gvsig.andami.messages.NotificationManager;
34
import org.gvsig.fmap.dal.DataTypes;
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
37
import org.gvsig.fmap.dal.feature.FeatureType;
38
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer;
39
import org.gvsig.fmap.dal.store.db.DBStoreParameters;
40
import org.gvsig.fmap.mapcontrol.MapControl;
41

  
42

  
43
public class TablesListItemVectorial extends TablesListItem {
44
	private MapControl mc;
45

  
46

  
47
	public TablesListItemVectorial(DBServerExplorer explorer,
48
			DBStoreParameters param,
49
			MapControl _mc, WizardVectorialDB _parent) {
50
		super(explorer, param, _parent);
51
		mc = _mc;
52
	}
53

  
54
    public UserTableSettingsPanel getUserTableSettingsPanel(String espView) {
55
		if (tableSettingsPanel == null) {
56

  
57
			String[] ids = new String[0];
58
			FeatureType ft = null;
59

  
60
			try {
61
				ft = explorer.getFeatureType(parameters);
62
			} catch (DataException e) {
63
				NotificationManager.addError(e);
64
				return null;
65
			}
66

  
67
			ArrayList auxAll = new ArrayList();
68
			String[] geos = new String[0];
69
			ArrayList auxGeo = new ArrayList();
70
			ArrayList auxId = new ArrayList();
71
			Iterator iter = ft.iterator();
72
			while (iter.hasNext()) {
73
				FeatureAttributeDescriptor dbattr = (FeatureAttributeDescriptor) iter
74
						.next();
75
				if (dbattr.getDataType().getType() == DataTypes.GEOMETRY) {
76
					auxGeo.add(dbattr.getName());
77
				}
78
				if (dbattr.isPrimaryKey()) {
79
					auxId.add(dbattr.getName());
80
				}
81
				auxAll.add(dbattr.getName());
82

  
83
			}
84

  
85
			geos = (String[]) auxGeo.toArray(new String[0]);
86
			if (auxId.size() > 0) {
87
				StringBuilder strb = new StringBuilder();
88
				strb.append('{');
89
				for (int i = 0; i < auxId.size() - 1; i++) {
90
					strb.append(((FeatureAttributeDescriptor) auxId.get(i))
91
							.getName());
92
					strb.append(',');
93
				}
94
				strb.append(auxId.get(auxId.size() - 1));
95

  
96
				strb.append('}');
97
				if (auxId.size() == 1) {
98
					auxAll.remove(auxId.get(0));
99
				}
100
				auxAll.add(0, strb.toString());
101
			}
102
			ids = (String[]) auxAll.toArray(new String[auxAll.size()]);
103
			int ids_size = ids.length;
104
			FieldComboItem[] ids_ci = new FieldComboItem[ids_size];
105

  
106
			for (int i = 0; i < ids_size; i++) {
107
				ids_ci[i] = new FieldComboItem(ids[i]);
108
			}
109

  
110

  
111
			int geos_size = geos.length;
112
			FieldComboItem[] geos_ci = new FieldComboItem[geos_size];
113

  
114
			for (int i = 0; i < geos_size; i++) {
115
				geos_ci[i] = new FieldComboItem(geos[i]);
116
			}
117

  
118
			tableSettingsPanel = new UserTableSettingsVectorialPanel(ids_ci,
119
					geos_ci,
120
					tableName, mc, false, (WizardVectorialDB) parent,
121
					getParameters(),
122
					currentProjection(espView,
123
							ids_ci, geos_ci));
124
		}
125

  
126
		return tableSettingsPanel;
127
	}
128

  
129
    public void setEnabledPanels(boolean b) {
130
    	super.setEnabledPanels(b);
131
		tableSettingsPanel.enableSpatialControls(b);
132
		tableSettingsPanel.enableAlphaControls(b);
133
	}
134

  
135
}
0 136

  
tags/v2_0_0_Build_2041/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/UserSelectedFieldsPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Prodevelop 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
 *   Prodevelop Integraci?n de Tecnolog?as SL
34
 *   Conde Salvatierra de ?lava , 34-10
35
 *   46004 Valencia
36
 *   Spain
37
 *
38
 *   +34 963 510 612
39
 *   +34 963 510 968
40
 *   gis@prodevelop.es
41
 *   http://www.prodevelop.es
42
 */
43
package org.gvsig.geodb.vectorialdb.wizard;
44

  
45
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionListener;
47
import java.util.ArrayList;
48

  
49
import javax.swing.DefaultListModel;
50
import javax.swing.JPanel;
51
import javax.swing.JScrollPane;
52

  
53
import org.gvsig.andami.PluginServices;
54
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
55
import org.gvsig.gui.beans.swing.JButton;
56

  
57

  
58

  
59
/**
60
 * Utility class that holds a single table field selection controls.
61
 *
62
 * @author jldominguez
63
 *
64
 */
65
public class UserSelectedFieldsPanel extends JPanel implements ActionListener {
66
    private FeatureAttributeDescriptor[] descriptors = null;
67
//    private String[] fieldTypes = null;
68
    private JScrollPane fieldsScrollPane = null;
69
    private AvailableFieldsCheckBoxList fieldsList = null;
70
    private JButton selAllFieldsButton = null;
71
    private JButton deselAllFieldsButton = null;
72
    private WizardDB parent = null;
73

  
74
    public UserSelectedFieldsPanel(FeatureAttributeDescriptor[] descriptors,
75
        boolean empty, WizardDB _p) {
76
        parent = _p;
77
        this.descriptors = descriptors;
78
//        fieldTypes = fTypes;
79
        initialize();
80

  
81
        if (empty) {
82
            enableControls(false);
83
        }
84
        else {
85
            setAllFieldsInTable(descriptors);
86
        }
87
    }
88

  
89
    public void loadValues() {
90
        setAllFieldsInTable(descriptors);
91
    }
92

  
93
    public String[] getUserSelectedFields(String idf, String geo) {
94
        String[] resp = getUserSelectedFields();
95
        if (idf != null) {
96
			resp = addBeginningIfNotContained(resp, idf);
97
		}
98
        if (geo != null) {
99
			resp = addBeginningIfNotContained(resp, geo);
100
		}
101

  
102
        return resp;
103
    }
104

  
105
    private String[] addBeginningIfNotContained(String[] arr, String item) {
106
        if (contains(arr, item)) {
107
            return arr;
108
        }
109
        else {
110
            int size = arr.length;
111
            String[] resp = new String[size + 1];
112
            resp[0] = item;
113

  
114
            for (int i = 0; i < size; i++) {
115
                resp[i + 1] = arr[i];
116
            }
117

  
118
            return resp;
119
        }
120
    }
121

  
122
    private String[] removeIfContained(String[] arr, String item) {
123
        if (!contains(arr, item)) {
124
            return arr;
125
        }
126
        else {
127
            int size = arr.length;
128
            ArrayList aux = new ArrayList();
129

  
130
            for (int i = 0; i < size; i++) {
131
				aux.add(arr[i]);
132
			}
133

  
134
            aux.remove(item);
135

  
136
            return (String[]) aux.toArray(new String[0]);
137
        }
138
    }
139

  
140
    private boolean contains(String[] arr, String item) {
141
        for (int i = 0; i < arr.length; i++) {
142
            if (arr[i].compareTo(item) == 0) {
143
                return true;
144
            }
145
        }
146

  
147
        return false;
148
    }
149

  
150
    public void enableControls(boolean enable) {
151
        getFieldsList().setEnabled(enable);
152
        getSelAllFieldsButton().setEnabled(enable);
153
        getDeselAllFieldsButton().setEnabled(enable);
154
    }
155

  
156
    private void initialize() {
157
        setLayout(null);
158
        setBounds(new java.awt.Rectangle(255, 55, 251, 166));
159
        setBorder(javax.swing.BorderFactory.createTitledBorder(null,
160
                PluginServices.getText(this, "table_fields"),
161
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
162
                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
163
        add(getFieldsScrollPane(), null);
164

  
165
        add(getSelAllFieldsButton(), null);
166
        add(getDeselAllFieldsButton(), null);
167
    }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff