Revision 39267

View differences:

tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/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>
0 152

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/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.selectiontools.app</artifactId>
7
	<packaging>pom</packaging>
8
	<version>1.0.0-SNAPSHOT</version>
9
	<name>org.gvsig.selectiontools.app</name>
10
	<description>Advanced selection tools:
11
- select all
12
- by buffer
13
- by cicle
14
- by polilyne
15
</description>
16
    <parent>
17
        <groupId>org.gvsig</groupId>
18
        <artifactId>org.gvsig.maven.base.extension.pom</artifactId>
19
        <version>1.0.8-SNAPSHOT</version>
20
    </parent>
21
    <scm>
22
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/extensions/org.gvsig.selectiontools.app</connection>
23
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/extensions/org.gvsig.selectiontools.app</developerConnection>
24
        <url>https://devel.gvsig.org/redmine/projects/gvsig-desktop/repository/show/branches/v2_0_0_prep/extensions/org.gvsig.selectiontools.app</url>
25
    </scm>
26
	<repositories>
27
		<repository>
28
			<id>gvsig-public-http-repository</id>
29
			<name>gvSIG maven public HTTP repository</name>
30
            <url>http://devel.gvsig.org/m2repo/j2se</url>
31
			<releases>
32
				<enabled>true</enabled>
33
				<updatePolicy>daily</updatePolicy>
34
				<checksumPolicy>warn</checksumPolicy>
35
			</releases>
36
			<snapshots>
37
				<enabled>true</enabled>
38
				<updatePolicy>daily</updatePolicy>
39
				<checksumPolicy>warn</checksumPolicy>
40
			</snapshots>
41
		</repository>
42
	</repositories>
43
    <dependencyManagement>
44
        <dependencies>          
45
            <dependency>
46
                <groupId>org.gvsig</groupId>
47
                <artifactId>org.gvsig.core.maven.dependencies</artifactId>
48
                <version>2.0.1-SNAPSHOT</version>
49
                <type>pom</type>
50
                <scope>import</scope>
51
            </dependency>
52
        </dependencies>
53
    </dependencyManagement>
54
	<modules>
55
		<module>org.gvsig.selectiontools.app.extension</module>
56
	</modules>
57
	<properties>
58
		<package.info.state>testing</package.info.state>
59
		<!-- alpha-devel -->
60
	</properties>
61

  
62
</project>
0 63

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/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

  
0 19

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/distribution/distribution.xml
1
<assembly>
2
</assembly>
0 3

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Tue Nov 13 15:35:14 CET 2012
3
buildNumber=2077
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/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.
0 9

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/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.selectiontools">
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>
0 38

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/resources/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<depends plugin-name="org.gvsig.app" />
4
	<resourceBundle name="text"/>
5
	<libraries library-dir="lib"/>
6
	<extensions>
7

  
8
<!--  		<extension class-name="org.gvsig.selectiontools.app.extension.AboutSelectionToolsExtension" -->
9
<!--             description="Extension Selection Tools of the Consejer?a de Medio Ambiente of the Junta de Castilla y Le?n Project." -->
10
<!-- 			active="true" -->
11
<!-- 			priority="1"> -->
12
<!-- 		</extension> -->
13
		
14
		<extension class-name="org.gvsig.selectiontools.app.extension.SelectAllExtension"
15
			description="Extension that allows select all geometries of the selected vectorial layers."
16
			active="true"
17
			priority="30">
18
			<menu text="Selection/SelectAll"
19
				action-command="SELALL"
20
				tooltip="SelectAll"
21
				icon="selection-select-all"
22
				position="300400000"/>
23
			<tool-bar name="Tools_Select" position="6">
24
				<selectable-tool icon="selection-select-all" action-command="SELALL" tooltip="SelectAll" position="7"/>
25
			</tool-bar>
26
		</extension>		
27
		 <extension class-name="org.gvsig.selectiontools.app.extension.SelectByCircleExtension"
28
			description="Extension that allows select all geometries of the selected vectorial layers that are contained or intersect with a circle defined by the user."
29
			active="true"
30
			priority="30">
31
			<menu text="Selection/Select_by_circle"
32
				action-command="SELCIRCLE"
33
				tooltip="Select_by_circle"
34
				icon="selection-select-by-circle"
35
				position="301000000"/>
36
			<tool-bar name="Tools_Select" position="6">
37
				<selectable-tool icon="selection-select-by-circle" action-command="SELCIRCLE" tooltip="Select_by_circle" position="6"/>
38
			</tool-bar>
39
		</extension>		
40
		<extension class-name="org.gvsig.selectiontools.app.extension.SelectByPolylineExtension"
41
			description="Extension that allows select all geometries of the selected vectorial layers that intersect with a polyline defined by the user."
42
			active="false"
43
			priority="30">
44
			<menu text="Selection/Select_by_polyline"
45
				action-command="SELPOLYLINE"
46
				tooltip="Select_by_polyline"
47
				icon="selection-select-by-polyline"
48
				position="301300000"/>
49
			<tool-bar name="Tools_Select" position="6">
50
				<selectable-tool icon="selection-select-by-polyline" action-command="SELPOLYLINE" tooltip="Select_by_polyline" position="5"/>
51
			</tool-bar>
52
		</extension>		
53

  
54
 		<extension class-name="org.gvsig.selectiontools.app.extension.SelectByBufferExtension"
55
			description="Extension that allows select all geometries of the selected vectorial layers that intersect with a buffer around their previously selected geometries."
56
			active="true"
57
			priority="30">
58
			<menu text="Selection/Select_by_buffer"
59
				action-command="SELBUFFER"
60
				tooltip="Select_by_buffer"
61
				icon="selection-select-by-buffer"
62
				position="300900000"/>
63
			<tool-bar name="Tools_Select" position="6">
64
				<action-tool icon="selection-select-by-buffer" action-command="SELBUFFER" tooltip="Select_by_buffer" position="7"/>
65
			</tool-bar>
66
		</extension>
67
				
68
	</extensions>
69
</plugin-config>
0 70

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/SelectByCircleExtension.java
1
package org.gvsig.selectiontools.app.extension;
2

  
3
import org.gvsig.andami.IconThemeHelper;
4
import org.gvsig.andami.PluginServices;
5
import org.gvsig.andami.plugins.Extension;
6
import org.gvsig.andami.ui.mdiManager.IWindow;
7
import org.gvsig.app.project.documents.view.ViewDocument;
8
import org.gvsig.app.project.documents.view.gui.IView;
9
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener;
10
import org.gvsig.fmap.mapcontext.MapContext;
11
import org.gvsig.fmap.mapcontext.layers.FLayer;
12
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
13
import org.gvsig.fmap.mapcontrol.MapControl;
14
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
15
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior;
16
import org.gvsig.selectiontools.app.extension.tools.CircleSelectListener;
17
import org.gvsig.selectiontools.app.extension.tools.behavior.CircleSelectionBehavior;
18

  
19
/* gvSIG. Geographic Information System of the Valencian Government
20
 *
21
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
22
 * of the Valencian Government (CIT)
23
 * 
24
 * This program is free software; you can redistribute it and/or
25
 * modify it under the terms of the GNU General Public License
26
 * as published by the Free Software Foundation; either version 2
27
 * of the License, or (at your option) any later version.
28
 * 
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 * GNU General Public License for more details.
33
 *  
34
 * You should have received a copy of the GNU General Public License
35
 * along with this program; if not, write to the Free Software
36
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
37
 * MA  02110-1301, USA.
38
 * 
39
 */
40

  
41
/**
42
 * <p>
43
 * Extension to add support for selecting the geometries of the active vector
44
 * layers that intersect with a circle defined by the user.
45
 * </p>
46
 * 
47
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
48
 */
49
public class SelectByCircleExtension extends Extension {
50

  
51
    public static final String CIRCLE_SELECTION_TOOL_NAME = "circleSelection";
52

  
53
    /*
54
     * @see com.iver.andami.plugins.IExtension#initialize()
55
     */
56
    public void initialize() {
57
    	IconThemeHelper.registerIcon("action", "selection-select-by-circle", this);
58
    	IconThemeHelper.registerIcon("cursor", "cursor-select-by-circle", this);
59
    }
60

  
61
    /*
62
     * (non-Javadoc)
63
     * 
64
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
65
     */
66
    public void execute(String actionCommand) {
67
        if (actionCommand.equals("SELCIRCLE")) {
68
            IWindow window = PluginServices.getMDIManager().getActiveWindow();
69
            if (window instanceof IView) {
70
                IView view = (IView) window;
71
                // Selection by circle
72
                MapControl mc = view.getMapControl();
73

  
74
                // If current's view MapControl doesn't have the
75
                // "CircleSelection" tool, adds it
76
                if (!mc.getNamesMapTools()
77
                    .containsKey(CIRCLE_SELECTION_TOOL_NAME)) {
78
                    CircleSelectListener circleSelListener =
79
                        new CircleSelectListener(mc);
80
                    mc.addBehavior(CIRCLE_SELECTION_TOOL_NAME, new Behavior[] {
81
                        new CircleSelectionBehavior(circleSelListener),
82
                        new MouseMovementBehavior(new StatusBarListener(mc)) });
83
                }
84

  
85
                mc.setTool(CIRCLE_SELECTION_TOOL_NAME);
86
            }
87
        }
88
    }
89

  
90
    /*
91
     * @see com.iver.andami.plugins.IExtension#isVisible()
92
     */
93
    public boolean isVisible() {
94
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
95

  
96
        if (f == null) {
97
            return false;
98
        }
99

  
100
        if (f instanceof IView) {
101
            IView vista = (IView) f;
102
            ViewDocument model = vista.getViewDocument();
103
            MapContext mapa = model.getMapContext();
104

  
105
            return mapa.getLayers().getLayersCount() > 0;
106
        }
107

  
108
        return false;
109
    }
110

  
111
    /*
112
     * @see com.iver.andami.plugins.IExtension#isEnabled()
113
     */
114
    public boolean isEnabled() {
115
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
116

  
117
        if (f == null) {
118
            return false;
119
        }
120

  
121
        if (f instanceof IView) {
122
            IView vista = (IView) f;
123
            ViewDocument model = vista.getViewDocument();
124
            MapContext mapa = model.getMapContext();
125

  
126
            FLayer layers[] = mapa.getLayers().getActives();
127
            FLayer layer;
128

  
129
            for (int i = 0; i < layers.length; i++) {
130
                layer = layers[i];
131

  
132
                if ((layer instanceof FLyrVect) && (layer.isAvailable())
133
                    && (layer.isActive()))
134
                    return true;
135
            }
136
        }
137

  
138
        return false;
139
    }
140
}
0 141

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/CircleSelectListener.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
package org.gvsig.selectiontools.app.extension.tools;
24

  
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.fmap.mapcontrol.MapControl;
27
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
28
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
29

  
30
/**
31
 * 
32
 * @version 06/04/2009
33
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
34
 */
35
public class CircleSelectListener extends CircleSelectionListener {
36

  
37
    public CircleSelectListener(MapControl mc) {
38
        super(mc);
39
    }
40

  
41
    public void circle(MeasureEvent event) throws BehaviorException {
42
        super.circle(event);
43
        PluginServices.getMainFrame().enableControls();
44
    }
45
}
0 46

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/PolyLineSelectionListener.java
1
package org.gvsig.selectiontools.app.extension.tools;
2

  
3
/* gvSIG. Geographic Information System of the Valencian Government
4
 *
5
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
6
 * of the Valencian Government (CIT)
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 2
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
 */
24

  
25
import java.awt.Cursor;
26
import java.awt.Image;
27
import java.awt.Point;
28
import java.awt.Toolkit;
29

  
30
import javax.swing.ImageIcon;
31

  
32
import org.gvsig.andami.IconThemeHelper;
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.messages.NotificationManager;
35
import org.gvsig.fmap.dal.feature.FeatureSelection;
36
import org.gvsig.fmap.dal.feature.FeatureSet;
37
import org.gvsig.fmap.geom.Geometry;
38
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
39
import org.gvsig.fmap.geom.Geometry.TYPES;
40
import org.gvsig.fmap.geom.GeometryLocator;
41
import org.gvsig.fmap.geom.GeometryManager;
42
import org.gvsig.fmap.geom.exception.CreateGeometryException;
43
import org.gvsig.fmap.geom.primitive.GeneralPathX;
44
import org.gvsig.fmap.geom.primitive.Surface;
45
import org.gvsig.fmap.mapcontext.layers.FLayer;
46
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
47
import org.gvsig.fmap.mapcontrol.MapControl;
48
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
49
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
50
import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener;
51

  
52
/**
53
 * <p>
54
 * Listener that selects all features of the active and vector layers which
55
 * intersect with the defined polyline in the associated {@link MapControl
56
 * MapControl} object.
57
 * </p>
58
 * 
59
 * <p>
60
 * The selection will be produced after user finishes the creation of the
61
 * polyline.
62
 * </p>
63
 * 
64
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
65
 */
66
public class PolyLineSelectionListener implements PolylineListener {
67

  
68
    /**
69
     * The image to display when the cursor is active.
70
     */
71
//    private final Image img = PluginServices.getIconTheme().get("cursor-select-by-polygon").getImage();
72

  
73
    /**
74
     * The cursor used to work with this tool listener.
75
     * 
76
     * @see #getCursor()
77
     */
78
    private Cursor cur = null;
79

  
80
    /**
81
     * Reference to the <code>MapControl</code> object that uses.
82
     */
83
    private MapControl mapCtrl;
84

  
85
    /**
86
     * <p>
87
     * Creates a new <code>PolygonSelectionListener</code> object.
88
     * </p>
89
     * 
90
     * @param mc
91
     *            the <code>MapControl</code> where is drawn the polyline
92
     */
93
    public PolyLineSelectionListener(MapControl mc) {
94
        this.mapCtrl = mc;
95
    }
96

  
97
    /*
98
     * (non-Javadoc)
99
     * 
100
     * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
101
     */
102
    public Cursor getCursor() {
103
    	if( cur == null ) {
104
    		cur = Toolkit.getDefaultToolkit().createCustomCursor(this.getImageCursor(),
105
    		        new Point(16, 16),
106
    		        "");
107
    	}
108
        return cur;
109
    }
110

  
111
    /*
112
     * (non-Javadoc)
113
     * 
114
     * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
115
     */
116
    public boolean cancelDrawing() {
117
        return false;
118
    }
119

  
120
    /*
121
     * (non-Javadoc)
122
     * 
123
     * @see
124
     * com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#points(com.iver
125
     * .cit.gvsig.fmap.tools.Events.MeasureEvent)
126
     */
127
    public void points(MeasureEvent event) throws BehaviorException {
128
    }
129

  
130
    /*
131
     * (non-Javadoc)
132
     * 
133
     * @see
134
     * com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#pointFixed(com
135
     * .iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
136
     */
137
    public void pointFixed(MeasureEvent event) throws BehaviorException {
138
    }
139

  
140
    /*
141
     * (non-Javadoc)
142
     * 
143
     * @see
144
     * com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#polylineFinished
145
     * (com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
146
     */
147
    public void polylineFinished(MeasureEvent event) throws BehaviorException {
148
        try {
149
            GeneralPathX gp = event.getGP();
150
            GeometryManager manager = GeometryLocator.getGeometryManager();
151
            Geometry geom = null;
152
            Surface surface = null;
153
            try {
154
                surface =
155
                    (Surface) manager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
156
                surface.setGeneralPath(gp);
157
                geom = surface;
158
            } catch (CreateGeometryException e1) {
159
                NotificationManager.showMessageError(PluginServices.getText(null,
160
                    "Failed_creating_geometry"),
161
                    e1);
162
            }
163
            if (geom == null)
164
                return;
165

  
166
            FLayer[] actives = mapCtrl.getMapContext().getLayers().getActives();
167

  
168
            for (int i = 0; i < actives.length; i++) {
169
                if (actives[i] instanceof FLyrVect) {
170
                    FLyrVect lyrVect = (FLyrVect) actives[i];
171
                    FeatureSet newSelection = null;
172

  
173
                    newSelection =
174
                        lyrVect.queryByGeometry(geom, lyrVect.getFeatureStore()
175
                            .getDefaultFeatureType());
176

  
177
                    if (event.getEvent().isControlDown()) {
178
                        ((FeatureSelection) lyrVect.getDataStore()
179
                            .getSelection()).select(newSelection);
180
                    } else {
181
                        lyrVect.getFeatureStore().setSelection(newSelection);
182
                    }
183
                }
184
            }
185
        } catch (com.vividsolutions.jts.geom.TopologyException topEx) {
186
            NotificationManager.showMessageError(PluginServices.getText(null,
187
                "Failed_selecting_geometries_by_polyline_topology_exception_explanation"),
188
                topEx);
189
        } catch (Exception ex) {
190
            NotificationManager.showMessageError(PluginServices.getText(null,
191
                "Failed_selecting_geometries"), ex);
192
        }
193
    }
194

  
195
    public Image getImageCursor() {
196
        return IconThemeHelper.getImage("cursor-select-by-polyline");
197
    }
198
}
0 199

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/buffer/gui/BufferConfigurationPanel.java
1
package org.gvsig.selectiontools.app.extension.tools.buffer.gui;
2

  
3
/* gvSIG. Geographic Information System of the Valencian Government
4
 *
5
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
6
 * of the Valencian Government (CIT)
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 2
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
 */
24

  
25
import java.awt.Dimension;
26
import java.awt.FlowLayout;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.awt.event.ComponentAdapter;
30
import java.awt.event.ComponentEvent;
31
import java.text.DecimalFormat;
32
import java.util.ArrayList;
33
import java.util.Arrays;
34
import java.util.Iterator;
35

  
36
import javax.swing.BorderFactory;
37
import javax.swing.JCheckBox;
38
import javax.swing.JLabel;
39
import javax.swing.JPanel;
40
import javax.swing.text.NumberFormatter;
41

  
42
import org.gvsig.andami.PluginServices;
43
import org.gvsig.andami.messages.NotificationManager;
44
import org.gvsig.andami.ui.mdiManager.IWindow;
45
import org.gvsig.andami.ui.mdiManager.WindowInfo;
46
import org.gvsig.app.project.documents.view.gui.IView;
47
import org.gvsig.fmap.dal.exception.DataException;
48
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
49
import org.gvsig.fmap.mapcontrol.MapControl;
50
import org.gvsig.gui.beans.AcceptCancelPanel;
51
import org.gvsig.gui.beans.incrementabletask.IncrementableTask;
52
import org.gvsig.gui.beans.progresspanel.ProgressPanel;
53
import org.gvsig.gui.beans.specificcaretposition.JFormattedTextFieldSCP;
54
import org.gvsig.selectiontools.app.extension.tools.buffer.process.BufferSelectionProcess;
55
import org.gvsig.utils.swing.JComboBox;
56

  
57
/**
58
 * 
59
 * 
60
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
61
 */
