Revision 144

View differences:

org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.hyperlink.app</artifactId>
6
	<packaging>pom</packaging>
7
	<version>1.0.25</version>
8
	<name>${project.artifactId}</name>
9
	<description>View. Hyperlink support</description>
10
	
11
    <parent>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.desktop</artifactId>
14
        <version>2.0.126</version>
15
    </parent>
16
        
17
	<url>https://devel.gvsig.org/redmine/projects/gvsig-hyperlink</url>
18
	
19
    <scm>
20
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-hyperlink/org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25</connection>
21
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-hyperlink/org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25</developerConnection>
22
        <url>scm:svn:https://devel.gvsig.org/svn/gvsig-hyperlink/org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25</url>
23
    </scm>
24
    
25
	<build>
26
        <plugins>
27
		    <plugin>
28
		      <artifactId>maven-release-plugin</artifactId>
29
		      <configuration>
30
		        <tagBase>https://devel.gvsig.org/svn/gvsig-hyperlink/org.gvsig.hyperlink.app/tags</tagBase>
31
		      </configuration>
32
		    </plugin>			
33
     
34
        </plugins>   
35
    </build>
36
    
37
	<developers>
38
		<developer>
39
			<id>jjdelcerro</id>
40
			<name>Joaqu?n Jos? del Cerro</name>
41
			<email>jjdelcerro@gvsig.org</email>
42
			<roles>
43
				<role>Architect</role>
44
				<role>Developer</role>
45
			</roles>
46
		</developer>
47
		<developer>
48
			<id>cordinyana</id>
49
			<name>C?sar Ordi?ana</name>
50
			<email>cordinyana@gvsig.com</email>
51
			<roles>
52
				<role>Architect</role>
53
				<role>Developer</role>
54
			</roles>
55
		</developer>
56
	</developers>
57
	<distributionManagement>
58
		<site>
59
			<id>gvsig-repository</id>
60
            <url>dav:https://devel.gvsig.org/sites/org.gvsig.hyperlink.app/${project.version}</url>
61
		</site>
62
	</distributionManagement>
63
	<repositories>
64
		<repository>
65
			<id>gvsig-public-http-repository</id>
66
			<name>gvSIG maven public HTTP repository</name>
67
			<url>http://devel.gvsig.org/m2repo/j2se</url>
68
			<releases>
69
				<enabled>true</enabled>
70
				<updatePolicy>daily</updatePolicy>
71
				<checksumPolicy>warn</checksumPolicy>
72
			</releases>
73
			<snapshots>
74
				<enabled>true</enabled>
75
				<updatePolicy>daily</updatePolicy>
76
				<checksumPolicy>warn</checksumPolicy>
77
			</snapshots>
78
		</repository>
79
	</repositories>
80
	<modules>
81
		<module>org.gvsig.hyperlink.app.extension</module>
82
	</modules>
83
</project>
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/org.gvsig.hyperlink.app.extension/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25
<!-- org.gvsig.app.mainplugin provides these libraries
26
  <dependencySets>
27
  
28
    <dependencySet>
29
      <useProjectArtifact>false</useProjectArtifact>
30
      <useTransitiveDependencies>false</useTransitiveDependencies>
31
      <outputDirectory>lib</outputDirectory>
32
      <includes>
33
            <include>org.jpedal:jpedal_lgpl</include>
34
            <include>com.sun:jimi</include>
35
            <include>org.apache.xmlgraphics:batik-gvt</include>
36
            <include>org.apache.xmlgraphics:batik-bridge</include>
37
            <include>org.apache.xmlgraphics:batik-script</include>
38
            <include>xml-apis:xml-apis-ext</include>
39
      </includes>
40
    </dependencySet>
41
  </dependencySets>
42
-->
43

  
44
</assembly>
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/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
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/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.fastIterator();
73
                Object val = null;
