Revision 412 org.gvsig.hyperlink.app/trunk/org.gvsig.hyperlink.app/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/AbstractHyperLinkPanel.java
AbstractHyperLinkPanel.java | ||
---|---|---|
25 | 25 |
import java.io.File; |
26 | 26 |
import java.io.IOException; |
27 | 27 |
import java.net.URI; |
28 |
import java.net.URISyntaxException; |
|
29 |
import java.util.logging.Level; |
|
28 | 30 |
|
29 | 31 |
import javax.swing.JPanel; |
30 | 32 |
|
31 | 33 |
import org.gvsig.andami.PluginServices; |
34 |
import org.gvsig.andami.messages.NotificationManager; |
|
32 | 35 |
import org.slf4j.Logger; |
33 | 36 |
import org.slf4j.LoggerFactory; |
34 | 37 |
|
... | ... | |
44 | 47 |
|
45 | 48 |
protected static final Logger logger = LoggerFactory.getLogger(AbstractHyperLinkPanel.class); |
46 | 49 |
|
47 |
protected URI document;
|
|
50 |
protected LinkTarget document;
|
|
48 | 51 |
|
49 |
public AbstractHyperLinkPanel(URI doc) {
|
|
52 |
public AbstractHyperLinkPanel(LinkTarget linkTarget) {
|
|
50 | 53 |
super(); |
51 |
document = doc;
|
|
54 |
document = linkTarget;
|
|
52 | 55 |
} |
53 | 56 |
|
54 |
public URI getURI() {
|
|
57 |
public LinkTarget getLinkTarget() {
|
|
55 | 58 |
return document; |
56 | 59 |
} |
57 | 60 |
|
... | ... | |
67 | 70 |
PluginServices.getLogger().warn(PluginServices.getText(this, |
68 | 71 |
"Hyperlink_linked_field_doesnot_exist")); |
69 | 72 |
return false; |
70 |
} else |
|
71 |
if (!document.isAbsolute()) { |
|
72 |
try { |
|
73 |
// try as a relative path |
|
74 |
File file = |
|
75 |
new File(document.toString()).getCanonicalFile(); |
|
76 |
if (!file.exists()) { |
|
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) { |
|
77 | 89 |
PluginServices.getLogger() |
78 |
.warn(PluginServices.getText(this, |
|
79 |
"Hyperlink_linked_field_doesnot_exist")); |
|
90 |
.warn(PluginServices.getText(this,
|
|
91 |
"Hyperlink_linked_field_doesnot_exist"));
|
|
80 | 92 |
return false; |
81 | 93 |
} |
82 |
document = file.toURI(); |
|
83 |
} catch (IOException e) { |
|
84 |
PluginServices.getLogger() |
|
85 |
.warn(PluginServices.getText(this, |
|
86 |
"Hyperlink_linked_field_doesnot_exist")); |
|
87 |
return false; |
|
88 | 94 |
} |
89 |
} |
|
95 |
} catch (URISyntaxException ex) { |
|
96 |
NotificationManager.addWarning(PluginServices.getText(this, |
|
97 |
"Hyperlink_linked_field_doesnot_exist"), ex); |
|
98 |
return false; |
|
99 |
} |
|
100 |
} |
|
90 | 101 |
return true; |
91 | 102 |
} |
92 | 103 |
} |
Also available in: Unified diff