62
public class BufferConfigurationPanel extends JPanel implements IWindow {
63

  
64
    private WindowInfo viewInfo = null;
65
    private final short Window_Width = 354;
66
    private final short Window_Height = 315; // 35;
67
    private JFormattedTextFieldSCP distanceTextField = null;
68
    private JComboBox distanceUnitsCombo = null;
69
    private JComboBox polygonSidesCombo = null;
70
    private JComboBox lineSidesCombo = null;
71
    private JComboBox pointSidesCombo = null;
72
    private JComboBox multiPointSidesCombo = null;
73
    private JLabel distanceUnitsLabel = null;
74
    private JLabel polygonSideLabel = null;
75
    private JLabel lineSideLabel = null;
76
    private JLabel pointSideLabel = null;
77
    private JLabel multiPointSideLabel = null;
78
    private JPanel polygonSidePanel = null;
79
    private JPanel lineSidePanel = null;
80
    private JPanel pointSidePanel = null;
81
    private JPanel multiPointSidePanel = null;
82
    private JLabel widthLabel = null;
83
    private JPanel widthPanel = null;
84
    // private JPanel distanceUnits = null;
85
    private JPanel sidePanel = null;
86
    private JPanel optionsPanel = null;
87
    private AdaptedAcceptCancelPanel acceptCancelPanel = null;
88
    private FLyrVect[] layers;
89
    private MapControl mapControl;
90
    private IView view;
91
    private JCheckBox multiLayerSelectionCBox;
92
    private SideInfo outside, inside, out_in_side;
93

  
94
    /**
95
     * <p>
96
     * Creates a new form where user can define the option of the buffer.
97
     * </p>
98
     */
99
    public BufferConfigurationPanel(FLyrVect[] array, IView view) {
100
        super();
101

  
102
        layers = array;
103
        this.view = view;
104
        mapControl = view.getMapControl();
105

  
106
        initialize();
107
    }
108

  
109
    /**
110
     * <p>
111
     * Initializes this component.
112
     * </p>
113
     */
114
    private void initialize() {
115
        outside =
116
            new SideInfo(BufferSelectionProcess.BUFFER_OUTSIDE_POLY,
117
                PluginServices.getText(null, "Outside"));
118
        inside =
119
            new SideInfo(BufferSelectionProcess.BUFFER_INSIDE_POLY,
120
                PluginServices.getText(null, "Inside"));
121
        out_in_side =
122
            new SideInfo(BufferSelectionProcess.BUFFER_INSIDE_OUTSIDE_POLY,
123
                PluginServices.getText(null, "Both"));
124

  
125
        setLayout(new FlowLayout());
126
        add(getWidthPanel());
127
        add(getSidePanel());
128
        add(getOptionsPanel());
129
        add(getAdaptedAcceptCancelPanel());
130
    }
131

  
132
    private JPanel getOptionsPanel() {
133
        if (optionsPanel == null) {
134
            optionsPanel = new JPanel();
135
            optionsPanel.setLayout(new FlowLayout());
136
            optionsPanel.setPreferredSize(new Dimension(344, 80)); // 106));
137
            optionsPanel.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(optionsPanel,
138
                "Options")));
139
            optionsPanel.add(getMultiLayerSelectionCBox());
140
        }
141

  
142
        return optionsPanel;
143
    }
144

  
145
    private JCheckBox getMultiLayerSelectionCBox() {
146
        if (multiLayerSelectionCBox == null) {
147
            multiLayerSelectionCBox = new JCheckBox();
148
            multiLayerSelectionCBox.setPreferredSize(new Dimension(330, 22));
149
            multiLayerSelectionCBox.setText(PluginServices.getText(multiLayerSelectionCBox,
150
                "multiLayer_selection"));
151
            multiLayerSelectionCBox.setSelected(true);
152
            multiLayerSelectionCBox.setToolTipText(PluginServices.getText(null,
153
                "multiLayerSelection_checkbox_TOOLTIP_HTML_explanation"));
154
        }
155

  
156
        return multiLayerSelectionCBox;
157
    }
158

  
159
    private JPanel getWidthPanel() {
160
        if (widthPanel == null) {
161
            widthPanel = new JPanel();
162
            widthPanel.setPreferredSize(new Dimension(344, 55));
163
            widthPanel.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(widthPanel,
164
                "Width")));
165
            widthPanel.setLayout(new FlowLayout());
166
            widthPanel.add(getWidthLabel());
167
            widthPanel.add(getWidthTextField());
168
            widthPanel.add(getDistanceUnitsLabel());
169
            widthPanel.add(getDistanceUnitsCombo());
170
        }
171

  
172
        return widthPanel;
173
    }
174

  
175
    private JLabel getWidthLabel() {
176
        if (widthLabel == null) {
177
            widthLabel = new JLabel();
178
            widthLabel.setPreferredSize(new Dimension(68, 22));
179
            widthLabel.setText(PluginServices.getText(widthLabel, "Width"));
180
            widthLabel.setToolTipText(PluginServices.getText(null,
181
                "bufferWidth_TOOLTIP_HTML_explanation"));
182
        }
183

  
184
        return widthLabel;
185
    }
186

  
187
    private JFormattedTextFieldSCP getWidthTextField() {
188
        if (distanceTextField == null) {
189
            DecimalFormat decimalFormat = new DecimalFormat();
190
            decimalFormat.setDecimalSeparatorAlwaysShown(true);
191
            decimalFormat.setMaximumIntegerDigits(12);
192
            decimalFormat.setMinimumIntegerDigits(1);
193
            decimalFormat.setMinimumFractionDigits(2);
194
            decimalFormat.setMaximumFractionDigits(4);
195

  
196
            NumberFormatter numberFormatter = new NumberFormatter();
197
            numberFormatter.setAllowsInvalid(false);
198
            numberFormatter.setOverwriteMode(false);
199
            numberFormatter.setCommitsOnValidEdit(true);
200
            numberFormatter.setMinimum(new Double(0));
201
            numberFormatter.setFormat(decimalFormat);
202

  
203
            // numberFormatter.setFormat(new
204
            // DecimalFormat("([+]|[-])?[0-9]+([.][0-9]+)?"));
205

  
206
            distanceTextField = new JFormattedTextFieldSCP(numberFormatter);
207
            distanceTextField.setPreferredSize(new Dimension(85, 22));
208
            distanceTextField.setValue(new Double(100.00));
209
            distanceTextField.setToolTipText(PluginServices.getText(null,
210
                "bufferWidth_TOOLTIP_HTML_explanation"));
211
        }
212

  
213
        return distanceTextField;
214
    }
215

  
216
    private JLabel getDistanceUnitsLabel() {
217
        if (distanceUnitsLabel == null) {
218
            distanceUnitsLabel =
219
                new JLabel(PluginServices.getText(distanceUnitsLabel, "Unit"));
220
            distanceUnitsLabel.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
221
            distanceUnitsLabel.setPreferredSize(new Dimension(68, 22));
222
            distanceUnitsLabel.setToolTipText(PluginServices.getText(null,
223
                "distanceUnitsLabel_TOOLTIP_HTML_explanation"));
224
        }
225

  
226
        return distanceUnitsLabel;
227
    }
228

  
229
    private JComboBox getDistanceUnitsCombo() {
230
        if (distanceUnitsCombo == null) {
231
            distanceUnitsCombo = new JComboBox();
232
            distanceUnitsCombo.setPreferredSize(new Dimension(85, 22));
233
            distanceUnitsCombo.addItem("km");
234
            distanceUnitsCombo.addItem("m");
235
            distanceUnitsCombo.addItem("cm");
236
            distanceUnitsCombo.addItem("mm");
237
            distanceUnitsCombo.addItem("mi");
238
            distanceUnitsCombo.addItem("Ya");
239
            distanceUnitsCombo.addItem("ft");
240
            distanceUnitsCombo.addItem("in");
241
            distanceUnitsCombo.addItem("?");
242
            distanceUnitsCombo.setSelectedIndex(1); // By default in meters
243
            distanceUnitsCombo.setToolTipText(PluginServices.getText(null,
244
                "distanceUnitsLabel_TOOLTIP_HTML_explanation"));
245
        }
246

  
247
        return distanceUnitsCombo;
248
    }
249

  
250
    private JPanel getSidePanel() {
251
        if (sidePanel == null) {
252
            sidePanel = new JPanel();
253
            sidePanel.setLayout(new FlowLayout());
254
            sidePanel.setPreferredSize(new Dimension(344, 166));
255
            sidePanel.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(sidePanel,
256
                "Side")));
257
            sidePanel.setToolTipText(PluginServices.getText(null,
258
                "sideLabel_TOOLTIP_HTML_explanation"));
259
            sidePanel.add(getPolygonSidePanel());
260
            sidePanel.add(getLineSidePanel());
261
            sidePanel.add(getPointSidePanel());
262
            sidePanel.add(getMultiPointSidePanel());
263
        }
264

  
265
        return sidePanel;
266
    }
267

  
268
    private JPanel getPolygonSidePanel() {
269
        if (polygonSidePanel == null) {
270
            polygonSidePanel = new JPanel();
271
            polygonSidePanel.setPreferredSize(new Dimension(336, 28));
272
            polygonSidePanel.add(getPolygonSideLabel());
273
            polygonSidePanel.add(getPolygonSidesCombo());
274
        }
275

  
276
        return polygonSidePanel;
277
    }
278

  
279
    private JLabel getPolygonSideLabel() {
280
        if (polygonSideLabel == null) {
281
            polygonSideLabel =
282
                new JLabel(PluginServices.getText(polygonSideLabel, "Polygon"));
283
            polygonSideLabel.setPreferredSize(new Dimension(90, 22));
284
            polygonSideLabel.setToolTipText(PluginServices.getText(null,
285
                "polygonSideLabel_TOOLTIP_HTML_explanation"));
286
        }
287

  
288
        return polygonSideLabel;
289
    }
290

  
291
    private JComboBox getPolygonSidesCombo() {
292
        if (polygonSidesCombo == null) {
293
            polygonSidesCombo = new JComboBox();
294
            polygonSidesCombo.setPreferredSize(new Dimension(230, 22));
295
            polygonSidesCombo.addItem(outside);
296
            polygonSidesCombo.addItem(inside);
297
            // polygonSidesCombo.addItem(out_in_side); // Disabled because fails
298
            // quite often
299
            polygonSidesCombo.setToolTipText(PluginServices.getText(null,
300
                "polygonSideLabel_TOOLTIP_HTML_explanation"));
301
        }
302

  
303
        return polygonSidesCombo;
304
    }
305

  
306
    private JPanel getLineSidePanel() {
307
        if (lineSidePanel == null) {
308
            lineSidePanel = new JPanel();
309
            lineSidePanel.setPreferredSize(new Dimension(336, 28));
310
            lineSidePanel.add(getLineSideLabel());
311
            lineSidePanel.add(getLineSidesCombo());
312
        }
313

  
314
        return lineSidePanel;
315
    }
316

  
317
    private JLabel getLineSideLabel() {
318
        if (lineSideLabel == null) {
319
            lineSideLabel =
320
                new JLabel(PluginServices.getText(lineSideLabel, "Line"));
321
            lineSideLabel.setPreferredSize(new Dimension(90, 22));
322
            lineSideLabel.setToolTipText(PluginServices.getText(null,
323
                "lineSideLabel_TOOLTIP_HTML_explanation"));
324
        }
325

  
326
        return lineSideLabel;
327
    }
328

  
329
    private JComboBox getLineSidesCombo() {
330
        if (lineSidesCombo == null) {
331
            lineSidesCombo = new JComboBox();
332
            lineSidesCombo.setPreferredSize(new Dimension(230, 22));
333
            lineSidesCombo.addItem(outside);
334
            lineSidesCombo.setToolTipText(PluginServices.getText(null,
335
                "lineSideLabel_TOOLTIP_HTML_explanation"));
336
        }
337

  
338
        return lineSidesCombo;
339
    }
340

  
341
    private JPanel getPointSidePanel() {
342
        if (pointSidePanel == null) {
343
            pointSidePanel = new JPanel();
344
            pointSidePanel.setPreferredSize(new Dimension(336, 28));
345
            pointSidePanel.add(getPointSideLabel());
346
            pointSidePanel.add(getPointSidesCombo());
347
        }
348

  
349
        return pointSidePanel;
350
    }
351

  
352
    private JLabel getPointSideLabel() {
353
        if (pointSideLabel == null) {
354
            pointSideLabel =
355
                new JLabel(PluginServices.getText(pointSideLabel, "Point"));
356
            pointSideLabel.setPreferredSize(new Dimension(90, 22));
357
            pointSideLabel.setToolTipText(PluginServices.getText(null,
358
                "pointSideLabel_TOOLTIP_HTML_explanation"));
359
        }
360

  
361
        return pointSideLabel;
362
    }
363

  
364
    private JComboBox getPointSidesCombo() {
365
        if (pointSidesCombo == null) {
366
            pointSidesCombo = new JComboBox();
367
            pointSidesCombo.setPreferredSize(new Dimension(230, 22));
368
            pointSidesCombo.addItem(outside);
369
            pointSidesCombo.setToolTipText(PluginServices.getText(null,
370
                "pointSideLabel_TOOLTIP_HTML_explanation"));
371
        }
372

  
373
        return pointSidesCombo;
374
    }
375

  
376
    private JPanel getMultiPointSidePanel() {
377
        if (multiPointSidePanel == null) {
378
            multiPointSidePanel = new JPanel();
379
            multiPointSidePanel.setPreferredSize(new Dimension(336, 28));
380
            multiPointSidePanel.add(getMultiPointSideLabel());
381
            multiPointSidePanel.add(getMultiPointSidesCombo());
382
        }
383

  
384
        return multiPointSidePanel;
385
    }
386

  
387
    private JLabel getMultiPointSideLabel() {
388
        if (multiPointSideLabel == null) {
389
            multiPointSideLabel =
390
                new JLabel(PluginServices.getText(multiPointSideLabel,
391
                    "MultiPoint"));
392
            multiPointSideLabel.setPreferredSize(new Dimension(90, 22));
393
            multiPointSideLabel.setToolTipText(PluginServices.getText(null,
394
                "multiPointSideLabel_TOOLTIP_HTML_explanation"));
395
        }
396

  
397
        return multiPointSideLabel;
398
    }
399

  
400
    private JComboBox getMultiPointSidesCombo() {
401
        if (multiPointSidesCombo == null) {
402
            multiPointSidesCombo = new JComboBox();
403
            multiPointSidesCombo.setPreferredSize(new Dimension(230, 22));
404
            multiPointSidesCombo.addItem(outside);
405
            multiPointSidesCombo.setToolTipText(PluginServices.getText(null,
406
                "multiPointSideLabel_TOOLTIP_HTML_explanation"));
407
        }
408

  
409
        return multiPointSidesCombo;
410
    }
411

  
412
    /**
413
     * <p>
414
     * This method initializes acceptCancelPanel.
415
     * </p>
416
     * 
417
     * @return an adapted {@link AcceptCancelPanel AcceptCancelPanel}
418
     */
419
    private AdaptedAcceptCancelPanel getAdaptedAcceptCancelPanel() {
420
        if (acceptCancelPanel == null) {
421
            acceptCancelPanel = new AdaptedAcceptCancelPanel();
422
        }
423

  
424
        return acceptCancelPanel;
425
    }
426

  
427
    /*
428
     * (non-Javadoc)
429
     * 
430
     * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
431
     */
432
    public WindowInfo getWindowInfo() {
433
        if (viewInfo == null) {
434
            viewInfo = new WindowInfo(WindowInfo.MODALDIALOG);
435
            viewInfo.setTitle(PluginServices.getText(this, "configuration"));
436
            viewInfo.setWidth(Window_Width);
437
            viewInfo.setHeight(Window_Height);
438
        }
439

  
440
        return viewInfo;
441
    }
442

  
443
    /**
444
     * <p>
445
     * Adapts {@link AcceptCancelPanel AcceptCancelPanel} to be used as a
446
     * component of the <code>BufferConfigurationPanel</code> panel.
447
     * </p>
448
     * 
449
     * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
450
     */
