Revision 446

View differences:

org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84/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.84</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.250</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.84</connection>
21
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-hyperlink/org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84</developerConnection>
22
        <url>scm:svn:https://devel.gvsig.org/svn/gvsig-hyperlink/org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84</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.84/org.gvsig.hyperlink.app.extension/buildNumber.properties
1
#Wed Oct 16 00:00:30 CEST 2019
2
buildNumber=2171
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84/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.84/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/LinkTarget.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.hyperlink.app.extension;
7

  
8
import java.net.URL;
9

  
10
/**
11
 *
12
 * @author osc
13
 */
14
public interface LinkTarget {
15
    public URL getURL();
16
    
17
    public void setURL(URL url);
18
    
19
    public Object getFromProfile();
20
    
21
    public String getProfileName();
22
    
23
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/config/LayerLinkConfig.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.config;
24

  
25
import java.util.ArrayList;
26
import java.util.List;
27

  
28
import org.gvsig.tools.ToolsLocator;
29
import org.gvsig.tools.dynobject.DynStruct;
30
import org.gvsig.tools.persistence.PersistenceManager;
31
import org.gvsig.tools.persistence.Persistent;
32
import org.gvsig.tools.persistence.PersistentState;
33
import org.gvsig.tools.persistence.exception.PersistenceException;
34
import org.gvsig.tools.util.Callable;
35

  
36
public class LayerLinkConfig implements Persistent {
37

  
38
    protected List<LinkConfig> linkList;
39
    protected boolean enabled;
40
    public static final String LAYERLINKCONFIG_PERSISTENCE_DEFINITION_NAME = "LayerLinkConfig";
41

  
42
    public LayerLinkConfig() {
43
        linkList = new ArrayList<LinkConfig>();
44
    }
45

  
46
    public void addLink(LinkConfig config) {
47
        linkList.add(config);
48
    }
49

  
50
    public void addLink(int position, LinkConfig config) {
51
        linkList.add(position, config);
52
    }
53

  
54
    public void addLink(String actionCode, String fieldName) {
55
        linkList.add(new LinkConfig(actionCode, fieldName));
56
    }
57

  
58
    public void addLink(String actionCode, String fieldName, String extension) {
59
        linkList.add(new LinkConfig(actionCode, fieldName, extension));
60
    }
61

  
62
    public LinkConfig removeLink(int linkIndex) {
63
        try {
64
            return linkList.remove(linkIndex);
65
        } catch (IndexOutOfBoundsException ex) {
66
            return null;
67
        }
68
    }
69

  
70
    public LinkConfig getLink(int index) {
71
        return linkList.get(index);
72
    }
73

  
74
    public int linkCount() {
75
        return linkList.size();
76
    }
77

  
78
    public String getClassName() {
79
        return this.getClass().getName();
80
    }
81

  
82
    public boolean isEnabled() {
83
        return enabled;
84
    }
85

  
86
    public void setEnabled(boolean enabled) {
87
        this.enabled = enabled;
88
    }
89

  
90
    public void saveToState(PersistentState state) throws PersistenceException {
91
        state.set("enabled", this.enabled);
92
        state.set("linkList", this.linkList);
93
    }
94

  
95
    @SuppressWarnings("unchecked")
96
    public void loadFromState(PersistentState state) throws PersistenceException {
97
        this.enabled = state.getBoolean("enabled");
98
        this.linkList = new ArrayList<LinkConfig>();
99
        this.linkList.addAll(state.getList("linkList"));
100
    }
101
    
102
    public static class RegisterPersistence implements Callable {
103

  
104
        public Object call() throws Exception {
105
            PersistenceManager manager = ToolsLocator.getPersistenceManager();
106
            if( manager.getDefinition(LAYERLINKCONFIG_PERSISTENCE_DEFINITION_NAME)==null ) {
107
                DynStruct definition = manager.addDefinition(
108
                        LayerLinkConfig.class,
109
                        LAYERLINKCONFIG_PERSISTENCE_DEFINITION_NAME,
110
                        LAYERLINKCONFIG_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
111
                        null, 
112
                        null
113
                );
114

  
115
                definition.addDynFieldBoolean("enabled").setMandatory(true);
116
                definition.addDynFieldList("linkList").setMandatory(false).setClassOfItems(LinkConfig.class);
117
            }
118
            return Boolean.TRUE;
119
        }
120
        
121
    }
122

  
123
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/config/LinkConfig.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.config;
24

  
25
import org.gvsig.tools.ToolsLocator;
26
import org.gvsig.tools.dynobject.DynStruct;
27
import org.gvsig.tools.persistence.PersistenceManager;
28
import org.gvsig.tools.persistence.Persistent;
29
import org.gvsig.tools.persistence.PersistentState;
30
import org.gvsig.tools.persistence.exception.PersistenceException;
31
import org.gvsig.tools.util.Callable;
32

  
33
public class LinkConfig implements Persistent {
34

  
35
    private String fieldName;
36
    private String extension = "";
37
    private String actionCode;
38
    public static final String LINKCONFIG_PERSISTENCE_DEFINITION_NAME = "LinkConfig";
39

  
40
    public LinkConfig() {
41
    }
42

  
43
    public LinkConfig(String actionCode, String fieldName) {
44
        this.actionCode = actionCode;
45
        this.fieldName = fieldName;
46
    }
47

  
48
    public LinkConfig(String actionCode, String fieldName, String extension) {
49
        this.actionCode = actionCode;
50
        this.fieldName = fieldName;
51
        this.extension = extension;
52
    }
53

  
54
    public String getFieldName() {
55
        return fieldName;
56
    }
57

  
58
    public String getActionCode() {
59
        return actionCode;
60
    }
61

  
62
    public void setFieldName(String fieldName) {
63
        this.fieldName = fieldName;
64
    }
65

  
66
    public void setActionCode(String actionCode) {
67
        this.actionCode = actionCode;
68
    }
69

  
70
    public void setExtension(String extension) {
71
        this.extension = extension;
72
    }
73

  
74
    public String getExtension() {
75
        return extension;
76
    }
77

  
78
    public String getClassName() {
79
        return this.getClass().getName();
80
    }
81

  
82
    public void saveToState(PersistentState state) throws PersistenceException {
83
        state.set("fieldName", this.fieldName);
84
        state.set("extension", this.extension);
85
        state.set("actionCode", this.actionCode);
86
    }
87

  
88
    public void loadFromState(PersistentState state) throws PersistenceException {
89
        this.fieldName = state.getString("fieldName");
90
        this.extension = state.getString("extension");
91
        this.actionCode = state.getString("actionCode");
92
    }
93
    
94
    public static class RegisterPersistence implements Callable {
95

  
96
        public Object call() throws Exception {
97
            PersistenceManager manager = ToolsLocator.getPersistenceManager();
98
            if( manager.getDefinition(LINKCONFIG_PERSISTENCE_DEFINITION_NAME)==null ) {
99
                DynStruct definition = manager.addDefinition(
100
                        LinkConfig.class,
101
                        LINKCONFIG_PERSISTENCE_DEFINITION_NAME,
102
                        LINKCONFIG_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
103
                        null, 
104
                        null
105
                );
106

  
107
                definition.addDynFieldString("fieldName").setMandatory(true);
108
                definition.addDynFieldString("extension").setMandatory(false);
109
                definition.addDynFieldString("actionCode").setMandatory(true);
110
            }
111
            return Boolean.TRUE;
112
        }
113
        
114
    }
115

  
116
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/config/gui/LinkRow.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.config.gui;
24

  
25
import java.awt.BorderLayout;
26
import java.awt.Dimension;
27

  
28
import javax.swing.BorderFactory;
29
import javax.swing.JComboBox;
30
import javax.swing.JLabel;
31
import javax.swing.JPanel;
32
import javax.swing.JTextField;
33
import javax.swing.border.BevelBorder;
34

  
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
37

  
38
public class LinkRow extends JPanel {
39

  
40
    JPanel pnlFieldAndExtension = null;
41
    JPanel pnlHyperLinkAction = null;
42
    JLabel lblLinkExtension = null;
43
    JLabel lblLinkField = null;
44
    JLabel lblDefaultAction = null;
45
    JTextField txtLinkExtension = null;
46
    JComboBox cmbLinkField = null;
47
    JComboBox cmbLinkType = null;
48

  
49
    public LinkRow() {
50
        super();
51
        initialize();
52
    }
53

  
54
    private void initialize() {
55
        GridBagLayoutPanel aux = new GridBagLayoutPanel();
56
        aux.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
57
        aux.addComponent(getPnlFieldAndExtension(), getPnlHyperLinkAction());
58
        this.setLayout(new BorderLayout());
59
        this.add(aux, BorderLayout.CENTER);
60
    }
61

  
62
    public String getSelectedField() {
63
        return (String) getCmbLinkField().getSelectedItem();
64
    }
65

  
66
    public void setFields(String[] fields) {
67
        for (int i = 0; i < fields.length; i++) {
68
            getCmbLinkField().addItem(fields[i]);
69
        }
70
    }
71

  
72
    public void setSelectedField(String field) {
73
        getCmbLinkField().setSelectedItem(field);
74
    }
75

  
76
    public int getSelectedAction() {
77
        return getCmbLinkType().getSelectedIndex();
78
    }
79

  
80
    public String getSelectedActionName() {
81
        return (String) getCmbLinkType().getSelectedItem();
82
    }
83

  
84
    public void setActions(String[] actions) {
85
        for (int i = 0; i < actions.length; i++) {
86
            getCmbLinkType().addItem(actions[i]);
87
        }
88
    }
89

  
90
    public void setSelectedAction(String action) {
91
        getCmbLinkType().setSelectedItem(action);
92
    }
93

  
94
    public void setSelectedAction(int action) {
95
        getCmbLinkType().setSelectedIndex(action);
96
    }
97

  
98
    public String getExtension() {
99
        return getTxtLinkExtension().getText();
100
    }
101

  
102
    public void setExtension(String extension) {
103
        getTxtLinkExtension().setText(extension);
104
    }
105

  
106
    private JPanel getPnlFieldAndExtension() {
107
        if (pnlFieldAndExtension == null) {
108
            lblLinkExtension = new JLabel();
109
            lblLinkExtension.setText(" \t \t"
110
                + PluginServices.getText(this, "Extension"));
111
            lblLinkField = new JLabel();
112
            lblLinkField.setText(PluginServices.getText(this, "Campo"));
113
            pnlFieldAndExtension = new JPanel();
114
            pnlFieldAndExtension.add(lblLinkField, null);
115
            pnlFieldAndExtension.add(getCmbLinkField(), null);
116
            pnlFieldAndExtension.add(lblLinkExtension, null);
117
            pnlFieldAndExtension.add(getTxtLinkExtension(), null);
118
        }
119
        return pnlFieldAndExtension;
120
    }
121

  
122
    /**
123
     * This method initializes jPanel8. This panel contains the ComboBox to
124
     * select
125
     * the action, (type of HyperLink)
126
     * 
127
     * @return javax.swing.JPanel
128
     */
129
    private JPanel getPnlHyperLinkAction() {
130
        if (pnlHyperLinkAction == null) {
131
            lblDefaultAction = new JLabel();
132
            lblDefaultAction.setText(PluginServices.getText(this, "Action")
133
                + "  ");
134
            pnlHyperLinkAction = new JPanel();
135
            pnlHyperLinkAction.add(lblDefaultAction, null);
136
            pnlHyperLinkAction.add(getCmbLinkType(), null);
137
        }
138
        return pnlHyperLinkAction;
139
    }
140

  
141
    /**
142
     * This method initializes jComboBox
143
     * 
144
     * @return javax.swing.JComboBox
145
     */
146
    private JComboBox getCmbLinkField() {
147
        if (cmbLinkField == null) {
148
            cmbLinkField = new JComboBox();
149
        }
150
        return cmbLinkField;
151
    }
152

  
153
    /**
154
     * This method initializes jTextField
155
     * 
156
     * @return javax.swing.JTextField
157
     */
158
    private JTextField getTxtLinkExtension() {
159
        if (txtLinkExtension == null) {
160
            txtLinkExtension = new JTextField();
161
            txtLinkExtension.setPreferredSize(new Dimension(40, 20));
162
        }
163
        return txtLinkExtension;
164
    }
165

  
166
    /**
167
     * This method initializes jComboBox1
168
     * 
169
     * @return javax.swing.JComboBox
170
     */
171
    private JComboBox getCmbLinkType() {
172
        if (cmbLinkType == null) {
173
            cmbLinkType = new JComboBox();
174

  
175
        }
176
        return cmbLinkType;
177
    }
178

  
179
    public void setEnabled(boolean enabled) {
180
        super.setEnabled(enabled);
181
        getTxtLinkExtension().setEnabled(enabled);
182
        getCmbLinkField().setEnabled(enabled);
183
        getCmbLinkType().setEnabled(enabled);
184
        lblLinkField.setEnabled(enabled);
185
        lblDefaultAction.setEnabled(enabled);
186
        lblLinkExtension.setEnabled(enabled);
187
    }
188
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/config/gui/ConfigTab.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.config.gui;
24

  
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.awt.Insets;
28
import java.awt.event.ActionEvent;
29
import java.awt.event.ActionListener;
30
import java.awt.event.ItemEvent;
31
import java.awt.event.ItemListener;
32
import java.util.ArrayList;
33

  
34
import javax.swing.BorderFactory;
35
import javax.swing.JButton;
36
import javax.swing.JCheckBox;
37
import javax.swing.JPanel;
38
import javax.swing.JScrollPane;
39
import javax.swing.border.EtchedBorder;
40
import javax.swing.border.TitledBorder;
41

  
42
import org.gvsig.andami.PluginServices;
43
import org.gvsig.andami.ui.mdiManager.IWindow;
44
import org.gvsig.andami.ui.mdiManager.WindowInfo;
45
import org.gvsig.app.project.documents.view.legend.gui.AbstractThemeManagerPage;
46
import org.gvsig.fmap.mapcontext.layers.FLayer;
47
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer;
48
import org.gvsig.hyperlink.app.extension.AbstractActionManager;
49
import org.gvsig.hyperlink.app.extension.HyperlinkExtension;
50
import org.gvsig.hyperlink.app.extension.config.LayerLinkConfig;
51
import org.gvsig.hyperlink.app.extension.config.LinkConfig;
52
import org.gvsig.hyperlink.app.extension.layers.ILinkLayerManager;
53
import org.gvsig.hyperlink.app.extension.layers.IncompatibleLayerException;
54
import org.gvsig.hyperlink.app.extension.layers.ManagerRegistry;
55
import org.gvsig.tools.ToolsLocator;
56
import org.gvsig.tools.extensionpoint.ExtensionPoint;
57

  
58
public class ConfigTab extends AbstractThemeManagerPage implements IWindow,
59
    ActionListener, ItemListener {
60

  
61
    FLayer layer;
62
    ArrayList rows = new ArrayList();
63
    JPanel rowList = null;
64
    GridBagLayout listLayout = null;
65
    private String[] actionCodes = null;
66
    private String[] actionNames = null;
67
    WindowInfo _windowInfo = null;
68
    JButton jbt_accept = null, jbt_cancel = null;
69
    JPanel emptyRow;
70
    JCheckBox jcb_enabled = null;
71
    JPanel borderPanel = null;
72
    JButton jbt_addAction = null, jbt_removeAction = null;
73

  
74
    public ConfigTab() {
75
        super();
76
        initialize();
77
    }
78

  
79
    private void initialize() {
80
        this.setLayout(new GridBagLayout());
81

  
82
        Insets insets = new Insets(8, 8, 8, 8);
83
        GridBagConstraints constraints = new GridBagConstraints();
84
        constraints.gridx = 0;
85
        constraints.gridy = 0;
86
        constraints.weightx = 1.0;
87
        constraints.fill = GridBagConstraints.NONE;
88
        constraints.insets = insets;
89
        constraints.anchor = GridBagConstraints.NORTHWEST;
90
        this.add(getEnabledCheckBox(), constraints);
91

  
92
        borderPanel = new JPanel(new GridBagLayout());
93
        borderPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
94
            PluginServices.getText(this, "Actions"),
95
            TitledBorder.DEFAULT_JUSTIFICATION,
96
            TitledBorder.DEFAULT_POSITION,
97
            null,
98
            null));
99

  
100
        insets = new Insets(8, 8, 8, 8);
101
        constraints = new GridBagConstraints();
102
        constraints.gridx = 0;
103
        constraints.gridy = 0;
104
        constraints.weightx = 1.0;
105
        constraints.fill = GridBagConstraints.NONE;
106
        constraints.insets = insets;
107
        constraints.anchor = GridBagConstraints.NORTHWEST;
108
        borderPanel.add(getAddRemoveActionsPanel(), constraints);
109

  
110
        listLayout = new GridBagLayout();
111
        rowList = new JPanel(listLayout);
112

  
113
        constraints.gridx = 0;
114
        constraints.gridy = 0;
115
        constraints.weightx = 1.0;
116
        constraints.weighty = 1.0;
117
        constraints.fill = GridBagConstraints.NONE;
118
        constraints.insets = insets;
119
        constraints.anchor = GridBagConstraints.SOUTH;
120
        emptyRow = new JPanel();
121
        rowList.add(emptyRow, constraints);
122

  
123
        JScrollPane scrolledList = new JScrollPane();
124
        scrolledList.setBorder(null);
125
        scrolledList.setViewportView(rowList);
126

  
127
        constraints.gridx = 0;
128
        constraints.gridy = 1;
129
        constraints.weightx = 1.0;
130
        constraints.weighty = 1.0;
131
        constraints.fill = GridBagConstraints.BOTH;
132
        constraints.insets = insets;
133
        constraints.anchor = GridBagConstraints.CENTER;
134
        borderPanel.add(scrolledList, constraints);
135

  
136
        constraints.gridx = 0;
137
        constraints.gridy = 1;
138
        constraints.weightx = 1.0;
139
        constraints.weighty = 1.0;
140
        constraints.fill = GridBagConstraints.BOTH;
141
        constraints.insets = insets;
142
        constraints.anchor = GridBagConstraints.NORTHWEST;
143
        this.add(borderPanel, constraints);
144

  
145
        // initAcceptCancelButtons(); uncomment this if you want to use this
146
        // window outside the ThemeManager
147
    }
148

  
149
    private void initAcceptCancelButtons() {
150
        JPanel acceptCancelButtons = new JPanel(new GridBagLayout());
151
        Insets insets = new Insets(14, 4, 8, 8);
152
        GridBagConstraints constraints = new GridBagConstraints();
153
        constraints.gridx = 0;
154
        constraints.gridy = 0;
155
        constraints.weightx = 1.0;
156
        constraints.fill = GridBagConstraints.NONE;
157
        constraints.insets = insets;
158
        constraints.anchor = GridBagConstraints.EAST;
159
        acceptCancelButtons.add(getAcceptButton(), constraints);
160

  
161
        constraints.gridx = 1;
162
        constraints.gridy = 0;
163
        constraints.weightx = 0.0;
164
        constraints.fill = GridBagConstraints.NONE;
165
        constraints.insets = insets;
166
        constraints.anchor = GridBagConstraints.EAST;
167
        acceptCancelButtons.add(getCancelButton(), constraints);
168

  
169
        constraints.gridx = 0;
170
        constraints.gridy = 2;
171
        constraints.weightx = 0.0;
172
        constraints.fill = GridBagConstraints.NONE;
173
        constraints.insets = insets;
174
        constraints.anchor = GridBagConstraints.SOUTHEAST;
175
        this.add(acceptCancelButtons, constraints);
176
    }
177

  
178
    private String[] getActionNames() {
179
        if (actionNames == null) {
180
            ExtensionPoint actions =
181
                ToolsLocator.getExtensionPointManager()
182
                    .get(HyperlinkExtension.ACTIONSEXTENSIONPOINT);
183

  
184
            String[] actionArray = new String[actions.getCount()];
185
            String[] codes = getActionCodes();
186
            for (int i = 0; i < codes.length; i++) {
187
                try {
188
                    AbstractActionManager aam =
189
                        (AbstractActionManager) actions.get(codes[i])
190
                            .getExtension()
191
                            .newInstance();
192
                    actionArray[i] = aam.getName();
193
                } catch (InstantiationException e) {
194
                    // TODO Auto-generated catch block
195
                    e.printStackTrace();
196
                } catch (IllegalAccessException e) {
197
                    // TODO Auto-generated catch block
198
                    e.printStackTrace();
199
                }
200
            }
201
            actionNames = actionArray;
202
        }
203
        return actionNames;
204
    }
205

  
206
    private String[] getActionCodes() {
207
        if (actionCodes == null) {
208
            ExtensionPoint actions =
209
                ToolsLocator.getExtensionPointManager()
210
                    .get(HyperlinkExtension.ACTIONSEXTENSIONPOINT);
211
            String[] actionArray = new String[actions.getCount()];
212
            actionArray = (String[]) actions.getNames().toArray(actionArray);
213
            actionCodes = actionArray;
214
        }
215
        return actionCodes;
216
    }
217

  
218
    private String[] getCandidateFields() {
219
        HyperlinkExtension ext =
220
            (HyperlinkExtension) PluginServices.getExtension(HyperlinkExtension.class);
221
        ManagerRegistry registry = ext.getLayerManager();
222
        try {
223
            ILinkLayerManager manager;
224
            manager = registry.get(layer);
225
            manager.setLayer(layer);
226
            return manager.getFieldCandidates();
227
        } catch (InstantiationException e) {
228
            PluginServices.getLogger()
229
                .warn("Hyperlink: error getting candidate fields", e);
230
        } catch (IllegalAccessException e) {
231
            PluginServices.getLogger()
232
                .warn("Hyperlink: error getting candidate fields", e);
233
        } catch (ClassNotFoundException e) {
234
            PluginServices.getLogger()
235
                .warn("Hyperlink: error getting candidate fields", e);
236
        } catch (IncompatibleLayerException e) {
237
            PluginServices.getLogger()
238
                .warn("Hyperlink: error getting candidate fields", e);
239
        } catch (NullPointerException e) {
240
            PluginServices.getLogger().warn("Hyperlink: error getting manager", e);
241
        }
242
        return new String[0];
243
    }
244

  
245
    public void acceptAction() {
246
        applyAction();
247
    }
248

  
249
    public void applyAction() {
250
        LayerLinkConfig config = new LayerLinkConfig();
251
        for (int i = 0; i < rows.size(); i++) {
252
            LinkRow row = (LinkRow) rows.get(i);
253
            
254
            if (row.getSelectedField() != null
255
                && row.getSelectedAction() != -1) {
256
                
257
                config.addLink(getActionCodes()[row.getSelectedAction()],
258
                    row.getSelectedField(),
259
                    row.getExtension());
260
            }
261
        }
262
        config.setEnabled(getEnabledCheckBox().isSelected());
263
        layer.setProperty(HyperlinkExtension.LAYERPROPERTYNAME, config);
264
    }
265

  
266
    public void cancelAction() {
267
    }
268

  
269
    public String getName() {
270
        return PluginServices.getText(this, "Hyperlink");
271
    }
272

  
273
    public void setModel(FLayer layer) {
274
        this.layer = layer;
275
        if( layer!=null && !layer.isAvailable() ) {
276
            setLinkEnabled(false);
277
            getEnabledCheckBox().setEnabled(false);
278
            return;
279
        }
280
        synchronized (rows) {
281
            HyperlinkExtension ext =
282
                (HyperlinkExtension) PluginServices.getExtension(HyperlinkExtension.class);
283
            LayerLinkConfig layerConfig = ext.loadLegacyConfig(layer);
284
            for (int i = rows.size() - 1; i >= 0; i--) { // clean rows
285
                LinkRow row = (LinkRow) rows.remove(i);
286
                rowList.remove(row);
287
            }
288

  
289
            if (layerConfig != null) {
290
                for (int i = 0; i < layerConfig.linkCount(); i++) {
291
                    LinkRow row = addRow();
292
                    LinkConfig config = layerConfig.getLink(i);
293
                    String selectedAction = config.getActionCode();
294
                    String[] actions = getActionCodes();
295
                    for (int j = 0; j < actions.length; j++) {
296
                        if (actions[j].equals(selectedAction)) {
297
                            row.setSelectedAction(j);
298
                        }
299
                    }
300
                    row.setSelectedField(config.getFieldName());
301
                    row.setExtension(config.getExtension());
302
                }
303
                if (layerConfig.linkCount() < 1) {
304
                    addRow(); // just one row by default
305
                }
306
                setLinkEnabled(layerConfig.isEnabled());
307
            } else {
308
                addRow(); // just one row by default
309
                setLinkEnabled(false);
310
            }
311
        }
312
    }
313

  
314
    protected JPanel getAddRemoveActionsPanel() {
315
        JPanel container = new JPanel();
316
        container.add(getAddActionButton());
317
        container.add(getRemoveActionButton());
318
        return container;
319
    }
320

  
321
    protected LinkRow addRow() {
322
        LinkRow row = new LinkRow();
323
        row.setFields(getCandidateFields());
324
        row.setActions(getActionNames());
325
        synchronized (rows) {
326
            rows.add(row);
327

  
328
            GridBagConstraints constraints = new GridBagConstraints();
329
            constraints.gridx = 0;
330
            constraints.gridy = rows.size() - 1;
331
            constraints.weightx = 1.0;
332
            constraints.weighty = 0.0;
333
            constraints.fill = GridBagConstraints.HORIZONTAL;
334
            constraints.insets = new Insets(2, 4, 2, 4);
335
            constraints.anchor = GridBagConstraints.NORTH;
336
            rowList.add(row, constraints);
337

  
338
            constraints = new GridBagConstraints();
339
            constraints.gridx = 0;
340
            constraints.gridy = rows.size();
341
            constraints.weightx = 1.0;
342
            constraints.weighty = 1.0;
343
            constraints.fill = GridBagConstraints.NONE;
344
            constraints.anchor = GridBagConstraints.CENTER;
345
            listLayout.setConstraints(emptyRow, constraints);
346
        }
347
        validate();
348
        return row;
349
    }
350

  
351
    protected boolean removeBottomRow() {
352
        LinkRow row;
353
        synchronized (rows) {
354
            if (rows.size() <= 1)
355
                return false;
356
            row = (LinkRow) rows.get(rows.size() - 1);
357
            rows.remove(rows.size() - 1);
358
        }
359
        rowList.remove(row);
360
        GridBagConstraints constraints = new GridBagConstraints();
361
        constraints.gridx = 0;
362
        constraints.gridy = rows.size();
363
        constraints.weightx = 1.0;
364
        constraints.weighty = 1.0;
365
        constraints.fill = GridBagConstraints.NONE;
366
        constraints.anchor = GridBagConstraints.CENTER;
367
        listLayout.setConstraints(emptyRow, constraints);
368

  
369
        validate();
370
        repaint();
371
        return true;
372
    }
373

  
374
    protected JButton getAddActionButton() {
375
        if (jbt_addAction == null) {
376
            jbt_addAction =
377
                new JButton(PluginServices.getText(this, "Add_action"));
378
            jbt_addAction.setSize(150, 70);
379
            jbt_addAction.setActionCommand("addButton");
380
            jbt_addAction.addActionListener(new ActionListener() {
381

  
382
                public void actionPerformed(ActionEvent e) {
383
                    if (e.getActionCommand().equals("addButton")) {
384
                        addRow();
385
                    }
386
                }
387
            });
388
        }
389
        return jbt_addAction;
390
    }
391

  
392
    protected JButton getRemoveActionButton() {
393
        if (jbt_removeAction == null) {
394
            jbt_removeAction =
395
                new JButton(PluginServices.getText(this, "Remove_action"));
396
            jbt_removeAction.setActionCommand("removeButton");
397
            jbt_removeAction.addActionListener(new ActionListener() {
398

  
399
                public void actionPerformed(ActionEvent e) {
400
                    if (e.getActionCommand().equals("removeButton")) {
401
                        removeBottomRow();
402
                    }
403
                }
404
            });
405
            return jbt_removeAction;
406
        }
407
        return jbt_removeAction;
408
    }
409

  
410
    public WindowInfo getWindowInfo() {
411
        if (_windowInfo == null) {
412
            _windowInfo =
413
                new WindowInfo(WindowInfo.ICONIFIABLE | WindowInfo.MAXIMIZABLE
414
                    | WindowInfo.RESIZABLE);
415
            _windowInfo.setWidth(680);
416
            _windowInfo.setHeight(500);
417
            _windowInfo.setTitle(PluginServices.getText(this,
418
                "Hyperlink_Settings"));
419
        }
420
        return _windowInfo;
421
    }
422

  
423
    protected JButton getAcceptButton() {
424
        if (jbt_accept == null) {
425
            jbt_accept =
426
                new org.gvsig.gui.beans.swing.JButton(PluginServices.getText(this,
427
                    "Aceptar"));
428
            jbt_accept.addActionListener(this);
429
        }
430
        return jbt_accept;
431
    }
432

  
433
    protected JButton getCancelButton() {
434
        if (jbt_cancel == null) {
435
            jbt_cancel =
436
                new org.gvsig.gui.beans.swing.JButton(PluginServices.getText(this,
437
                    "Cancel"));
438
            jbt_cancel.addActionListener(this);
439
        }
440
        return jbt_cancel;
441
    }
442

  
443
    protected JCheckBox getEnabledCheckBox() {
444
        if (jcb_enabled == null) {
445
            jcb_enabled =
446
                new JCheckBox(PluginServices.getText(this, "Enable_hyperlink"),
447
                    true);
448
            jcb_enabled.addItemListener(this);
449
        }
450
        return jcb_enabled;
451
    }
452

  
453
    public void actionPerformed(ActionEvent e) {
454
        if (e.getSource() == getAcceptButton()) {
455
            acceptAction();
456
            PluginServices.getMDIManager().closeWindow(this);
457

  
458
        } else
459
            if (e.getSource() == getCancelButton()) {
460
                cancelAction();
461
                PluginServices.getMDIManager().closeWindow(this);
462
            }
463
    }
464

  
465
    protected void setListEnabled(boolean enabled) {
466
        getAddActionButton().setEnabled(enabled);
467
        getRemoveActionButton().setEnabled(enabled);
468
        synchronized (rows) {
469
            for (int i = 0; i < rows.size(); i++) {
470
                LinkRow row = (LinkRow) rows.get(i);
471
                row.setEnabled(enabled);
472
            }
473
        }
474
    }
475

  
476
    protected void setLinkEnabled(boolean enabled) {
477
        getEnabledCheckBox().setSelected(enabled);
478
        setListEnabled(enabled);
479
    }
480

  
481
    public void itemStateChanged(ItemEvent e) {
482
        if (e.getSource() == getEnabledCheckBox()) {
483
            if (e.getStateChange() == ItemEvent.DESELECTED) {
484
                setListEnabled(false);
485
            } else {
486
                setListEnabled(true);
487
            }
488
        }
489
    }
490

  
491
    public Object getWindowProfile() {
492
        return WindowInfo.DIALOG_PROFILE;
493
    }
494
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/AbstractHyperLinkPanel.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.io.File;
26
import java.io.IOException;
27
import java.net.URI;
28
import java.net.URISyntaxException;
29
import java.util.logging.Level;
30

  
31
import javax.swing.JPanel;
32

  
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.messages.NotificationManager;
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

  
38
/**
39
 * This class extends JPanel and implements IExtensioBuilder. Provides the
40
 * methods that will be reimplemented by the descendant class. Creates a panel
41
 * that shows the content of a URI. The necessary code that allows to show the
42
 * content of the URI is provided by the descendant class. Implmenting
43
 * IExtenssionBuilder this class and its the descendant provides a point of
44
 * extension for other extensions.
45
 */
46
public abstract class AbstractHyperLinkPanel extends JPanel {
47

  
48
    protected static final Logger logger = LoggerFactory.getLogger(AbstractHyperLinkPanel.class);
49
    
50
    protected LinkTarget document;
51

  
52
    public AbstractHyperLinkPanel(LinkTarget linkTarget) {
53
        super();
54
        document = linkTarget;
55
    }
56

  
57
    public LinkTarget getLinkTarget() {
58
        return document;
59
    }
60

  
61
    /**
62
     * Tries to make an absolute url from a relative one,
63
     * and returns true if the URL is valid.
64
     * false otherwise
65
     * 
66
     * @return
67
     */
68
    protected boolean checkAndNormalizeURI() {
69
        if (document == null) {
70
            PluginServices.getLogger().warn(PluginServices.getText(this,
71
                "Hyperlink_linked_field_doesnot_exist"));
72
            return false;
73
        } else if (document.getURL()!=null) {
74
            try {
75
                if (!document.getURL().toURI().isAbsolute()) {
76
                    try {
77
                        // try as a relative path
78
                        File file =
79
                                new File(document.toString()).getCanonicalFile();
80
                        if (!file.exists()) {
81
                            PluginServices.getLogger()
82
                                    .warn(PluginServices.getText(this,
83
                                            "Hyperlink_linked_field_doesnot_exist"));
84
                            return false;
85
                        }
86
                        document.setURL(file.toURI().toURL());
87
                        return true;
88
                    } catch (IOException e) {
89
                        PluginServices.getLogger()
90
                                .warn(PluginServices.getText(this,
91
                                        "Hyperlink_linked_field_doesnot_exist"));
92
                        return false;
93
                    }
94
                }
95
        } catch (URISyntaxException ex) {
96
            NotificationManager.addWarning(PluginServices.getText(this,
97
                "Hyperlink_linked_field_doesnot_exist"), ex);
98
            return false; 
99
        }
100
        }
101
        return true;
102
    }
103
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/DefaultLinkTarget.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.hyperlink.app.extension;
7

  
8
import java.io.File;
9
import java.net.MalformedURLException;
10
import java.net.URI;
11
import java.net.URISyntaxException;
12
import java.net.URL;
13
import java.net.URLClassLoader;
14
import java.util.logging.Level;
15
import java.util.logging.Logger;
16
import java.util.regex.Matcher;
17
import java.util.regex.Pattern;
18
import org.apache.commons.io.FileUtils;
19
import org.apache.commons.lang3.StringUtils;
20
import org.gvsig.app.ApplicationLocator;
21
import org.gvsig.app.project.Project;
22
import org.gvsig.app.project.ProjectManager;
23
import org.gvsig.fmap.dal.exception.DataException;
24
import org.gvsig.fmap.dal.feature.Feature;
25
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
26
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
27
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
28

  
29
/**
30
 *
31
 * @author osc
32
 */
33
public class DefaultLinkTarget implements LinkTarget {
34

  
35
    private URL url;
36
    private final String fieldExtension;
37
    private final FLyrVect _layer;
38
    private final String fieldName;
39
    private Object content;
40
    private String profileName;
41

  
42

  
43
    public DefaultLinkTarget(FLyrVect layer,Feature feature, String fieldName, String fieldExtension) {
44
        this.fieldName = fieldName;
45
        this.fieldExtension = fieldExtension;
46
        this._layer = layer;
47
        this.url = null;
48
        Object val = feature.get(fieldName);
49
        String fieldValue = (val == null) ? "" : val.toString();
50
        if (!fieldValue.equals("")) {
51
            try {
52
                URI uri = this.getURI(fieldValue, fieldExtension);
53
                if (uri != null) {
54
                    this.url = uri.toURL();
55
                } else {
56
                    this.url = null;
57
                }
58

  
59
            } catch (URISyntaxException ex) {
60
                Logger.getLogger(DefaultLinkTarget.class.getName()).log(Level.SEVERE, null, ex);
61
                this.url = null;
62
            } catch (MalformedURLException ex) {
63
                Logger.getLogger(DefaultLinkTarget.class.getName()).log(Level.SEVERE, null, ex);
64
                this.url = null;
65
            }
66
            if (this.url == null) {
67
                FeatureAttributeDescriptor fad;
68

  
69
                try {
70
                    this.content = feature.getFromProfile(fieldName);
71
                    fad = feature.getStore().getDefaultFeatureType().getAttributeDescriptor(fieldName);
72
                } catch (DataException ex) {
73
                    fad = null;
74
                    Logger.getLogger(DefaultLinkTarget.class.getName()).log(Level.SEVERE, null, ex);
75
                }
76
                if (fad != null) {
77
                    this.profileName = fad.getDataProfileName();
78
                } else {
79
                    this.profileName = null;
80
                }
81

  
82
            }
83
        }
84
        
85

  
86
    }
87
    protected URI getBasicURI(String baseURI, String extension) throws URISyntaxException {
88
        String pathname;
89
        if( StringUtils.isEmpty(extension) ) {
90
            pathname = baseURI;
91
        } else {
92
            if (extension.startsWith(".")) {
93
                pathname = baseURI + extension;
94
            } else {
95
                pathname = baseURI + "." + extension;
96
            }
97
        }
98
        pathname = pathname.replace("\\","//");
99
        if( this._layer.getFeatureStore().getParameters() instanceof FilesystemStoreParameters ) {
100
            FilesystemStoreParameters params = (FilesystemStoreParameters) this._layer.getFeatureStore().getParameters();
101
            File f = params.getFile();
102
            URLClassLoader loader = new URLClassLoader(new URL[] {toURL(f)});
103
            URL url = loader.getResource(pathname);
104
            if( url != null ) {
105
                return url.toURI();
106
            }
107
            url = loader.getResource("/" + pathname);
108
            if( url != null ) {
109
                return url.toURI();
110
            }
111
            File ff = FileUtils.getFile(f.getParentFile(), pathname);
112
            if( ff.exists() ) {
113
                return ff.toURI();
114
            }
115
        }
116
        ProjectManager projectManager = ApplicationLocator.getProjectManager();
117
        Project project = projectManager.getCurrentProject();
118
        if( project.getFile()!=null ) {
119
            File ff = FileUtils.getFile(project.getFile().getParentFile(), pathname);
120
            if( ff.exists() ) {
121
                return ff.toURI();
122
            }
123
        }
124
        File ff = new File(pathname);
125
        if( ff.exists() ) {
126
            return ff.toURI();
127
        }
128
        return null;
129
    }
130
    
131
     protected URI getURI(String baseURI, String extension) throws URISyntaxException {
132
        if( StringUtils.isEmpty(baseURI) ) {
133
            return null;
134
        }
135
        URI uri = getBasicURI(baseURI, extension);
136
        if( uri!=null ) {
137
            return uri;
138
        }
139
        String value = baseURI.trim();
140

  
141
        Pattern pattern = Pattern.compile(".*<img[^>]*src=\"([^\"]*)\".*",  Pattern.CASE_INSENSITIVE|Pattern.MULTILINE|Pattern.DOTALL);
142
        Matcher m = pattern.matcher(value);
143
        if( m!=null && m.matches() ) {
144
            String x = m.group(1);
145
            if( !StringUtils.isEmpty(x) ) {
146
                uri = getBasicURI(x, extension);
147
                if( uri!=null ) {
148
                    return uri;
149
                }
150
            }
151
        }
152
        pattern = Pattern.compile(".*<a[^>]*href=\"([^\"]*)\".*", Pattern.CASE_INSENSITIVE|Pattern.MULTILINE|Pattern.DOTALL);
153
        m = pattern.matcher(value);
154
        if( m!=null && m.matches() ) {
155
            String x = m.group(1);
156
            if( !StringUtils.isEmpty(x) ) {
157
                uri = getBasicURI(x, extension);
158
                if( uri!=null ) {
159
                    return uri;
160
                }
161
            }
162
        }
163
        try {
164
            URI createURI = new URI(baseURI);
165
            return createURI;
166
        } catch (Exception e) {
167
            //throw new URISyntaxException(baseURI, "Can't make a valid URI.");
168
            return null;
169
        }
170
    }
171
     
172
    private URL toURL(File f) {
173
        try {
174
            return f.toURI().toURL();
175
        } catch (MalformedURLException ex) {
176
            return null;
177
        }
178
    }
179
    
180
    @Override
181
    public URL getURL() {
182
        return this.url;
183
    }
184

  
185
    @Override
186
    public Object getFromProfile() {
187
        return this.content;
188
 }
189

  
190
    @Override
191
    public String getProfileName() {
192
        return this.profileName;
193
    }
194

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

  
23
package org.gvsig.hyperlink.app.extension;
24

  
25
import java.util.Map;
26

  
27
public abstract class AbstractActionManager implements ILinkActionManager {
28

  
29
    public boolean hasPanel() {
30
        return false;
31
    }
32

  
33
    public Object create() {
34
        return this;
35
    }
36

  
37
    public Object create(Object[] args) {
38
        return this;
39
    }
40

  
41
    public Object create(Map args) {
42
        return this;
43
    }
44

  
45
}
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.84/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.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff