From 185e2e84db9ea4bc0d8baf1717e3903ae042e049 Mon Sep 17 00:00:00 2001 From: Igor Maznitsa Date: Sat, 3 Oct 2015 14:37:17 +0300 Subject: [PATCH] changes in file opeining logic --- .../nbmindmap/nb/editor/MMDGraphEditor.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mind-map/nb-mind-map/src/main/java/com/igormaznitsa/nbmindmap/nb/editor/MMDGraphEditor.java b/mind-map/nb-mind-map/src/main/java/com/igormaznitsa/nbmindmap/nb/editor/MMDGraphEditor.java index 2f53585fa..052a44c4c 100644 --- a/mind-map/nb-mind-map/src/main/java/com/igormaznitsa/nbmindmap/nb/editor/MMDGraphEditor.java +++ b/mind-map/nb-mind-map/src/main/java/com/igormaznitsa/nbmindmap/nb/editor/MMDGraphEditor.java @@ -77,6 +77,7 @@ import org.openide.filesystems.FileChooserBuilder; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; +import org.openide.filesystems.URLMapper; import org.openide.loaders.DataFolder; import org.openide.loaders.DataObject; import org.openide.nodes.Node; @@ -373,10 +374,17 @@ public void onClickOnExtra(final MindMapPanel source, final int clicks, final To case FILE: { final FileObject fileObj; final MMapURI uri = (MMapURI) extra.getValue(); + final File theFile = uri.asFile(this.editorSupport.getProjectDirectory()); try { - fileObj = FileUtil.toFileObject(uri.asFile(this.editorSupport.getProjectDirectory())); + fileObj = FileUtil.toFileObject(theFile); if (fileObj == null) { - NbUtils.msgError(String.format(BUNDLE.getString("MMDGraphEditor.onClickExtra.errorCanfFindFile"), uri.toString())); + logger.warn("Can't find FileObject for " + theFile); + if (theFile.exists()) { + NbUtils.openInExternalEditor(theFile); + } + else { + NbUtils.msgError(String.format(BUNDLE.getString("MMDGraphEditor.onClickExtra.errorCanfFindFile"), theFile.getAbsolutePath())); + } return; } } @@ -387,8 +395,6 @@ public void onClickOnExtra(final MindMapPanel source, final int clicks, final To } try { - final File theFile = uri.asFile(this.editorSupport.getProjectDirectory()); - if (Boolean.parseBoolean(uri.getParameters().getProperty(FILELINK_ATTR_OPEN_IN_SYSTEM, "false"))) { //NOI18N NbUtils.openInExternalEditor(theFile); }