74

  
75
                while (it.hasNext()) {
76
                    Feature feature = (Feature) it.next();
77
                    val = feature.get(fieldName);
78
                    String fieldValue = (val == null) ? "" : val.toString();
79
                    if (!fieldValue.equals("")) {
80
                        try {
81
                            uriList.add(getURI(fieldValue, fileExtension));
82
                        } catch (URISyntaxException e) {
83
                            NotificationManager.addWarning(PluginServices.getText(this,
84
                                "Hyperlink__field_value_is_not_valid_file"),
85
                                e);
86
                        }
87
                    }
88

  
89
                }
90
                it.dispose();
91
                return (URI[]) uriList.toArray(new URI[0]);
92
            } catch (DataException e1) {
93
                PluginServices.getLogger()
94
                    .error("Hyperlink__cant_get_the_iterator", e1);
95
            }
96
        }
97
        return new URI[0];
98
    }
99

  
100
    protected URI getURI(String baseURI, String extension) throws URISyntaxException {
101
        String stringURI;
102
        if (extension.equals("")) {
103
            stringURI = baseURI;
104
        } else
105
            if (extension.startsWith(".")) {
106
                stringURI = baseURI + extension;
107
            } else {
108
                stringURI = baseURI + "." + extension;
109
            }
110
        File file = new File(stringURI);
111
        if (file.exists()) {
112
            return file.toURI();
113
        } else {
114
            return new URI(stringURI);
115
        }
116
    }
117

  
118
    public FLayer getLayer() {
119
        return _layer;
120
    }
121

  
122
    public void setLayer(FLayer layer) throws IncompatibleLayerException {
123
        try {
124
            _layer = (FLyrVect) layer;
125
        } catch (ClassCastException ex) {
126
            throw new IncompatibleLayerException(ex);
127
        }
128
    }
129

  
130
    public Object create() {
131
        return this;
132
    }
133

  
134
    public Object create(Object[] args) {
135
        return this;
136
    }
137

  
138
    public Object create(Map args) {
139
        return this;
140
    }
141

  
142
    public URI[][] getLink(Point2D point,
143
        double tolerance,
144
        String[] fieldName,
145
        String fileExtension) {
146
        FLyrVect lyrVect = (FLyrVect) _layer;
147
        FeatureSet features;
148
        FeatureType featureType;
149
        URI uri[][] = null;
150

  
151
        try {
152
            // FIXME: Habr? que ver como lo hacemos con las capas multigeometr?a
153
            featureType = _layer.getFeatureStore().getDefaultFeatureType();
154
            features = lyrVect.queryByPoint(point, tolerance, featureType);
155
        } catch (Exception e) {
156
            return null;
157
        }
158

  
159
        // Si el conjunto creado no est? vac?o creamos el vector de URLS
160
        // correspondientes
161
        // a la consulta que hemos hecho.
162

  
163
        if (features != null) {
164
            try {
165
                // Creo el vector de URL?s con la misma longitud que features
166
                uri = new URI[(int) features.getSize()][fieldName.length];
167

  
168
                // Recorremos las features siguiendo el ejemplo de la clase que
169
                // se
170
                // proporciona en la API
171
                int count = 0;
172
                DisposableIterator it = features.fastIterator();
173
                while (it.hasNext()) {
174
                    Feature feat = (Feature) it.next();
175
                    for (int fieldCount = 0; fieldCount < fieldName.length; fieldCount++) {
176
                        // get the field ID using the field name
177
                        String auxField =
178
                            feat.get(fieldName[fieldCount]).toString();
179
                        if (auxField != null) {
180
                            if (auxField.startsWith("http:/")) {
181
                                try {
182
                                    uri[count][fieldCount] = new URI(auxField);
183
                                } catch (URISyntaxException e) {
184
                                    PluginServices.getLogger().error("", e);
185
                                }
186
                            } else {
187
                                File file = new File(auxField);
188
                                uri[count][fieldCount] = file.toURI();
189
                            }
190
                        } else {
191
                            PluginServices.getLogger()
192
                                .error("Hyperlink error. Field "
193
                                    + fieldName[fieldCount] + "doesn't exist!!");
194
                            uri[count][fieldCount] = null;
195
                        }
196
                    }
197
                    count++;
198
                }
199
                it.dispose();
200

  
201
                return uri;
202
            } catch (DataException e) {
203
                PluginServices.getLogger().error("", e);
204
            }
205
        }
206
        return new URI[0][0];
207
    }
208

  
209
    public String[] getFieldCandidates() {
210
        try {
211
            FeatureType featureType =
212
                _layer.getFeatureStore().getDefaultFeatureType();
213
            ArrayList<String> fields = new ArrayList<String>();
214
            FeatureAttributeDescriptor[] descriptors =
215
                featureType.getAttributeDescriptors();
216
            for (int i = 0; i < descriptors.length; i++) {
217
                FeatureAttributeDescriptor descriptor = descriptors[i];
218
                if (descriptor.getDataType().isNumeric()
219
                    || descriptor.getDataType().getType() == DataTypes.STRING) {
220
                    fields.add(descriptor.getName());
221
                }
222
            }
223
            return (String[]) fields.toArray(new String[0]);
224
        } catch (DataException e) {
225
            NotificationManager.addError(PluginServices.getText(this,
226
                "Error_reading_layer_fields"), e);
227
        }
228
        return new String[0];
229
    }
230

  
231
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/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
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/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
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/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.fmap.mapcontext.layers.vectorial.FLyrVect;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.extensionpoint.ExtensionPoint;
35
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension;
36
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
37

  
38
public class ManagerRegistry {
39

  
40
    public static final String EXTENSIONPOINTNAME = "hyperlink.layer.manager";
41
    private ExtensionPoint extensionPoint;
42
    /**
43
     * We will cache the proper manager for each class, so that we don't
44
     * calculate the right one everytime.
45
     * This assumes that no manager will be added after extensions' initialize()
46
     * method, otherwise the
47
     * cached values will be incorrect.
48
     */
49
    private HashMap<Class, String> cachedManagers;
50
    /**
51
     * We will also cache the unmanaged layers (layers without managers).
52
     */
53
    private HashSet<Class> cachedUnmanagedLayers;
54

  
55
    public ManagerRegistry() {
56
        ExtensionPointManager epm = ToolsLocator.getExtensionPointManager();
57
        extensionPoint =
58
            epm.add(EXTENSIONPOINTNAME,
59
                "Registers ILinkToolManagers that are able to manage specific layer types.");
60
        cachedManagers = new HashMap<Class, String>();
61
        /*
62
         * Add vector layer
63
         * If we don't, persisted layers will not work well
64
         */
65
        cachedManagers.put(FLyrVect.class, FLyrVect.class.getName());
66

  
67
        cachedUnmanagedLayers = new HashSet<Class>();
68
    }
69

  
70
    public void put(Class layerType, Class manager) {
71
        if (layerType.isInterface()) {
72
            throw new RuntimeException("Interfaces are not supported");
73
        }
74
        if (!ILinkLayerManager.class.isAssignableFrom(manager)) {
75
            throw new RuntimeException("Managers must be of type ILinkLayerManager");
76
        }
77
        extensionPoint.append(layerType.getName(), "", manager);
78
    }
79

  
80
    public ILinkLayerManager get(FLayer layer) throws ClassNotFoundException,
81
        InstantiationException,
82
        IllegalAccessException,
83
        IncompatibleLayerException {
84
        if (cachedManagers.containsKey(layer.getClass())) {
85
            String layerType = cachedManagers.get(layer.getClass());
86
            ILinkLayerManager manager =
87
                (ILinkLayerManager) extensionPoint.create(layerType);
88
            manager.setLayer(layer);
89
            return manager;
90
        } else
91
            if (cachedUnmanagedLayers.contains(layer.getClass())) {
92
                return null;
93
            }
94
        // search for proper manager for this class
95
        Iterator it = extensionPoint.getNames().iterator();
96
        TreeSet<Class> classList = new TreeSet<Class>(new ClassComparator());
97
        while (it.hasNext()) {
98
            String layerType = it.next().toString();
99
            Class layerClass = Class.forName(layerType);
100
            if (layerClass.isInstance(layer)) {
101
                classList.add(layerClass);
102
            }
103
        }
104

  
105
        if (!classList.isEmpty()) {
106
            ILinkLayerManager manager =
107
                (ILinkLayerManager) extensionPoint.create(classList.first()
108
                    .getName());
109
            cachedManagers.put(layer.getClass(), classList.first().getName());
110
            manager.setLayer(layer);
111
            return manager;
112
        } else {
113
            cachedUnmanagedLayers.add(layer.getClass());
114
            return null;
115
        }
116
    }
117

  
118
    public boolean hasManager(FLayer layer) {
119
        if (cachedManagers.containsKey(layer.getClass())) {
120
            return true;
121
        } else
122
            if (cachedUnmanagedLayers.contains(layer.getClass())) {
123
                return false;
124
            }
125

  
126
        Iterator it = extensionPoint.iterator();
127
        while (it.hasNext()) {
128
            Class layerClass = ((Extension) it.next()).getExtension();
129
            if (layerClass.isInstance(layer)) {
130
                return true;
131
            }
132
        }
133

  
134
//        cachedUnmanagedLayers.add(layer.getClass());
135
        return false;
136
    }
137

  
138
    private class ClassComparator implements Comparator<Class> {
139

  
140
        public int compare(Class class1, Class class2) {
141
            if (class1.equals(class2))
142
                return 0;
143
            if (class1.isAssignableFrom(class2)) {
144
                return 1;
145
            } else {
146
                return -1;
147
            }
148
        }
149
    }
150
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/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
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/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
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/actions/PdfFormat.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 PdfFormat extends AbstractActionManager implements Serializable {
33

  
34
    public static final String actionCode = "PDF_format";
35

  
36
    public AbstractHyperLinkPanel createPanel(URI doc) throws UnsupportedOperationException {
37
        return new PdfHyperlinkPanel(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_PDF_files_in_gvSIG");
54
    }
55

  
56
    public String getName() {
57
        return PluginServices.getText(this, "PDF_format");
58
    }
59
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/actions/DesktopApi.java
1
package org.gvsig.hyperlink.app.extension.actions;
2

  
3
/*
4
 * Based on portions of code of MightyPork, http://www.ondrovo.com/
5
 * extracted from :
6
 * http://stackoverflow.com/questions/18004150/desktop-api-is-not-supported-on-the-current-platform
7
 */
8

  
9
import java.awt.Desktop;
10
import java.io.File;
11
import java.io.IOException;
12
import java.net.URI;
13
import java.util.ArrayList;
14
import java.util.List;
15
import org.slf4j.Logger;
16
import org.slf4j.LoggerFactory;
17

  
18
public class DesktopApi {
19

  
20
    private static Logger logger = LoggerFactory.getLogger(DesktopApi.class);
21

  
22
    public static boolean browse(URI uri) {
23

  
24
        if ( browseDESKTOP(uri) ) {
25
            return true;
26
        }
27

  
28
        if ( openSystemSpecific(uri.toString()) ) {
29
            return true;
30
        }
31

  
32
        return false;
33
    }
34

  
35
    public static boolean open(File file) {
36

  
37
        if ( openDESKTOP(file) ) {
38
            return true;
39
        }
40

  
41
        if ( openSystemSpecific(file.getPath()) ) {
42
            return true;
43
        }
44

  
45
        return false;
46
    }
47

  
48
    public static boolean edit(File file) {
49

  
50
        if ( editDESKTOP(file) ) {
51
            return true;
52
        }
53

  
54
        if ( openSystemSpecific(file.getPath()) ) {
55
            return true;
56
        }
57

  
58
        return false;
59
    }
60

  
61
    private static boolean openSystemSpecific(String what) {
62

  
63
        EnumOS os = getOs();
64

  
65
        if (os.isLinux()) {
66
//            if (runCommand("gnome-open", "%s", what)) {
67
//                return true;
68
//            }
69
//            if (runCommand("kde-open", "%s", what)) {
70
//                return true;
71
//            }
72
            if (runCommand("xdg-open", "%s", what)) {
73
                return true;
74
            }
75
        }
76

  
77
        if ( os.isMac() ) {
78
            if ( runCommand("open", "%s", what) ) {
79
                return true;
80
            }
81
        }
82

  
83
        if ( os.isWindows() ) {
84
            if ( runCommand("explorer", "%s", what) ) {
85
                return true;
86
            }
87
        }
88

  
89
        return false;
90
    }
91

  
92
    private static boolean browseDESKTOP(URI uri) {
93

  
94
        logOut("Trying to use Desktop.getDesktop().browse() with " + uri.toString());
95
        try {
96
            if ( !Desktop.isDesktopSupported() ) {
97
                logErr("Platform is not supported.");
98
                return false;
99
            }
100

  
101
            if ( !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE) ) {
102
                logErr("BROWSE is not supported.");
103
                return false;
104
            }
105

  
106
            Desktop.getDesktop().browse(uri);
107

  
108
            return true;
109
        } catch (Throwable t) {
110
            logErr("Error using desktop browse.", t);
111
            return false;
112
        }
113
    }
114

  
115
    private static boolean openDESKTOP(File file) {
116

  
117
        logOut("Trying to use Desktop.getDesktop().open() with " + file.toString());
118
        try {
119
            if ( !Desktop.isDesktopSupported() ) {
120
                logErr("Platform is not supported.");
121
                return false;
122
            }
123

  
124
            if ( !Desktop.getDesktop().isSupported(Desktop.Action.OPEN) ) {
125
                logErr("OPEN is not supported.");
126
                return false;
127
            }
128

  
129
            Desktop.getDesktop().open(file);
130

  
131
            return true;
132
        } catch (Throwable t) {
133
            logErr("Error using desktop open.", t);
134
            return false;
135
        }
136
    }
137

  
138
    private static boolean editDESKTOP(File file) {
139

  
140
        logOut("Trying to use Desktop.getDesktop().edit() with " + file);
141
        try {
142
            if ( !Desktop.isDesktopSupported() ) {
143
                logErr("Platform is not supported.");
144
                return false;
145
            }
146

  
147
            if ( !Desktop.getDesktop().isSupported(Desktop.Action.EDIT) ) {
148
                logErr("EDIT is not supported.");
149
                return false;
150
            }
151

  
152
            Desktop.getDesktop().edit(file);
153

  
154
            return true;
155
        } catch (Throwable t) {
156
            logErr("Error using desktop edit.", t);
157
            return false;
158
        }
159
    }
160

  
161
    private static boolean runCommand(String command, String args, String file) {
162

  
163
        logOut("Trying to exec:\n   cmd = " + command + "\n   args = " + args + "\n   %s = " + file);
164

  
165
        String[] parts = prepareCommand(command, args, file);
166

  
167
        try {
168
            Process p = Runtime.getRuntime().exec(parts);
169
            if ( p == null ) {
170
                return false;
171
            }
172

  
173
            try {
174
                int retval = p.exitValue();
175
                if ( retval == 0 ) {
176
                    logErr("Process ended immediately.");
177
                    return false;
178
                } else {
179
                    logErr("Process crashed.");
180
                    return false;
181
                }
182
            } catch (IllegalThreadStateException itse) {
183
                logErr("Process is running.");
184
                return true;
185
            }
186
        } catch (IOException e) {
187
            logErr("Error running command.", e);
188
            return false;
189
        }
190
    }
191

  
192
    private static String[] prepareCommand(String command, String args, String file) {
193

  
194
        List<String> parts = new ArrayList<String>();
195
        parts.add(command);
196

  
197
        if ( args != null ) {
198
            for ( String s : args.split(" ") ) {
199
                s = String.format(s, file); // put in the filename thing
200

  
201
                parts.add(s.trim());
202
            }
203
        }
204

  
205
        return parts.toArray(new String[parts.size()]);
206
    }
207

  
208
    private static void logErr(String msg, Throwable t) {
209
        logger.warn(msg,t);
210
    }
211

  
212
    private static void logErr(String msg) {
213
        logger.warn(msg);
214
    }
215

  
216
    private static void logOut(String msg) {
217
        logger.info(msg);
218
    }
219

  
220
    public static enum EnumOS {
221

  
222
        linux, macos, solaris, unknown, windows;
223

  
224
        public boolean isLinux() {
225

  
226
            return this == linux || this == solaris;
227
        }
228

  
229
        public boolean isMac() {
230

  
231
            return this == macos;
232
        }
233

  
234
        public boolean isWindows() {
235

  
236
            return this == windows;
237
        }
238
    }
239

  
240
    public static EnumOS getOs() {
241

  
242
        String s = System.getProperty("os.name").toLowerCase();
243

  
244
        if ( s.contains("win") ) {
245
            return EnumOS.windows;
246
        }
247

  
248
        if ( s.contains("mac") ) {
249
            return EnumOS.macos;
250
        }
251

  
252
        if ( s.contains("solaris") ) {
253
            return EnumOS.solaris;
254
        }
255

  
256
        if ( s.contains("sunos") ) {
257
            return EnumOS.solaris;
258
        }
259

  
260
        if ( s.contains("linux") ) {
261
            return EnumOS.linux;
262
        }
263

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

  
26
import java.awt.Desktop;
27
import java.io.File;
28
import java.io.IOException;
29
import java.io.Serializable;
30
import java.net.URI;
31
import javax.swing.JOptionPane;
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.hyperlink.app.extension.AbstractActionManager;
34
import org.gvsig.hyperlink.app.extension.AbstractHyperLinkPanel;
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

  
38
public class FolderFormat extends AbstractActionManager implements Serializable {
39

  
40
    /**
41
     *
42
     */
43
    private static final long serialVersionUID = 1L;
44
    public static final String actionCode = "Folder_format";
45
    private static Logger logger = LoggerFactory.getLogger(FolderFormat.class);
46

  
47
    public String getActionCode() {
48
        return actionCode;
49
    }
50

  
51
    public boolean hasPanel() {
52
        return false;
53
    }
54

  
55
    public void showDocument(URI doc) {
56
        File folder = new File(doc.getPath());
57
        if ( folder.exists() ) {
58
               DesktopApi.browse(doc);
59
//               DesktopApi.open(folder);
60
//             Desktop desktop = Desktop.getDesktop();
61
//             try {
62
//                desktop.open(folder);
63
//            } catch (IOException e1) {
64
//                logger.error("Can't open folder '" + folder.getAbsolutePath() + "'.", e1);
65
//            }
66

  
67
        } else {
68
            JOptionPane.showMessageDialog(null, PluginServices.getText(this, "Bad_path") + " : " + folder.getAbsolutePath());
69
        }
70
    }
71

  
72
    public String getDescription() {
73
        return PluginServices.getText(this, "Shows_Folders_in_gvSIG");
74
    }
75

  
76
    public String getName() {
77
        return PluginServices.getText(this, "Folder_formats");
78
    }
79

  
80
    public AbstractHyperLinkPanel createPanel(URI doc)
81
            throws UnsupportedOperationException {
82
        return null;
83
    }
84

  
85
}
86

  
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.25/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/actions/ImgFormat.java
1
/* gvSIG. Desktop Geographic Information System.
2

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

  
25
package org.gvsig.hyperlink.app.extension.actions;
26

  
27
import java.io.Serializable;
28
import java.net.URI;
29

  
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.hyperlink.app.extension.AbstractActionManager;
32
import org.gvsig.hyperlink.app.extension.AbstractHyperLinkPanel;
33

  
34
public class ImgFormat extends AbstractActionManager implements Serializable {
35

  
36
    /**
37
     *
38
     */
39
    private static final long serialVersionUID = -7625497033974714867L;
40
    public static final String actionCode = "Image_format";
41

  
42
    public AbstractHyperLinkPanel createPanel(URI doc) throws UnsupportedOperationException {
43
        return new ImgPanel(doc);
44
    }
45

  
46
    public String getActionCode() {
47
        return actionCode;
48
    }
49

  
50
    public boolean hasPanel() {
51
        return true;
52
    }
53

  
54
    public void showDocument(URI doc) {
55
        throw new UnsupportedOperationException();
56
    }
57

  
58
    public String getDescription() {
59
        return PluginServices.getText(this, "Shows_image_files_in_gvSIG");
60
    }
61

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff