summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViolaine Batthish2013-05-07 11:50:28 (EDT)
committer Chris Recoskie2013-05-07 11:50:28 (EDT)
commit3c61a6f06398f1549f221cbce0f9b82a4fad84e5 (patch)
tree7784df5f6875b461aca0e8fe89a103732a97682e
parentda9b0fb07829b1afa292842d529b13b573a846ae (diff)
downloadorg.eclipse.ptp-3c61a6f06398f1549f221cbce0f9b82a4fad84e5.zip
org.eclipse.ptp-3c61a6f06398f1549f221cbce0f9b82a4fad84e5.tar.gz
org.eclipse.ptp-3c61a6f06398f1549f221cbce0f9b82a4fad84e5.tar.bz2
Bug 407350 - Opening a file that has been deleted in the Remote Type
Hierarchy view generates an error
-rwxr-xr-xrdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/callhierarchy/RemoteCHViewPart.java26
-rwxr-xr-xrdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/typehierarchy/RemoteTHViewPart.java43
2 files changed, 55 insertions, 14 deletions
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/callhierarchy/RemoteCHViewPart.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/callhierarchy/RemoteCHViewPart.java
index f793bd3..27b9066 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/callhierarchy/RemoteCHViewPart.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/callhierarchy/RemoteCHViewPart.java
@@ -18,6 +18,7 @@
package org.eclipse.ptp.internal.rdt.ui.callhierarchy;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -39,9 +40,12 @@ import org.eclipse.cdt.internal.ui.callhierarchy.CHMultiDefNode;
import org.eclipse.cdt.internal.ui.callhierarchy.CHNode;
import org.eclipse.cdt.internal.ui.callhierarchy.CHReferenceInfo;
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.internal.ui.util.Messages;
+import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
@@ -52,7 +56,10 @@ import org.eclipse.cdt.internal.ui.viewsupport.TreeNavigator;
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.actions.CdtActionConstants;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
@@ -88,6 +95,7 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IViewSite;
@@ -607,7 +615,23 @@ public class RemoteCHViewPart extends ViewPart {
try {
CModel model = CModelManager.getDefault().getCModel();
ICProject cproject = model.findCProject(elem.getCProject().getProject());
- IEditorPart editor = EditorUtility.openInEditor(elem.getLocationURI(), cproject);
+ IEditorInput input = EditorUtility.getEditorInputForLocation(elem.getLocationURI(), cproject);
+ if (input instanceof ExternalEditorInput) {
+ try {
+ IFileStore f = EFS.getStore(elem.getLocationURI());
+ if (!f.fetchInfo().exists()) {
+ StatusLineHandler.showStatusLineMessage(this.getSite(), MessageFormat.format(
+ CSearchMessages.SelectionParseAction_FileOpenFailure_format,
+ new Object[] { elem.getLocationURI().getRawSchemeSpecificPart()}));
+ setMessage(CHMessages.CHViewPart_emptyPageMessage);
+ fTreeViewer.setInput(null);
+ return;
+ }
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
+ }
+ IEditorPart editor = EditorUtility.openInEditor(input);
if(editor instanceof ITextEditor && elem instanceof ISourceReference) {
ISourceReference sr = (ISourceReference) elem;
int offset = sr.getSourceRange().getIdStartPos();
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/typehierarchy/RemoteTHViewPart.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/typehierarchy/RemoteTHViewPart.java
index 47f7080..e494354 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/typehierarchy/RemoteTHViewPart.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/typehierarchy/RemoteTHViewPart.java
@@ -36,10 +36,13 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.CopyTreeAction;
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
import org.eclipse.cdt.internal.ui.typehierarchy.ITHModelPresenter;
import org.eclipse.cdt.internal.ui.typehierarchy.Messages;
import org.eclipse.cdt.internal.ui.typehierarchy.THNode;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
+import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider;
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
@@ -50,7 +53,10 @@ import org.eclipse.cdt.internal.ui.viewsupport.SelectionProviderMediator;
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.actions.CdtActionConstants;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
@@ -101,6 +107,7 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IViewSite;
@@ -854,28 +861,38 @@ public class RemoteTHViewPart extends ViewPart implements ITHModelPresenter {
try {
CModel model = CModelManager.getDefault().getCModel();
ICProject cproject = model.findCProject(elem.getCProject().getProject());
- IEditorPart editor = EditorUtility.openInEditor(elem.getLocationURI(), cproject);
- if(editor instanceof ITextEditor && elem instanceof ISourceReference) {
+ IEditorInput input = EditorUtility.getEditorInputForLocation(elem.getLocationURI(), cproject);
+ if (input instanceof ExternalEditorInput) {
+ try {
+ IFileStore f = EFS.getStore(elem.getLocationURI());
+ if (!f.fetchInfo().exists()) {
+ StatusLineHandler.showStatusLineMessage(this.getSite(), MessageFormat.format(
+ CSearchMessages.SelectionParseAction_FileOpenFailure_format, new Object[] { elem
+ .getLocationURI().getRawSchemeSpecificPart() }));
+ setMessage(Messages.THViewPart_instruction);
+ fHierarchyTreeViewer.setInput(null);
+ fMemberViewer.setInput(null);
+ return;
+ }
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
+ }
+ IEditorPart editor = EditorUtility.openInEditor(input);
+ if (editor instanceof ITextEditor && elem instanceof ISourceReference) {
ISourceReference sr = (ISourceReference) elem;
int offset = sr.getSourceRange().getIdStartPos();
int length = sr.getSourceRange().getIdLength();
-
- if(offset >= 0 && length >= 0) {
- ((ITextEditor)editor).selectAndReveal(offset, length);
+
+ if (offset >= 0 && length >= 0) {
+ ((ITextEditor) editor).selectAndReveal(offset, length);
}
- }
+ }
} catch (PartInitException e) {
CUIPlugin.log(e);
} catch (CModelException e) {
CUIPlugin.log(e);
}
-
-// IWorkbenchPage page= getSite().getPage();
-// try {
-// EditorOpener.open(page, elem);
-// } catch (CModelException e) {
-// CUIPlugin.log(e);
-// }
}
}