Revision 28132
trunk/extensions/extHyperlink/build.xml | ||
---|---|---|
1 |
<project name="extHyperlink" default="dist" basedir="."> |
|
2 |
<description> |
|
3 |
Instala el plugin |
|
4 |
</description> |
|
5 |
<!-- set global properties for this build --> |
|
6 |
<property name="src" location="src"/> |
|
7 |
<property name="src-test" location="src-test"/> |
|
8 |
<property name="lib" location="../_fwAndami/lib"/> |
|
9 |
<property name="build" location="bin"/> |
|
10 |
<property name="build-test" location="bin-test"/> |
|
11 |
<property name="dist" location="dist"/> |
|
12 |
<property name="andamiJar" location="../_fwAndami/andami.jar"/> |
|
13 |
<property name="plugin" value="org.gvsig.hyperlink"/> |
|
14 |
<property name="gvsig-plugin" value="gvsig-hyperlink"/> |
|
15 |
<property name="targetDir" location="../_fwAndami/gvSIG/extensiones"/> |
|
16 |
<property name="gvsig-targetDir" location="${targetDir}/com.iver.cit.gvsig/lib"/> |
|
17 |
<import file="../binaries/ant/utilities.xml"/> |
|
18 |
|
|
19 |
<target name="init"> |
|
20 |
<!-- Create the time stamp --> |
|
21 |
<tstamp/> |
|
22 |
<echo> |
|
23 |
Compiling ${ant.project.name}...</echo> |
|
24 |
<!-- create the build.number file --> |
|
25 |
<buildnumber/> |
|
26 |
<!-- Create the build directory structure used by compile --> |
|
27 |
<mkdir dir="${build}"/> |
|
28 |
</target> |
|
29 |
|
|
30 |
<target name="dist" description="generate the distribution" |
|
31 |
depends="create-jar,copy-libs,copy-data-files,move-to-andami" /> |
|
32 |
|
|
33 |
<target name="batch-build" |
|
34 |
description="compile the sources, create the jar file" |
|
35 |
depends="init,compile,create-jar,copy-libs,copy-data-files,move-to-andami"> |
|
36 |
</target> |
|
37 |
|
|
38 |
<target name="compile" description="compile the source" > |
|
39 |
<!-- Compile the Java code from ${src} to ${build} --> |
|
40 |
<mkdir dir="${build}" /> |
|
41 |
<loadEclipseClasspath project="${basedir}"/> |
|
42 |
<gvSIG-javac |
|
43 |
classpath="${eclipseClasspath}" |
|
44 |
/> |
|
45 |
</target> |
|
46 |
|
|
47 |
<target name="copy-libs"> |
|
48 |
<copy todir="${dist}"> |
|
49 |
<fileset dir="lib" includes="*.jar"/> |
|
50 |
</copy> |
|
51 |
</target> |
|
52 |
|
|
53 |
<target name="copy-data-files"> |
|
54 |
<copy file="config/config.xml" todir="${dist}"/> |
|
55 |
<copy file="build.number" todir="${dist}"/> |
|
56 |
<!-- <copy file="config/about.htm" todir="${dist}" overwrite="yes"/> |
|
57 |
<loadproperties srcFile="build.number"/> |
|
58 |
<replace casesensitive="true" |
|
59 |
file="${dist}/about.htm" |
|
60 |
token="#build.number#" |
|
61 |
value="${build.number}"> |
|
62 |
</replace>--> |
|
63 |
<copy todir="${dist}"> |
|
64 |
<fileset dir="config" includes="text*.properties"/> |
|
65 |
</copy> |
|
66 |
<copy todir="${dist}/images"> |
|
67 |
<fileset dir="images/" includes="*"/> |
|
68 |
</copy> |
|
69 |
<copy todir="${dist}"> |
|
70 |
<fileset dir="." includes="*.jar"/> |
|
71 |
</copy> |
|
72 |
</target> |
|
73 |
|
|
74 |
<target name="move-to-andami" description="Moves the build directory to andami"> |
|
75 |
<move todir="${gvsig-targetDir}/"> |
|
76 |
<fileset dir="${dist}" includes="${gvsig-plugin}.jar"/> |
|
77 |
</move> |
|
78 |
<move todir="${targetDir}/${plugin}/"> |
|
79 |
<fileset dir="${dist}" includes="**/**"/> |
|
80 |
</move> |
|
81 |
</target> |
|
82 |
|
|
83 |
<target name="create-jar" description="Crea el jar de la aplicacion"> |
|
84 |
<mkdir dir="${dist}"/> |
|
85 |
<jar jarfile="${dist}/${plugin}.jar" basedir="${build}" excludes="org/gvsig/tools/hyperlink/config/*"/> |
|
86 |
<jar jarfile="${dist}/${gvsig-plugin}.jar" basedir="${build}" includes="org/gvsig/tools/hyperlink/config/*"/> |
|
87 |
</target> |
|
88 |
|
|
89 |
<target name="clean" description="clean up" > |
|
90 |
<!-- Delete the ${build} and ${dist} directory trees --> |
|
91 |
<delete dir="${build}"/> |
|
92 |
<delete dir="${dist}"/> |
|
93 |
</target> |
|
94 |
|
|
95 |
<target name="run-tests" depends="batch-build,compile-tests"> |
|
96 |
<antcall target="generic-run-tests"> |
|
97 |
<param name="TestSuite.Name" value="com.iver.core.AllTests"/> |
|
98 |
</antcall> |
|
99 |
</target> |
|
100 |
</project> |
|
101 |
|
|
0 | 102 |
trunk/extensions/extHyperlink/.classpath | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
5 |
<classpathentry combineaccessrules="false" kind="src" path="/_fwAndami"/> |
|
6 |
<classpathentry combineaccessrules="false" kind="src" path="/appgvSIG"/> |
|
7 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap"/> |
|
8 |
<classpathentry kind="lib" path="/_fwAndami/lib/iver-utiles.jar" sourcepath="/libIverUtiles"/> |
|
9 |
<classpathentry kind="lib" path="/_fwAndami/lib/log4j-1.2.8.jar"/> |
|
10 |
<classpathentry kind="lib" path="/libFMap/lib/gdbms-0.8-SNAPSHOT.jar" sourcepath="/libGDBMS"/> |
|
11 |
<classpathentry kind="lib" path="/libFMap/lib/batik-awt-util.jar"/> |
|
12 |
<classpathentry combineaccessrules="false" kind="src" path="/libGDBMS"/> |
|
13 |
<classpathentry kind="lib" path="/appgvSIG/lib/JimiProClasses.zip"/> |
|
14 |
<classpathentry kind="lib" path="lib/jpedalSTD-3.47b25.jar"/> |
|
15 |
<classpathentry kind="lib" path="lib/bcprov-jdk15-139.jar"/> |
|
16 |
<classpathentry kind="lib" path="/_fwAndami/lib/xml-apis.jar"/> |
|
17 |
<classpathentry kind="lib" path="/libFMap/lib/driver-manager-1.1.jar" sourcepath="/libDriverManager"/> |
|
18 |
<classpathentry kind="lib" path="/_fwAndami/lib/org.gvsig.ui.jar" sourcepath="/libUIComponent/src"/> |
|
19 |
<classpathentry kind="lib" path="/libFMap/lib/org.cresques.cts.jar" sourcepath="/extJCRS/src/org/gvsig/crs"/> |
|
20 |
<classpathentry combineaccessrules="false" kind="src" path="/extRasterTools-SE"/> |
|
21 |
<classpathentry kind="lib" path="/_fwAndami/lib/org.gvsig.exceptions.jar" sourcepath="/libExceptions/src"/> |
|
22 |
<classpathentry kind="lib" path="/libFMap/lib/batik-bridge.jar"/> |
|
23 |
<classpathentry kind="lib" path="/libFMap/lib/batik-script.jar"/> |
|
24 |
<classpathentry kind="lib" path="/libFMap/lib/batik-gvt.jar"/> |
|
25 |
<classpathentry kind="lib" path="/libFMap/lib/xml-apis-ext.jar"/> |
|
26 |
<classpathentry kind="lib" path="/libFMap/lib/batik-util.jar"/> |
|
27 |
<classpathentry kind="output" path="bin"/> |
|
28 |
</classpath> |
|
0 | 29 |
trunk/extensions/extHyperlink/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>extHyperlink</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
</buildSpec> |
|
14 |
<natures> |
|
15 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
16 |
</natures> |
|
17 |
</projectDescription> |
|
0 | 18 |
trunk/extensions/extHyperlink/config/text.properties | ||
---|---|---|
1 |
#Translations for language [es] |
|
2 |
Action=Acci?n |
|
3 |
Actions=Acciones |
|
4 |
Add_action=A?adir acci?n |
|
5 |
Advanced_Hyperlink=Hiperenlace avanzado |
|
6 |
Campo=Campo |
|
7 |
Enable_hyperlink=Activar hiperenlace |
|
8 |
Extension=Extensi?n |
|
9 |
HTML_and_text_formats=Enlazar con ficheros de texto y HTML |
|
10 |
Hyperlink=Hiperenlace |
|
11 |
Hyperlink_Settings=Configurar Hiperenlace |
|
12 |
Hyperlink_settings=Configurar hiperenlace |
|
13 |
Image_format=Enlazar con ficheros de imagen |
|
14 |
Load_Raster_Layer=Cargar capa r?ster |
|
15 |
Loads_raster_layers_in_gvSIG=Carga capas r?ster en la vista activa |
|
16 |
Load_Vector_Layer=Cargar capa vectorial |
|
17 |
Loads_vector_layers_in_gvSIG=Carga capas vectoriales en la vista activa |
|
18 |
PDF_format=Enlazar con ficheros PDF |
|
19 |
Remove_action=Eliminar acci?n |
|
20 |
Shows_image_files_in_gvSIG=Muestra im?genes en gvSIG |
|
21 |
Shows_HTML_or_text_files_in_gvSIG=Muestra ficheros HTML o de texto en gvSIG |
|
22 |
Shows_PDF_files_in_gvSIG=Muestra ficheros PDF en gvSIG |
|
23 |
Shows_SVG_files_in_gvSIG=Muestra ficheros SVG en gvSIG |
|
24 |
SVG_format=Enlazar con ficheros SVG |
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
0 | 29 |
trunk/extensions/extHyperlink/config/text_en.properties | ||
---|---|---|
1 |
#Translations for language [en] |
|
2 |
Action=Action |
|
3 |
Actions=Actions |
|
4 |
Add_action=Add action |
|
5 |
Advanced_Hyperlink=Advanced Hyperlink |
|
6 |
Campo=Field |
|
7 |
Enable_hyperlink=Enable hyperlink |
|
8 |
Extension=Extension |
|
9 |
HTML_and_text_formats=Link to text and HTML files |
|
10 |
Hyperlink=Hyperlink |
|
11 |
Hyperlink_Settings=Hyperlink Settings |
|
12 |
Hyperlink_settings=Hyperlink settings |
|
13 |
Image_format=Link to image files |
|
14 |
Load_Raster_Layer=Load raster layer |
|
15 |
Loads_raster_layers_in_gvSIG=Loads raster layers in active view |
|
16 |
Load_Vector_Layer=Load Vector Layer |
|
17 |
Loads_vector_layers_in_gvSIG=Loads vector layers in active view |
|
18 |
PDF_format=Link to PDF files |
|
19 |
Remove_action=Remove action |
|
20 |
Shows_image_files_in_gvSIG=Shows image files in gvSIG |
|
21 |
Shows_HTML_or_text_files_inside_gvSIG=Shows HTML or text files in gvSIG |
|
22 |
Shows_PDF_files_in_gvSIG=Shows PDF files in gvSIG |
|
23 |
Shows_SVG_files_in_gvSIG=Shows SVG files in gvSIG |
|
24 |
SVG_format=Link to SVG files |
|
0 | 25 |
trunk/extensions/extHyperlink/config/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<libraries library-dir="."/> |
|
4 |
<depends plugin-name="com.iver.cit.gvsig"/> |
|
5 |
<resourceBundle name="text"/> |
|
6 |
<extensions> |
|
7 |
<extension class-name="org.gvsig.hyperlink.LinkControls" |
|
8 |
description="Manages the advanced hyperlink." |
|
9 |
active="true" |
|
10 |
priority="20"> |
|
11 |
<menu text="Capa/Advanced_Hyperlink" action-command="HYPERLINK" icon="images/Link.png" position="5040"/> |
|
12 |
<tool-bar name="View_Tools_Query" position="5"> |
|
13 |
<selectable-tool icon="view-query-link" action-command="HYPERLINK" tooltip="Advanced_Hyperlink" position="7"/> |
|
14 |
</tool-bar> |
|
15 |
</extension> |
|
16 |
<!-- <extension class-name="org.gvsig.hyperlink.LinkConfigExtension" |
|
17 |
description="Manages the advanced hyperlink." |
|
18 |
active="true" |
|
19 |
priority="10" |
|
20 |
enable-text="Select one vectorial layer in TOC to activate"> |
|
21 |
<menu text="Capa/Hyperlink_settings" action-command="LINK_SETTINGS" icon="view-query-link" position="5045"/> |
|
22 |
</extension> --> |
|
23 |
</extensions> |
|
24 |
</plugin-config> |
|
0 | 25 |
trunk/extensions/extHyperlink/build.number | ||
---|---|---|
1 |
#Build Number for ANT. Do not edit! |
|
2 |
#Wed Apr 16 12:43:36 CEST 2008 |
|
3 |
build.number=1229 |
trunk/extensions/extHyperlink/lib/copyright.txt | ||
---|---|---|
1 |
The following libraries are used in the project: |
|
2 |
|
|
3 |
- JPEDAL: A library to show PDF files. |
|
4 |
Homepage: http://www.jpedal.org/ |
|
5 |
License: GPL (http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt) |
|
6 |
|
|
7 |
- Bouncy Castle Crypto API (bcprov): A Java cryptography library, used by |
|
8 |
JPEDAL to open encrypted PDFs. |
|
9 |
Homepage: http://www.bouncycastle.org/ |
|
10 |
License: |
|
11 |
Copyright (c) 2000 - 2006 |
|
12 |
The Legion Of The Bouncy Castle (http://www.bouncycastle.org) |
|
13 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
14 |
of this software and associated documentation files (the "Software"), to deal |
|
15 |
in the Software without restriction, including without limitation the rights |
|
16 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
17 |
copies of the Software, and to permit persons to whom the Software is |
|
18 |
furnished to do so, subject to the following conditions: |
|
19 |
The above copyright notice and this permission notice shall be included in all |
|
20 |
copies or substantial portions of the Software. |
|
21 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
22 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
23 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
24 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
25 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
26 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
27 |
SOFTWARE. |
|
0 | 28 |
trunk/extensions/extHyperlink/src/org/gvsig/hyperlink/config/LayerLinkConfig.java | ||
---|---|---|
1 |
package org.gvsig.hyperlink.config; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
import com.iver.utiles.IPersistence; |
|
6 |
import com.iver.utiles.XMLEntity; |
|
7 |
|
|
8 |
public class LayerLinkConfig implements IPersistence { |
|
9 |
protected ArrayList<LinkConfig> linkList; |
|
10 |
protected boolean enabled; |
|
11 |
|
|
12 |
public LayerLinkConfig() { |
|
13 |
linkList = new ArrayList<LinkConfig>(); |
|
14 |
} |
|
15 |
|
|
16 |
public void addLink(LinkConfig config) { |
|
17 |
linkList.add(config); |
|
18 |
} |
|
19 |
|
|
20 |
public void addLink(int position, LinkConfig config) { |
|
21 |
linkList.add(position, config); |
|
22 |
} |
|
23 |
|
|
24 |
public void addLink(String actionCode, String fieldName) { |
|
25 |
linkList.add(new LinkConfig(actionCode, fieldName)); |
|
26 |
} |
|
27 |
|
|
28 |
public void addLink(String actionCode, String fieldName, String extension) { |
|
29 |
linkList.add(new LinkConfig(actionCode, fieldName, extension)); |
|
30 |
} |
|
31 |
|
|
32 |
public LinkConfig removeLink(int linkIndex) { |
|
33 |
try { |
|
34 |
return linkList.remove(linkIndex); |
|
35 |
} |
|
36 |
catch (IndexOutOfBoundsException ex) { |
|
37 |
return null; |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
41 |
public LinkConfig getLink(int index) { |
|
42 |
return linkList.get(index); |
|
43 |
} |
|
44 |
|
|
45 |
public int linkCount() { |
|
46 |
return linkList.size(); |
|
47 |
} |
|
48 |
|
|
49 |
public String getClassName() { |
|
50 |
return this.getClass().getName(); |
|
51 |
} |
|
52 |
|
|
53 |
public boolean isEnabled() { |
|
54 |
return enabled; |
|
55 |
} |
|
56 |
|
|
57 |
public void setEnabled(boolean enabled) { |
|
58 |
this.enabled = enabled; |
|
59 |
} |
|
60 |
|
|
61 |
public XMLEntity getXMLEntity() { |
|
62 |
XMLEntity xmlconfig = new XMLEntity(); |
|
63 |
xmlconfig.putProperty("className", this.getClassName()); |
|
64 |
xmlconfig.putProperty("enabled", isEnabled()); |
|
65 |
for (int i=0; i<linkList.size(); i++) { |
|
66 |
xmlconfig.addChild(linkList.get(i).getXMLEntity()); |
|
67 |
} |
|
68 |
return xmlconfig; |
|
69 |
} |
|
70 |
|
|
71 |
public void setXMLEntity(XMLEntity xml) { |
|
72 |
if (xml.contains("enabled")) { |
|
73 |
setEnabled(xml.getBooleanProperty("enabled")); |
|
74 |
} |
|
75 |
else { |
|
76 |
setEnabled(false); |
|
77 |
} |
|
78 |
for (int i=0; i<xml.getChildrenCount(); i++) { |
|
79 |
LinkConfig link = LinkConfig.createFromXMLEntity(xml.getChild(i)); |
|
80 |
linkList.add(link); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
} |
|
0 | 85 |
trunk/extensions/extHyperlink/src/org/gvsig/hyperlink/config/LinkConfig.java | ||
---|---|---|
1 |
package org.gvsig.hyperlink.config; |
|
2 |
|
|
3 |
import com.iver.utiles.IPersistence; |
|
4 |
import com.iver.utiles.XMLEntity; |
|
5 |
|
|
6 |
public class LinkConfig implements IPersistence { |
|
7 |
private String fieldName; |
|
8 |
private String extension = ""; |
|
9 |
private String actionCode; |
|
10 |
|
|
11 |
protected LinkConfig() { |
|
12 |
} |
|
13 |
|
|
14 |
public LinkConfig(String actionCode, String fieldName) { |
|
15 |
this.actionCode = actionCode; |
|
16 |
this.fieldName = fieldName; |
|
17 |
} |
|
18 |
|
|
19 |
public LinkConfig(String actionCode, String fieldName, String extension) { |
|
20 |
this.actionCode = actionCode; |
|
21 |
this.fieldName = fieldName; |
|
22 |
this.extension = extension; |
|
23 |
} |
|
24 |
|
|
25 |
public String getFieldName() { |
|
26 |
return fieldName; |
|
27 |
} |
|
28 |
|
|
29 |
public String getActionCode() { |
|
30 |
return actionCode; |
|
31 |
} |
|
32 |
|
|
33 |
public void setFieldName(String fieldName) { |
|
34 |
this.fieldName = fieldName; |
|
35 |
} |
|
36 |
|
|
37 |
public void setActionCode(String actionCode) { |
|
38 |
this.actionCode = actionCode; |
|
39 |
} |
|
40 |
|
|
41 |
public void setExtension(String extension) { |
|
42 |
this.extension = extension; |
|
43 |
} |
|
44 |
|
|
45 |
public String getExtension() { |
|
46 |
return extension; |
|
47 |
} |
|
48 |
|
|
49 |
public String getClassName() { |
|
50 |
return this.getClass().getName(); |
|
51 |
} |
|
52 |
|
|
53 |
public XMLEntity getXMLEntity() { |
|
54 |
XMLEntity xml = new XMLEntity(); |
|
55 |
xml.putProperty("className", this.getClassName()); |
|
56 |
xml.putProperty("actionCode", getActionCode()); |
|
57 |
xml.putProperty("fieldName", getFieldName()); |
|
58 |
xml.putProperty("extension", getExtension()); |
|
59 |
return xml; |
|
60 |
} |
|
61 |
|
|
62 |
public void setXMLEntity(XMLEntity xml) { |
|
63 |
if (xml.contains("actionCode")) { |
|
64 |
setActionCode(xml.getStringProperty("actionCode")); |
|
65 |
} |
|
66 |
else { |
|
67 |
setActionCode(""); |
|
68 |
} |
|
69 |
if (xml.contains("fieldName")) { |
|
70 |
setFieldName(xml.getStringProperty("fieldName")); |
|
71 |
} |
|
72 |
else { |
|
73 |
setFieldName(""); |
|
74 |
} |
|
75 |
if (xml.contains("extension")) { |
|
76 |
setExtension(xml.getStringProperty("extension")); |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
public static LinkConfig createFromXMLEntity(XMLEntity xml) { |
|
81 |
LinkConfig link = new LinkConfig(); |
|
82 |
link.setXMLEntity(xml); |
|
83 |
return link; |
|
84 |
} |
|
85 |
} |
|
0 | 86 |
trunk/extensions/extHyperlink/src/org/gvsig/hyperlink/config/gui/ConfigTab.java | ||
---|---|---|
1 |
package org.gvsig.hyperlink.config.gui; |
|
2 |
|
|
3 |
import java.awt.GridBagConstraints; |
|
4 |
import java.awt.GridBagLayout; |
|
5 |
import java.awt.Insets; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
import java.awt.event.ItemEvent; |
|
9 |
import java.awt.event.ItemListener; |
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.Iterator; |
|
12 |
|
|
13 |
import javax.swing.BorderFactory; |
|
14 |
import javax.swing.JButton; |
|
15 |
import javax.swing.JCheckBox; |
|
16 |
import javax.swing.JPanel; |
|
17 |
import javax.swing.JScrollPane; |
|
18 |
import javax.swing.border.EtchedBorder; |
|
19 |
import javax.swing.border.TitledBorder; |
|
20 |
|
|
21 |
import org.gvsig.hyperlink.ILinkActionManager; |
|
22 |
import org.gvsig.hyperlink.LinkControls; |
|
23 |
import org.gvsig.hyperlink.config.LayerLinkConfig; |
|
24 |
import org.gvsig.hyperlink.config.LinkConfig; |
|
25 |
import org.gvsig.hyperlink.layers.ILinkLayerManager; |
|
26 |
import org.gvsig.hyperlink.layers.IncompatibleLayerException; |
|
27 |
import org.gvsig.hyperlink.layers.ManagerRegistry; |
|
28 |
|
|
29 |
import com.iver.andami.PluginServices; |
|
30 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
31 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
32 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
33 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.AbstractThemeManagerPage; |
|
34 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
|
35 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
36 |
|
|
37 |
public class ConfigTab extends AbstractThemeManagerPage implements IWindow, ActionListener, ItemListener { |
|
38 |
FLayer layer; |
|
39 |
ArrayList rows = new ArrayList(); |
|
40 |
JPanel rowList = null; |
|
41 |
GridBagLayout listLayout = null; |
|
42 |
String[] actionCodes = null; |
|
43 |
String[] actionNames = null; |
|
44 |
WindowInfo _windowInfo = null; |
|
45 |
JButton jbt_accept = null, jbt_cancel = null; |
|
46 |
JPanel emptyRow; |
|
47 |
JCheckBox jcb_enabled = null; |
|
48 |
JPanel borderPanel = null; |
|
49 |
JButton jbt_addAction = null, jbt_removeAction=null; |
|
50 |
|
|
51 |
public ConfigTab() { |
|
52 |
super(); |
|
53 |
initialize(); |
|
54 |
} |
|
55 |
|
|
56 |
private void initialize() { |
|
57 |
this.setLayout(new GridBagLayout()); |
|
58 |
|
|
59 |
Insets insets = new Insets(8, 8, 8, 8); |
|
60 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
61 |
constraints.gridx = 0; |
|
62 |
constraints.gridy = 0; |
|
63 |
constraints.weightx = 1.0; |
|
64 |
constraints.fill = GridBagConstraints.NONE; |
|
65 |
constraints.insets = insets; |
|
66 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
67 |
this.add(getEnabledCheckBox(), constraints); |
|
68 |
|
|
69 |
borderPanel = new JPanel(new GridBagLayout()); |
|
70 |
borderPanel.setBorder(BorderFactory.createTitledBorder( |
|
71 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
|
72 |
PluginServices.getText(this, "Actions"), |
|
73 |
TitledBorder.DEFAULT_JUSTIFICATION, |
|
74 |
TitledBorder.DEFAULT_POSITION, null, null) |
|
75 |
); |
|
76 |
|
|
77 |
insets = new Insets(8, 8, 8, 8); |
|
78 |
constraints = new GridBagConstraints(); |
|
79 |
constraints.gridx = 0; |
|
80 |
constraints.gridy = 0; |
|
81 |
constraints.weightx = 1.0; |
|
82 |
constraints.fill = GridBagConstraints.NONE; |
|
83 |
constraints.insets = insets; |
|
84 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
85 |
borderPanel.add(getAddRemoveActionsPanel(), constraints); |
|
86 |
|
|
87 |
listLayout = new GridBagLayout(); |
|
88 |
rowList = new JPanel(listLayout); |
|
89 |
|
|
90 |
constraints.gridx = 0; |
|
91 |
constraints.gridy = 0; |
|
92 |
constraints.weightx = 1.0; |
|
93 |
constraints.weighty = 1.0; |
|
94 |
constraints.fill = GridBagConstraints.NONE; |
|
95 |
constraints.insets = insets; |
|
96 |
constraints.anchor = GridBagConstraints.SOUTH; |
|
97 |
emptyRow = new JPanel(); |
|
98 |
rowList.add(emptyRow, constraints); |
|
99 |
|
|
100 |
JScrollPane scrolledList = new JScrollPane(); |
|
101 |
scrolledList.setBorder(null); |
|
102 |
scrolledList.setViewportView(rowList); |
|
103 |
|
|
104 |
constraints.gridx = 0; |
|
105 |
constraints.gridy = 1; |
|
106 |
constraints.weightx = 1.0; |
|
107 |
constraints.weighty = 1.0; |
|
108 |
constraints.fill = GridBagConstraints.BOTH; |
|
109 |
constraints.insets = insets; |
|
110 |
constraints.anchor = GridBagConstraints.CENTER; |
|
111 |
borderPanel.add(scrolledList, constraints); |
|
112 |
|
|
113 |
constraints.gridx = 0; |
|
114 |
constraints.gridy = 1; |
|
115 |
constraints.weightx = 1.0; |
|
116 |
constraints.weighty = 1.0; |
|
117 |
constraints.fill = GridBagConstraints.BOTH; |
|
118 |
constraints.insets = insets; |
|
119 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
120 |
this.add(borderPanel, constraints); |
|
121 |
|
|
122 |
// initAcceptCancelButtons(); uncomment this if you want to use this window outside the ThemeManager |
|
123 |
} |
|
124 |
|
|
125 |
private void initAcceptCancelButtons() { |
|
126 |
JPanel acceptCancelButtons = new JPanel(new GridBagLayout()); |
|
127 |
Insets insets = new Insets(14, 4, 8, 8); |
|
128 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
129 |
constraints.gridx = 0; |
|
130 |
constraints.gridy = 0; |
|
131 |
constraints.weightx = 1.0; |
|
132 |
constraints.fill = GridBagConstraints.NONE; |
|
133 |
constraints.insets = insets; |
|
134 |
constraints.anchor = GridBagConstraints.EAST; |
|
135 |
acceptCancelButtons.add(getAcceptButton(), constraints); |
|
136 |
|
|
137 |
constraints.gridx = 1; |
|
138 |
constraints.gridy = 0; |
|
139 |
constraints.weightx = 0.0; |
|
140 |
constraints.fill = GridBagConstraints.NONE; |
|
141 |
constraints.insets = insets; |
|
142 |
constraints.anchor = GridBagConstraints.EAST; |
|
143 |
acceptCancelButtons.add(getCancelButton(), constraints); |
|
144 |
|
|
145 |
constraints.gridx = 0; |
|
146 |
constraints.gridy = 2; |
|
147 |
constraints.weightx = 0.0; |
|
148 |
constraints.fill = GridBagConstraints.NONE; |
|
149 |
constraints.insets = insets; |
|
150 |
constraints.anchor = GridBagConstraints.SOUTHEAST; |
|
151 |
this.add(acceptCancelButtons, constraints); |
|
152 |
} |
|
153 |
|
|
154 |
private String[] getActionNames() { |
|
155 |
if (actionNames==null) { |
|
156 |
ExtensionPoint actions = (ExtensionPoint) ExtensionPointsSingleton.getInstance().get("HyperLinkAction"); |
|
157 |
String[] actionArray = new String[actions.size()]; |
|
158 |
Iterator actionsIter = actions.values().iterator(); |
|
159 |
int i = 0; |
|
160 |
while (actionsIter.hasNext()) { |
|
161 |
ILinkActionManager action = (ILinkActionManager) actionsIter.next(); |
|
162 |
actionArray[i++] = action.getName(); |
|
163 |
} |
|
164 |
actionNames = actionArray; |
|
165 |
} |
|
166 |
return actionNames; |
|
167 |
} |
|
168 |
|
|
169 |
private String[] getActionCodes() { |
|
170 |
if (actionCodes==null) { |
|
171 |
ExtensionPoint actions = (ExtensionPoint) ExtensionPointsSingleton.getInstance().get("HyperLinkAction"); |
|
172 |
String[] actionArray = new String[actions.size()]; |
|
173 |
Iterator actionsIter = actions.values().iterator(); |
|
174 |
int i = 0; |
|
175 |
while (actionsIter.hasNext()) { |
|
176 |
ILinkActionManager action = (ILinkActionManager) actionsIter.next(); |
|
177 |
actionArray[i++] = action.getActionCode(); |
|
178 |
} |
|
179 |
actionCodes = actionArray; |
|
180 |
} |
|
181 |
return actionCodes; |
|
182 |
} |
|
183 |
|
|
184 |
private String[] getCandidateFields() { |
|
185 |
LinkControls ext = (LinkControls) PluginServices.getExtension(LinkControls.class); |
|
186 |
ManagerRegistry registry = ext.getLayerManager(); |
|
187 |
try { |
|
188 |
ILinkLayerManager manager; |
|
189 |
manager = registry.get(layer); |
|
190 |
manager.setLayer(layer); |
|
191 |
return manager.getFieldCandidates(); |
|
192 |
} catch (InstantiationException e) { |
|
193 |
PluginServices.getLogger().warn("Hyperlink: error getting candidate fields", e); |
|
194 |
} catch (IllegalAccessException e) { |
|
195 |
PluginServices.getLogger().warn("Hyperlink: error getting candidate fields", e); |
|
196 |
} catch (ClassNotFoundException e) { |
|
197 |
PluginServices.getLogger().warn("Hyperlink: error getting candidate fields", e); |
|
198 |
} catch (IncompatibleLayerException e) { |
|
199 |
PluginServices.getLogger().warn("Hyperlink: error getting candidate fields", e); |
|
200 |
} |
|
201 |
return new String[0]; |
|
202 |
} |
|
203 |
|
|
204 |
public void acceptAction() { |
|
205 |
applyAction(); |
|
206 |
} |
|
207 |
|
|
208 |
public void applyAction() { |
|
209 |
LayerLinkConfig config = new LayerLinkConfig(); |
|
210 |
for (int i=0; i<rows.size(); i++) { |
|
211 |
LinkRow row = (LinkRow) rows.get(i); |
|
212 |
config.addLink(getActionCodes()[row.getSelectedAction()], row.getSelectedField(), row.getExtension()); |
|
213 |
} |
|
214 |
config.setEnabled(getEnabledCheckBox().isSelected()); |
|
215 |
layer.setProperty(LinkControls.LAYERPROPERTYNAME, config); |
|
216 |
} |
|
217 |
|
|
218 |
public void cancelAction() { |
|
219 |
} |
|
220 |
|
|
221 |
|
|
222 |
public String getName() { |
|
223 |
return PluginServices.getText(this,"Hyperlink"); |
|
224 |
} |
|
225 |
|
|
226 |
public void setModel(FLayer layer) { |
|
227 |
this.layer = layer; |
|
228 |
synchronized (rows) { |
|
229 |
LinkControls ext = (LinkControls) PluginServices.getExtension(LinkControls.class); |
|
230 |
LayerLinkConfig layerConfig = ext.loadLegacyConfig(layer); |
|
231 |
for (int i=rows.size()-1; i>=0; i--) { // clean rows |
|
232 |
LinkRow row = (LinkRow) rows.remove(i); |
|
233 |
rowList.remove(row); |
|
234 |
} |
|
235 |
|
|
236 |
if (layerConfig!=null) { |
|
237 |
for (int i=0; i<layerConfig.linkCount(); i++) { |
|
238 |
LinkRow row = addRow(); |
|
239 |
LinkConfig config = layerConfig.getLink(i); |
|
240 |
String selectedAction = config.getActionCode(); |
|
241 |
String[] actions = getActionCodes(); |
|
242 |
for (int j=0; j<actions.length; j++) { |
|
243 |
if (actions[j].equals(selectedAction)) { |
|
244 |
row.setSelectedAction(j); |
|
245 |
} |
|
246 |
} |
|
247 |
row.setSelectedField(config.getFieldName()); |
|
248 |
row.setExtension(config.getExtension()); |
|
249 |
} |
|
250 |
if (layerConfig.linkCount()<1) { |
|
251 |
addRow(); //just one row by default |
|
252 |
} |
|
253 |
setLinkEnabled(layerConfig.isEnabled()); |
|
254 |
} |
|
255 |
else { |
|
256 |
addRow(); //just one row by default |
|
257 |
setLinkEnabled(false); |
|
258 |
} |
|
259 |
} |
|
260 |
} |
|
261 |
|
|
262 |
protected JPanel getAddRemoveActionsPanel(){ |
|
263 |
JPanel container = new JPanel(); |
|
264 |
container.add(getAddActionButton()); |
|
265 |
container.add(getRemoveActionButton()); |
|
266 |
return container; |
|
267 |
} |
|
268 |
|
|
269 |
protected LinkRow addRow(){ |
|
270 |
LinkRow row = new LinkRow(); |
|
271 |
row.setFields(getCandidateFields()); |
|
272 |
row.setActions(getActionNames()); |
|
273 |
synchronized (rows) { |
|
274 |
rows.add(row); |
|
275 |
|
|
276 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
277 |
constraints.gridx = 0; |
|
278 |
constraints.gridy = rows.size()-1; |
|
279 |
constraints.weightx = 1.0; |
|
280 |
constraints.weighty = 0.0; |
|
281 |
constraints.fill = GridBagConstraints.HORIZONTAL; |
|
282 |
constraints.insets = new Insets(2,4,2,4); |
|
283 |
constraints.anchor = GridBagConstraints.NORTH; |
|
284 |
rowList.add(row, constraints); |
|
285 |
|
|
286 |
constraints = new GridBagConstraints(); |
|
287 |
constraints.gridx = 0; |
|
288 |
constraints.gridy = rows.size(); |
|
289 |
constraints.weightx = 1.0; |
|
290 |
constraints.weighty = 1.0; |
|
291 |
constraints.fill = GridBagConstraints.NONE; |
|
292 |
constraints.anchor = GridBagConstraints.CENTER; |
|
293 |
listLayout.setConstraints(emptyRow, constraints); |
|
294 |
} |
|
295 |
validate(); |
|
296 |
return row; |
|
297 |
} |
|
298 |
|
|
299 |
protected boolean removeBottomRow() { |
|
300 |
LinkRow row; |
|
301 |
synchronized (rows) { |
|
302 |
if (rows.size()<=1) |
|
303 |
return false; |
|
304 |
row = (LinkRow) rows.get(rows.size()-1); |
|
305 |
rows.remove(rows.size()-1); |
|
306 |
} |
|
307 |
rowList.remove(row); |
|
308 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
309 |
constraints.gridx = 0; |
|
310 |
constraints.gridy = rows.size(); |
|
311 |
constraints.weightx = 1.0; |
|
312 |
constraints.weighty = 1.0; |
|
313 |
constraints.fill = GridBagConstraints.NONE; |
|
314 |
constraints.anchor = GridBagConstraints.CENTER; |
|
315 |
listLayout.setConstraints(emptyRow, constraints); |
|
316 |
|
|
317 |
validate(); |
|
318 |
repaint(); |
|
319 |
return true; |
|
320 |
} |
|
321 |
|
|
322 |
protected JButton getAddActionButton() { |
|
323 |
if (jbt_addAction==null) { |
|
324 |
jbt_addAction = new JButton(PluginServices.getText(this, "Add_action")); |
|
325 |
jbt_addAction.setSize(150, 70); |
|
326 |
jbt_addAction.setActionCommand("addButton"); |
|
327 |
jbt_addAction.addActionListener(new ActionListener() { |
|
328 |
|
|
329 |
public void actionPerformed(ActionEvent e) { |
|
330 |
if (e.getActionCommand().equals("addButton")) { |
|
331 |
addRow(); |
|
332 |
} |
|
333 |
} |
|
334 |
} |
|
335 |
); |
|
336 |
} |
|
337 |
return jbt_addAction; |
|
338 |
} |
|
339 |
|
|
340 |
protected JButton getRemoveActionButton() { |
|
341 |
if (jbt_removeAction==null) { |
|
342 |
jbt_removeAction = new JButton(PluginServices.getText(this, "Remove_action")); |
|
343 |
jbt_removeAction.setActionCommand("removeButton"); |
|
344 |
jbt_removeAction.addActionListener(new ActionListener() { |
|
345 |
|
|
346 |
public void actionPerformed(ActionEvent e) { |
|
347 |
if (e.getActionCommand().equals("removeButton")) { |
|
348 |
removeBottomRow(); |
|
349 |
} |
|
350 |
} |
|
351 |
} |
|
352 |
); |
|
353 |
return jbt_removeAction; |
|
354 |
} |
|
355 |
return jbt_removeAction; |
|
356 |
} |
|
357 |
|
|
358 |
public WindowInfo getWindowInfo() { |
|
359 |
if (_windowInfo == null) { |
|
360 |
_windowInfo = new WindowInfo(WindowInfo.ICONIFIABLE | WindowInfo.MAXIMIZABLE | WindowInfo.RESIZABLE); |
|
361 |
_windowInfo.setWidth(680); |
|
362 |
_windowInfo.setHeight(500); |
|
363 |
_windowInfo.setTitle(PluginServices.getText(this, "Hyperlink_Settings")); |
|
364 |
} |
|
365 |
return _windowInfo; |
|
366 |
} |
|
367 |
|
|
368 |
protected JButton getAcceptButton() { |
|
369 |
if (jbt_accept==null) { |
|
370 |
jbt_accept = new org.gvsig.gui.beans.swing.JButton(PluginServices.getText(this, "Aceptar")); |
|
371 |
jbt_accept.addActionListener(this); |
|
372 |
} |
|
373 |
return jbt_accept; |
|
374 |
} |
|
375 |
|
|
376 |
protected JButton getCancelButton() { |
|
377 |
if (jbt_cancel==null) { |
|
378 |
jbt_cancel = new org.gvsig.gui.beans.swing.JButton(PluginServices.getText(this, "Cancel")); |
|
379 |
jbt_cancel.addActionListener(this); |
|
380 |
} |
|
381 |
return jbt_cancel; |
|
382 |
} |
|
383 |
|
|
384 |
protected JCheckBox getEnabledCheckBox() { |
|
385 |
if (jcb_enabled==null) { |
|
386 |
jcb_enabled = new JCheckBox(PluginServices.getText(this, "Enable_hyperlink"), true); |
|
387 |
jcb_enabled.addItemListener(this); |
|
388 |
} |
|
389 |
return jcb_enabled; |
|
390 |
} |
|
391 |
|
|
392 |
public void actionPerformed(ActionEvent e) { |
|
393 |
if (e.getSource()==getAcceptButton()) { |
|
394 |
acceptAction(); |
|
395 |
PluginServices.getMDIManager().closeWindow(this); |
|
396 |
|
|
397 |
} |
|
398 |
else if (e.getSource()==getCancelButton()) { |
|
399 |
cancelAction(); |
|
400 |
PluginServices.getMDIManager().closeWindow(this); |
|
401 |
} |
|
402 |
} |
|
403 |
|
|
404 |
protected void setListEnabled(boolean enabled) { |
|
405 |
getAddActionButton().setEnabled(enabled); |
|
406 |
getRemoveActionButton().setEnabled(enabled); |
|
407 |
synchronized (rows) { |
|
408 |
for (int i=0; i<rows.size(); i++) { |
|
409 |
LinkRow row = (LinkRow)rows.get(i); |
|
410 |
row.setEnabled(enabled); |
|
411 |
} |
|
412 |
} |
|
413 |
} |
|
414 |
|
|
415 |
protected void setLinkEnabled(boolean enabled) { |
|
416 |
getEnabledCheckBox().setSelected(enabled); |
|
417 |
setListEnabled(enabled); |
|
418 |
} |
|
419 |
|
|
420 |
public void itemStateChanged(ItemEvent e) { |
|
421 |
if (e.getSource()==getEnabledCheckBox()) { |
|
422 |
if (e.getStateChange()==ItemEvent.DESELECTED) { |
|
423 |
setListEnabled(false); |
|
424 |
} |
|
425 |
else { |
|
426 |
setListEnabled(true); |
|
427 |
} |
|
428 |
} |
|
429 |
} |
|
430 |
|
|
431 |
|
|
432 |
public Object getWindowProfile() { |
|
433 |
return WindowInfo.DIALOG_PROFILE; |
|
434 |
} |
|
435 |
} |
|
0 | 436 |
trunk/extensions/extHyperlink/src/org/gvsig/hyperlink/config/gui/LinkRow.java | ||
---|---|---|
1 |
package org.gvsig.hyperlink.config.gui; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Dimension; |
|
5 |
|
|
6 |
import javax.swing.BorderFactory; |
|
7 |
import javax.swing.JComboBox; |
|
8 |
import javax.swing.JLabel; |
|
9 |
import javax.swing.JPanel; |
|
10 |
import javax.swing.JTextField; |
|
11 |
import javax.swing.border.BevelBorder; |
|
12 |
|
|
13 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
14 |
|
|
15 |
import com.iver.andami.PluginServices; |
|
16 |
|
|
17 |
public class LinkRow extends JPanel { |
|
18 |
JPanel pnlFieldAndExtension = null; |
|
19 |
JPanel pnlHyperLinkAction = null; |
|
20 |
JLabel lblLinkExtension = null; |
|
21 |
JLabel lblLinkField = null; |
|
22 |
JLabel lblDefaultAction = null; |
|
23 |
JTextField txtLinkExtension = null; |
|
24 |
JComboBox cmbLinkField = null; |
|
25 |
JComboBox cmbLinkType = null; |
|
26 |
|
|
27 |
public LinkRow() { |
|
28 |
super(); |
|
29 |
initialize(); |
|
30 |
} |
|
31 |
|
|
32 |
private void initialize() { |
|
33 |
GridBagLayoutPanel aux = new GridBagLayoutPanel(); |
|
34 |
aux.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
|
35 |
aux.addComponent(getPnlFieldAndExtension(), getPnlHyperLinkAction()); |
|
36 |
this.setLayout(new BorderLayout()); |
|
37 |
this.add(aux, BorderLayout.CENTER); |
|
38 |
} |
|
39 |
|
|
40 |
public String getSelectedField() { |
|
41 |
return (String) getCmbLinkField().getSelectedItem(); |
|
42 |
} |
|
43 |
|
|
44 |
public void setFields(String[] fields) { |
|
45 |
for (int i=0; i<fields.length; i++) { |
|
46 |
getCmbLinkField().addItem(fields[i]); |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
public void setSelectedField(String field) { |
|
51 |
getCmbLinkField().setSelectedItem(field); |
|
52 |
} |
|
53 |
|
|
54 |
public int getSelectedAction() { |
|
55 |
return getCmbLinkType().getSelectedIndex(); |
|
56 |
} |
|
57 |
|
|
58 |
public String getSelectedActionName() { |
|
59 |
return (String) getCmbLinkType().getSelectedItem(); |
|
60 |
} |
|
61 |
|
|
62 |
public void setActions(String[] actions) { |
|
63 |
for (int i=0; i<actions.length; i++) { |
|
64 |
getCmbLinkType().addItem(actions[i]); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
public void setSelectedAction(String action) { |
|
69 |
getCmbLinkType().setSelectedItem(action); |
|
70 |
} |
|
71 |
|
|
72 |
public void setSelectedAction(int action) { |
|
73 |
getCmbLinkType().setSelectedIndex(action); |
|
74 |
} |
|
75 |
|
|
76 |
public String getExtension() { |
|
77 |
return getTxtLinkExtension().getText(); |
|
78 |
} |
|
79 |
|
|
80 |
public void setExtension(String extension) { |
|
81 |
getTxtLinkExtension().setText(extension); |
|
82 |
} |
|
83 |
|
|
84 |
private JPanel getPnlFieldAndExtension() { |
|
85 |
if (pnlFieldAndExtension == null) { |
|
86 |
lblLinkExtension = new JLabel(); |
|
87 |
lblLinkExtension.setText(" \t \t"+PluginServices.getText(this,"Extension")); |
|
88 |
lblLinkField = new JLabel(); |
|
89 |
lblLinkField.setText(PluginServices.getText(this, "Campo")); |
|
90 |
pnlFieldAndExtension = new JPanel(); |
|
91 |
pnlFieldAndExtension.add(lblLinkField, null); |
|
92 |
pnlFieldAndExtension.add(getCmbLinkField(), null); |
|
93 |
pnlFieldAndExtension.add(lblLinkExtension, null); |
|
94 |
pnlFieldAndExtension.add(getTxtLinkExtension(), null); |
|
95 |
} |
|
96 |
return pnlFieldAndExtension; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* This method initializes jPanel8. This panel contains the ComboBox to select |
|
101 |
* the action, (type of HyperLink) |
|
102 |
* |
|
103 |
* @return javax.swing.JPanel |
|
104 |
*/ |
|
105 |
private JPanel getPnlHyperLinkAction() { |
|
106 |
if (pnlHyperLinkAction == null) { |
|
107 |
lblDefaultAction = new JLabel(); |
|
108 |
lblDefaultAction.setText(PluginServices.getText(this, "Action") + " "); |
|
109 |
pnlHyperLinkAction = new JPanel(); |
|
110 |
pnlHyperLinkAction.add(lblDefaultAction, null); |
|
111 |
pnlHyperLinkAction.add(getCmbLinkType(), null); |
|
112 |
} |
|
113 |
return pnlHyperLinkAction; |
|
114 |
} |
|
115 |
/** |
|
116 |
* This method initializes jComboBox |
|
117 |
* |
|
118 |
* @return javax.swing.JComboBox |
|
119 |
*/ |
|
120 |
private JComboBox getCmbLinkField() { |
|
121 |
if (cmbLinkField == null) { |
|
122 |
cmbLinkField = new JComboBox(); |
|
123 |
} |
|
124 |
return cmbLinkField; |
|
125 |
} |
|
126 |
/** |
|
127 |
* This method initializes jTextField |
|
128 |
* |
|
129 |
* @return javax.swing.JTextField |
|
130 |
*/ |
|
131 |
private JTextField getTxtLinkExtension() { |
|
132 |
if (txtLinkExtension == null) { |
|
133 |
txtLinkExtension = new JTextField(); |
|
134 |
txtLinkExtension.setPreferredSize(new Dimension(40,20)); |
|
135 |
} |
|
136 |
return txtLinkExtension; |
|
137 |
} |
|
138 |
/** |
|
139 |
* This method initializes jComboBox1 |
|
140 |
* |
|
141 |
* @return javax.swing.JComboBox |
|
142 |
*/ |
|
143 |
private JComboBox getCmbLinkType() { |
|
144 |
if (cmbLinkType == null) { |
|
145 |
cmbLinkType = new JComboBox(); |
|
146 |
|
|
147 |
} |
|
148 |
return cmbLinkType; |
|
149 |
} |
|
150 |
|
|
151 |
public void setEnabled(boolean enabled) { |
|
152 |
super.setEnabled(enabled); |
|
153 |
getTxtLinkExtension().setEnabled(enabled); |
|
154 |
getCmbLinkField().setEnabled(enabled); |
|
155 |
getCmbLinkType().setEnabled(enabled); |
|
156 |
lblLinkField.setEnabled(enabled); |
|
157 |
lblDefaultAction.setEnabled(enabled); |
|
158 |
lblLinkExtension.setEnabled(enabled); |
|
159 |
} |
|
160 |
} |
|
0 | 161 |
trunk/extensions/extHyperlink/src/org/gvsig/hyperlink/AbstractHyperLinkPanel.java | ||
---|---|---|
1 |
package org.gvsig.hyperlink; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
import java.net.URI; |
|
6 |
|
|
7 |
import javax.swing.JPanel; |
|
8 |
|
|
9 |
import com.iver.andami.PluginServices; |
|
10 |
|
|
11 |
/** |
|
12 |
* This class extends JPanel and implements IExtensioBuilder. Provides the methods that will |
|
13 |
* be reimplemented by the descendant class. Creates a panel that shows the content of a |
|
14 |
* URI. The necessary code that allows to show the content of the URI is provided by the |
|
15 |
* descendant class. Implmenting IExtenssionBuilder this class and its the descendant |
|
16 |
* provides a point of extension for other extensions. |
|
17 |
*/ |
|
18 |
public abstract class AbstractHyperLinkPanel extends JPanel { |
|
19 |
protected URI document; |
|
20 |
public AbstractHyperLinkPanel(URI doc) { |
|
21 |
super(); |
|
22 |
document = doc; |
|
23 |
} |
|
24 |
|
|
25 |
public URI getURI() { |
|
26 |
return document; |
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* Tries to make an absolute url from a relative one, |
|
31 |
* and returns true if the URL is valid. |
|
32 |
* false otherwise |
|
33 |
* @return |
|
34 |
*/ |
|
35 |
protected boolean checkAndNormalizeURI() { |
|
36 |
if (document==null) { |
|
37 |
PluginServices.getLogger().warn(PluginServices.getText(this, "Hyperlink_linked_field_doesnot_exist")); |
|
38 |
return false; |
|
39 |
} |
|
40 |
else if (!document.isAbsolute()) { |
|
41 |
try { |
|
42 |
// try as a relative path |
|
43 |
File file = new File(document.toString()).getCanonicalFile(); |
|
44 |
if (!file.exists()) { |
|
45 |
PluginServices.getLogger().warn(PluginServices.getText(this, "Hyperlink_linked_field_doesnot_exist")); |
|
46 |
return false; |
|
47 |
} |
|
48 |
document = file.toURI(); |
|
49 |
} catch (IOException e) { |
|
50 |
PluginServices.getLogger().warn(PluginServices.getText(this, "Hyperlink_linked_field_doesnot_exist")); |
|
51 |
return false; |
|
52 |
} |
|
53 |
} |
|
54 |
return true; |
|
55 |
} |
|
56 |
} |
|
0 | 57 |
trunk/extensions/extHyperlink/src/org/gvsig/hyperlink/AbstractActionManager.java | ||
---|---|---|
1 |
package org.gvsig.hyperlink; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
public abstract class AbstractActionManager implements ILinkActionManager { |
|
8 |
public boolean hasPanel() { |
|
9 |
return false; |
|
10 |
} |
|
11 |
|
|
12 |
public Object create() { |
|
13 |
return this; |
|
14 |
} |
|
15 |
|
|
16 |
public Object create(Object[] args) { |
|
17 |
return this; |
|
18 |
} |
|
19 |
|
|
20 |
public Object create(Map args) { |
|
21 |
return this; |
|
22 |
} |
|
23 |
|
|
24 |
} |
|
0 | 25 |
trunk/extensions/extHyperlink/src/org/gvsig/hyperlink/ILinkActionManager.java | ||
---|---|---|
1 |
package org.gvsig.hyperlink; |
|
2 |
|
|
3 |
import java.net.URI; |
|
4 |
|
|
5 |
import com.iver.utiles.extensionPoints.IExtensionBuilder; |
|
6 |
|
|
7 |
/** |
|
8 |
* TODO document this interface |
|
9 |
* This interface must be implemented by format managers for the |
|
10 |
* hyperlink tool. A manager is able to load an specific file, either |
|
11 |
* by loading it in an AbstractHyperLinkPanel or by opening the proper |
|
12 |
* program to do the task. |
|
13 |
* |
|
14 |
* Format managers must be registered in the ExtensionPoint named |
|
15 |
* "HyperLinkAction" in order to be available in the HyperLink tool. |
|
16 |
* |
|
17 |
* @author cesar |
|
18 |
* |
|
19 |
*/ |
|
20 |
public interface ILinkActionManager extends IExtensionBuilder { |
|
21 |
|
|
22 |
public void showDocument(URI doc) throws UnsupportedOperationException; |
|
23 |
|
|
24 |
public boolean hasPanel(); |
|
25 |
|
|
26 |
public AbstractHyperLinkPanel createPanel(URI doc) throws UnsupportedOperationException; |
|
27 |
|
|
28 |
public String getActionCode(); |
|
29 |
|
|
30 |
public String getName(); |
|
31 |
|
|
32 |
public String getDescription(); |
|
33 |
} |
|
0 | 34 |
trunk/extensions/extHyperlink/src/org/gvsig/hyperlink/layers/ILinkLayerManager.java | ||
---|---|---|
1 |
package org.gvsig.hyperlink.layers; |
|
2 |
|
|
3 |
import java.awt.geom.Point2D; |
|
4 |
import java.net.URI; |
|
5 |
|
|
6 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
7 |
|
|
8 |
public interface ILinkLayerManager { |
|
9 |
public void setLayer(FLayer layer) throws IncompatibleLayerException; |
|
10 |
|
|
11 |
public FLayer getLayer(); |
|
12 |
//public AbstractLinkProperties getLinkProperties(); |
|
13 |
|
|
14 |
public URI[] getLink(Point2D point, double tolerance, String fieldName, String fileExtension); |
|
15 |
|
|
16 |
public URI[][] getLink(Point2D point, double tolerance, String[] fieldName, String fileExtension); |
|
17 |
|
|
18 |
public String[] getFieldCandidates(); |
|
19 |
} |
|
0 | 20 |
trunk/extensions/extHyperlink/src/org/gvsig/hyperlink/layers/IncompatibleLayerException.java | ||
---|---|---|
1 |
package org.gvsig.hyperlink.layers; |
|
2 |
|
|
3 |
public class IncompatibleLayerException extends Exception { |
|
4 |
|
|
5 |
public IncompatibleLayerException(Throwable ex) { |
|
6 |
super(ex); |
|
7 |
} |
|
8 |
|
|
9 |
} |
|
0 | 10 |
trunk/extensions/extHyperlink/src/org/gvsig/hyperlink/layers/ManagerRegistry.java | ||
---|---|---|
1 |
package org.gvsig.hyperlink.layers; |
|
2 |
|
|
3 |
import java.util.Comparator; |
|
4 |
import java.util.HashMap; |
|
5 |
import java.util.HashSet; |
|
6 |
import java.util.Iterator; |
|
7 |
import java.util.TreeSet; |
|
8 |
|
|
9 |
import com.iver.andami.PluginServices; |
|
10 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
11 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
|
12 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
13 |
|
|
14 |
public class ManagerRegistry{ |
|
15 |
public static final String EXTENSIONPOINTNAME = "hyperlink.layer.manager"; |
|
16 |
private ExtensionPoint extensionPoint; |
|
17 |
/** |
|
18 |
* We will cache the proper manager for each class, so that we don't calculate the right one everytime. |
|
19 |
* This assumes that no manager will be added after extensions' initialize() method, otherwise the |
|
20 |
* cached values will be incorrect. |
|
21 |
*/ |
|
22 |
private HashMap<Class, String> cachedManagers; |
|
23 |
/** |
|
24 |
* We will also cache the unmanaged layers (layers without managers). |
|
25 |
*/ |
|
26 |
private HashSet<Class> cachedUnmanagedLayers; |
|
27 |
|
|
28 |
public ManagerRegistry() { |
|
29 |
extensionPoint = new ExtensionPoint(EXTENSIONPOINTNAME, "Registers ILinkToolManagers that are able to manage specific layer types."); |
|
30 |
ExtensionPointsSingleton.getInstance().put(extensionPoint); |
|
31 |
cachedManagers = new HashMap<Class, String>(); |
|
32 |
cachedUnmanagedLayers = new HashSet<Class>(); |
|
33 |
} |
|
34 |
|
|
35 |
public void put(Class layerType, Class manager) { |
|
36 |
if (layerType.isInterface()) { |
|
37 |
throw new RuntimeException("Interfaces are not supported"); |
|
38 |
} |
|
39 |
if (!ILinkLayerManager.class.isAssignableFrom(manager)) { |
|
40 |
throw new RuntimeException("Managers must be of type ILinkLayerManager"); |
|
41 |
} |
|
42 |
extensionPoint.put(layerType.getName(), manager); |
|
43 |
} |
|
44 |
|
|
45 |
public ILinkLayerManager get(FLayer layer) throws ClassNotFoundException, InstantiationException, |
|
46 |
IllegalAccessException, IncompatibleLayerException { |
|
47 |
if (cachedManagers.containsKey(layer.getClass())) { |
|
48 |
String layerType = cachedManagers.get(layer.getClass()); |
|
49 |
ILinkLayerManager manager = (ILinkLayerManager) extensionPoint.create(layerType); |
|
50 |
manager.setLayer(layer); |
|
51 |
return manager; |
|
52 |
} |
|
53 |
else if (cachedUnmanagedLayers.contains(layer.getClass())) { |
|
54 |
return null; |
|
55 |
} |
|
56 |
// search for proper manager for this class |
|
57 |
Iterator<String> iterator = extensionPoint.keySet().iterator(); |
|
58 |
TreeSet<Class> classList = new TreeSet<Class>(new ClassComparator()); |
|
59 |
while (iterator.hasNext()) { |
|
60 |
String layerType = iterator.next(); |
|
61 |
Class layerClass = Class.forName(layerType); |
|
62 |
if (layerClass.isInstance(layer)) { |
|
63 |
classList.add(layerClass); |
|
64 |
} |
|
65 |
} |
|
66 |
if (!classList.isEmpty()) { |
|
67 |
ILinkLayerManager manager = (ILinkLayerManager) extensionPoint.create(classList.first().getName()); |
|
68 |
cachedManagers.put(layer.getClass(), classList.first().getName()); |
|
69 |
manager.setLayer(layer); |
|
70 |
return manager; |
|
71 |
} |
|
72 |
else { |
|
73 |
cachedUnmanagedLayers.add(layer.getClass()); |
|
74 |
return null; |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
public boolean hasManager(FLayer layer){ |
|
79 |
if (cachedManagers.containsKey(layer.getClass())) { |
|
80 |
return true; |
|
81 |
} |
|
82 |
else if (cachedUnmanagedLayers.contains(layer.getClass())) { |
|
83 |
return false; |
|
84 |
} |
|
85 |
Iterator<String> iterator = extensionPoint.keySet().iterator(); |
|
86 |
while (iterator.hasNext()) { |
|
87 |
String layerType = iterator.next(); |
|
88 |
try { |
|
89 |
Class layerClass = Class.forName(layerType); |
|
90 |
if (layerClass.isInstance(layer)) { |
|
91 |
// there is a manager for this layer class |
|
92 |
return true; |
|
93 |
} |
|
94 |
} |
|
95 |
catch (ClassNotFoundException ex) { |
|
96 |
PluginServices.getLogger().error(ex); |
|
97 |
} |
|
98 |
} |
|
99 |
cachedUnmanagedLayers.add(layer.getClass()); |
|
100 |
return false; |
|
101 |
} |
|
102 |
|
|
103 |
private class ClassComparator implements Comparator<Class> { |
|
104 |
|
|
105 |
public int compare(Class class1, Class class2) { |
|
106 |
if (class1.equals(class2)) |
|
107 |
return 0; |
|
108 |
if (class1.isAssignableFrom(class2)) { |
|
109 |
return 1; |
|
110 |
} |
|
111 |
else { |
|
112 |
return -1; |
|
113 |
} |
|
114 |
} |
|
115 |
} |
|
116 |
} |
|
0 | 117 |
Also available in: Unified diff