Revision 39
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.4/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.4</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.89</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.4</connection> |
|
21 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-hyperlink/org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.4</developerConnection> |
|
22 |
<url>scm:svn:https://devel.gvsig.org/svn/gvsig-hyperlink/org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.4</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.4/org.gvsig.hyperlink.app.extension/buildNumber.properties | ||
---|---|---|
1 |
#Wed Apr 01 11:01:36 CEST 2015 |
|
2 |
buildNumber=2091 |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.4/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.4/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.hyperlink.app.extension.AbstractActionManager; |
|
48 |
import org.gvsig.hyperlink.app.extension.HyperlinkExtension; |
|
49 |
import org.gvsig.hyperlink.app.extension.config.LayerLinkConfig; |
|
50 |
import org.gvsig.hyperlink.app.extension.config.LinkConfig; |
|
51 |
import org.gvsig.hyperlink.app.extension.layers.ILinkLayerManager; |
|
52 |
import org.gvsig.hyperlink.app.extension.layers.IncompatibleLayerException; |
|
53 |
import org.gvsig.hyperlink.app.extension.layers.ManagerRegistry; |
|
54 |
import org.gvsig.tools.ToolsLocator; |
|
55 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
56 |
|
|
57 |
public class ConfigTab extends AbstractThemeManagerPage implements IWindow, |
|
58 |
ActionListener, ItemListener { |
|
59 |
|
|
60 |
FLayer layer; |
|
61 |
ArrayList rows = new ArrayList(); |
|
62 |
JPanel rowList = null; |
|
63 |
GridBagLayout listLayout = null; |
|
64 |
private String[] actionCodes = null; |
|
65 |
private String[] actionNames = null; |
|
66 |
WindowInfo _windowInfo = null; |
|
67 |
JButton jbt_accept = null, jbt_cancel = null; |
|
68 |
JPanel emptyRow; |
|
69 |
JCheckBox jcb_enabled = null; |
|
70 |
JPanel borderPanel = null; |
|
71 |
JButton jbt_addAction = null, jbt_removeAction = null; |
|
72 |
|
|
73 |
public ConfigTab() { |
|
74 |
super(); |
|
75 |
initialize(); |
|
76 |
} |
|
77 |
|
|
78 |
private void initialize() { |
|
79 |
this.setLayout(new GridBagLayout()); |
|
80 |
|
|
81 |
Insets insets = new Insets(8, 8, 8, 8); |
|
82 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
83 |
constraints.gridx = 0; |
|
84 |
constraints.gridy = 0; |
|
85 |
constraints.weightx = 1.0; |
|
86 |
constraints.fill = GridBagConstraints.NONE; |
|
87 |
constraints.insets = insets; |
|
88 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
89 |
this.add(getEnabledCheckBox(), constraints); |
|
90 |
|
|
91 |
borderPanel = new JPanel(new GridBagLayout()); |
|
92 |
borderPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
|
93 |
PluginServices.getText(this, "Actions"), |
|
94 |
TitledBorder.DEFAULT_JUSTIFICATION, |
|
95 |
TitledBorder.DEFAULT_POSITION, |
|
96 |
null, |
|
97 |
null)); |
|
98 |
|
|
99 |
insets = new Insets(8, 8, 8, 8); |
|
100 |
constraints = new GridBagConstraints(); |
|
101 |
constraints.gridx = 0; |
|
102 |
constraints.gridy = 0; |
|
103 |
constraints.weightx = 1.0; |
|
104 |
constraints.fill = GridBagConstraints.NONE; |
|
105 |
constraints.insets = insets; |
|
106 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
107 |
borderPanel.add(getAddRemoveActionsPanel(), constraints); |
|
108 |
|
|
109 |
listLayout = new GridBagLayout(); |
|
110 |
rowList = new JPanel(listLayout); |
|
111 |
|
|
112 |
constraints.gridx = 0; |
|
113 |
constraints.gridy = 0; |
|
114 |
constraints.weightx = 1.0; |
|
115 |
constraints.weighty = 1.0; |
|
116 |
constraints.fill = GridBagConstraints.NONE; |
|
117 |
constraints.insets = insets; |
|
118 |
constraints.anchor = GridBagConstraints.SOUTH; |
|
119 |
emptyRow = new JPanel(); |
|
120 |
rowList.add(emptyRow, constraints); |
|
121 |
|
|
122 |
JScrollPane scrolledList = new JScrollPane(); |
|
123 |
scrolledList.setBorder(null); |
|
124 |
scrolledList.setViewportView(rowList); |
|
125 |
|
|
126 |
constraints.gridx = 0; |
|
127 |
constraints.gridy = 1; |
|
128 |
constraints.weightx = 1.0; |
|
129 |
constraints.weighty = 1.0; |
|
130 |
constraints.fill = GridBagConstraints.BOTH; |
|
131 |
constraints.insets = insets; |
|
132 |
constraints.anchor = GridBagConstraints.CENTER; |
|
133 |
borderPanel.add(scrolledList, constraints); |
|
134 |
|
|
135 |
constraints.gridx = 0; |
|
136 |
constraints.gridy = 1; |
|
137 |
constraints.weightx = 1.0; |
|
138 |
constraints.weighty = 1.0; |
|
139 |
constraints.fill = GridBagConstraints.BOTH; |
|
140 |
constraints.insets = insets; |
|
141 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
142 |
this.add(borderPanel, constraints); |
|
143 |
|
|
144 |
// initAcceptCancelButtons(); uncomment this if you want to use this |
|
145 |
// window outside the ThemeManager |
|
146 |
} |
|
147 |
|
|
148 |
private void initAcceptCancelButtons() { |
|
149 |
JPanel acceptCancelButtons = new JPanel(new GridBagLayout()); |
|
150 |
Insets insets = new Insets(14, 4, 8, 8); |
|
151 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
152 |
constraints.gridx = 0; |
|
153 |
constraints.gridy = 0; |
|
154 |
constraints.weightx = 1.0; |
|
155 |
constraints.fill = GridBagConstraints.NONE; |
|
156 |
constraints.insets = insets; |
|
157 |
constraints.anchor = GridBagConstraints.EAST; |
|
158 |
acceptCancelButtons.add(getAcceptButton(), constraints); |
|
159 |
|
|
160 |
constraints.gridx = 1; |
|
161 |
constraints.gridy = 0; |
|
162 |
constraints.weightx = 0.0; |
|
163 |
constraints.fill = GridBagConstraints.NONE; |
|
164 |
constraints.insets = insets; |
|
165 |
constraints.anchor = GridBagConstraints.EAST; |
|
166 |
acceptCancelButtons.add(getCancelButton(), constraints); |
|
167 |
|
|
168 |
constraints.gridx = 0; |
|
169 |
constraints.gridy = 2; |
|
170 |
constraints.weightx = 0.0; |
|
171 |
constraints.fill = GridBagConstraints.NONE; |
|
172 |
constraints.insets = insets; |
|
173 |
constraints.anchor = GridBagConstraints.SOUTHEAST; |
|
174 |
this.add(acceptCancelButtons, constraints); |
|
175 |
} |
|
176 |
|
|
177 |
private String[] getActionNames() { |
|
178 |
if (actionNames == null) { |
|
179 |
ExtensionPoint actions = |
|
180 |
ToolsLocator.getExtensionPointManager() |
|
181 |
.get(HyperlinkExtension.ACTIONSEXTENSIONPOINT); |
|
182 |
|
|
183 |
String[] actionArray = new String[actions.getCount()]; |
|
184 |
String[] codes = getActionCodes(); |
|
185 |
for (int i = 0; i < codes.length; i++) { |
|
186 |
try { |
|
187 |
AbstractActionManager aam = |
|
188 |
(AbstractActionManager) actions.get(codes[i]) |
|
189 |
.getExtension() |
|
190 |
.newInstance(); |
|
191 |
actionArray[i] = aam.getName(); |
|
192 |
} catch (InstantiationException e) { |
|
193 |
// TODO Auto-generated catch block |
|
194 |
e.printStackTrace(); |
|
195 |
} catch (IllegalAccessException e) { |
|
196 |
// TODO Auto-generated catch block |
|
197 |
e.printStackTrace(); |
|
198 |
} |
|
199 |
} |
|
200 |
actionNames = actionArray; |
|
201 |
} |
|
202 |
return actionNames; |
|
203 |
} |
|
204 |
|
|
205 |
private String[] getActionCodes() { |
|
206 |
if (actionCodes == null) { |
|
207 |
ExtensionPoint actions = |
|
208 |
ToolsLocator.getExtensionPointManager() |
|
209 |
.get(HyperlinkExtension.ACTIONSEXTENSIONPOINT); |
|
210 |
String[] actionArray = new String[actions.getCount()]; |
|
211 |
actionArray = (String[]) actions.getNames().toArray(actionArray); |
|
212 |
actionCodes = actionArray; |
|
213 |
} |
|
214 |
return actionCodes; |
|
215 |
} |
|
216 |
|
|
217 |
private String[] getCandidateFields() { |
|
218 |
HyperlinkExtension ext = |
|
219 |
(HyperlinkExtension) PluginServices.getExtension(HyperlinkExtension.class); |
|
220 |
ManagerRegistry registry = ext.getLayerManager(); |
|
221 |
try { |
|
222 |
ILinkLayerManager manager; |
|
223 |
manager = registry.get(layer); |
|
224 |
manager.setLayer(layer); |
|
225 |
return manager.getFieldCandidates(); |
|
226 |
} catch (InstantiationException e) { |
|
227 |
PluginServices.getLogger() |
|
228 |
.warn("Hyperlink: error getting candidate fields", e); |
|
229 |
} catch (IllegalAccessException e) { |
|
230 |
PluginServices.getLogger() |
|
231 |
.warn("Hyperlink: error getting candidate fields", e); |
|
232 |
} catch (ClassNotFoundException e) { |
|
233 |
PluginServices.getLogger() |
|
234 |
.warn("Hyperlink: error getting candidate fields", e); |
|
235 |
} catch (IncompatibleLayerException e) { |
|
236 |
PluginServices.getLogger() |
|
237 |
.warn("Hyperlink: error getting candidate fields", e); |
|
238 |
} catch (NullPointerException e) { |
|
239 |
PluginServices.getLogger().warn("Hyperlink: error getting manager", e); |
|
240 |
} |
|
241 |
return new String[0]; |
|
242 |
} |
|
243 |
|
|
244 |
public void acceptAction() { |
|
245 |
applyAction(); |
|
246 |
} |
|
247 |
|
|
248 |
public void applyAction() { |
|
249 |
LayerLinkConfig config = new LayerLinkConfig(); |
|
250 |
for (int i = 0; i < rows.size(); i++) { |
|
251 |
LinkRow row = (LinkRow) rows.get(i); |
|
252 |
|
|
253 |
if (row.getSelectedField() != null |
|
254 |
&& row.getSelectedAction() != -1) { |
|
255 |
|
|
256 |
config.addLink(getActionCodes()[row.getSelectedAction()], |
|
257 |
row.getSelectedField(), |
|
258 |
row.getExtension()); |
|
259 |
} |
|
260 |
} |
|
261 |
config.setEnabled(getEnabledCheckBox().isSelected()); |
|
262 |
layer.setProperty(HyperlinkExtension.LAYERPROPERTYNAME, config); |
|
263 |
} |
|
264 |
|
|
265 |
public void cancelAction() { |
|
266 |
} |
|
267 |
|
|
268 |
public String getName() { |
|
269 |
return PluginServices.getText(this, "Hyperlink"); |
|
270 |
} |
|
271 |
|
|
272 |
public void setModel(FLayer layer) { |
|
273 |
this.layer = layer; |
|
274 |
synchronized (rows) { |
|
275 |
HyperlinkExtension ext = |
|
276 |
(HyperlinkExtension) PluginServices.getExtension(HyperlinkExtension.class); |
|
277 |
LayerLinkConfig layerConfig = ext.loadLegacyConfig(layer); |
|
278 |
for (int i = rows.size() - 1; i >= 0; i--) { // clean rows |
|
279 |
LinkRow row = (LinkRow) rows.remove(i); |
|
280 |
rowList.remove(row); |
|
281 |
} |
|
282 |
|
|
283 |
if (layerConfig != null) { |
|
284 |
for (int i = 0; i < layerConfig.linkCount(); i++) { |
|
285 |
LinkRow row = addRow(); |
|
286 |
LinkConfig config = layerConfig.getLink(i); |
|
287 |
String selectedAction = config.getActionCode(); |
|
288 |
String[] actions = getActionCodes(); |
|
289 |
for (int j = 0; j < actions.length; j++) { |
|
290 |
if (actions[j].equals(selectedAction)) { |
|
291 |
row.setSelectedAction(j); |
|
292 |
} |
|
293 |
} |
|
294 |
row.setSelectedField(config.getFieldName()); |
|
295 |
row.setExtension(config.getExtension()); |
|
296 |
} |
|
297 |
if (layerConfig.linkCount() < 1) { |
|
298 |
addRow(); // just one row by default |
|
299 |
} |
|
300 |
setLinkEnabled(layerConfig.isEnabled()); |
|
301 |
} else { |
|
302 |
addRow(); // just one row by default |
|
303 |
setLinkEnabled(false); |
|
304 |
} |
|
305 |
} |
|
306 |
} |
|
307 |
|
|
308 |
protected JPanel getAddRemoveActionsPanel() { |
|
309 |
JPanel container = new JPanel(); |
|
310 |
container.add(getAddActionButton()); |
|
311 |
container.add(getRemoveActionButton()); |
|
312 |
return container; |
|
313 |
} |
|
314 |
|
|
315 |
protected LinkRow addRow() { |
|
316 |
LinkRow row = new LinkRow(); |
|
317 |
row.setFields(getCandidateFields()); |
|
318 |
row.setActions(getActionNames()); |
|
319 |
synchronized (rows) { |
|
320 |
rows.add(row); |
|
321 |
|
|
322 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
323 |
constraints.gridx = 0; |
|
324 |
constraints.gridy = rows.size() - 1; |
|
325 |
constraints.weightx = 1.0; |
|
326 |
constraints.weighty = 0.0; |
|
327 |
constraints.fill = GridBagConstraints.HORIZONTAL; |
|
328 |
constraints.insets = new Insets(2, 4, 2, 4); |
|
329 |
constraints.anchor = GridBagConstraints.NORTH; |
|
330 |
rowList.add(row, constraints); |
|
331 |
|
|
332 |
constraints = new GridBagConstraints(); |
|
333 |
constraints.gridx = 0; |
|
334 |
constraints.gridy = rows.size(); |
|
335 |
constraints.weightx = 1.0; |
|
336 |
constraints.weighty = 1.0; |
|
337 |
constraints.fill = GridBagConstraints.NONE; |
|
338 |
constraints.anchor = GridBagConstraints.CENTER; |
|
339 |
listLayout.setConstraints(emptyRow, constraints); |
|
340 |
} |
|
341 |
validate(); |
|
342 |
return row; |
|
343 |
} |
|
344 |
|
|
345 |
protected boolean removeBottomRow() { |
|
346 |
LinkRow row; |
|
347 |
synchronized (rows) { |
|
348 |
if (rows.size() <= 1) |
|
349 |
return false; |
|
350 |
row = (LinkRow) rows.get(rows.size() - 1); |
|
351 |
rows.remove(rows.size() - 1); |
|
352 |
} |
|
353 |
rowList.remove(row); |
|
354 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
355 |
constraints.gridx = 0; |
|
356 |
constraints.gridy = rows.size(); |
|
357 |
constraints.weightx = 1.0; |
|
358 |
constraints.weighty = 1.0; |
|
359 |
constraints.fill = GridBagConstraints.NONE; |
|
360 |
constraints.anchor = GridBagConstraints.CENTER; |
|
361 |
listLayout.setConstraints(emptyRow, constraints); |
|
362 |
|
|
363 |
validate(); |
|
364 |
repaint(); |
|
365 |
return true; |
|
366 |
} |
|
367 |
|
|
368 |
protected JButton getAddActionButton() { |
|
369 |
if (jbt_addAction == null) { |
|
370 |
jbt_addAction = |
|
371 |
new JButton(PluginServices.getText(this, "Add_action")); |
|
372 |
jbt_addAction.setSize(150, 70); |
|
373 |
jbt_addAction.setActionCommand("addButton"); |
|
374 |
jbt_addAction.addActionListener(new ActionListener() { |
|
375 |
|
|
376 |
public void actionPerformed(ActionEvent e) { |
|
377 |
if (e.getActionCommand().equals("addButton")) { |
|
378 |
addRow(); |
|
379 |
} |
|
380 |
} |
|
381 |
}); |
|
382 |
} |
|
383 |
return jbt_addAction; |
|
384 |
} |
|
385 |
|
|
386 |
protected JButton getRemoveActionButton() { |
|
387 |
if (jbt_removeAction == null) { |
|
388 |
jbt_removeAction = |
|
389 |
new JButton(PluginServices.getText(this, "Remove_action")); |
|
390 |
jbt_removeAction.setActionCommand("removeButton"); |
|
391 |
jbt_removeAction.addActionListener(new ActionListener() { |
|
392 |
|
|
393 |
public void actionPerformed(ActionEvent e) { |
|
394 |
if (e.getActionCommand().equals("removeButton")) { |
|
395 |
removeBottomRow(); |
|
396 |
} |
|
397 |
} |
|
398 |
}); |
|
399 |
return jbt_removeAction; |
|
400 |
} |
|
401 |
return jbt_removeAction; |
|
402 |
} |
|
403 |
|
|
404 |
public WindowInfo getWindowInfo() { |
|
405 |
if (_windowInfo == null) { |
|
406 |
_windowInfo = |
|
407 |
new WindowInfo(WindowInfo.ICONIFIABLE | WindowInfo.MAXIMIZABLE |
|
408 |
| WindowInfo.RESIZABLE); |
|
409 |
_windowInfo.setWidth(680); |
|
410 |
_windowInfo.setHeight(500); |
|
411 |
_windowInfo.setTitle(PluginServices.getText(this, |
|
412 |
"Hyperlink_Settings")); |
|
413 |
} |
|
414 |
return _windowInfo; |
|
415 |
} |
|
416 |
|
|
417 |
protected JButton getAcceptButton() { |
|
418 |
if (jbt_accept == null) { |
|
419 |
jbt_accept = |
|
420 |
new org.gvsig.gui.beans.swing.JButton(PluginServices.getText(this, |
|
421 |
"Aceptar")); |
|
422 |
jbt_accept.addActionListener(this); |
|
423 |
} |
|
424 |
return jbt_accept; |
|
425 |
} |
|
426 |
|
|
427 |
protected JButton getCancelButton() { |
|
428 |
if (jbt_cancel == null) { |
|
429 |
jbt_cancel = |
|
430 |
new org.gvsig.gui.beans.swing.JButton(PluginServices.getText(this, |
|
431 |
"Cancel")); |
|
432 |
jbt_cancel.addActionListener(this); |
|
433 |
} |
|
434 |
return jbt_cancel; |
|
435 |
} |
|
436 |
|
|
437 |
protected JCheckBox getEnabledCheckBox() { |
|
438 |
if (jcb_enabled == null) { |
|
439 |
jcb_enabled = |
|
440 |
new JCheckBox(PluginServices.getText(this, "Enable_hyperlink"), |
|
441 |
true); |
|
442 |
jcb_enabled.addItemListener(this); |
|
443 |
} |
|
444 |
return jcb_enabled; |
|
445 |
} |
|
446 |
|
|
447 |
public void actionPerformed(ActionEvent e) { |
|
448 |
if (e.getSource() == getAcceptButton()) { |
|
449 |
acceptAction(); |
|
450 |
PluginServices.getMDIManager().closeWindow(this); |
|
451 |
|
|
452 |
} else |
|
453 |
if (e.getSource() == getCancelButton()) { |
|
454 |
cancelAction(); |
|
455 |
PluginServices.getMDIManager().closeWindow(this); |
|
456 |
} |
|
457 |
} |
|
458 |
|
|
459 |
protected void setListEnabled(boolean enabled) { |
|
460 |
getAddActionButton().setEnabled(enabled); |
|
461 |
getRemoveActionButton().setEnabled(enabled); |
|
462 |
synchronized (rows) { |
|
463 |
for (int i = 0; i < rows.size(); i++) { |
|
464 |
LinkRow row = (LinkRow) rows.get(i); |
|
465 |
row.setEnabled(enabled); |
|
466 |
} |
|
467 |
} |
|
468 |
} |
|
469 |
|
|
470 |
protected void setLinkEnabled(boolean enabled) { |
|
471 |
getEnabledCheckBox().setSelected(enabled); |
|
472 |
setListEnabled(enabled); |
|
473 |
} |
|
474 |
|
|
475 |
public void itemStateChanged(ItemEvent e) { |
|
476 |
if (e.getSource() == getEnabledCheckBox()) { |
|
477 |
if (e.getStateChange() == ItemEvent.DESELECTED) { |
|
478 |
setListEnabled(false); |
|
479 |
} else { |
|
480 |
setListEnabled(true); |
|
481 |
} |
|
482 |
} |
|
483 |
} |
|
484 |
|
|
485 |
public Object getWindowProfile() { |
|
486 |
return WindowInfo.DIALOG_PROFILE; |
|
487 |
} |
|
488 |
} |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.4/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.4/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.4/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.4/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 |
|
|
29 |
import javax.swing.JPanel; |
|
30 |
|
|
31 |
import org.gvsig.andami.PluginServices; |
|
32 |
|
|
33 |
/** |
|
34 |
* This class extends JPanel and implements IExtensioBuilder. Provides the |
|
35 |
* methods that will be reimplemented by the descendant class. Creates a panel |
|
36 |
* that shows the content of a URI. The necessary code that allows to show the |
|
37 |
* content of the URI is provided by the descendant class. Implmenting |
|
38 |
* IExtenssionBuilder this class and its the descendant provides a point of |
|
39 |
* extension for other extensions. |
|
40 |
*/ |
|
41 |
public abstract class AbstractHyperLinkPanel extends JPanel { |
|
42 |
|
|
43 |
protected URI document; |
|
44 |
|
|
45 |
public AbstractHyperLinkPanel(URI doc) { |
|
46 |
super(); |
|
47 |
document = doc; |
|
48 |
} |
|
49 |
|
|
50 |
public URI getURI() { |
|
51 |
return document; |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Tries to make an absolute url from a relative one, |
|
56 |
* and returns true if the URL is valid. |
|
57 |
* false otherwise |
|
58 |
* |
|
59 |
* @return |
|
60 |
*/ |
|
61 |
protected boolean checkAndNormalizeURI() { |
|
62 |
if (document == null) { |
|
63 |
PluginServices.getLogger().warn(PluginServices.getText(this, |
|
64 |
"Hyperlink_linked_field_doesnot_exist")); |
|
65 |
return false; |
|
66 |
} else |
|
67 |
if (!document.isAbsolute()) { |
|
68 |
try { |
|
69 |
// try as a relative path |
|
70 |
File file = |
|
71 |
new File(document.toString()).getCanonicalFile(); |
|
72 |
if (!file.exists()) { |
|
73 |
PluginServices.getLogger() |
|
74 |
.warn(PluginServices.getText(this, |
|
75 |
"Hyperlink_linked_field_doesnot_exist")); |
|
76 |
return false; |
|
77 |
} |
|
78 |
document = file.toURI(); |
|
79 |
} catch (IOException e) { |
|
80 |
PluginServices.getLogger() |
|
81 |
.warn(PluginServices.getText(this, |
|
82 |
"Hyperlink_linked_field_doesnot_exist")); |
|
83 |
return false; |
|
84 |
} |
|
85 |
} |
|
86 |
return true; |
|
87 |
} |
|
88 |
} |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.4/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.4/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.4/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.4/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.4/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 |
|
Also available in: Unified diff