451
    private class AdaptedAcceptCancelPanel extends AcceptCancelPanel {
452

  
453
        public AdaptedAcceptCancelPanel() {
454
            super();
455

  
456
            addOkButtonActionListener(getOKAction());
457
            addCancelButtonActionListener(getCancelAction());
458
            setPreferredSize(new Dimension(350, 30));
459
        }
460

  
461
        /**
462
         * <p>
463
         * Create the action that will be executed when user pressed the
464
         * <i>ok</i> button.
465
         * </p>
466
         * 
467
         * @return action that will be executed when user pressed the
468
         *         <i>cancel</i>
469
         *         button
470
         */
471
        private ActionListener getOKAction() {
472
            // OK button action
473
            return new ActionListener() {
474

  
475
                /*
476
                 * @see
477
                 * java.awt.event.ActionListener#actionPerformed(java.awt.event
478
                 * .ActionEvent)
479
                 */
480
                public void actionPerformed(ActionEvent e) {
481
                    /* 1- Closes this window */
482
                    closeThis();
483

  
484
                    /* 2- Validates the buffer width */
485
                    double width;
486

  
487
                    try {
488
                        width =
489
                            Double.parseDouble(getWidthTextField().getText()
490
                                .replaceAll("(\\.)?", "")
491
                                .replace(",", ".")); // Formats the decimal
492
                                                     // number to be parsed
493
                    } catch (Exception ex) {
494
                        NotificationManager.showMessageError(PluginServices.getText(null,
495
                            "Invalid_width"),
496
                            ex);
497
                        return;
498
                    }
499

  
500
                    /* 3- Creates the process */
501
                    // checks layers to proccess if multilayer is not selected
502
                    ArrayList<FLyrVect> tmpLayersToProccess =
503
                        new ArrayList<FLyrVect>(layers.length);
504
                    tmpLayersToProccess.addAll(Arrays.asList(layers));
505
                    if (!multiLayerSelectionCBox.isSelected()) {
506
                        Iterator<FLyrVect> iter =
507
                            tmpLayersToProccess.iterator();
508
                        FLyrVect curLayer;
509
                        while (iter.hasNext()) {
510
                            curLayer = (FLyrVect) iter.next();
511
                            try {
512
                                if (curLayer.getFeatureStore()
513
                                    .getFeatureSelection()
514
                                    .isEmpty()) {
515
                                    iter.remove();
516
                                }
517
                            } catch (DataException e1) {
518
                                NotificationManager.showMessageError(PluginServices.getText(null,
519
                                    "Failed_selecting_layer"),
520
                                    e1);
521
                                return;
522

  
523
                            }
524
                        }
525
                    }
526
                    FLyrVect[] layersToProcess =
527
                        (FLyrVect[]) tmpLayersToProccess.toArray(new FLyrVect[tmpLayersToProccess.size()]);
528

  
529
                    BufferSelectionProcess iprocess =
530
                        new BufferSelectionProcess(PluginServices.getText(this,
531
                            "Selection_by_buffer_process"),
532
                            PluginServices.getText(this,
533
                                "Ongoing_process_please_wait"),
534
                            mapControl,
535
                            ((SideInfo) getPolygonSidesCombo().getSelectedItem()).getSide(),
536
                            ((SideInfo) getLineSidesCombo().getSelectedItem()).getSide(),
537
                            ((SideInfo) getPointSidesCombo().getSelectedItem()).getSide(),
538
                            ((SideInfo) getMultiPointSidesCombo().getSelectedItem()).getSide(),
539
                            width,
540
                            (short) getDistanceUnitsCombo().getSelectedIndex(),
541
                            layersToProcess,
542
                            getMultiLayerSelectionCBox().isSelected());// getAddBufferLayersCBox().isSelected(),
543
                                                                       // getAddInfluenceAreaLayersCBox().isSelected(),
544
                                                                       // getMultiLayerSelectionCBox().isSelected());
545
                    IncrementableTask iTask =
546
                        new IncrementableTask(iprocess,
547
                            new ProgressPanel(false));
548
                    iTask.addIncrementableListener(iprocess);
549
                    iprocess.setIncrementableTask(iTask);
550
                    final BufferSelectionProcess f_iprocess = iprocess;
551
                    final IncrementableTask f_iTask = iTask;
552

  
553
                    iTask.getProgressPanel()
554
                        .addComponentListener(new ComponentAdapter() {
555

  
556
                            /*
557
                             * (non-Javadoc)
558
                             * 
559
                             * @see
560
                             * java.awt.event.ComponentAdapter#componentHidden
561
                             * (java.awt.event.ComponentEvent)
562
                             */
563
                            public void componentHidden(ComponentEvent e) {
564
                                /*
565
                                 * 5- If the process has failed, tries to reload
566
                                 * the layers
567
                                 */
568
                                if (f_iprocess.getPercent() < 100) {
569
                                    /* 5.1- Forces to reload the active layers */
570
                                    mapControl.drawMap(false);
571
                                    f_iTask.getProgressPanel().dispose();
572

  
573
                                    for (int i = 0; i < layers.length; i++) {
574
                                        try {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff