Revision 44702

View differences:

tags/org.gvsig.desktop-2.0.264/org.gvsig.desktop.buildtools/src/main/resources/gvsig/checkstyle.xml
1
<?xml version="1.0"?>
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
<!DOCTYPE module PUBLIC
28
    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
29
    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
30

  
31
<!--
32

  
33
  Checkstyle configuration that checks the sun coding conventions from:
34

  
35
    - the Java Language Specification at
36
      http://java.sun.com/docs/books/jls/second_edition/html/index.html
37

  
38
    - the Sun Code Conventions at http://java.sun.com/docs/codeconv/
39

  
40
    - the Javadoc guidelines at
41
      http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
42

  
43
    - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
44

  
45
    - some best practices
46

  
47
  Checkstyle is very configurable. Be sure to read the documentation at
48
  http://checkstyle.sf.net (or in your downloaded distribution).
49

  
50
  Most Checks are configurable, be sure to consult the documentation.
51

  
52
  To completely disable a check, just comment it out or delete it from the file.
53

  
54
  Finally, it is worth reading the documentation.
55

  
56
-->
57

  
58
<module name="Checker">
59
    <!--
60
        If you set the basedir property below, then all reported file
61
        names will be relative to the specified directory. See
62
        http://checkstyle.sourceforge.net/5.x/config.html#Checker
63

  
64
        <property name="basedir" value="${basedir}"/>
65
    -->
66
    <!-- gvSIG: All project files have the ISO-8859-1 charset -->
67
	<property name="charset" value="ISO-8859-1" />
68

  
69
    <!-- Checks that a package-info.java file exists for each package.     -->
70
    <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
71
	<module name="JavadocPackage">
72
		<property name="allowLegacy" value="true" />
73
	</module>
74

  
75
    <!-- Checks whether files end with a new line.                        -->
76
    <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
77
    <module name="NewlineAtEndOfFile"/>
78

  
79
    <!-- Checks that property files contain the same keys.         -->
80
    <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
81
    <module name="Translation"/>
82
    
83
    <!-- Checks for Size Violations.                    -->
84
    <!-- See http://checkstyle.sf.net/config_sizes.html -->
85
    <module name="FileLength"/>
86
    
87
    <!-- Checks for whitespace                               -->
88
    <!-- See http://checkstyle.sf.net/config_whitespace.html -->
89
    <module name="FileTabCharacter"/>
90

  
91

  
92
    <module name="TreeWalker">
93

  
94
	    <!-- Miscellaneous other checks.                   -->
95
	    <!-- See http://checkstyle.sf.net/config_misc.html -->
96
	    <!-- gvSIG: apply only to java files -->
97
	    <module name="RegexpSinglelineJava">
98
	       <property name="format" value="\s+$"/>
99
	       <property name="minimum" value="0"/>
100
	       <property name="maximum" value="0"/>
101
	       <property name="message" value="Line has trailing spaces."/>
102
	       <property name="ignoreComments" value="true"/>
103
	    </module>
104
	    
105
        <!-- Checks for Javadoc comments.                     -->
106
        <!-- See http://checkstyle.sf.net/config_javadoc.html -->
107
		<!--
108
			gvSIG rule 3: All protected or public classes must have a Javadoc comments,
109
			except getters and setters
110
		-->
111
		<module name="JavadocMethod">
112
			<property name="scope" value="protected" />
113
			<property name="allowMissingPropertyJavadoc" value="true" />
114
		</module>
115
		<!--
116
			gvSIG rule 9: All classes must have a Javadoc comment
117
			with the "@author tag" and the "@version $Id$" tag included 
118
		-->
119
		<module name="JavadocType">
120
			<property name="scope" value="private" />
121
			<property name="authorFormat" value="\S" />
122
			<property name="versionFormat" value="\$Id.*\$"/>
123
		</module>
124
        <module name="JavadocVariable">
125
			<property name="scope" value="protected" />
126
		</module>
127
		<!-- gvSIG rule 3: Check correctly formatted Javadoc -->
128
		<module name="JavadocStyle">
129
			<property name="scope" value="protected" />
130
		</module>
131

  
132

  
133
        <!-- Checks for Naming Conventions.                  -->
134
        <!-- See http://checkstyle.sf.net/config_naming.html -->
135
        <module name="ConstantName"/>
136
        <module name="LocalFinalVariableName"/>
137
        <module name="LocalVariableName"/>
138
        <module name="MemberName"/>
139
        <module name="MethodName"/>
140
		<!-- gvSIG rule 15: All packages must begin with org.gvsig.  -->
141
		<module name="PackageName">
142
			<property name="format" value="^org\.gvsig(\.[a-z][a-z0-9]*)+$" />
143
		</module>
144
		<!-- gvSIG advised rule 1: Abstract class names must begin with Abstract. -->
145
		<!-- module name="AbstractClassName" /-->
146
        <module name="ParameterName"/>
147
        <module name="StaticVariableName"/>
148
        <module name="TypeName"/>
149

  
150
        <!-- Checks for imports                              -->
151
        <!-- See http://checkstyle.sf.net/config_import.html -->
152
        <module name="AvoidStarImport"/>
153
        <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
154
        <module name="RedundantImport"/>
155
        <module name="UnusedImports"/>
156

  
157

  
158
        <!-- Checks for Size Violations.                    -->
159
        <!-- See http://checkstyle.sf.net/config_sizes.html -->
160
        <module name="LineLength"/>
161
        <module name="MethodLength"/>
162
        <module name="ParameterNumber"/>
163

  
164

  
165
        <!-- Checks for whitespace                               -->
166
        <!-- See http://checkstyle.sf.net/config_whitespace.html -->
167
        <module name="EmptyForIteratorPad"/>
168
        <module name="GenericWhitespace"/>
169
        <module name="MethodParamPad"/>
170
        <module name="NoWhitespaceAfter"/>
171
        <module name="NoWhitespaceBefore"/>
172
        <module name="OperatorWrap"/>
173
        <module name="ParenPad"/>
174
        <module name="TypecastParenPad"/>
175
        <module name="WhitespaceAfter"/>
176
        <module name="WhitespaceAround"/>
177

  
178

  
179
        <!-- Modifier Checks                                    -->
180
        <!-- See http://checkstyle.sf.net/config_modifiers.html -->
181
        <module name="ModifierOrder"/>
182
        <module name="RedundantModifier"/>
183

  
184

  
185
        <!-- Checks for blocks. You know, those {}'s         -->
186
        <!-- See http://checkstyle.sf.net/config_blocks.html -->
187
        <module name="AvoidNestedBlocks"/>
188
        <module name="EmptyBlock"/>
189
        <module name="LeftCurly"/>
190
        <module name="NeedBraces"/>
191
        <module name="RightCurly"/>
192

  
193

  
194
        <!-- Checks for common coding problems               -->
195
        <!-- See http://checkstyle.sf.net/config_coding.html -->
196
        <module name="AvoidInlineConditionals"/>
197
        <module name="DoubleCheckedLocking"/>    <!-- MY FAVOURITE -->
198
        <module name="EmptyStatement"/>
199
        <module name="EqualsHashCode"/>
200
        <module name="HiddenField"/>
201
        <module name="IllegalInstantiation"/>
202
        <module name="InnerAssignment"/>
203
        <module name="MagicNumber"/>
204
        <module name="MissingSwitchDefault"/>
205
        <module name="RedundantThrows"/>
206
        <module name="SimplifyBooleanExpression"/>
207
        <module name="SimplifyBooleanReturn"/>
208

  
209
		<!-- gvSIG: Check for some common programming errors -->
210
		<module name="CovariantEquals" />
211
		<module name="StringLiteralEquality" />
212

  
213
        <!-- Checks for class design                         -->
214
        <!-- See http://checkstyle.sf.net/config_design.html -->
215
        <module name="DesignForExtension"/>
216
        <module name="FinalClass"/>
217
        <module name="HideUtilityClassConstructor"/>
218
        <module name="InterfaceIsType"/>
219
        <module name="VisibilityModifier"/>
220

  
221

  
222
        <!-- Miscellaneous other checks.                   -->
223
        <!-- See http://checkstyle.sf.net/config_misc.html -->
224
        <module name="ArrayTypeStyle"/>
225
        <!-- gvSIG: removed -->
226
        <!-- module name="FinalParameters"/-->
227
        <module name="TodoComment"/>
228
        <module name="UpperEll"/>
229
				
230
	    <!-- gvSIG rule 2: Sun style with 4 spaces -->
231
	    <module name="Indentation">
232
	    	<property name="basicOffset" value="4"/>
233
		    <property name="caseIndent" value="0"/>
234
		</module>
235
        
236
        <!-- gvSIG rule 10: Do not use System.out/err to log -->
237
		<module name="Regexp">
238
		    <!-- . matches any character, so we need to escape it and use \. 
239
		    to match dots.-->
240
		    <property name="format" value="System\.[out|err]\.println"/>
241
		    <property name="illegalPattern" value="true"/>
242
		</module>
243
		
244
		<!-- gvSIG rule 11: Try to avoid catching Throwable or 
245
		Exception and catch specific exceptions instead. -->
246
		<module name="IllegalCatch"/>
247
		
248
		<!-- gvSIG rule 13: Use interfaces in the declaration of 
249
		methods and variables.
250
        By default only avoids usage of Classes:
251
			"java.util.GregorianCalendar, java.util.Hashtable, 
252
		  	java.util.HashSet, java.util.HashMap, java.util.ArrayList, 
253
		  	java.util.LinkedList, java.util.LinkedHashMap, 
254
		  	java.util.LinkedHashSet, java.util.TreeSet, 
255
		  	java.util.TreeMap, java.util.Vector" -->
256
		<module name="IllegalType">
257
		    <property name="ignoredMethodNames" value="getInstance"/>
258
		</module>
259
		
260
    </module>
261

  
262
	<!--  gvSIG rule 1: check for the gvSIG header -->
263
    <!-- Uneeded, use the maven-license-plugin instead
264
	<module name="RegexpHeader"> -->
265
		<!-- The follow property value demonstrates the ability     -->
266
		<!-- to have access to ANT properties. In this case it uses -->
267
		<!-- the ${basedir} property to allow Checkstyle to be run  -->
268
		<!-- from any directory within a project. See property      -->
269
		<!-- expansion,                                             -->
270
		<!-- http://checkstyle.sf.net/config.html#properties        -->
271
    <!--
272
		<property name="headerFile" value="${checkstyle.header.file}" />
273
	</module>
274
    -->
275

  
276
</module>
0 277

  
tags/org.gvsig.desktop-2.0.264/org.gvsig.desktop.buildtools/src/main/resources/header.txt
1
gvSIG. Desktop Geographic Information System.
2

  
3
Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston, 
18
MA  02110-1301, USA.
19

  
20
For any additional information, do not hesitate to contact us 
21
at info AT gvsig.com, or visit our website www.gvsig.com.
0 22

  
tags/org.gvsig.desktop-2.0.264/org.gvsig.desktop.buildtools/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4
  <groupId>org.gvsig</groupId>
5
  <artifactId>org.gvsig.desktop.buildtools</artifactId>
6
  <version>1.0.0</version>
7
  <packaging>jar</packaging>
8
  <name>${project.artifactId}</name>
9
  <description>Resources used for build gvsig desktop</description>
10

  
11

  
12
<!-- No puede ser hijo de org.gvsig.desktop para evitar referencas circulares -->
13
<!--
14
  <parent>
15
    <groupId>org.gvsig</groupId>
16
    <artifactId>org.gvsig.desktop</artifactId>
17
    <version>2.0.10-SNAPSHOT</version>
18
  </parent>  
19
-->
20

  
21

  
22
    <licenses>
23
        <license>
24
            <name>GPLv3</name>
25
            <url>http://www.gnu.org/licenses/gpl.html</url>
26
            <distribution>repo</distribution>
27
            <comments>
28
			"GPL" stands for "General Public License". The most widespread such
29
			license is the GNU General Public License, or GNU GPL for short.
30
			This can be further shortened to "GPL", when it is understood that
31
			the GNU GPL is the one intended.
32
	      	</comments>
33
        </license>
34
    </licenses>
35

  
36
    <organization>
37
        <name>gvSIG Association</name>
38
        <url>http://www.gvsig.com/</url>
39
    </organization>
40

  
41
    <scm>
42
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/trunk</connection>
43
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/trunk</developerConnection>
44
        <url>https://devel.gvsig.org/redmine/projects/gvsig-desktop/repository/show/trunk</url>
45
    </scm>
46
    
47
    <repositories>
48
      <repository>
49
        <id>gvsig-public-http-repository</id>
50
        <name>gvSIG maven public HTTP repository</name>
51
        <url>http://devel.gvsig.org/m2repo/j2se</url>
52
        <releases>
53
          <enabled>true</enabled>
54
          <updatePolicy>daily</updatePolicy>
55
          <checksumPolicy>warn</checksumPolicy>
56
        </releases>
57
        <snapshots>
58
          <enabled>true</enabled>
59
          <updatePolicy>daily</updatePolicy>
60
          <checksumPolicy>warn</checksumPolicy>
61
        </snapshots>
62
      </repository>
63
    </repositories>
64

  
65
    <distributionManagement>
66
      <site>
67
        <id>gvsig-repository</id>
68
        <url>dav:https://devel.gvsig.org/sites/${project.artifactId}/${project.version}</url>
69
      </site>
70
      <repository>
71
          <id>gvsig-repository</id>
72
          <name>gvSIG maven repository</name>
73
          <url>dav:https://devel.gvsig.org/m2repo/j2se</url>
74
          <uniqueVersion>false</uniqueVersion>
75
      </repository>
76
      <snapshotRepository>
77
          <id>gvsig-repository</id>
78
          <name>gvSIG maven repository</name>
79
          <url>dav:https://devel.gvsig.org/m2repo/j2se</url>
80
          <uniqueVersion>false</uniqueVersion>
81
      </snapshotRepository>
82
    </distributionManagement>
83
    
84
    <issueManagement>
85
      <system>redmine</system>
86
      <url>https://devel.gvsig.org/redmine/projects/gvsig-desktop</url>
87
    </issueManagement>
88

  
89
    <mailingLists>
90
      <mailingList>
91
        <name>User List</name>
92
        <subscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_usuarios</subscribe>
93
        <unsubscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_usuarios</unsubscribe>
94
        <post>gvsig_usuarios@listserv.gva.es</post>
95
        <archive>http://www.gvsig.org/web/community/mailing-lists/gvsig-nabble</archive>
96
        <otherArchives>
97
          <otherArchive>http://www.mail-archive.com/gvsig_usuarios@runas.cap.gva.es</otherArchive>
98
          <otherArchive>http://dir.gmane.org/index.php?prefix=gmane.comp.gis.gvsig</otherArchive>
99
        </otherArchives>
100
      </mailingList>
101
      <mailingList>
102
        <name>Developer List</name>
103
        <subscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_desarrolladores</subscribe>
104
        <unsubscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_desarrolladores</unsubscribe>
105
        <post>gvsig_desarrolladores@listserv.gva.es</post>
106
        <archive>http://www.gvsig.org/web/community/mailing-lists/gvsig-nabble</archive>
107
        <otherArchives>
108
          <otherArchive>http://www.mail-archive.com/gvsig_desarrolladores@runas.cap.gva.es</otherArchive>
109
          <otherArchive>http://dir.gmane.org/index.php?prefix=gmane.comp.gis.gvsig</otherArchive>
110
        </otherArchives>
111
      </mailingList>
112
      <mailingList>
113
        <name>International List</name>
114
        <subscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</subscribe>
115
        <unsubscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</unsubscribe>
116
        <post>gvsig_internacional@listserv.gva.es</post>
117
        <archive>http://www.gvsig.org/web/community/mailing-lists/gvsig-nabble</archive>
118
        <otherArchives>
119
          <otherArchive>http://www.mail-archive.com/gvsig_internacional@runas.cap.gva.es</otherArchive>
120
          <otherArchive>http://dir.gmane.org/index.php?prefix=gmane.comp.gis.gvsig</otherArchive>
121
        </otherArchives>
122
      </mailingList>
123
    </mailingLists>
124
    
125
    <build>
126
        <extensions>
127
            <extension>
128
                <groupId>org.apache.maven.wagon</groupId>
129
                <artifactId>wagon-webdav-jackrabbit</artifactId>
130
                <version>1.0-beta-7</version>
131
            </extension>
132
        </extensions>
133
    </build>
134

  
135
</project>
0 136

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

  
26
import java.awt.geom.Point2D;
27

  
28
import org.cresques.cts.IProjection;
29
import org.gvsig.fmap.crs.CRSFactory;
30
import org.gvsig.fmap.mapcontext.MapContext;
31
import org.gvsig.fmap.mapcontext.ViewPort;
32
import org.gvsig.fmap.mapcontrol.MapControl;
33
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
34

  
35

  
36
public class AreaListenerTest extends AbstractLibraryAutoInitTestCase {
37
	private IProjection projectionUTM = CRSFactory.getCRS("EPSG:23030");
38
	private IProjection projectionGeo = CRSFactory.getCRS("EPSG:4230");
39
		
40
	@Override
41
	protected void doSetUp() throws Exception {
42
		// Nothing to do	
43
	}
44

  
45
	public void test1() {
46
		AreaListenerImpl areaListenerUTM=new AreaListenerImpl(newMapControlUTM());
47
		AreaListenerImpl areaListenerGeo=new AreaListenerImpl(newMapControlGeo());
48
		Double[] xsUTM=new Double[] {new Double(731292),new Double(731901),new Double(730138)};
49
		Double[] ysUTM=new Double[] {new Double(4351223),new Double(4350768),new Double(4349232)};
50
		double areaUTM=areaListenerUTM.returnCoordsArea(xsUTM,ysUTM,new Point2D.Double(730138,4349232));
51
		Double[] xsGeo=new Double[] {new Double(-0.31888183),new Double(-0.31173131),new Double(-0.33268401)};
52
		Double[] ysGeo=new Double[] {new Double(39.27871741),new Double(39.27464327),new Double(39.26117368)};
53
		double areaGeo=areaListenerGeo.returnGeoCArea(xsGeo,ysGeo,new Point2D.Double(-0.33268401,39.26117368));
54
		assertTrue("Area UTM igual a Geo",areaUTM<(areaGeo+1000)&& areaUTM>(areaGeo-1000));
55
	}
56
	private MapControl newMapControlUTM() {
57
		ViewPort vp = new ViewPort(projectionUTM);
58
		MapControl mc=new MapControl();
59
		mc.setMapContext(new MapContext(vp));
60
		return mc;
61
	}
62
	private MapControl newMapControlGeo() {
63
		ViewPort vp = new ViewPort(projectionGeo);
64
		MapControl mc=new MapControl();
65
		mc.setMapContext(new MapContext(vp));
66
		return mc;
67
	}
68
}
0 69

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

  
26
import org.gvsig.fmap.mapcontext.MapContext;
27
import org.gvsig.i18n.Messages;
28
import org.gvsig.utils.swing.JComboBox;
29

  
30

  
31
/**
32
 * <p>Class representing a JComboBox with the measure units handled by the application.
33
 * It takes values from Attributes.NAMES and Attributes.CHANGE static fields. So, to
34
 * add more measure units, you must edit Attributes class and change will be automatically
35
 * reflected in the combo box.</p>
36
 *
37
 * <p>The internatiolanization of the field is automatically handled by the system</p>
38
 * @author jaume dominguez faus - jaume.dominguez@iver.es
39
 */
40
public class JComboBoxUnits extends JComboBox {
41
	private static final long serialVersionUID = 8015263853737441433L;
42

  
43
	/**
44
	 * Creates a new instance of JUnitComboBox including "pixel" units and
45
	 * setting them as automatically pre-selected.
46
	 */
47
	public JComboBoxUnits() {
48
		this(true);
49
	}
50

  
51
	/**
52
	 *
53
	 * Creates a new instance of JUnitComboBox. If includePixel is true
54
	 * then pixel units are included in the list and they are automatically
55
	 * pre-selected. Otherwise, meters are preselected.
56
	 *
57
	 */
58
	public JComboBoxUnits(boolean includePixel) {
59
		super();
60
		String[] names=MapContext.getDistanceNames();
61

  
62
		for (int i = 0; i < names.length; i++) {
63
			super.addItem(Messages.getText(names[i]));
64
		}
65
		if (includePixel) {
66
			super.addItem(Messages.getText("_Pixels"));
67
			setSelectedItem(Messages.getText("_Pixels"));
68
		} else {
69
			setSelectedIndex(1);
70
		}
71
		setMaximumRowCount(10);
72
	}
73

  
74

  
75
	/**
76
	 * Returns the conversion factor from the <b>unit selected in the combo box</b>
77
	 * to <b>meters</b> or <b>0</b> if pixels have been selected as the size unit.
78
	 * @return
79
	 */
80
	public double getUnitConversionFactor() {
81
			double unitFactor;
82
			try {
83
				unitFactor = MapContext.getDistanceTrans2Meter()[getSelectedIndex()];
84
			} catch (ArrayIndexOutOfBoundsException aioobEx) { //jijiji
85
				unitFactor = 0; // which represents size in pixel
86
			}
87
			return unitFactor;
88

  
89
	}
90

  
91
	/**
92
	 * the use of this method is not allowed in this combo box.
93
	 * @deprecated
94
	 */
95
	public void addItem(Object anObject) {
96
		throw new Error("Operation not allowed");
97
	}
98

  
99
	/**
100
	 * the use of this method is not allowed for this combo box.
101
	 * @deprecated
102
	 */
103
	public void removeAllItems() {
104
		throw new Error("Operation not allowed");
105
	}
106

  
107
	public int getSelectedUnitIndex() {
108
		int i = getSelectedIndex();
109
		if (i>MapContext.getDistanceNames().length-1)
110
			return -1;
111
		else return i;
112
	}
113

  
114
	public void setSelectedUnitIndex(int unitIndex) {
115
		if (unitIndex == -1) {
116
			setSelectedIndex(getItemCount()-1);
117
		} else {
118
			setSelectedIndex(unitIndex);
119
		}
120
	}
121

  
122

  
123

  
124
}
0 125

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

  
26
import java.awt.Image;
27

  
28
import javax.swing.ImageIcon;
29

  
30
import org.gvsig.tools.swing.api.ToolsSwingLocator;
31
import org.gvsig.tools.swing.icontheme.IconTheme;
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34

  
35
public class IconThemeHelper {
36

  
37
	private static Logger logger = LoggerFactory.getLogger(IconThemeHelper.class);
38
	
39
	public static void registerIcon(String group, String name, Object obj) {
40
		String resourceName;
41
		ClassLoader loader;
42
		IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent();
43
		if( group == null || group.trim().length()==0 ) {
44
			resourceName = "images/"+name+".png";
45
		} else {
46
			resourceName = "images/"+group+"/"+name+".png";
47
		}
48
		if( obj instanceof Class ) {
49
			loader = ((Class) obj).getClassLoader();
50
		} else {
51
			loader = obj.getClass().getClassLoader();
52
		}
53
		try {
54
			iconTheme.registerDefault("mapcontrol", group, name, null, loader.getResource(resourceName));
55
		} catch( Throwable e) {
56
			logger.info(e.getMessage());
57
		}
58
	}
59

  
60
	public static ImageIcon getImageIcon(String iconName) {
61
		IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent();
62
		return iconTheme.get(iconName);
63
	}
64
	
65
	public static Image getImage(String iconName) {
66
		IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent();
67
		return iconTheme.get(iconName).getImage();
68
	}
69
}
0 70

  
tags/org.gvsig.desktop-2.0.264/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/dal/jdbc/JDBCConnectionPanelLayout.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6

  
7
package org.gvsig.fmap.mapcontrol.dal.jdbc;
8

  
9
/**
10
 *
11
 * @author jjdelcerro
12
 */
13
public class JDBCConnectionPanelLayout extends javax.swing.JPanel {
14

  
15
    /**
16
     * Creates new form DBConnectionPanelLayout
17
     */
18
    public JDBCConnectionPanelLayout() {
19
        initComponents();
20
    }
21

  
22
    /**
23
     * This method is called from within the constructor to initialize the form.
24
     * WARNING: Do NOT modify this code. The content of this method is always
25
     * regenerated by the Form Editor.
26
     */
27
    @SuppressWarnings("unchecked")
28
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
29
    private void initComponents() {
30
        java.awt.GridBagConstraints gridBagConstraints;
31

  
32
        lblConnectionName = new javax.swing.JLabel();
33
        lblConnector = new javax.swing.JLabel();
34
        lblServer = new javax.swing.JLabel();
35
        lblPort = new javax.swing.JLabel();
36
        lblDataBase = new javax.swing.JLabel();
37
        lblUsername = new javax.swing.JLabel();
38
        lblPassword = new javax.swing.JLabel();
39
        cboConnectors = new javax.swing.JComboBox();
40
        txtServer = new javax.swing.JTextField();
41
        txtPort = new javax.swing.JTextField();
42
        txtDataBase = new javax.swing.JTextField();
43
        txtUsername = new javax.swing.JTextField();
44
        txtPassword = new javax.swing.JPasswordField();
45
        lblFoother = new javax.swing.JLabel();
46
        cboConnections = new javax.swing.JComboBox();
47
        filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
48

  
49
        java.awt.GridBagLayout layout = new java.awt.GridBagLayout();
50
        layout.columnWidths = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0};
51
        layout.rowHeights = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0};
52
        setLayout(layout);
53

  
54
        lblConnectionName.setText("Nombre de la conexion:");
55
        gridBagConstraints = new java.awt.GridBagConstraints();
56
        gridBagConstraints.gridx = 2;
57
        gridBagConstraints.gridy = 2;
58
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
59
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
60
        add(lblConnectionName, gridBagConstraints);
61

  
62
        lblConnector.setText("Conector");
63
        gridBagConstraints = new java.awt.GridBagConstraints();
64
        gridBagConstraints.gridx = 2;
65
        gridBagConstraints.gridy = 4;
66
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
67
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
68
        add(lblConnector, gridBagConstraints);
69

  
70
        lblServer.setText("Servidor");
71
        gridBagConstraints = new java.awt.GridBagConstraints();
72
        gridBagConstraints.gridx = 2;
73
        gridBagConstraints.gridy = 6;
74
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
75
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
76
        add(lblServer, gridBagConstraints);
77

  
78
        lblPort.setText("Puerto");
79
        gridBagConstraints = new java.awt.GridBagConstraints();
80
        gridBagConstraints.gridx = 2;
81
        gridBagConstraints.gridy = 8;
82
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
83
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
84
        add(lblPort, gridBagConstraints);
85

  
86
        lblDataBase.setText("Base de datos");
87
        gridBagConstraints = new java.awt.GridBagConstraints();
88
        gridBagConstraints.gridx = 2;
89
        gridBagConstraints.gridy = 10;
90
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
91
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
92
        add(lblDataBase, gridBagConstraints);
93

  
94
        lblUsername.setText("Usuario");
95
        gridBagConstraints = new java.awt.GridBagConstraints();
96
        gridBagConstraints.gridx = 2;
97
        gridBagConstraints.gridy = 12;
98
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
99
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
100
        add(lblUsername, gridBagConstraints);
101

  
102
        lblPassword.setText("Clave");
103
        gridBagConstraints = new java.awt.GridBagConstraints();
104
        gridBagConstraints.gridx = 2;
105
        gridBagConstraints.gridy = 14;
106
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
107
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
108
        add(lblPassword, gridBagConstraints);
109

  
110
        gridBagConstraints = new java.awt.GridBagConstraints();
111
        gridBagConstraints.gridx = 4;
112
        gridBagConstraints.gridy = 4;
113
        gridBagConstraints.gridwidth = 3;
114
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
115
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
116
        gridBagConstraints.weightx = 0.1;
117
        add(cboConnectors, gridBagConstraints);
118
        gridBagConstraints = new java.awt.GridBagConstraints();
119
        gridBagConstraints.gridx = 4;
120
        gridBagConstraints.gridy = 6;
121
        gridBagConstraints.gridwidth = 3;
122
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
123
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
124
        gridBagConstraints.weightx = 0.1;
125
        add(txtServer, gridBagConstraints);
126
        gridBagConstraints = new java.awt.GridBagConstraints();
127
        gridBagConstraints.gridx = 4;
128
        gridBagConstraints.gridy = 8;
129
        gridBagConstraints.gridwidth = 3;
130
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
131
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
132
        gridBagConstraints.weightx = 0.1;
133
        add(txtPort, gridBagConstraints);
134
        gridBagConstraints = new java.awt.GridBagConstraints();
135
        gridBagConstraints.gridx = 4;
136
        gridBagConstraints.gridy = 10;
137
        gridBagConstraints.gridwidth = 3;
138
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
139
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
140
        gridBagConstraints.weightx = 0.1;
141
        add(txtDataBase, gridBagConstraints);
142
        gridBagConstraints = new java.awt.GridBagConstraints();
143
        gridBagConstraints.gridx = 4;
144
        gridBagConstraints.gridy = 12;
145
        gridBagConstraints.gridwidth = 3;
146
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
147
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
148
        gridBagConstraints.weightx = 0.1;
149
        add(txtUsername, gridBagConstraints);
150
        gridBagConstraints = new java.awt.GridBagConstraints();
151
        gridBagConstraints.gridx = 4;
152
        gridBagConstraints.gridy = 14;
153
        gridBagConstraints.gridwidth = 3;
154
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
155
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
156
        gridBagConstraints.weightx = 0.1;
157
        add(txtPassword, gridBagConstraints);
158

  
159
        lblFoother.setText("<html>\nTenga en cuenta que el nombre de usuario y la  contrase?a deben coincidir en mayusculas y minusculas con el registrado en la base de dato.\n<html>"); // NOI18N
160
        gridBagConstraints = new java.awt.GridBagConstraints();
161
        gridBagConstraints.gridx = 2;
162
        gridBagConstraints.gridy = 18;
163
        gridBagConstraints.gridwidth = 5;
164
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
165
        gridBagConstraints.weightx = 0.1;
166
        add(lblFoother, gridBagConstraints);
167

  
168
        gridBagConstraints = new java.awt.GridBagConstraints();
169
        gridBagConstraints.gridx = 4;
170
        gridBagConstraints.gridy = 2;
171
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
172
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
173
        gridBagConstraints.weightx = 0.1;
174
        add(cboConnections, gridBagConstraints);
175
        gridBagConstraints = new java.awt.GridBagConstraints();
176
        gridBagConstraints.gridx = 2;
177
        gridBagConstraints.gridy = 20;
178
        gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
179
        gridBagConstraints.weighty = 0.2;
180
        add(filler1, gridBagConstraints);
181
    }// </editor-fold>//GEN-END:initComponents
182

  
183

  
184
    // Variables declaration - do not modify//GEN-BEGIN:variables
185
    protected javax.swing.JComboBox cboConnections;
186
    protected javax.swing.JComboBox cboConnectors;
187
    protected javax.swing.Box.Filler filler1;
188
    protected javax.swing.JLabel lblConnectionName;
189
    protected javax.swing.JLabel lblConnector;
190
    protected javax.swing.JLabel lblDataBase;
191
    protected javax.swing.JLabel lblFoother;
192
    protected javax.swing.JLabel lblPassword;
193
    protected javax.swing.JLabel lblPort;
194
    protected javax.swing.JLabel lblServer;
195
    protected javax.swing.JLabel lblUsername;
196
    protected javax.swing.JTextField txtDataBase;
197
    protected javax.swing.JPasswordField txtPassword;
198
    protected javax.swing.JTextField txtPort;
199
    protected javax.swing.JTextField txtServer;
200
    protected javax.swing.JTextField txtUsername;
201
    // End of variables declaration//GEN-END:variables
202
}
tags/org.gvsig.desktop-2.0.264/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/dal/jdbc/JDBCConnectionPanel.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.fmap.mapcontrol.dal.jdbc;
7

  
8
import java.awt.event.ItemEvent;
9
import java.awt.event.ItemListener;
10
import java.util.Iterator;
11
import java.util.List;
12
import javax.swing.ComboBoxModel;
13
import javax.swing.JTextField;
14
import org.apache.commons.lang3.StringUtils;
15
import org.gvsig.fmap.dal.DALLocator;
16
import org.gvsig.fmap.dal.DataManager;
17
import org.gvsig.fmap.dal.DataServerExplorerParameters;
18
import org.gvsig.fmap.dal.DataServerExplorerPool;
19
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry;
20
import org.gvsig.fmap.dal.exception.DataException;
21
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
22
import org.gvsig.tools.ToolsLocator;
23
import org.gvsig.tools.i18n.I18nManager;
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26

  
27
// org.gvsig.fmap.mapcontrol.dal.jdbc.JDBCConnectionPanel
28
public class JDBCConnectionPanel extends JDBCConnectionPanelLayout {
29

  
30
    private static final Logger logger = LoggerFactory.getLogger(JDBCConnectionPanel.class);
31

  
32
    private JDBCServerExplorerParameters forcedParameters;
33
    
34
    private static class ServerExplorerParametersComboItem {
35

  
36
        private JDBCServerExplorerParameters params;
37
        private String label;
38

  
39
        public ServerExplorerParametersComboItem(String label, JDBCServerExplorerParameters params) {
40
            this.params = params;
41
            this.label = label;
42
        }
43

  
44
        public ServerExplorerParametersComboItem(JDBCServerExplorerParameters params) {
45
            this(params.getExplorerName(), params);
46
        }
47

  
48
        public String toString() {
49
            return this.label;
50
        }
51

  
52
        public JDBCServerExplorerParameters getParams() {
53
            return this.params;
54
        }
55

  
56
        public String getLabel() {
57
            return this.label;
58
        }
59
    }
60

  
61
    public JDBCConnectionPanel() {
62
        initComponents();
63
    }
64

  
65
    protected void initComponents() {
66
        this.cboConnections.setEditable(true);
67
        this.cboConnections.addItemListener(new ItemListener() {
68
            public void itemStateChanged(ItemEvent e) {
69
                onChangeConnection();
70
            }
71
        });
72
        this.cboConnectors.addItemListener(new ItemListener() {
73
            public void itemStateChanged(ItemEvent e) {
74
                onChangeConnector();
75
            }
76
        });
77
        try {
78
            fillConnections();
79
            fillConnectors();
80
        } catch(Throwable th) {
81
            // Ignore it to allow use in GUI builders
82
        }
83
        this.translate();
84
    }
85

  
86
    private void translate() {
87
        I18nManager i18nManager = ToolsLocator.getI18nManager();
88
        
89
        this.lblConnectionName.setText(i18nManager.getTranslation("_Connection_name"));
90
        this.lblConnector.setText(i18nManager.getTranslation("_Driver_type"));
91
        this.lblServer.setText(i18nManager.getTranslation("_Host"));
92
        this.lblPort.setText(i18nManager.getTranslation("_Port"));
93
        this.lblDataBase.setText(i18nManager.getTranslation("_Database"));
94
        this.lblUsername.setText(i18nManager.getTranslation("_User"));
95
        this.lblPassword.setText(i18nManager.getTranslation("_Password"));
96
        this.lblFoother.setText("<html>"+i18nManager.getTranslation("_JDBCConecctionPanel_foother")+"</html>");
97
    }
98
    
99
    public void setServerExplorerParameters(JDBCServerExplorerParameters parameters) {
100
        this.forcedParameters = (JDBCServerExplorerParameters) parameters.getCopy();
101
        
102
        int indexConnector = this.getIndexOfConnector(parameters);
103
        if ( indexConnector >= 0 && this.cboConnectors.getSelectedIndex()!=indexConnector ) {
104
            this.cboConnectors.setSelectedIndex(indexConnector);
105
        }
106

  
107
        this.txtServer.setText(parameters.getHost());
108
        Integer port = parameters.getPort();
109
        if ( port == null ) {
110
            this.txtPort.setText("");
111
        } else {
112
            this.txtPort.setText(String.valueOf(port));
113
        }
114
        this.txtDataBase.setText(parameters.getDBName());
115
        this.txtUsername.setText(parameters.getUser());
116
        this.txtPassword.setText(parameters.getPassword());
117
    }
118

  
119
    public JDBCServerExplorerParameters getServerExplorerParameters() {
120
        JDBCServerExplorerParameters params;
121
        JDBCServerExplorerParameters connector = this.getConnector();
122
        if( this.forcedParameters==null ) {
123
            params = (JDBCServerExplorerParameters) connector.getCopy();
124
        } else {
125
            params = (JDBCServerExplorerParameters) this.forcedParameters.getCopy();
126
        }
127
        String s = this.getServer();
128
        if( s!=null ) {
129
            params.setHost(s);
130
        }
131
        int n = this.getPort();
132
        if( n>0 ) {
133
            params.setPort(n);
134
        }
135
        s = this.getDataBaseName();
136
        if( s!=null ) {
137
            params.setDBName(s);
138
        }
139
        s = this.getUsername();
140
        if( s!=null ) {
141
            params.setUser(s);
142
        }
143
        s = this.getPassword();
144
        if( s!=null ) {
145
            params.setPassword(s);
146
        }
147

  
148
        if ( this.getConnectionName() != null ) {
149
            DataManager dataManager = DALLocator.getDataManager();
150
            DataServerExplorerPool pool = dataManager.getDataServerExplorerPool();
151
            pool.add(this.getConnectionName(), params);
152
        }
153
        return params;
154
    }
155

  
156
    protected void setConnectionName(String connectionName) {
157
        JTextField txtConnections = (JTextField) this.cboConnections.getEditor().getEditorComponent();
158
        txtConnections.setText(connectionName);
159
    }
160

  
161
    public String getConnectionName() {
162
        JTextField txtConnections = (JTextField) this.cboConnections.getEditor().getEditorComponent();
163
        String value = txtConnections.getText();
164
        return StringUtils.defaultIfBlank(value, null);
165
    }
166

  
167
    protected JDBCServerExplorerParameters getConnector() {
168
        ServerExplorerParametersComboItem item = (ServerExplorerParametersComboItem) this.cboConnectors.getSelectedItem();
169
        JDBCServerExplorerParameters value = item.getParams();
170
        return value;
171
    }
172

  
173
    protected String getConnectorName() {
174
        JDBCServerExplorerParameters value = this.getConnector();
175
        if ( value == null ) {
176
            return null;
177
        }
178
        return StringUtils.defaultIfBlank(value.getExplorerName(), null);
179
    }
180

  
181
    protected String getServer() {
182
        return StringUtils.defaultIfBlank(this.txtServer.getText(), null);
183
    }
184

  
185
    protected int getPort() {
186
        String svalue = StringUtils.defaultIfBlank(this.txtPort.getText(), null);
187
        int ivalue = -1;
188
        try {
189
            ivalue = Integer.parseInt(svalue);
190
        } catch (Exception ex) {
191
            ivalue = -1;
192
        }
193
        return ivalue;
194
    }
195

  
196
    protected String getDataBaseName() {
197
        return StringUtils.defaultIfBlank(this.txtDataBase.getText(), null);
198
    }
199

  
200
    protected String getUsername() {
201
        return StringUtils.defaultIfBlank(this.txtUsername.getText(), null);
202
    }
203

  
204
    protected String getPassword() {
205
        return StringUtils.defaultIfBlank(this.txtPassword.getText(), null);
206
    }
207

  
208
    private void onChangeConnector() {
209
        ServerExplorerParametersComboItem item = (ServerExplorerParametersComboItem) this.cboConnectors.getSelectedItem();
210
        if( item==null ) {
211
            return;
212
        }
213
        JDBCServerExplorerParameters connector = item.getParams();
214
        
215
        if ( connector == null ) {
216
            return;
217
        }
218
        this.setServerExplorerParameters(connector);
219
    }
220

  
221
    private void onChangeConnection() {
222
        Object item = this.cboConnections.getSelectedItem();
223
        if ( item instanceof ServerExplorerParametersComboItem ) {
224
            JDBCServerExplorerParameters connection = ((ServerExplorerParametersComboItem) item).getParams();
225
            if ( connection == null ) {
226
                return;
227
            }
228
            this.setServerExplorerParameters(connection);
229
        }
230
    }
231
    
232

  
233
    private int getIndexOfConnector(JDBCServerExplorerParameters explorerParameters) {
234
        String code = null;
235
        try {
236
            code = explorerParameters.toString();
237
            ComboBoxModel model = this.cboConnectors.getModel();
238
            for ( int i = 0; i < model.getSize(); i++ ) {
239
                ServerExplorerParametersComboItem x = (ServerExplorerParametersComboItem) model.getElementAt(i);
240
                if ( x.getLabel().equalsIgnoreCase(explorerParameters.getExplorerName()) ) {
241
                    return i;
242
                }
243
            }
244
        } catch (Exception ex) {
245
            logger.warn("Can't get index of exporer parameter '" + code + "'.", ex);
246
        }
247
        return -1;
248
    }
249

  
250
    private void fillConnectors() {
251
        DataManager dataManager = DALLocator.getDataManager();
252
        List<String> explorers = dataManager.getExplorerProviders();
253

  
254
        DataServerExplorerParameters params;
255

  
256
        JDBCServerExplorerParameters last = null;
257
        Iterator<String> it = explorers.iterator();
258
        while ( it.hasNext() ) {
259
            String explorerName = it.next();
260
            try {
261
                params = dataManager.createServerExplorerParameters(explorerName);
262
            } catch (DataException e) {
263
                continue;
264
            }
265
            if ( params instanceof JDBCServerExplorerParameters ) {
266
                JDBCServerExplorerParameters dbParams = (JDBCServerExplorerParameters) params;
267
                if( dbParams.getClass().getName().equals(JDBCServerExplorerParameters.class.getName()) ) {
268
                    last = dbParams;
269
                } else {
270
                    this.cboConnectors.addItem(
271
                            new ServerExplorerParametersComboItem(dbParams)
272
                    );
273
                }
274
            }
275
        }
276
        if( last!=null ) {
277
            this.cboConnectors.addItem(
278
                    new ServerExplorerParametersComboItem(last)
279
            );
280
        }
281
    }
282

  
283
    private void fillConnections() {
284
        DataManager dataManager = DALLocator.getDataManager();
285
        DataServerExplorerPool pool = dataManager.getDataServerExplorerPool();
286

  
287
        DataServerExplorerParameters params;
288

  
289
        Iterator<DataServerExplorerPoolEntry> it = pool.iterator();
290
        while ( it.hasNext() ) {
291
            DataServerExplorerPoolEntry entry = it.next();
292
            if ( entry.getExplorerParameters() instanceof JDBCServerExplorerParameters ) {
293
                JDBCServerExplorerParameters dbParams = (JDBCServerExplorerParameters) entry.getExplorerParameters();
294
                this.cboConnections.addItem(
295
                        new ServerExplorerParametersComboItem(entry.getName(), dbParams)
296
                );
297
            }
298
        }
299
        this.cboConnections.setSelectedIndex(-1);
300
    }
301

  
302
    public void delete() {
303
        String name = this.getConnectionName();
304
        DataManager dataManager = DALLocator.getDataManager();
305
        DataServerExplorerPool pool = dataManager.getDataServerExplorerPool();
306
        
307
        pool.remove(name);
308
    }
309
    
310
    public void clear() {
311
        this.cboConnections.setSelectedIndex(-1);
312
        this.cboConnectors.setSelectedIndex(-1);
313
        this.txtServer.setText("");
314
        this.txtPort.setText("");
315
        this.txtDataBase.setText("");
316
        this.txtUsername.setText("");
317
        this.txtPassword.setText("");
318
    }
319
}
tags/org.gvsig.desktop-2.0.264/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/dal/jdbc/JDBCConnectionPanelLayout.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.JLabel" name="lblConnectionName">
18
      <Properties>
19
        <Property name="text" type="java.lang.String" value="Nombre de la conexion:"/>
20
      </Properties>
21
      <Constraints>
22
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
23
          <GridBagConstraints gridX="2" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
24
        </Constraint>
25
      </Constraints>
26
    </Component>
27
    <Component class="javax.swing.JLabel" name="lblConnector">
28
      <Properties>
29
        <Property name="text" type="java.lang.String" value="Conector"/>
30
      </Properties>
31
      <Constraints>
32
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
33
          <GridBagConstraints gridX="2" gridY="4" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
34
        </Constraint>
35
      </Constraints>
36
    </Component>
37
    <Component class="javax.swing.JLabel" name="lblServer">
38
      <Properties>
39
        <Property name="text" type="java.lang.String" value="Servidor"/>
40
      </Properties>
41
      <Constraints>
42
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
43
          <GridBagConstraints gridX="2" gridY="6" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
44
        </Constraint>
45
      </Constraints>
46
    </Component>
47
    <Component class="javax.swing.JLabel" name="lblPort">
48
      <Properties>
49
        <Property name="text" type="java.lang.String" value="Puerto"/>
50
      </Properties>
51
      <Constraints>
52
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
53
          <GridBagConstraints gridX="2" gridY="8" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
54
        </Constraint>
55
      </Constraints>
56
    </Component>
57
    <Component class="javax.swing.JLabel" name="lblDataBase">
58
      <Properties>
59
        <Property name="text" type="java.lang.String" value="Base de datos"/>
60
      </Properties>
61
      <Constraints>
62
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
63
          <GridBagConstraints gridX="2" gridY="10" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
64
        </Constraint>
65
      </Constraints>
66
    </Component>
67
    <Component class="javax.swing.JLabel" name="lblUsername">
68
      <Properties>
69
        <Property name="text" type="java.lang.String" value="Usuario"/>
70
      </Properties>
71
      <Constraints>
72
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
73
          <GridBagConstraints gridX="2" gridY="12" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
74
        </Constraint>
75
      </Constraints>
76
    </Component>
77
    <Component class="javax.swing.JLabel" name="lblPassword">
78
      <Properties>
79
        <Property name="text" type="java.lang.String" value="Clave"/>
80
      </Properties>
81
      <Constraints>
82
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
83
          <GridBagConstraints gridX="2" gridY="14" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
84
        </Constraint>
85
      </Constraints>
86
    </Component>
87
    <Component class="javax.swing.JComboBox" name="cboConnectors">
88
      <Properties>
89
        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
90
          <StringArray count="0"/>
91
        </Property>
92
      </Properties>
93
      <Constraints>
94
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
95
          <GridBagConstraints gridX="4" gridY="4" gridWidth="3" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.1" weightY="0.0"/>
96
        </Constraint>
97
      </Constraints>
98
    </Component>
99
    <Component class="javax.swing.JTextField" name="txtServer">
100
      <Constraints>
101
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
102
          <GridBagConstraints gridX="4" gridY="6" gridWidth="3" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.1" weightY="0.0"/>
103
        </Constraint>
104
      </Constraints>
105
    </Component>
106
    <Component class="javax.swing.JTextField" name="txtPort">
107
      <Constraints>
108
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
109
          <GridBagConstraints gridX="4" gridY="8" gridWidth="3" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.1" weightY="0.0"/>
110
        </Constraint>
111
      </Constraints>
112
    </Component>
113
    <Component class="javax.swing.JTextField" name="txtDataBase">
114
      <Constraints>
115
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
116
          <GridBagConstraints gridX="4" gridY="10" gridWidth="3" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.1" weightY="0.0"/>
117
        </Constraint>
118
      </Constraints>
119
    </Component>
120
    <Component class="javax.swing.JTextField" name="txtUsername">
121
      <Constraints>
122
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
123
          <GridBagConstraints gridX="4" gridY="12" gridWidth="3" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.1" weightY="0.0"/>
124
        </Constraint>
125
      </Constraints>
126
    </Component>
127
    <Component class="javax.swing.JPasswordField" name="txtPassword">
128
      <Constraints>
129
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
130
          <GridBagConstraints gridX="4" gridY="14" gridWidth="3" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.1" weightY="0.0"/>
131
        </Constraint>
132
      </Constraints>
133
    </Component>
134
    <Component class="javax.swing.JLabel" name="lblFoother">
135
      <Properties>
136
        <Property name="text" type="java.lang.String" value="&lt;html&gt;&#xa;Tenga en cuenta que el nombre de usuario y la  contrase&#xf1;a deben coincidir en mayusculas y minusculas con el registrado en la base de dato.&#xa;&lt;html&gt;" noResource="true"/>
137
      </Properties>
138
      <Constraints>
139
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
140
          <GridBagConstraints gridX="2" gridY="18" gridWidth="5" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.1" weightY="0.0"/>
141
        </Constraint>
142
      </Constraints>
143
    </Component>
144
    <Component class="javax.swing.JComboBox" name="cboConnections">
145
      <Properties>
146
        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
147
          <StringArray count="0"/>
148
        </Property>
149
      </Properties>
150
      <Constraints>
151
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
152
          <GridBagConstraints gridX="4" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.1" weightY="0.0"/>
153
        </Constraint>
154
      </Constraints>
155
    </Component>
156
    <Component class="javax.swing.Box$Filler" name="filler1">
157
      <Properties>
158
        <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
159
          <Dimension value="[0, 32767]"/>
160
        </Property>
161
      </Properties>
162
      <AuxValues>
163
        <AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalGlue"/>
164
      </AuxValues>
165
      <Constraints>
166
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
167
          <GridBagConstraints gridX="2" gridY="20" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.2"/>
168
        </Constraint>
169
      </Constraints>
170
    </Component>
171
  </SubComponents>
172
  <LayoutCode>
173
    <CodeStatement>
174
      <CodeExpression id="1_layout">
175
        <CodeVariable name="layout" type="4096" declaredType="java.awt.GridBagLayout"/>
176
        <ExpressionOrigin>
177
          <ExpressionProvider type="CodeConstructor">
178
            <CodeConstructor class="java.awt.GridBagLayout" parameterTypes=""/>
179
          </ExpressionProvider>
180
        </ExpressionOrigin>
181
      </CodeExpression>
182
      <StatementProvider type="CodeExpression">
183
        <CodeExpression id="1_layout"/>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff