Revision 38019
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.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_2045/extensions/org.gvsig.hyperlink.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.hyperlink.app</artifactId> |
|
7 |
<packaging>pom</packaging> |
|
8 |
<version>1.0.0-SNAPSHOT</version> |
|
9 |
<name>org.gvsig.hyperlink.app</name> |
|
10 |
<description>View. Hyperlink support</description> |
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.maven.base.extension.pom</artifactId> |
|
14 |
<version>1.0.8-SNAPSHOT</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<scm> |
|
18 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/extensions/org.gvsig.hyperlink.app</connection> |
|
19 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/extensions/org.gvsig.hyperlink.app</developerConnection> |
|
20 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-desktop/repository/show/branches/v2_0_0_prep/extensions/org.gvsig.hyperlink.app</url> |
|
21 |
</scm> |
|
22 |
|
|
23 |
<developers> |
|
24 |
<developer> |
|
25 |
<id>jjdelcerro</id> |
|
26 |
<name>Joaqu?n Jos? del Cerro</name> |
|
27 |
<email>jjdelcerro@gvsig.org</email> |
|
28 |
<roles> |
|
29 |
<role>Architect</role> |
|
30 |
<role>Developer</role> |
|
31 |
</roles> |
|
32 |
</developer> |
|
33 |
<developer> |
|
34 |
<id>jbadia</id> |
|
35 |
<name>Jos? Bad?a</name> |
|
36 |
<email>badia_jos@gva.es</email> |
|
37 |
<roles> |
|
38 |
<role>Developer</role> |
|
39 |
</roles> |
|
40 |
</developer> |
|
41 |
<developer> |
|
42 |
<id>cordinyana</id> |
|
43 |
<name>C?sar Ordi?ana</name> |
|
44 |
<email>cordinyana@gvsig.com</email> |
|
45 |
<roles> |
|
46 |
<role>Architect</role> |
|
47 |
<role>Developer</role> |
|
48 |
</roles> |
|
49 |
</developer> |
|
50 |
</developers> |
|
51 |
|
|
52 |
<repositories> |
|
53 |
<repository> |
|
54 |
<id>gvsig-public-http-repository</id> |
|
55 |
<name>gvSIG maven public HTTP repository</name> |
|
56 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
57 |
<releases> |
|
58 |
<enabled>true</enabled> |
|
59 |
<updatePolicy>daily</updatePolicy> |
|
60 |
<checksumPolicy>warn</checksumPolicy> |
|
61 |
</releases> |
|
62 |
<snapshots> |
|
63 |
<enabled>true</enabled> |
|
64 |
<updatePolicy>daily</updatePolicy> |
|
65 |
<checksumPolicy>warn</checksumPolicy> |
|
66 |
</snapshots> |
|
67 |
</repository> |
|
68 |
</repositories> |
|
69 |
<dependencyManagement> |
|
70 |
<dependencies> |
|
71 |
<dependency> |
|
72 |
<groupId>org.gvsig</groupId> |
|
73 |
<artifactId>org.gvsig.core.maven.dependencies</artifactId> |
|
74 |
<version>2.0.1-SNAPSHOT</version> |
|
75 |
<type>pom</type> |
|
76 |
<scope>import</scope> |
|
77 |
</dependency> |
|
78 |
<dependency> |
|
79 |
<groupId>org.gvsig</groupId> |
|
80 |
<artifactId>org.gvsig.fmap.dal.store.raster</artifactId> |
|
81 |
<version>2.0-SNAPSHOT</version> |
|
82 |
<scope>compile</scope> |
|
83 |
</dependency> |
|
84 |
<dependency> |
|
85 |
<groupId>org.gvsig</groupId> |
|
86 |
<artifactId>org.gvsig.app</artifactId> |
|
87 |
<version>2.0-SNAPSHOT</version> |
|
88 |
<scope>compile</scope> |
|
89 |
</dependency> |
|
90 |
<dependency> |
|
91 |
<groupId>org.gvsig</groupId> |
|
92 |
<artifactId>org.gvsig.dwg.extension</artifactId> |
|
93 |
<version>2.0-SNAPSHOT</version> |
|
94 |
<scope>compile</scope> |
|
95 |
</dependency> |
|
96 |
</dependencies> |
|
97 |
</dependencyManagement> |
|
98 |
|
|
99 |
<modules> |
|
100 |
<module>org.gvsig.hyperlink.app.extension</module> |
|
101 |
</modules> |
|
102 |
<properties> |
|
103 |
<package.info.state>alpha4</package.info.state> |
|
104 |
</properties> |
|
105 |
</project> |
|
0 | 106 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.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_2045/extensions/org.gvsig.hyperlink.app/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
</assembly> |
|
0 | 3 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Tue Feb 14 18:10:31 CET 2012 |
|
3 |
buildNumber=2053 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>distribution</id> |
|
3 |
<formats> |
|
4 |
<format>dir</format> |
|
5 |
</formats> |
|
6 |
<fileSets> |
|
7 |
<!-- Estructure for the extension --> |
|
8 |
<fileSet> |
|
9 |
<directory>src/main/resources</directory> |
|
10 |
<outputDirectory>${extension.install.dir.name} |
|
11 |
</outputDirectory> |
|
12 |
</fileSet> |
|
13 |
</fileSets> |
|
14 |
<files> |
|
15 |
<file> |
|
16 |
<source>package.info</source> |
|
17 |
<outputDirectory>${extension.install.dir.name} |
|
18 |
</outputDirectory> |
|
19 |
</file> |
|
20 |
</files> |
|
21 |
<dependencySets> |
|
22 |
<dependencySet> |
|
23 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
24 |
</outputDirectory> |
|
25 |
<includes> |
|
26 |
<include>org.gvsig:org.gvsig.hyperlink.app.extension</include> |
|
27 |
</includes> |
|
28 |
</dependencySet> |
|
29 |
</dependencySets> |
|
30 |
</assembly> |
|
0 | 31 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Tue Feb 14 18:10:31 CET 2012 |
|
3 |
buildNumber=2045 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.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_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.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.hyperlink"> |
|
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_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/AbstractActionManager.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.hyperlink.app.extension; |
|
24 |
|
|
25 |
import java.util.Map; |
|
26 |
|
|
27 |
public abstract class AbstractActionManager implements ILinkActionManager { |
|
28 |
|
|
29 |
public boolean hasPanel() { |
|
30 |
return false; |
|
31 |
} |
|
32 |
|
|
33 |
public Object create() { |
|
34 |
return this; |
|
35 |
} |
|
36 |
|
|
37 |
public Object create(Object[] args) { |
|
38 |
return this; |
|
39 |
} |
|
40 |
|
|
41 |
public Object create(Map args) { |
|
42 |
return this; |
|
43 |
} |
|
44 |
|
|
45 |
} |
|
0 | 46 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/ILinkActionManager.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.hyperlink.app.extension; |
|
24 |
|
|
25 |
import java.net.URI; |
|
26 |
|
|
27 |
import org.gvsig.tools.extensionpoint.ExtensionBuilder; |
|
28 |
|
|
29 |
/** |
|
30 |
* TODO document this interface |
|
31 |
* This interface must be implemented by format managers for the |
|
32 |
* hyperlink tool. A manager is able to load an specific file, either |
|
33 |
* by loading it in an AbstractHyperLinkPanel or by opening the proper |
|
34 |
* program to do the task. |
|
35 |
* |
|
36 |
* Format managers must be registered in the ExtensionPoint named |
|
37 |
* "HyperLinkAction" in order to be available in the HyperLink tool. |
|
38 |
* |
|
39 |
* @author cesar |
|
40 |
* |
|
41 |
*/ |
|
42 |
public interface ILinkActionManager extends ExtensionBuilder { |
|
43 |
|
|
44 |
public void showDocument(URI doc) throws UnsupportedOperationException; |
|
45 |
|
|
46 |
public boolean hasPanel(); |
|
47 |
|
|
48 |
public AbstractHyperLinkPanel createPanel(URI doc) throws UnsupportedOperationException; |
|
49 |
|
|
50 |
public String getActionCode(); |
|
51 |
|
|
52 |
public String getName(); |
|
53 |
|
|
54 |
public String getDescription(); |
|
55 |
} |
|
0 | 56 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/layers/IncompatibleLayerException.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.hyperlink.app.extension.layers; |
|
24 |
|
|
25 |
public class IncompatibleLayerException extends Exception { |
|
26 |
|
|
27 |
public IncompatibleLayerException(Throwable ex) { |
|
28 |
super(ex); |
|
29 |
} |
|
30 |
|
|
31 |
} |
|
0 | 32 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/layers/ManagerRegistry.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.hyperlink.app.extension.layers; |
|
24 |
|
|
25 |
import java.util.Comparator; |
|
26 |
import java.util.HashMap; |
|
27 |
import java.util.HashSet; |
|
28 |
import java.util.Iterator; |
|
29 |
import java.util.TreeSet; |
|
30 |
|
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
32 |
import org.gvsig.tools.ToolsLocator; |
|
33 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
34 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
|
35 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
36 |
|
|
37 |
public class ManagerRegistry { |
|
38 |
|
|
39 |
public static final String EXTENSIONPOINTNAME = "hyperlink.layer.manager"; |
|
40 |
private ExtensionPoint extensionPoint; |
|
41 |
/** |
|
42 |
* We will cache the proper manager for each class, so that we don't |
|
43 |
* calculate the right one everytime. |
|
44 |
* This assumes that no manager will be added after extensions' initialize() |
|
45 |
* method, otherwise the |
|
46 |
* cached values will be incorrect. |
|
47 |
*/ |
|
48 |
private HashMap<Class, String> cachedManagers; |
|
49 |
/** |
|
50 |
* We will also cache the unmanaged layers (layers without managers). |
|
51 |
*/ |
|
52 |
private HashSet<Class> cachedUnmanagedLayers; |
|
53 |
|
|
54 |
public ManagerRegistry() { |
|
55 |
ExtensionPointManager epm = ToolsLocator.getExtensionPointManager(); |
|
56 |
extensionPoint = |
|
57 |
epm.add(EXTENSIONPOINTNAME, |
|
58 |
"Registers ILinkToolManagers that are able to manage specific layer types."); |
|
59 |
cachedManagers = new HashMap<Class, String>(); |
|
60 |
cachedUnmanagedLayers = new HashSet<Class>(); |
|
61 |
} |
|
62 |
|
|
63 |
public void put(Class layerType, Class manager) { |
|
64 |
if (layerType.isInterface()) { |
|
65 |
throw new RuntimeException("Interfaces are not supported"); |
|
66 |
} |
|
67 |
if (!ILinkLayerManager.class.isAssignableFrom(manager)) { |
|
68 |
throw new RuntimeException("Managers must be of type ILinkLayerManager"); |
|
69 |
} |
|
70 |
extensionPoint.append(layerType.getName(), "", manager); |
|
71 |
} |
|
72 |
|
|
73 |
public ILinkLayerManager get(FLayer layer) throws ClassNotFoundException, |
|
74 |
InstantiationException, |
|
75 |
IllegalAccessException, |
|
76 |
IncompatibleLayerException { |
|
77 |
if (cachedManagers.containsKey(layer.getClass())) { |
|
78 |
String layerType = cachedManagers.get(layer.getClass()); |
|
79 |
ILinkLayerManager manager = |
|
80 |
(ILinkLayerManager) extensionPoint.create(layerType); |
|
81 |
manager.setLayer(layer); |
|
82 |
return manager; |
|
83 |
} else |
|
84 |
if (cachedUnmanagedLayers.contains(layer.getClass())) { |
|
85 |
return null; |
|
86 |
} |
|
87 |
// search for proper manager for this class |
|
88 |
Iterator it = extensionPoint.getNames().iterator(); |
|
89 |
TreeSet<Class> classList = new TreeSet<Class>(new ClassComparator()); |
|
90 |
while (it.hasNext()) { |
|
91 |
String layerType = it.next().toString(); |
|
92 |
Class layerClass = Class.forName(layerType); |
|
93 |
if (layerClass.isInstance(layer)) { |
|
94 |
classList.add(layerClass); |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
if (!classList.isEmpty()) { |
|
99 |
ILinkLayerManager manager = |
|
100 |
(ILinkLayerManager) extensionPoint.create(classList.first() |
|
101 |
.getName()); |
|
102 |
cachedManagers.put(layer.getClass(), classList.first().getName()); |
|
103 |
manager.setLayer(layer); |
|
104 |
return manager; |
|
105 |
} else { |
|
106 |
cachedUnmanagedLayers.add(layer.getClass()); |
|
107 |
return null; |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
public boolean hasManager(FLayer layer) { |
|
112 |
if (cachedManagers.containsKey(layer.getClass())) { |
|
113 |
return true; |
|
114 |
} else |
|
115 |
if (cachedUnmanagedLayers.contains(layer.getClass())) { |
|
116 |
return false; |
|
117 |
} |
|
118 |
|
|
119 |
Iterator it = extensionPoint.iterator(); |
|
120 |
while (it.hasNext()) { |
|
121 |
Class layerClass = ((Extension) it.next()).getExtension(); |
|
122 |
if (layerClass.isInstance(layer)) { |
|
123 |
return true; |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
// cachedUnmanagedLayers.add(layer.getClass()); |
|
128 |
return false; |
|
129 |
} |
|
130 |
|
|
131 |
private class ClassComparator implements Comparator<Class> { |
|
132 |
|
|
133 |
public int compare(Class class1, Class class2) { |
|
134 |
if (class1.equals(class2)) |
|
135 |
return 0; |
|
136 |
if (class1.isAssignableFrom(class2)) { |
|
137 |
return 1; |
|
138 |
} else { |
|
139 |
return -1; |
|
140 |
} |
|
141 |
} |
|
142 |
} |
|
143 |
} |
|
0 | 144 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/layers/VectLayerManager.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.hyperlink.app.extension.layers; |
|
24 |
|
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.io.File; |
|
27 |
import java.net.URI; |
|
28 |
import java.net.URISyntaxException; |
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.Map; |
|
31 |
|
|
32 |
import org.gvsig.andami.PluginServices; |
|
33 |
import org.gvsig.andami.messages.NotificationManager; |
|
34 |
import org.gvsig.fmap.dal.exception.DataException; |
|
35 |
import org.gvsig.fmap.dal.feature.Feature; |
|
36 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
37 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
39 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
40 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
41 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
42 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
43 |
|
|
44 |
public class VectLayerManager implements ILinkLayerManager { |
|
45 |
|
|
46 |
private FLyrVect _layer = null; |
|
47 |
|
|
48 |
public URI[] getLink(Point2D point, |
|
49 |
double tolerance, |
|
50 |
String fieldName, |
|
51 |
String fileExtension) { |
|
52 |
FLyrVect lyrVect = (FLyrVect) _layer; |
|
53 |
ArrayList<URI> uriList = new ArrayList(); |
|
54 |
FeatureSet features; |
|
55 |
FeatureType featureType; |
|
56 |
|
|
57 |
try { |
|
58 |
// FIXME: Habr? que ver como lo hacemos con las capas multigeometr?a |
|
59 |
featureType = _layer.getFeatureStore().getDefaultFeatureType(); |
|
60 |
features = lyrVect.queryByPoint(point, tolerance, featureType); |
|
61 |
} catch (Exception e) { |
|
62 |
return null; |
|
63 |
} |
|
64 |
|
|
65 |
// Si el conjunto creado no est? vac?o creamos el vector de URLS |
|
66 |
// correspondientes |
|
67 |
// a la consulta que hemos hecho. |
|
68 |
|
|
69 |
if (features != null) { |
|
70 |
try { |
|
71 |
DisposableIterator it; |
|
72 |
it = features.iterator(); |
|
73 |
while (it.hasNext()) { |
|
74 |
Feature feature = (Feature) it.next(); |
|
75 |
String fieldValue = feature.get(fieldName).toString(); |
|
76 |
if (!fieldValue.equals("")) { |
|
77 |
try { |
|
78 |
uriList.add(getURI(fieldValue, fileExtension)); |
|
79 |
} catch (URISyntaxException e) { |
|
80 |
NotificationManager.addWarning(PluginServices.getText(this, |
|
81 |
"Hyperlink__field_value_is_not_valid_file"), |
|
82 |
e); |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
} |
|
87 |
it.dispose(); |
|
88 |
return (URI[]) uriList.toArray(new URI[0]); |
|
89 |
} catch (DataException e1) { |
|
90 |
PluginServices.getLogger() |
|
91 |
.error("Hyperlink__cant_get_the_iterator", e1); |
|
92 |
} |
|
93 |
} |
|
94 |
return new URI[0]; |
|
95 |
} |
|
96 |
|
|
97 |
protected URI getURI(String baseURI, String extension) throws URISyntaxException { |
|
98 |
String stringURI; |
|
99 |
if (extension.equals("")) { |
|
100 |
stringURI = baseURI; |
|
101 |
} else |
|
102 |
if (extension.startsWith(".")) { |
|
103 |
stringURI = baseURI + extension; |
|
104 |
} else { |
|
105 |
stringURI = baseURI + "." + extension; |
|
106 |
} |
|
107 |
File file = new File(stringURI); |
|
108 |
if (file.exists()) { |
|
109 |
return file.toURI(); |
|
110 |
} else { |
|
111 |
return new URI(stringURI); |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
public FLayer getLayer() { |
|
116 |
return _layer; |
|
117 |
} |
|
118 |
|
|
119 |
public void setLayer(FLayer layer) throws IncompatibleLayerException { |
|
120 |
try { |
|
121 |
_layer = (FLyrVect) layer; |
|
122 |
} catch (ClassCastException ex) { |
|
123 |
throw new IncompatibleLayerException(ex); |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
public Object create() { |
|
128 |
return this; |
|
129 |
} |
|
130 |
|
|
131 |
public Object create(Object[] args) { |
|
132 |
return this; |
|
133 |
} |
|
134 |
|
|
135 |
public Object create(Map args) { |
|
136 |
return this; |
|
137 |
} |
|
138 |
|
|
139 |
public URI[][] getLink(Point2D point, |
|
140 |
double tolerance, |
|
141 |
String[] fieldName, |
|
142 |
String fileExtension) { |
|
143 |
FLyrVect lyrVect = (FLyrVect) _layer; |
|
144 |
FeatureSet features; |
|
145 |
FeatureType featureType; |
|
146 |
URI uri[][] = null; |
|
147 |
|
|
148 |
try { |
|
149 |
// FIXME: Habr? que ver como lo hacemos con las capas multigeometr?a |
|
150 |
featureType = _layer.getFeatureStore().getDefaultFeatureType(); |
|
151 |
features = lyrVect.queryByPoint(point, tolerance, featureType); |
|
152 |
} catch (Exception e) { |
|
153 |
return null; |
|
154 |
} |
|
155 |
|
|
156 |
// Si el conjunto creado no est? vac?o creamos el vector de URLS |
|
157 |
// correspondientes |
|
158 |
// a la consulta que hemos hecho. |
|
159 |
|
|
160 |
if (features != null) { |
|
161 |
try { |
|
162 |
// Creo el vector de URL?s con la misma longitud que features |
|
163 |
uri = new URI[(int) features.getSize()][fieldName.length]; |
|
164 |
|
|
165 |
// Recorremos las features siguiendo el ejemplo de la clase que |
|
166 |
// se |
|
167 |
// proporciona en la API |
|
168 |
int count = 0; |
|
169 |
DisposableIterator it = features.iterator(); |
|
170 |
while (it.hasNext()) { |
|
171 |
Feature feat = (Feature) it.next(); |
|
172 |
for (int fieldCount = 0; fieldCount < fieldName.length; fieldCount++) { |
|
173 |
// get the field ID using the field name |
|
174 |
String auxField = |
|
175 |
feat.get(fieldName[fieldCount]).toString(); |
|
176 |
if (auxField != null) { |
|
177 |
if (auxField.startsWith("http:/")) { |
|
178 |
try { |
|
179 |
uri[count][fieldCount] = new URI(auxField); |
|
180 |
} catch (URISyntaxException e) { |
|
181 |
PluginServices.getLogger().error("", e); |
|
182 |
} |
|
183 |
} else { |
|
184 |
File file = new File(auxField); |
|
185 |
uri[count][fieldCount] = file.toURI(); |
|
186 |
} |
|
187 |
} else { |
|
188 |
PluginServices.getLogger() |
|
189 |
.error("Hyperlink error. Field " |
|
190 |
+ fieldName[fieldCount] + "doesn't exist!!"); |
|
191 |
uri[count][fieldCount] = null; |
|
192 |
} |
|
193 |
} |
|
194 |
count++; |
|
195 |
} |
|
196 |
it.dispose(); |
|
197 |
|
|
198 |
return uri; |
|
199 |
} catch (DataException e) { |
|
200 |
PluginServices.getLogger().error("", e); |
|
201 |
} |
|
202 |
} |
|
203 |
return new URI[0][0]; |
|
204 |
} |
|
205 |
|
|
206 |
public String[] getFieldCandidates() { |
|
207 |
try { |
|
208 |
FeatureType featureType = |
|
209 |
_layer.getFeatureStore().getDefaultFeatureType(); |
|
210 |
ArrayList<String> fields = new ArrayList<String>(); |
|
211 |
FeatureAttributeDescriptor[] descriptors = |
|
212 |
featureType.getAttributeDescriptors(); |
|
213 |
for (int i = 0; i < descriptors.length; i++) { |
|
214 |
FeatureAttributeDescriptor descriptor = descriptors[i]; |
|
215 |
if (descriptor.getDataType().isNumeric() |
|
216 |
|| descriptor.getDataType().getType() == DataTypes.STRING) { |
|
217 |
fields.add(descriptor.getName()); |
|
218 |
} |
|
219 |
} |
|
220 |
return (String[]) fields.toArray(new String[0]); |
|
221 |
} catch (DataException e) { |
|
222 |
NotificationManager.addError(PluginServices.getText(this, |
|
223 |
"Error reading layer fields"), e); |
|
224 |
} |
|
225 |
return new String[0]; |
|
226 |
} |
|
227 |
|
|
228 |
} |
|
0 | 229 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/layers/ILinkLayerManager.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.hyperlink.app.extension.layers; |
|
24 |
|
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.net.URI; |
|
27 |
|
|
28 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
29 |
|
|
30 |
public interface ILinkLayerManager { |
|
31 |
|
|
32 |
public void setLayer(FLayer layer) throws IncompatibleLayerException; |
|
33 |
|
|
34 |
public FLayer getLayer(); |
|
35 |
|
|
36 |
public URI[] getLink(Point2D point, |
|
37 |
double tolerance, |
|
38 |
String fieldName, |
|
39 |
String fileExtension); |
|
40 |
|
|
41 |
public URI[][] getLink(Point2D point, |
|
42 |
double tolerance, |
|
43 |
String[] fieldName, |
|
44 |
String fileExtension); |
|
45 |
|
|
46 |
public String[] getFieldCandidates(); |
|
47 |
} |
|
0 | 48 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/LinkConfigExtension.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.hyperlink.app.extension; |
|
24 |
|
|
25 |
import org.gvsig.andami.PluginServices; |
|
26 |
import org.gvsig.andami.plugins.Extension; |
|
27 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
28 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
29 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
32 |
import org.gvsig.hyperlink.app.extension.config.gui.ConfigTab; |
|
33 |
import org.gvsig.hyperlink.app.extension.layers.ManagerRegistry; |
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
/** |
|
38 |
* Extensi?n para gestionar los hiperlinks. |
|
39 |
* |
|
40 |
* @author Vicente Caballero Navarro |
|
41 |
*/ |
|
42 |
public class LinkConfigExtension extends Extension { |
|
43 |
|
|
44 |
private static final Logger logger = |
|
45 |
LoggerFactory.getLogger(LinkConfigExtension.class); |
|
46 |
ManagerRegistry layerManager; |
|
47 |
|
|
48 |
/** |
|
49 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
50 |
*/ |
|
51 |
public void execute(String s) { |
|
52 |
logger.debug("Command : " + s); |
|
53 |
|
|
54 |
if (s.compareTo("LINK_SETTINGS") == 0) { |
|
55 |
IView view = |
|
56 |
(IView) PluginServices.getMDIManager().getActiveWindow(); |
|
57 |
HyperlinkExtension ext = |
|
58 |
(HyperlinkExtension) PluginServices.getExtension(HyperlinkExtension.class); |
|
59 |
// init tool and load legacy config in case it has been not done |
|
60 |
ext.initTool(view); |
|
61 |
FLayer[] activas = |
|
62 |
view.getMapControl().getMapContext().getLayers().getActives(); |
|
63 |
for (int i = 0; i < activas.length; i++) { |
|
64 |
if (!activas[i].isAvailable()) { |
|
65 |
return; |
|
66 |
} |
|
67 |
|
|
68 |
if (layerManager.hasManager(activas[i])) { |
|
69 |
ConfigTab configWindow = new ConfigTab(); |
|
70 |
configWindow.setModel(activas[i]); |
|
71 |
PluginServices.getMDIManager() |
|
72 |
.addCentredWindow(configWindow); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible() |
|
81 |
*/ |
|
82 |
public boolean isVisible() { |
|
83 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
84 |
|
|
85 |
if (window == null) { |
|
86 |
return false; |
|
87 |
} |
|
88 |
|
|
89 |
if (window instanceof IView) { |
|
90 |
|
|
91 |
MapContext mapa = |
|
92 |
((IView) window).getViewDocument().getMapContext(); |
|
93 |
|
|
94 |
return mapa.getLayers().getLayersCount() > 0; |
|
95 |
} else { |
|
96 |
return false; |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
102 |
*/ |
|
103 |
public boolean isEnabled() { |
|
104 |
// it will be enabled when there is only ONE active layer, and this |
|
105 |
// layer |
|
106 |
// is available and has a valid ILayerLinkManager |
|
107 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
108 |
|
|
109 |
if (window == null) { |
|
110 |
return false; |
|
111 |
} |
|
112 |
|
|
113 |
if (window instanceof IView) { |
|
114 |
IView view = (IView) window; |
|
115 |
ViewDocument model = view.getViewDocument(); |
|
116 |
FLayer[] activas = model.getMapContext().getLayers().getActives(); |
|
117 |
if (activas.length == 1) { |
|
118 |
if (activas[0].isAvailable() |
|
119 |
&& layerManager.hasManager(activas[0])) { |
|
120 |
return true; |
|
121 |
} |
|
122 |
} |
|
123 |
} |
|
124 |
return false; |
|
125 |
} |
|
126 |
|
|
127 |
public void postInitialize() { |
|
128 |
HyperlinkExtension ext = |
|
129 |
(HyperlinkExtension) PluginServices.getExtension(HyperlinkExtension.class); |
|
130 |
layerManager = ext.getLayerManager(); |
|
131 |
} |
|
132 |
|
|
133 |
public void initialize() { |
|
134 |
//Do nothing |
|
135 |
} |
|
136 |
|
|
137 |
} |
|
0 | 138 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/ShowPanel.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.hyperlink.app.extension; |
|
24 |
|
|
25 |
import java.awt.BorderLayout; |
|
26 |
import java.awt.event.ComponentEvent; |
|
27 |
import java.awt.event.ComponentListener; |
|
28 |
import java.io.File; |
|
29 |
import java.net.MalformedURLException; |
|
30 |
|
|
31 |
import javax.swing.JPanel; |
|
32 |
import javax.swing.JScrollPane; |
|
33 |
|
|
34 |
import org.gvsig.andami.PluginServices; |
|
35 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
36 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
37 |
|
|
38 |
/** |
|
39 |
* This class extends JPanel. This class implements a Panel to show the content |
|
40 |
* of the URI |
|
41 |
* that the constructor of the class receives. This panel invokes a new one with |
|
42 |
* the content |
|
43 |
* of the URI. The type of the supported URI should be added like extension |
|
44 |
* point in the |
|
45 |
* initialization of the extension. |
|
46 |
* |
|
47 |
* @author Vicente Caballero Navarro |
|
48 |
* @author Eustaquio Vercher |
|
49 |
* |
|
50 |
*/ |
|
51 |
public class ShowPanel extends JPanel implements IWindow, ComponentListener { |
|
52 |
|
|
53 |
private JScrollPane jScrollPane = null; |
|
54 |
private WindowInfo m_ViewInfo = null; |
|
55 |
private AbstractHyperLinkPanel contents = null; |
|
56 |
private static int xpos = 0; |
|
57 |
private static int ypos = 0; |
|
58 |
|
|
59 |
public ShowPanel(AbstractHyperLinkPanel contents) { |
|
60 |
super(); |
|
61 |
this.contents = contents; |
|
62 |
initialize(); |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* This method initializes this |
|
67 |
*/ |
|
68 |
private void initialize() { |
|
69 |
this.setLayout(new BorderLayout()); |
|
70 |
this.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
|
71 |
getJScrollPane().setViewportView(contents); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Returns a Scroll Pane with the content of the HyperLink |
|
76 |
* |
|
77 |
* @return jScrollPane |
|
78 |
*/ |
|
79 |
private JScrollPane getJScrollPane() { |
|
80 |
if (jScrollPane == null) { |
|
81 |
jScrollPane = new JScrollPane(); |
|
82 |
// jScrollPane.setPreferredSize(new java.awt.Dimension(300, 400)); |
|
83 |
} |
|
84 |
return jScrollPane; |
|
85 |
} |
|
86 |
|
|
87 |
/* |
|
88 |
* (non-Javadoc) |
|
89 |
* |
|
90 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo() |
|
91 |
*/ |
|
92 |
public WindowInfo getWindowInfo() { |
|
93 |
if (m_ViewInfo == null) { |
|
94 |
m_ViewInfo = |
|
95 |
new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE |
|
96 |
| WindowInfo.ICONIFIABLE | WindowInfo.PALETTE); |
|
97 |
if (contents.getURI().toString().startsWith("file:") |
|
98 |
&& contents.getURI().isAbsolute()) { |
|
99 |
try { |
|
100 |
File file = new File(contents.getURI().toURL().getFile()); |
|
101 |
m_ViewInfo.setTitle(PluginServices.getText(this, |
|
102 |
"Hyperlink") + " - " + file.getName()); |
|
103 |
} catch (MalformedURLException e) { |
|
104 |
m_ViewInfo.setTitle(PluginServices.getText(this, |
|
105 |
"Hyperlink") + " - " + contents.getURI().toString()); |
|
106 |
} catch (NullPointerException e) { |
|
107 |
m_ViewInfo.setTitle(PluginServices.getText(this, |
|
108 |
"Hyperlink") + " - " + contents.getURI().toString()); |
|
109 |
} |
|
110 |
} else { |
|
111 |
m_ViewInfo.setTitle(PluginServices.getText(this, "Hyperlink") |
|
112 |
+ " - " + contents.getURI().toString()); |
|
113 |
} |
|
114 |
int height = (int) contents.getPreferredSize().getHeight() + 15; |
|
115 |
if (height > 650) |
|
116 |
height = 650; |
|
117 |
else |
|
118 |
if (height < 450) |
|
119 |
height = 450; |
|
120 |
int width = (int) contents.getPreferredSize().getWidth() + 20; |
|
121 |
if (width > 800) |
|
122 |
width = 800; |
|
123 |
else |
|
124 |
if (width < 450) |
|
125 |
width = 450; |
|
126 |
m_ViewInfo.setWidth(width); |
|
127 |
m_ViewInfo.setHeight(height); |
|
128 |
m_ViewInfo.setX(xpos); |
|
129 |
xpos = (xpos + 20) % 270; |
|
130 |
m_ViewInfo.setY(ypos); |
|
131 |
ypos = (ypos + 15) % 150; |
|
132 |
} |
|
133 |
return m_ViewInfo; |
|
134 |
} |
|
135 |
|
|
136 |
/* |
|
137 |
* (non-Javadoc) |
|
138 |
* |
|
139 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event. |
|
140 |
* ComponentEvent) |
|
141 |
*/ |
|
142 |
public void componentResized(ComponentEvent e) { |
|
143 |
|
|
144 |
} |
|
145 |
|
|
146 |
/* |
|
147 |
* (non-Javadoc) |
|
148 |
* |
|
149 |
* @see |
|
150 |
* java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent |
|
151 |
* ) |
|
152 |
*/ |
|
153 |
public void componentMoved(ComponentEvent e) { |
|
154 |
|
|
155 |
} |
|
156 |
|
|
157 |
/* |
|
158 |
* (non-Javadoc) |
|
159 |
* |
|
160 |
* @see |
|
161 |
* java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent |
|
162 |
* ) |
|
163 |
*/ |
|
164 |
public void componentShown(ComponentEvent e) { |
|
165 |
|
|
166 |
} |
|
167 |
|
|
168 |
/* |
|
169 |
* (non-Javadoc) |
|
170 |
* |
|
171 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event. |
|
172 |
* ComponentEvent) |
|
173 |
*/ |
|
174 |
public void componentHidden(ComponentEvent e) { |
|
175 |
|
|
176 |
} |
|
177 |
|
|
178 |
public Object getWindowProfile() { |
|
179 |
return WindowInfo.EDITOR_PROFILE; |
|
180 |
} |
|
181 |
} |
|
0 | 182 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/actions/SvgFormat.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.hyperlink.app.extension.actions; |
|
24 |
|
|
25 |
import java.io.Serializable; |
|
26 |
import java.net.URI; |
|
27 |
|
|
28 |
import org.gvsig.andami.PluginServices; |
|
29 |
import org.gvsig.hyperlink.app.extension.AbstractActionManager; |
|
30 |
import org.gvsig.hyperlink.app.extension.AbstractHyperLinkPanel; |
|
31 |
|
|
32 |
public class SvgFormat extends AbstractActionManager implements Serializable { |
|
33 |
|
|
34 |
public static final String actionCode = "SVG_format"; |
|
35 |
|
|
36 |
public AbstractHyperLinkPanel createPanel(URI doc) throws UnsupportedOperationException { |
|
37 |
return new SvgPanel(doc); |
|
38 |
} |
|
39 |
|
|
40 |
public String getActionCode() { |
|
41 |
return actionCode; |
|
42 |
} |
|
43 |
|
|
44 |
public boolean hasPanel() { |
|
45 |
return true; |
|
46 |
} |
|
47 |
|
|
48 |
public void showDocument(URI doc) { |
|
49 |
throw new UnsupportedOperationException(); |
|
50 |
} |
|
51 |
|
|
52 |
public String getDescription() { |
|
53 |
return PluginServices.getText(this, "Shows_SVG_files_in_gvSIG"); |
|
54 |
} |
|
55 |
|
|
56 |
public String getName() { |
|
57 |
return PluginServices.getText(this, "SVG_format"); |
|
58 |
} |
|
59 |
} |
|
0 | 60 |
tags/v2_0_0_Build_2045/extensions/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/actions/TxtFormat.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.hyperlink.app.extension.actions; |
Also available in: Unified diff