Revision 38307
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.gvsig.newlayer</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
</buildSpec> |
|
9 |
<natures> |
|
10 |
</natures> |
|
11 |
</projectDescription> |
|
0 | 12 |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/prepare-workspace.xml | ||
---|---|---|
1 |
<project name="org.gvsig.initial.build" default="prepare-workspace"> |
|
2 |
|
|
3 |
<dirname property="org.gvsig.initial.build.basedir" file="${ant.file.org.gvsig.initial.build}" /> |
|
4 |
|
|
5 |
<property name="workspace.basedir" value="${org.gvsig.initial.build.basedir}/.." /> |
|
6 |
<property name="build.basedir" value="${workspace.basedir}/org.gvsig.maven.base.build" description="Eclipse workspace location" /> |
|
7 |
<property name="build.jar.version" value="1.0.8-SNAPSHOT" /> |
|
8 |
<property name="build.jar.file" value="org.gvsig.maven.base.build-${build.jar.version}.jar" /> |
|
9 |
|
|
10 |
<property name="ant.libs.dir" location="${build.basedir}" description="Additional ant tasks libs folder" /> |
|
11 |
|
|
12 |
<target name="check-maven-base-build-available"> |
|
13 |
<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" property="maven-base-build-available" /> |
|
14 |
</target> |
|
15 |
|
|
16 |
<target name="get-maven-base-build-local" depends="check-maven-base-build-available" if="maven-base-build-available"> |
|
17 |
<!-- Unzip de build jar file from the maven repository into the workspace root folder --> |
|
18 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
19 |
<zipfileset src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}"> |
|
20 |
<patternset> |
|
21 |
<exclude name="META-INF/**" /> |
|
22 |
</patternset> |
|
23 |
</zipfileset> |
|
24 |
</copy> |
|
25 |
</target> |
|
26 |
|
|
27 |
<target name="get-maven-base-build-remote" depends="check-maven-base-build-available" unless="maven-base-build-available"> |
|
28 |
<mkdir dir="target" /> |
|
29 |
|
|
30 |
<!-- Download the build jar file --> |
|
31 |
<get src="http://devel.gvsig.org/m2repo/j2se/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" dest="target/${build.jar.file}" verbose="true" /> |
|
32 |
|
|
33 |
<!-- Unzip de build jar file into the workspace root folder --> |
|
34 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
35 |
<zipfileset src="target/${build.jar.file}"> |
|
36 |
<patternset> |
|
37 |
<exclude name="META-INF/**" /> |
|
38 |
</patternset> |
|
39 |
</zipfileset> |
|
40 |
</copy> |
|
41 |
|
|
42 |
</target> |
|
43 |
|
|
44 |
<target name="find.depends.natives.file"> |
|
45 |
<condition property="depends.natives.file.exists"> |
|
46 |
<available file="${org.gvsig.initial.build.basedir}/DEPENDS_ON_NATIVE_LIBRARIES"/> |
|
47 |
</condition> |
|
48 |
</target> |
|
49 |
|
|
50 |
<target name="find.gvsig.platform.properties.file" |
|
51 |
depends="find.depends.natives.file" |
|
52 |
if="depends.natives.file.exists"> |
|
53 |
<condition property="gvsig.platform.exists"> |
|
54 |
<available file="${user.home}/.gvsig.platform.properties"/> |
|
55 |
</condition> |
|
56 |
</target> |
|
57 |
|
|
58 |
<target name="check.gvsig.platform.properties" |
|
59 |
depends="find.gvsig.platform.properties.file"> |
|
60 |
<fail if="depends.natives.file.exists" unless="gvsig.platform.exists"> |
|
61 |
ERROR!! |
|
62 |
|
|
63 |
You have to define your gvSIG platform properties, |
|
64 |
by creating the file: ${user.home}/.gvsig.platform.properties |
|
65 |
with the following content: |
|
66 |
|
|
67 |
native_platform=linux |
|
68 |
native_distribution=all |
|
69 |
native_compiler=gcc4 |
|
70 |
native_arch=i386 |
|
71 |
native_libraryType=dynamic |
|
72 |
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType} |
|
73 |
|
|
74 |
Replace the fifth initial variables values with the ones appropiate |
|
75 |
to your platform. |
|
76 |
|
|
77 |
If you use maven in the command line, you can use the previous file also |
|
78 |
to define the MAVEN_OPTS environment variable, by adding to your |
|
79 |
.bash_rc file something like this: |
|
80 |
|
|
81 |
if [ -f "${HOME}/.gvsig.platform.properties" ] |
|
82 |
then |
|
83 |
. ${HOME}/.gvsig.platform.properties |
|
84 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier}" |
|
85 |
else |
|
86 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m" |
|
87 |
fi |
|
88 |
|
|
89 |
It will work if you use the bash shell. In any other case or platform, you'll |
|
90 |
have to define your MAVEN_OPTS environment variable and set the |
|
91 |
"native-classifier" parameter directly. |
|
92 |
</fail> |
|
93 |
|
|
94 |
</target> |
|
95 |
|
|
96 |
<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote,check.gvsig.platform.properties"> |
|
97 |
|
|
98 |
<mkdir dir="target" /> |
|
99 |
|
|
100 |
<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug" /> |
|
101 |
|
|
102 |
<!-- Copy the maven launchers to the workspace metadata folder --> |
|
103 |
<copy todir="${workspace.basedir}/.metadata"> |
|
104 |
<fileset dir="${build.basedir}/eclipse-launchers"> |
|
105 |
<exclude name="**/org.eclipse.jdt.core.prefs" /> |
|
106 |
<exclude name="**/org.eclipse.core.variables.prefs" /> |
|
107 |
</fileset> |
|
108 |
</copy> |
|
109 |
|
|
110 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" append="true"> |
|
111 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.jdt.core.prefs" /> |
|
112 |
</concat> |
|
113 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" append="true"> |
|
114 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.core.variables.prefs" /> |
|
115 |
</concat> |
|
116 |
|
|
117 |
<!-- Configure the eclipse workspace --> |
|
118 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace" /> |
|
119 |
|
|
120 |
<!-- Configure the gvSIG profile --> |
|
121 |
<ant antfile="${build.basedir}/check-gvsig-profile.xml" /> |
|
122 |
|
|
123 |
<property name="user-settings-file-location" value="${user.home}/.m2/settings.xml" /> |
|
124 |
|
|
125 |
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"> |
|
126 |
<classpath> |
|
127 |
<pathelement location="${ant.libs.dir}/com.oopsconsultancy.xmltask-1.16.1.jar" /> |
|
128 |
</classpath> |
|
129 |
</taskdef> |
|
130 |
|
|
131 |
<xmltask source="${user-settings-file-location}" dest="${user-settings-file-location}"> |
|
132 |
<copy path="//:settings/:profiles/:profile[:id/text() = 'gvsig-install']/:properties/:gvsig.install.dir/text()" property="current-gvsig-location" /> |
|
133 |
</xmltask> |
|
134 |
|
|
135 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
136 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
137 |
|
|
138 |
<!-- Compile, install and generate eclipse projects --> |
|
139 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse" /> |
|
140 |
|
|
141 |
<echo>INFORMATION!!!</echo> |
|
142 |
<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo> |
|
143 |
|
|
144 |
<!-- TODO: copiar al proyecto de configuraciĆ³n general --> |
|
145 |
</target> |
|
146 |
|
|
147 |
<target name="clean"> |
|
148 |
<delete dir="target" /> |
|
149 |
</target> |
|
150 |
|
|
151 |
</project> |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.newlayer</artifactId> |
|
7 |
<packaging>pom</packaging> |
|
8 |
<version>1.0.0-SNAPSHOT</version> |
|
9 |
<name>org.gvsig.newlayer</name> |
|
10 |
<description>newlayer example project</description> |
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.maven.base.pom</artifactId> |
|
14 |
<version>1.0.8-SNAPSHOT</version> |
|
15 |
</parent> |
|
16 |
<scm> |
|
17 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/libraries/org.gvsig.newlayer</connection> |
|
18 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/libraries/org.gvsig.newlayer</developerConnection> |
|
19 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-desktop/repository/show/branches/v2_0_0_prep/libraries/org.gvsig.newlayer</url> |
|
20 |
</scm> |
|
21 |
<developers> |
|
22 |
<developer> |
|
23 |
<id>jpiera</id> |
|
24 |
<name>Jorge Piera</name> |
|
25 |
<email>jpiera@gvsig.org</email> |
|
26 |
<roles> |
|
27 |
<role>Architect</role> |
|
28 |
<role>Developer</role> |
|
29 |
</roles> |
|
30 |
</developer> |
|
31 |
<developer> |
|
32 |
<id>jjdelcerro</id> |
|
33 |
<name>Joaqu?n Jos? del Cerro</name> |
|
34 |
<email>jjdelcerro@gvsig.org</email> |
|
35 |
<roles> |
|
36 |
<role>Architect</role> |
|
37 |
</roles> |
|
38 |
</developer> |
|
39 |
</developers> |
|
40 |
<repositories> |
|
41 |
<repository> |
|
42 |
<id>gvsig-public-http-repository</id> |
|
43 |
<name>gvSIG maven public HTTP repository</name> |
|
44 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
45 |
<releases> |
|
46 |
<enabled>true</enabled> |
|
47 |
<updatePolicy>daily</updatePolicy> |
|
48 |
<checksumPolicy>warn</checksumPolicy> |
|
49 |
</releases> |
|
50 |
<snapshots> |
|
51 |
<enabled>true</enabled> |
|
52 |
<updatePolicy>daily</updatePolicy> |
|
53 |
<checksumPolicy>warn</checksumPolicy> |
|
54 |
</snapshots> |
|
55 |
</repository> |
|
56 |
</repositories> |
|
57 |
<dependencyManagement> |
|
58 |
<dependencies> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.core.maven.dependencies</artifactId> |
|
62 |
<version>2.0.1-SNAPSHOT</version> |
|
63 |
<type>pom</type> |
|
64 |
<scope>import</scope> |
|
65 |
</dependency> |
|
66 |
<dependency> |
|
67 |
<groupId>org.gvsig</groupId> |
|
68 |
<artifactId>org.gvsig.geodb</artifactId> |
|
69 |
<version>2.0-SNAPSHOT</version> |
|
70 |
</dependency> |
|
71 |
</dependencies> |
|
72 |
</dependencyManagement> |
|
73 |
|
|
74 |
<dependencies> |
|
75 |
<dependency> |
|
76 |
<groupId>org.gvsig</groupId> |
|
77 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
78 |
</dependency> |
|
79 |
<dependency> |
|
80 |
<groupId>org.gvsig</groupId> |
|
81 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
82 |
<type>test-jar</type> |
|
83 |
</dependency> |
|
84 |
</dependencies> |
|
85 |
|
|
86 |
<modules> |
|
87 |
<module>org.gvsig.newlayer.lib</module> |
|
88 |
<module>org.gvsig.newlayer.prov</module> |
|
89 |
</modules> |
|
90 |
</project> |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/README.txt | ||
---|---|---|
1 |
The first time you checkout the current project to a new workspace, |
|
2 |
you have to prepare it to be able to work easily with maven from |
|
3 |
eclipse itself. |
|
4 |
|
|
5 |
Perform the following steps: |
|
6 |
|
|
7 |
1.- Launch the *prepare-workspace.xml* ant build file. |
|
8 |
You can do it by loading the file into the ant view, |
|
9 |
and running the default task, or right-clicking the |
|
10 |
file from the package explorer or the navigator and |
|
11 |
select the option: *Run as > Ant build*. |
|
12 |
|
|
13 |
2.- Restart eclipse. |
|
14 |
|
|
15 |
3.- Import the subprojects of the project you have just checked out. |
|
16 |
|
|
17 |
Those steps are only needed once per workspace. |
|
18 |
|
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/test/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your test classes. |
|
2 |
|
|
3 |
This folder is added to the Tests classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your tests classes. |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.newlayer"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="INFO" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.newlayer.impl.NewLayerDefaultImplLibrary |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/resources/org/gvsig/newlayer/lib/impl/newlayerfilters.properties | ||
---|---|---|
1 |
#point_geometries_only= |
|
2 |
#curve_geometries_only= |
|
3 |
#surface_geometries_only= |
|
4 |
prov_demo=PROV < '10' |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/resources/org/gvsig/newlayer/lib/impl/i18n/text.properties | ||
---|---|---|
1 |
cant_create_new_layer=No se puede crear la nueva capa |
|
2 |
new_layers_parameters_missing=No se puede crear una nueva capa.\nFaltan los par?metros.\nVuelva atr?s e introd?zcalos. |
|
3 |
new_layer_not_store_name=No se puede crear la nueva capa.\nEl nombre del store no existe.\nVuelva atr?s e introd?zcalo. |
|
4 |
not_applicable=No aplicable |
|
0 | 5 |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/resources/org/gvsig/newlayer/lib/impl/i18n/text_en.properties | ||
---|---|---|
1 |
cant_create_new_layer=Can't create the new layer |
|
2 |
new_layer_parameters_missing=Can't create a new layer.\n The store paremeters are missing.\n Go back and enter it, please. |
|
3 |
new_layer_not_store_name=Can't create a new layer.\n The store name is missing.\n Go back and enter it, please. |
|
4 |
not_applicable=Not applicable |
|
0 | 5 |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/AddNewLayerQuestionPanel.java | ||
---|---|---|
1 |
package org.gvsig.newlayer.impl; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
|
|
5 |
import javax.swing.JCheckBox; |
|
6 |
import javax.swing.JPanel; |
|
7 |
|
|
8 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
|
9 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
10 |
import org.gvsig.i18n.Messages; |
|
11 |
import org.gvsig.newlayer.NewLayerService; |
|
12 |
import org.gvsig.newlayer.NewLayerWizard; |
|
13 |
|
|
14 |
public class AddNewLayerQuestionPanel extends JPanel implements OptionPanel{ |
|
15 |
|
|
16 |
private static final long serialVersionUID = -5251910576017225307L; |
|
17 |
private NewLayerWizard wizard; |
|
18 |
private JCheckBox questionCheckBox = null; |
|
19 |
|
|
20 |
public AddNewLayerQuestionPanel(NewLayerWizard wizard){ |
|
21 |
this.wizard = wizard; |
|
22 |
initializeComponents(); |
|
23 |
} |
|
24 |
|
|
25 |
public String getPanelTitle() { |
|
26 |
return "Add layer question panel"; |
|
27 |
} |
|
28 |
|
|
29 |
public void nextPanel() throws NotContinueWizardException { |
|
30 |
getService().addLayerToView(getAddLayerToView()); |
|
31 |
} |
|
32 |
|
|
33 |
public void lastPanel() { |
|
34 |
// do nothing |
|
35 |
|
|
36 |
} |
|
37 |
|
|
38 |
public void updatePanel() { |
|
39 |
initializeComponents(); |
|
40 |
} |
|
41 |
|
|
42 |
public JPanel getJPanel() { |
|
43 |
return this; |
|
44 |
} |
|
45 |
|
|
46 |
private void initializeComponents() { |
|
47 |
this.setLayout(new BorderLayout()); |
|
48 |
this.add(getQuestionCheckBox(), BorderLayout.CENTER); |
|
49 |
} |
|
50 |
|
|
51 |
private JCheckBox getQuestionCheckBox(){ |
|
52 |
if (this.questionCheckBox == null){ |
|
53 |
this.questionCheckBox = new JCheckBox(Messages.getText("add_layer_to_view_question"), true); |
|
54 |
} |
|
55 |
return this.questionCheckBox; |
|
56 |
} |
|
57 |
|
|
58 |
private NewLayerService getService() { |
|
59 |
return this.wizard.getService(); |
|
60 |
} |
|
61 |
|
|
62 |
public boolean getAddLayerToView(){ |
|
63 |
return getQuestionCheckBox().isSelected(); |
|
64 |
} |
|
65 |
} |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/DefaultNewLayerService.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 |
package org.gvsig.newlayer.impl; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.Iterator; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import org.gvsig.fmap.dal.DALLocator; |
|
29 |
import org.gvsig.fmap.dal.DataManager; |
|
30 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
31 |
import org.gvsig.fmap.dal.DataStore; |
|
32 |
import org.gvsig.fmap.dal.exception.DataException; |
|
33 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
34 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
35 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
36 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
37 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
38 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
39 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
40 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
41 |
import org.gvsig.newlayer.NewLayerManager; |
|
42 |
import org.gvsig.newlayer.NewLayerProvider; |
|
43 |
import org.gvsig.newlayer.NewLayerProviderFactory; |
|
44 |
import org.gvsig.newlayer.NewLayerService; |
|
45 |
import org.gvsig.newlayer.NewLayerServiceException; |
|
46 |
import org.gvsig.tools.service.ServiceException; |
|
47 |
|
|
48 |
/** |
|
49 |
* Default {@link NewLayerService} implementation. |
|
50 |
* |
|
51 |
* @author gvSIG Team |
|
52 |
* @version $Id$ |
|
53 |
*/ |
|
54 |
public class DefaultNewLayerService implements NewLayerService { |
|
55 |
|
|
56 |
private NewLayerManager newLayerManager; |
|
57 |
private NewLayerProviderFactory type; |
|
58 |
private NewLayerProvider provider; |
|
59 |
private boolean addLayerToView = true; |
|
60 |
private MapContext mapContext; |
|
61 |
|
|
62 |
/** |
|
63 |
* {@link DefaultNewLayerService} constructor |
|
64 |
*/ |
|
65 |
public DefaultNewLayerService(NewLayerManager manager, MapContext mapContext) { |
|
66 |
this.newLayerManager = manager; |
|
67 |
this.mapContext = mapContext; |
|
68 |
} |
|
69 |
|
|
70 |
public NewLayerProvider getProvider() { |
|
71 |
return provider; |
|
72 |
} |
|
73 |
|
|
74 |
public void createLayer() throws NewLayerServiceException { |
|
75 |
try { |
|
76 |
this.getExplorer().add(this.getStoreName(), |
|
77 |
this.getNewStoreParameters(), true); |
|
78 |
} catch (DataException e) { |
|
79 |
throw new CantCreateNewLayerException(e); |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
public void loadLayer() throws NewLayerServiceException { |
|
84 |
try { |
|
85 |
String storeName = this.getStoreName(); |
|
86 |
NewFeatureStoreParameters storeParameters = |
|
87 |
this.getNewStoreParameters(); |
|
88 |
DataManager dataManager = DALLocator.getDataManager(); |
|
89 |
DataStore store = dataManager.openStore(storeName, storeParameters); |
|
90 |
String layerName = store.getName(); |
|
91 |
|
|
92 |
MapContextManager mapContextManager = |
|
93 |
MapContextLocator.getMapContextManager(); |
|
94 |
FLayer lyr = mapContextManager.createLayer(layerName, store); |
|
95 |
lyr.setActive(true); |
|
96 |
lyr.setVisible(true); |
|
97 |
mapContext.getLayers().addLayer(lyr); |
|
98 |
|
|
99 |
lyr.dispose(); |
|
100 |
} catch (DataException e) { |
|
101 |
throw new CantOpenStoreException(e); |
|
102 |
} catch (ValidateDataParametersException e) { |
|
103 |
throw new CantOpenStoreException(e); |
|
104 |
} catch (LoadLayerException e) { |
|
105 |
throw new CantLoadNewLayerException(e); |
|
106 |
} |
|
107 |
|
|
108 |
} |
|
109 |
|
|
110 |
public class CantCreateNewLayerException extends NewLayerServiceException { |
|
111 |
|
|
112 |
/** |
|
113 |
* |
|
114 |
*/ |
|
115 |
private static final long serialVersionUID = 4208215791054246118L; |
|
116 |
|
|
117 |
public CantCreateNewLayerException(Throwable cause) { |
|
118 |
super("Can't create the layer", cause, "_cant_create_the_layer", |
|
119 |
serialVersionUID); |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
public class CantOpenStoreException extends NewLayerServiceException { |
|
124 |
|
|
125 |
/** |
|
126 |
* |
|
127 |
*/ |
|
128 |
private static final long serialVersionUID = -2245228621032918630L; |
|
129 |
|
|
130 |
public CantOpenStoreException(Throwable cause) { |
|
131 |
super("Can't open store", cause, "_cant_open_store", |
|
132 |
serialVersionUID); |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
public class CantLoadNewLayerException extends NewLayerServiceException { |
|
137 |
|
|
138 |
/** |
|
139 |
* |
|
140 |
*/ |
|
141 |
private static final long serialVersionUID = -1711950651766745963L; |
|
142 |
|
|
143 |
public CantLoadNewLayerException(Throwable cause) { |
|
144 |
super("Can't load the new layer", cause, |
|
145 |
"_cant_load_the_new_layer", serialVersionUID); |
|
146 |
} |
|
147 |
} |
|
148 |
|
|
149 |
public void setType(String type) { |
|
150 |
try { |
|
151 |
setProviderFactory(this.newLayerManager |
|
152 |
.getNewLayerProviderFactory(type)); |
|
153 |
} catch (ServiceException e) { |
|
154 |
throw new RuntimeException(e); |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
public DataServerExplorer getExplorer() { |
|
159 |
return getProvider().getExplorer(); |
|
160 |
} |
|
161 |
|
|
162 |
public String getStoreName() { |
|
163 |
return getProvider().getStoreName(); |
|
164 |
} |
|
165 |
|
|
166 |
public EditableFeatureType getFeatureType() { |
|
167 |
return getProvider().getFeatureType(); |
|
168 |
} |
|
169 |
|
|
170 |
public NewFeatureStoreParameters getNewStoreParameters() { |
|
171 |
return getProvider().getNewStoreParameters(); |
|
172 |
} |
|
173 |
|
|
174 |
public List<String> getTypes() { |
|
175 |
List<String> types = new ArrayList<String>(); |
|
176 |
List<NewLayerProviderFactory> providers = getProviderFactories(); |
|
177 |
Iterator<NewLayerProviderFactory> it = providers.iterator(); |
|
178 |
while (it.hasNext()) { |
|
179 |
NewLayerProviderFactory newLayerProviderFactory = it.next(); |
|
180 |
types.add(newLayerProviderFactory.getName()); |
|
181 |
} |
|
182 |
return types; |
|
183 |
} |
|
184 |
|
|
185 |
public String getType() { |
|
186 |
return this.type.getName(); |
|
187 |
} |
|
188 |
|
|
189 |
public void addLayerToView(boolean b) { |
|
190 |
this.addLayerToView = b; |
|
191 |
} |
|
192 |
|
|
193 |
public MapContext getMapContext() { |
|
194 |
return mapContext; |
|
195 |
} |
|
196 |
|
|
197 |
public void setProviderFactory(NewLayerProviderFactory type) { |
|
198 |
this.type = type; |
|
199 |
this.provider = type.create(this); |
|
200 |
} |
|
201 |
|
|
202 |
public NewLayerProviderFactory getProviderFactory() { |
|
203 |
return type; |
|
204 |
} |
|
205 |
|
|
206 |
public List<NewLayerProviderFactory> getProviderFactories() { |
|
207 |
|
|
208 |
List<NewLayerProviderFactory> providers = |
|
209 |
new ArrayList<NewLayerProviderFactory>( |
|
210 |
this.newLayerManager |
|
211 |
.getProviders(NewLayerManager.STORETYPE.ANY)); |
|
212 |
|
|
213 |
for (Iterator<NewLayerProviderFactory> iterator = providers.iterator(); iterator |
|
214 |
.hasNext();) { |
|
215 |
NewLayerProviderFactory newLayerProviderFactory = iterator.next(); |
|
216 |
if (!newLayerProviderFactory.isEnabled()) { |
|
217 |
iterator.remove(); |
|
218 |
} |
|
219 |
} |
|
220 |
|
|
221 |
return providers; |
|
222 |
} |
|
223 |
|
|
224 |
} |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/DefaultNewLayerWizard.java | ||
---|---|---|
1 |
package org.gvsig.newlayer.impl; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.swing.ImageIcon; |
|
8 |
import javax.swing.JOptionPane; |
|
9 |
import javax.swing.JPanel; |
|
10 |
|
|
11 |
import jwizardcomponent.CancelAction; |
|
12 |
import jwizardcomponent.DefaultJWizardComponents; |
|
13 |
import jwizardcomponent.FinishAction; |
|
14 |
import jwizardcomponent.JWizardComponents; |
|
15 |
|
|
16 |
import org.slf4j.Logger; |
|
17 |
import org.slf4j.LoggerFactory; |
|
18 |
|
|
19 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
|
20 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
21 |
import org.gvsig.i18n.Messages; |
|
22 |
import org.gvsig.newlayer.NewLayerException; |
|
23 |
import org.gvsig.newlayer.NewLayerProviderFactory; |
|
24 |
import org.gvsig.newlayer.NewLayerProviderPanel; |
|
25 |
import org.gvsig.newlayer.NewLayerService; |
|
26 |
import org.gvsig.newlayer.NewLayerServiceException; |
|
27 |
import org.gvsig.newlayer.NewLayerWizard; |
|
28 |
|
|
29 |
public class DefaultNewLayerWizard extends NewLayerWizard { |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
*/ |
|
34 |
private static final long serialVersionUID = -5827106636136663823L; |
|
35 |
private NewLayerService service; |
|
36 |
private AddNewLayerQuestionPanel addNewLayerQuestionPanel; |
|
37 |
private static final Logger LOG = |
|
38 |
LoggerFactory.getLogger(DefaultNewLayerWizard.class); |
|
39 |
|
|
40 |
public DefaultNewLayerWizard(ImageIcon logo, NewLayerService service) { |
|
41 |
super(logo); |
|
42 |
setPreferredSize(new Dimension(800, 400)); |
|
43 |
this.service = service; |
|
44 |
this.getWizardComponents().setFinishAction( |
|
45 |
new MyFinishAction(this.getWizardComponents())); |
|
46 |
this.getWizardComponents().setCancelAction( |
|
47 |
new MyCancelAction(this.getWizardComponents())); |
|
48 |
this.createTypeSelector(); |
|
49 |
} |
|
50 |
|
|
51 |
public NewLayerService getService() { |
|
52 |
return this.service; |
|
53 |
} |
|
54 |
|
|
55 |
private void createTypeSelector() { |
|
56 |
|
|
57 |
TypeSelectorPanel panel = new TypeSelectorPanel(this); |
|
58 |
this.addOptionPanel(panel); |
|
59 |
|
|
60 |
} |
|
61 |
|
|
62 |
private void createFeatureTypePanel() { |
|
63 |
|
|
64 |
FeatureTypePanel panel = new FeatureTypePanel(this); |
|
65 |
this.addOptionPanel(panel); |
|
66 |
|
|
67 |
} |
|
68 |
|
|
69 |
private void createProviderPanels() { |
|
70 |
DefaultJWizardComponents wizardComponents = this.getWizardComponents(); |
|
71 |
for (int i = wizardComponents.getWizardPanelList().size() - 1; i >= 1; i--) { |
|
72 |
wizardComponents.removeWizardPanel(i); |
|
73 |
} |
|
74 |
List<NewLayerProviderPanel> panels = service.getProvider().getPanels(); |
|
75 |
Iterator<NewLayerProviderPanel> it = panels.iterator(); |
|
76 |
while (it.hasNext()) { |
|
77 |
NewLayerProviderPanel panel = it.next(); |
|
78 |
this.addOptionPanel(new OptionPanelWrapper(panel)); |
|
79 |
} |
|
80 |
this.createFeatureTypePanel(); |
|
81 |
this.createAddNewLayerQuestionPanel(); |
|
82 |
} |
|
83 |
|
|
84 |
private AddNewLayerQuestionPanel getAddNewLayerQuestionPanel() { |
|
85 |
if (this.addNewLayerQuestionPanel == null) { |
|
86 |
this.addNewLayerQuestionPanel = new AddNewLayerQuestionPanel(this); |
|
87 |
} |
|
88 |
return this.addNewLayerQuestionPanel; |
|
89 |
} |
|
90 |
|
|
91 |
private void createAddNewLayerQuestionPanel() { |
|
92 |
this.addOptionPanel(getAddNewLayerQuestionPanel()); |
|
93 |
} |
|
94 |
|
|
95 |
private boolean getAddLayerToView() { |
|
96 |
return getAddNewLayerQuestionPanel().getAddLayerToView(); |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public void setType(NewLayerProviderFactory currentType) { |
|
101 |
this.service.setProviderFactory(currentType); |
|
102 |
createProviderPanels(); |
|
103 |
} |
|
104 |
|
|
105 |
private class OptionPanelWrapper implements OptionPanel { |
|
106 |
|
|
107 |
private NewLayerProviderPanel panel; |
|
108 |
|
|
109 |
public OptionPanelWrapper(NewLayerProviderPanel panel) { |
|
110 |
this.panel = panel; |
|
111 |
} |
|
112 |
|
|
113 |
public String getPanelTitle() { |
|
114 |
return this.panel.getTitle(); |
|
115 |
} |
|
116 |
|
|
117 |
public void nextPanel() throws NotContinueWizardException { |
|
118 |
|
|
119 |
try { |
|
120 |
if (!this.panel.isValidPanel()) { |
|
121 |
throw new NotContinueWizardException("Error validating the form", panel, false); |
|
122 |
} |
|
123 |
} catch (NewLayerException e) { |
|
124 |
LOG.error("Error validating the form", e); |
|
125 |
throw new NotContinueWizardException("Error validating the form", |
|
126 |
e, panel); |
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
public void lastPanel() { |
|
131 |
} |
|
132 |
|
|
133 |
public void updatePanel() { |
|
134 |
this.panel.updatePanel(); |
|
135 |
} |
|
136 |
|
|
137 |
public JPanel getJPanel() { |
|
138 |
return this.panel; |
|
139 |
} |
|
140 |
|
|
141 |
} |
|
142 |
|
|
143 |
private class MyFinishAction extends FinishAction { |
|
144 |
|
|
145 |
public MyFinishAction(JWizardComponents arg0) { |
|
146 |
super(arg0); |
|
147 |
} |
|
148 |
|
|
149 |
public void performAction() { |
|
150 |
|
|
151 |
if (getService().getStoreName() == null) { |
|
152 |
JOptionPane |
|
153 |
.showMessageDialog( |
|
154 |
null, |
|
155 |
Messages.getText("new_layer_not_store_name"), |
|
156 |
Messages.getText("new_layer"), |
|
157 |
JOptionPane.WARNING_MESSAGE); |
|
158 |
return; |
|
159 |
} |
|
160 |
if (getService().getNewStoreParameters() == null) { |
|
161 |
JOptionPane |
|
162 |
.showMessageDialog( |
|
163 |
null, |
|
164 |
Messages.getText("new_layer_parameters_missing"), |
|
165 |
Messages.getText("new_layer"), |
|
166 |
JOptionPane.WARNING_MESSAGE); |
|
167 |
return; |
|
168 |
} |
|
169 |
getService().addLayerToView(getAddLayerToView()); |
|
170 |
try { |
|
171 |
getService().createLayer(); |
|
172 |
} catch (NewLayerServiceException e) { |
|
173 |
LOG.error("Can't create the new layer", e); |
|
174 |
JOptionPane |
|
175 |
.showMessageDialog( |
|
176 |
null, |
|
177 |
Messages.getText("cant_create_new_layer") + "\n" + e.getMessageStack(), |
|
178 |
Messages.getText("new_layer"), |
|
179 |
JOptionPane.ERROR_MESSAGE); |
|
180 |
return; |
|
181 |
} |
|
182 |
|
|
183 |
try { |
|
184 |
getService().loadLayer(); |
|
185 |
} catch (NewLayerServiceException e) { |
|
186 |
JOptionPane |
|
187 |
.showMessageDialog( |
|
188 |
null, |
|
189 |
"The new layer has been succesfully created but can't load the new layer.\n Try load it yourshelf, please.", |
|
190 |
"Can't create a new layer", |
|
191 |
JOptionPane.WARNING_MESSAGE); |
|
192 |
} |
|
193 |
setVisible(false); |
|
194 |
return; |
|
195 |
} |
|
196 |
|
|
197 |
} |
|
198 |
|
|
199 |
private class MyCancelAction extends CancelAction { |
|
200 |
|
|
201 |
public MyCancelAction(DefaultJWizardComponents wizardComponents) { |
|
202 |
super(wizardComponents); |
|
203 |
} |
|
204 |
|
|
205 |
public void performAction() { |
|
206 |
setVisible(false); |
|
207 |
} |
|
208 |
|
|
209 |
} |
|
210 |
} |
tags/v2_0_0_Build_2047/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/FeatureTypePanel.java | ||
---|---|---|
1 |
package org.gvsig.newlayer.impl; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Component; |
|
5 |
import java.awt.event.ActionEvent; |
|
6 |
import java.awt.event.ActionListener; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.Iterator; |
|
9 |
import java.util.List; |
|
10 |
|
|
11 |
import javax.swing.ComboBoxModel; |
|
12 |
import javax.swing.DefaultCellEditor; |
|
13 |
import javax.swing.JButton; |
|
14 |
import javax.swing.JCheckBox; |
|
15 |
import javax.swing.JComboBox; |
|
16 |
import javax.swing.JLabel; |
|
17 |
import javax.swing.JPanel; |
|
18 |
import javax.swing.JScrollPane; |
|
19 |
import javax.swing.JTable; |
|
20 |
import javax.swing.ListSelectionModel; |
|
21 |
import javax.swing.UIManager; |
|
22 |
import javax.swing.event.ListDataListener; |
|
23 |
import javax.swing.event.ListSelectionEvent; |
|
24 |
import javax.swing.event.ListSelectionListener; |
|
25 |
import javax.swing.event.TableModelEvent; |
|
26 |
import javax.swing.event.TableModelListener; |
|
27 |
import javax.swing.table.DefaultTableModel; |
|
28 |
import javax.swing.table.TableCellRenderer; |
|
29 |
import javax.swing.table.TableColumn; |
|
30 |
|
|
31 |
import org.cresques.cts.IProjection; |
|
32 |
import org.slf4j.Logger; |
|
33 |
import org.slf4j.LoggerFactory; |
|
34 |
|
|
35 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
|
36 |
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel; |
|
37 |
import org.gvsig.fmap.dal.DALLocator; |
|
38 |
import org.gvsig.fmap.dal.DataManager; |
|
39 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
40 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
41 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
42 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
43 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
|
44 |
import org.gvsig.fmap.geom.DataTypes; |
|
45 |
import org.gvsig.fmap.geom.Geometry; |
|
46 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
|
47 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
48 |
import org.gvsig.i18n.Messages; |
|
49 |
import org.gvsig.newlayer.NewLayerService; |
|
50 |
import org.gvsig.newlayer.NewLayerWizard; |
|
51 |
import org.gvsig.tools.dataTypes.DataType; |
|
52 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
53 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
54 |
|
|
55 |
public class FeatureTypePanel extends JPanel implements OptionPanel { |
|
56 |
private static final int COLUMN_FIELD = 0; |
|
57 |
private static final int COLUMN_TYPE = 1; |
|
58 |
private static final int COLUMN_LENGTH = 2; |
|
59 |
private static final int COLUMN_GEOMETRYTYPE = 3; |
|
60 |
private static final int COLUMN_GEOMETRYSUBTYPE = 4; |
|
61 |
private static final int COLUMN_CRS = 5; |
|
62 |
private static final int COLUMN_PRIMARYKEY = 6; |
|
63 |
private static final int COLUMN_MANDATORY = 7; |
|
64 |
|
|
65 |
private static final long serialVersionUID = 263541873998597624L; |
|
66 |
private NewLayerWizard wizard; |
|
67 |
private static final Logger logger = LoggerFactory |
|
68 |
.getLogger(FeatureTypePanel.class); |
|
69 |
|
|
70 |
private JLabel jLabel = null; |
|
71 |
private JScrollPane jScrollPane = null; |
|
72 |
protected JTable jTable = null; |
|
73 |
private JPanel jPanelEast = null; |
|
74 |
private JButton jButtonAddField = null; |
|
75 |
private JButton jButtonDeleteField = null; |
|
76 |
protected int MAX_FIELD_LENGTH = 254; |
|
77 |
private List removedFields; |
|
78 |
|
|
79 |
private DataServerExplorer explorer = null; |
|
80 |
|
|
81 |
public FeatureTypePanel(NewLayerWizard wizard) { |
|
82 |
this.wizard = wizard; |
|
83 |
removedFields = new ArrayList<String>(); |
|
84 |
} |
|
85 |
|
|
86 |
private void initializeComponents() { |
|
87 |
jLabel = new JLabel(); |
|
88 |
jLabel.setText(Messages.getText("define_fields")); |
|
89 |
this.setLayout(new BorderLayout(5, 5)); |
|
90 |
this.setSize(new java.awt.Dimension(499, 232)); |
|
91 |
this.add(jLabel, java.awt.BorderLayout.NORTH); |
|
92 |
this.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
|
93 |
this.add(getJPanelEast(), java.awt.BorderLayout.EAST); |
|
94 |
|
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* This method initializes jScrollPane |
|
99 |
* |
|
100 |
* @return javax.swing.JScrollPane |
|
101 |
*/ |
|
102 |
private JScrollPane getJScrollPane() { |
|
103 |
if (jScrollPane == null) { |
|
104 |
jScrollPane = new JScrollPane(); |
|
105 |
jScrollPane.setViewportView(getJTable()); |
|
106 |
} |
|
107 |
return jScrollPane; |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* This method initializes jTable |
|
112 |
* |
|
113 |
* @return javax.swing.JTable |
|
114 |
*/ |
|
115 |
private JTable getJTable() { |
|
116 |
if (jTable == null) { |
|
117 |
jTable = new JTable(){ |
|
118 |
public boolean isCellEditable(int row,int column){ |
|
119 |
Object o = getValueAt(row,column); |
|
120 |
|
|
121 |
if ((column == COLUMN_GEOMETRYTYPE) || |
|
122 |
(column == COLUMN_GEOMETRYSUBTYPE) || |
|
123 |
(column == COLUMN_CRS)) { |
|
124 |
DataType dataType = |
|
125 |
((ComboItemDataType) getValueAt(row, COLUMN_TYPE)).dataType; |
|
126 |
return dataType.getType() == DataTypes.GEOMETRY; |
|
127 |
} |
|
128 |
return true; |
|
129 |
} |
|
130 |
}; |
|
131 |
|
|
132 |
DefaultTableModel tm = (DefaultTableModel) jTable.getModel(); |
|
133 |
tm.addColumn(Messages.getText("field")); |
|
134 |
|
|
135 |
tm.addColumn(Messages.getText("type")); |
|
136 |
tm.addColumn(Messages.getText("length")); |
|
137 |
tm.addColumn(Messages.getText("geomType")); |
|
138 |
tm.addColumn(Messages.getText("geomSubtype")); |
|
139 |
tm.addColumn(Messages.getText("CRS")); |
|
140 |
tm.addColumn(Messages.getText("primaryKey")); |
|
141 |
tm.addColumn(Messages.getText("mandatory")); |
|
142 |
|
|
143 |
// Ask to be notified of selection changes. |
|
144 |
ListSelectionModel rowSM = jTable.getSelectionModel(); |
|
145 |
rowSM.addListSelectionListener(new ListSelectionListener() { |
|
146 |
public void valueChanged(ListSelectionEvent e) { |
|
147 |
// Ignore extra messages. |
|
148 |
if (e.getValueIsAdjusting()) |
|
149 |
return; |
|
150 |
|
|
151 |
ListSelectionModel lsm = (ListSelectionModel) e.getSource(); |
|
152 |
if (lsm.isSelectionEmpty()) { |
|
153 |
// no rows are selected |
|
154 |
jButtonDeleteField.setEnabled(false); |
|
155 |
} else { |
|
156 |
jButtonDeleteField.setEnabled(true); |
|
157 |
} |
|
158 |
} |
|
159 |
}); |
|
160 |
jTable.getColumn(Messages.getText("field")).setWidth(180); |
|
161 |
|
|
162 |
jTable.getModel().addTableModelListener(new TableModelListener() { |
|
163 |
public void tableChanged(TableModelEvent e) { |
|
164 |
if (e.getColumn() == COLUMN_TYPE){ |
|
165 |
jTable.repaint(); |
|
166 |
} |
|
167 |
} |
|
168 |
}); |
|
169 |
|
|
170 |
// Rellenado de la tabla |
|
171 |
EditableFeatureType featureType = this.wizard.getService() |
|
172 |
.getFeatureType(); |
|
173 |
if (featureType != null) { |
|
174 |
int row = 0; |
|
175 |
tm.setRowCount(featureType.size()); |
|
176 |
Iterator it = featureType.iterator(); |
|
177 |
while (it.hasNext()) { |
|
178 |
FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) it |
|
179 |
.next(); |
|
180 |
tm.setValueAt(descriptor.getName(), row, COLUMN_FIELD); |
|
181 |
tm.setValueAt(descriptor.getType(), row, COLUMN_TYPE); |
|
182 |
tm.setValueAt(descriptor.getSize(), row, COLUMN_LENGTH); |
|
183 |
tm.setValueAt(descriptor.getGeometryType(), row, COLUMN_GEOMETRYTYPE); |
|
184 |
tm.setValueAt(descriptor.getGeometrySubType(), row, COLUMN_GEOMETRYSUBTYPE); |
|
185 |
tm.setValueAt(descriptor.getSRS(), row, COLUMN_CRS); |
|
186 |
tm.setValueAt(descriptor.isPrimaryKey(), row, COLUMN_PRIMARYKEY); |
|
187 |
tm.setValueAt(descriptor.isMandatory(), row, COLUMN_MANDATORY); |
|
188 |
row++; |
|
189 |
} |
|
190 |
} |
|
191 |
|
|
192 |
} |
|
193 |
jTable.setEnabled(allowEditableFeatureType()); |
|
194 |
return jTable; |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* This method initializes jPanelWest |
|
199 |
* |
|
200 |
* @return javax.swing.JPanel |
|
201 |
*/ |
|
202 |
private JPanel getJPanelEast() { |
|
203 |
if (jPanelEast == null) { |
|
204 |
jPanelEast = new JPanel(); |
|
205 |
jPanelEast.setLayout(null); |
|
206 |
jPanelEast.setPreferredSize(new java.awt.Dimension(170, 100)); |
|
207 |
jPanelEast.add(getJButtonAddField(), null); |
|
208 |
jPanelEast.add(getJButtonDeleteField(), null); |
|
209 |
} |
|
210 |
return jPanelEast; |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* This method initializes jButtonAddField |
|
215 |
* |
|
216 |
* @return javax.swing.JButton |
|
217 |
*/ |
|
218 |
private JButton getJButtonAddField() { |
|
219 |
if (jButtonAddField == null) { |
|
220 |
jButtonAddField = new JButton(); |
|
221 |
jButtonAddField.setText(Messages.getText("add_field")); |
|
222 |
jButtonAddField.setLocation(new java.awt.Point(7, 5)); |
|
223 |
jButtonAddField.setSize(new java.awt.Dimension(145, 23)); |
|
224 |
jButtonAddField.setPreferredSize(new java.awt.Dimension(100, 26)); |
|
225 |
jButtonAddField |
|
226 |
.addActionListener(new java.awt.event.ActionListener() { |
|
227 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
228 |
DefaultTableModel tm = (DefaultTableModel) jTable |
|
229 |
.getModel(); |
|
230 |
|
|
231 |
// Figure out a suitable field name |
|
232 |
ArrayList fieldNames = new ArrayList(); |
|
233 |
for (int i = 0; i < jTable.getRowCount(); i++) { |
|
234 |
fieldNames.add(tm.getValueAt(i, COLUMN_FIELD)); |
|
235 |
} |
|
236 |
String[] currentFieldNames = (String[]) fieldNames |
|
237 |
.toArray(new String[0]); |
|
238 |
String newField = Messages.getText("field") |
|
239 |
.replaceAll(" +", "_"); |
|
240 |
int index = 0; |
|
241 |
for (int i = 0; i < currentFieldNames.length; i++) { |
|
242 |
if (currentFieldNames[i].startsWith(newField)) { |
|
243 |
try { |
|
244 |
index = Integer |
|
245 |
.parseInt(currentFieldNames[i] |
|
246 |
.replaceAll(newField, |
|
247 |
"")); |
|
248 |
} catch (Exception ex) { /* we don't care */ |
|
249 |
} |
|
250 |
} |
|
251 |
} |
|
252 |
String newFieldName = newField + (++index); |
|
253 |
|
|
254 |
// Esto lo a?ado aqu? porque si no tiene registros, |
|
255 |
// no hace caso. (Por eso no |
|
256 |
// lo pongo en getJTable() |
|
257 |
TableColumn typeColumn = jTable.getColumnModel() |
|
258 |
.getColumn(COLUMN_TYPE); |
|
259 |
DataManager dataManager = DALLocator |
|
260 |
.getDataManager(); |
|
261 |
ComboModelDataType model = new ComboModelDataType( |
|
262 |
dataManager.getDataTypes()); |
|
263 |
JComboBox comboBox = new JComboBox(model); |
|
264 |
typeColumn.setCellEditor(new DefaultCellEditor( |
|
265 |
comboBox)); |
|
266 |
|
|
267 |
TableColumn widthColumn = jTable.getColumnModel() |
|
268 |
.getColumn(COLUMN_LENGTH); |
|
269 |
|
|
270 |
TableColumn geomTypeColumn = jTable |
|
271 |
.getColumnModel().getColumn(COLUMN_GEOMETRYTYPE); |
|
272 |
ComboModelGeomType geomTypeModel = new ComboModelGeomType( |
|
273 |
getGeomTypes()); |
|
274 |
JComboBox geomTypeComboBox = new JComboBox( |
|
275 |
geomTypeModel); |
|
276 |
geomTypeColumn.setCellEditor(new DefaultCellEditor( |
|
277 |
geomTypeComboBox)); |
|
278 |
geomTypeColumn.setCellRenderer(new GeometryComboCellRenderer()); |
|
279 |
|
|
280 |
|
|
281 |
TableColumn geomSubTypeColumn = jTable |
|
282 |
.getColumnModel().getColumn(COLUMN_GEOMETRYSUBTYPE); |
|
283 |
ComboModelGeomType geomSubTypeModel = new ComboModelGeomType( |
|
284 |
getGeomSubtypes()); |
|
285 |
JComboBox geomSubTypeComboBox = new JComboBox( |
|
286 |
geomSubTypeModel); |
|
287 |
geomSubTypeColumn |
|
288 |
.setCellEditor(new DefaultCellEditor( |
|
289 |
geomSubTypeComboBox)); |
|
290 |
geomSubTypeColumn.setCellRenderer(new GeometryComboCellRenderer()); |
|
291 |
|
|
292 |
TableColumn crsColumn = jTable.getColumnModel() |
|
293 |
.getColumn(COLUMN_CRS); |
|
294 |
crsColumn.setCellEditor(new ButtonEditor( |
|
295 |
new JCheckBox())); |
|
296 |
CrsRenderer crsButtonRenderer = new CrsRenderer(); |
|
297 |
crsColumn.setCellRenderer(crsButtonRenderer); |
|
298 |
|
|
299 |
TableColumn primaryKeyColumn = jTable |
|
300 |
.getColumnModel().getColumn(COLUMN_PRIMARYKEY); |
|
301 |
JCheckBox primaryKeyCheckBox = new JCheckBox(); |
|
302 |
primaryKeyColumn |
|
303 |
.setCellEditor(new DefaultCellEditor( |
|
304 |
primaryKeyCheckBox)); |
|
305 |
CheckBoxRenderer primaryKeyCheckBoxRenderer = new CheckBoxRenderer(); |
|
306 |
primaryKeyColumn |
|
307 |
.setCellRenderer(primaryKeyCheckBoxRenderer); |
|
308 |
|
|
309 |
TableColumn mandatoryColumn = jTable |
|
310 |
.getColumnModel().getColumn(COLUMN_MANDATORY); |
|
311 |
JCheckBox mandatoryCheckBox = new JCheckBox(); |
|
312 |
mandatoryColumn |
|
313 |
.setCellEditor(new DefaultCellEditor( |
|
314 |
mandatoryCheckBox)); |
|
315 |
CheckBoxRenderer mandatoryCheckBoxRenderer = new CheckBoxRenderer(); |
|
316 |
mandatoryColumn |
|
317 |
.setCellRenderer(mandatoryCheckBoxRenderer); |
|
318 |
|
|
319 |
// Add a new row |
|
320 |
Object[] newRow = new Object[tm.getColumnCount()]; |
|
321 |
newRow[COLUMN_FIELD] = newFieldName; |
|
322 |
newRow[COLUMN_TYPE] = model.getElementAt(0); |
|
323 |
newRow[COLUMN_LENGTH] = "20"; |
|
324 |
newRow[COLUMN_GEOMETRYTYPE] = geomTypeModel.getElementAt(0); |
|
325 |
newRow[COLUMN_GEOMETRYSUBTYPE] = geomSubTypeModel.getElementAt(0); |
|
326 |
// Por defecto, la proyeccion de la vista |
|
327 |
newRow[COLUMN_CRS] = wizard.getService().getMapContext() |
|
328 |
.getProjection(); |
|
329 |
newRow[COLUMN_PRIMARYKEY] = primaryKeyCheckBox.isSelected(); |
|
330 |
newRow[COLUMN_MANDATORY] = mandatoryCheckBox.isSelected(); |
|
331 |
tm.addRow(newRow); |
|
332 |
} |
|
333 |
}); |
|
334 |
|
|
335 |
} |
|
336 |
jButtonAddField.setEnabled(allowEditableFeatureType()); |
|
337 |
return jButtonAddField; |
|
338 |
} |
|
339 |
|
|
340 |
private boolean allowEditableFeatureType(){ |
|
341 |
NewLayerService service = this.wizard.getService(); |
|
342 |
DataManager dataManager = DALLocator.getDataManager(); |
|
343 |
FeatureStoreProviderFactory factory = (FeatureStoreProviderFactory) dataManager.getStoreProviderFactory(service.getStoreName()); |
|
344 |
if (factory.allowEditableFeatureType()==FeatureStoreProviderFactory.NO) { |
|
345 |
return false; |
|
346 |
} |
|
347 |
return true; |
|
348 |
} |
|
349 |
|
|
350 |
private class ComboItemDataType { |
|
351 |
private DataType dataType; |
|
352 |
|
|
353 |
public ComboItemDataType(DataType dataType) { |
|
354 |
this.dataType = dataType; |
|
355 |
} |
|
356 |
|
|
357 |
@Override |
|
358 |
public String toString() { |
|
359 |
return this.dataType.getName(); |
|
360 |
} |
|
361 |
} |
|
362 |
|
|
363 |
private class ComboModelDataType implements ComboBoxModel { |
|
364 |
|
|
365 |
private List<ComboItemDataType> dataTypes; |
|
366 |
private ComboItemDataType selected; |
|
367 |
|
|
368 |
public ComboModelDataType(List<DataType> dataTypes) { |
|
369 |
this.dataTypes = new ArrayList<ComboItemDataType>(); |
|
370 |
for (Iterator iterator = dataTypes.iterator(); iterator.hasNext();) { |
|
371 |
DataType dataType = (DataType) iterator.next(); |
|
372 |
this.dataTypes.add(new ComboItemDataType(dataType)); |
|
373 |
} |
|
374 |
} |
|
375 |
|
|
376 |
public void addListDataListener(ListDataListener arg0) { |
|
377 |
// DO NOTHING |
|
378 |
} |
|
379 |
|
|
380 |
public Object getElementAt(int arg0) { |
|
381 |
return this.dataTypes.get(arg0); |
|
382 |
} |
|
383 |
|
|
384 |
public int getSize() { |
|
385 |
return this.dataTypes.size(); |
|
386 |
} |
|
387 |
|
|
388 |
public void removeListDataListener(ListDataListener arg0) { |
|
389 |
// DO NOTHING |
|
390 |
} |
|
391 |
|
|
392 |
public Object getSelectedItem() { |
|
393 |
return this.selected; |
|
394 |
} |
|
395 |
|
|
396 |
public void setSelectedItem(Object anItem) { |
|
397 |
this.selected = (ComboItemDataType) anItem; |
|
398 |
} |
|
399 |
|
|
400 |
} |
|
401 |
|
|
402 |
class CrsRenderer extends JButton implements TableCellRenderer { |
|
403 |
private static final long serialVersionUID = -573793294070515376L; |
|
404 |
private JLabel label = null; |
|
405 |
|
|
406 |
public CrsRenderer() { |
|
407 |
setOpaque(true); |
|
408 |
label = new JLabel(Messages.getText("not_applicable")); |
|
409 |
} |
|
410 |
|
|
411 |
public Component getTableCellRendererComponent(JTable table, |
|
412 |
Object value, boolean isSelected, boolean hasFocus, int row, |
|
413 |
int column) { |
|
414 |
|
|
415 |
DataType dataType = |
|
416 |
((ComboItemDataType) table.getValueAt(row, COLUMN_TYPE)).dataType; |
|
417 |
|
|
418 |
if (dataType.getType() != DataTypes.GEOMETRY) { |
|
419 |
return label; |
|
420 |
} |
|
421 |
|
|
422 |
if (isSelected) { |
|
423 |
setForeground(table.getSelectionForeground()); |
|
424 |
setBackground(table.getSelectionBackground()); |
|
425 |
} else { |
|
426 |
setForeground(table.getForeground()); |
|
427 |
setBackground(UIManager.getColor("Button.background")); |
|
428 |
} |
|
429 |
setText((value == null) ? "" : ((IProjection) value).getFullCode()); |
|
430 |
return this; |
|
431 |
} |
|
432 |
} |
|
433 |
|
|
434 |
private class GeometryComboCellRenderer extends JLabel implements TableCellRenderer{ |
|
435 |
|
|
436 |
public Component getTableCellRendererComponent(JTable table, |
|
437 |
Object value, boolean isSelected, boolean hasFocus, int row, |
|
438 |
int column) { |
|
439 |
|
|
440 |
DataType dataType = |
|
441 |
((ComboItemDataType) table.getValueAt(row, COLUMN_TYPE)).dataType; |
|
442 |
|
|
443 |
if (dataType.getType() == DataTypes.GEOMETRY) { |
|
444 |
ComboItemGeomType geomType = (ComboItemGeomType)value; |
|
445 |
if (geomType != null) { |
|
446 |
this.setText(geomType.toString()); |
|
447 |
} |
|
448 |
} else { |
|
449 |
this.setText(Messages.getText("not_applicable")); |
|
450 |
} |
|
451 |
|
|
452 |
return this; |
|
453 |
} |
|
454 |
|
|
455 |
} |
|
456 |
|
|
457 |
class ButtonEditor extends DefaultCellEditor { |
|
458 |
/** |
|
459 |
* |
|
460 |
*/ |
|
461 |
private static final long serialVersionUID = -2820892672026188802L; |
|
462 |
|
|
463 |
protected JButton button; |
|
464 |
|
|
465 |
private String label; |
|
466 |
|
|
467 |
private boolean isPushed; |
|
468 |
|
|
469 |
private Object value; |
|
470 |
|
|
471 |
public ButtonEditor(JCheckBox checkBox) { |
|
472 |
super(checkBox); |
|
473 |
button = new JButton(); |
|
474 |
button.setOpaque(true); |
|
475 |
button.addActionListener(new ActionListener() { |
|
476 |
public void actionPerformed(ActionEvent e) { |
|
477 |
fireEditingStopped(); |
|
478 |
} |
|
479 |
}); |
|
480 |
} |
|
481 |
|
|
482 |
public Component getTableCellEditorComponent(JTable table, |
|
483 |
Object value, boolean isSelected, int row, int column) { |
|
484 |
if (isSelected) { |
|
485 |
button.setForeground(table.getSelectionForeground()); |
|
486 |
button.setBackground(table.getSelectionBackground()); |
|
487 |
} else { |
|
488 |
button.setForeground(table.getForeground()); |
|
489 |
button.setBackground(table.getBackground()); |
|
490 |
} |
|
491 |
label = (value == null) ? "" : ((IProjection) value).getFullCode();// .toString(); |
|
492 |
button.setText(label); |
|
493 |
isPushed = true; |
|
494 |
this.value = value; |
|
495 |
return button; |
|
496 |
} |
|
497 |
|
|
498 |
public Object getCellEditorValue() { |
|
499 |
IProjection curProj = (IProjection) this.value; |
|
500 |
if (isPushed) { |
|
501 |
ISelectCrsPanel csSelect = CRSSelectPanel.getUIFactory() |
|
502 |
.getSelectCrsPanel(curProj, true); |
|
503 |
WindowManager wm = ToolsSwingLocator.getWindowManager(); |
|
504 |
wm.showWindow((JPanel) csSelect, "Projection", |
|
505 |
WindowManager.MODE.DIALOG); |
|
506 |
curProj = csSelect.getProjection(); |
|
507 |
} |
|
508 |
isPushed = false; |
|
509 |
return curProj; |
|
510 |
} |
|
511 |
|
|
512 |
public boolean stopCellEditing() { |
|
513 |
isPushed = false; |
|
514 |
return super.stopCellEditing(); |
|
515 |
} |
|
516 |
|
|
517 |
protected void fireEditingStopped() { |
|
518 |
super.fireEditingStopped(); |
|
519 |
} |
|
520 |
} |
|
521 |
|
|
522 |
private class ComboItemGeomType { |
|
523 |
private int type; |
|
524 |
private String name; |
|
525 |
|
|
526 |
public ComboItemGeomType(String name, int type) { |
|
527 |
this.type = type; |
|
528 |
this.name = name; |
|
529 |
} |
|
530 |
|
|
531 |
@Override |
|
532 |
public String toString() { |
|
533 |
return this.name; |
|
534 |
} |
|
535 |
} |
|
536 |
|
|
537 |
private class ComboModelGeomType implements ComboBoxModel { |
|
538 |
|
|
539 |
private List<ComboItemGeomType> geomTypes; |
|
540 |
private ComboItemGeomType selected; |
|
541 |
|
|
542 |
public ComboModelGeomType(List<ComboItemGeomType> geomTypes) { |
|
543 |
this.geomTypes = geomTypes; |
|
544 |
} |
|
545 |
|
|
546 |
public void addListDataListener(ListDataListener arg0) { |
|
547 |
// DO NOTHING |
|
548 |
} |
|
549 |
|
|
550 |
public Object getElementAt(int arg0) { |
|
551 |
return this.geomTypes.get(arg0); |
|
552 |
} |
|
553 |
|
|
554 |
public int getSize() { |
|
555 |
return this.geomTypes.size(); |
|
556 |
} |
|
557 |
|
|
558 |
public void removeListDataListener(ListDataListener arg0) { |
|
559 |
// DO NOTHING |
|
560 |
} |
|
561 |
|
|
562 |
public Object getSelectedItem() { |
|
563 |
return this.selected; |
|
564 |
} |
|
565 |
|
|
566 |
public void setSelectedItem(Object anItem) { |
|
567 |
this.selected = (ComboItemGeomType) anItem; |
|
568 |
} |
|
569 |
|
|
570 |
} |
|
571 |
|
Also available in: Unified diff