Lines 16-23
Link Here
|
16 |
import java.util.Iterator; |
16 |
import java.util.Iterator; |
17 |
import java.util.List; |
17 |
import java.util.List; |
18 |
|
18 |
|
|
|
19 |
import org.eclipse.osgi.util.NLS; |
20 |
|
21 |
import org.eclipse.swt.widgets.Composite; |
22 |
import org.eclipse.swt.widgets.Shell; |
23 |
|
19 |
import org.eclipse.core.filesystem.EFS; |
24 |
import org.eclipse.core.filesystem.EFS; |
20 |
import org.eclipse.core.filesystem.IFileStore; |
25 |
import org.eclipse.core.filesystem.IFileStore; |
|
|
26 |
|
27 |
import org.eclipse.core.runtime.CoreException; |
28 |
import org.eclipse.core.runtime.IAdaptable; |
29 |
import org.eclipse.core.runtime.IStatus; |
30 |
import org.eclipse.core.runtime.MultiStatus; |
31 |
import org.eclipse.core.runtime.Platform; |
32 |
import org.eclipse.core.runtime.QualifiedName; |
33 |
import org.eclipse.core.runtime.SafeRunner; |
34 |
import org.eclipse.core.runtime.content.IContentDescription; |
35 |
import org.eclipse.core.runtime.content.IContentType; |
36 |
import org.eclipse.core.runtime.content.IContentTypeMatcher; |
37 |
|
21 |
import org.eclipse.core.resources.IFile; |
38 |
import org.eclipse.core.resources.IFile; |
22 |
import org.eclipse.core.resources.IMarker; |
39 |
import org.eclipse.core.resources.IMarker; |
23 |
import org.eclipse.core.resources.IResource; |
40 |
import org.eclipse.core.resources.IResource; |
Lines 32-54
Link Here
|
32 |
import org.eclipse.core.resources.mapping.ResourceMapping; |
49 |
import org.eclipse.core.resources.mapping.ResourceMapping; |
33 |
import org.eclipse.core.resources.mapping.ResourceMappingContext; |
50 |
import org.eclipse.core.resources.mapping.ResourceMappingContext; |
34 |
import org.eclipse.core.resources.mapping.ResourceTraversal; |
51 |
import org.eclipse.core.resources.mapping.ResourceTraversal; |
35 |
import org.eclipse.core.runtime.CoreException; |
52 |
|
36 |
import org.eclipse.core.runtime.IAdaptable; |
|
|
37 |
import org.eclipse.core.runtime.IStatus; |
38 |
import org.eclipse.core.runtime.MultiStatus; |
39 |
import org.eclipse.core.runtime.Platform; |
40 |
import org.eclipse.core.runtime.QualifiedName; |
41 |
import org.eclipse.core.runtime.SafeRunner; |
42 |
import org.eclipse.core.runtime.content.IContentDescription; |
43 |
import org.eclipse.core.runtime.content.IContentType; |
44 |
import org.eclipse.core.runtime.content.IContentTypeMatcher; |
45 |
import org.eclipse.jface.dialogs.ErrorDialog; |
53 |
import org.eclipse.jface.dialogs.ErrorDialog; |
46 |
import org.eclipse.jface.dialogs.IDialogConstants; |
54 |
import org.eclipse.jface.dialogs.IDialogConstants; |
47 |
import org.eclipse.jface.util.SafeRunnable; |
55 |
import org.eclipse.jface.util.SafeRunnable; |
48 |
import org.eclipse.jface.viewers.IStructuredSelection; |
56 |
import org.eclipse.jface.viewers.IStructuredSelection; |
49 |
import org.eclipse.osgi.util.NLS; |
57 |
|
50 |
import org.eclipse.swt.widgets.Composite; |
|
|
51 |
import org.eclipse.swt.widgets.Shell; |
52 |
import org.eclipse.ui.IEditorDescriptor; |
58 |
import org.eclipse.ui.IEditorDescriptor; |
53 |
import org.eclipse.ui.IEditorInput; |
59 |
import org.eclipse.ui.IEditorInput; |
54 |
import org.eclipse.ui.IEditorPart; |
60 |
import org.eclipse.ui.IEditorPart; |
Lines 1049-1054
Link Here
|
1049 |
return editor; |
1055 |
return editor; |
1050 |
} |
1056 |
} |
1051 |
|
1057 |
|
|
|
1058 |
/** |
1059 |
* Opens an editor on the given IFileStore object. |
1060 |
* <p> |
1061 |
* Unlike the other <code>openEditor</code> methods, this one |
1062 |
* can be used to open files that reside outside the workspace |
1063 |
* resource set. |
1064 |
* </p> |
1065 |
* <p> |
1066 |
* If the page already has an editor open on the target object then that |
1067 |
* editor is brought to front; otherwise, a new editor is opened. |
1068 |
* </p> |
1069 |
* |
1070 |
* @param page |
1071 |
* the page in which the editor will be opened |
1072 |
* @param fileStore |
1073 |
* the IFileStore representing the file to open |
1074 |
* @return an open editor or <code>null</code> if an external editor was opened |
1075 |
* @exception PartInitException |
1076 |
* if the editor could not be initialized |
1077 |
* @see org.eclipse.ui.IWorkbenchPage#openEditor(IEditorInput, String) |
1078 |
* @since 3.3 |
1079 |
*/ |
1080 |
public static IEditorPart openEditorOnFileStore(IWorkbenchPage page, IFileStore fileStore) throws PartInitException { |
1081 |
//sanity checks |
1082 |
if (page == null) { |
1083 |
throw new IllegalArgumentException(); |
1084 |
} |
1085 |
|
1086 |
IEditorInput input = getEditorInput(fileStore); |
1087 |
String editorId = getEditorId(fileStore); |
1088 |
|
1089 |
// open the editor on the file |
1090 |
return page.openEditor(input, editorId); |
1091 |
} |
1092 |
|
1093 |
/** |
1094 |
* Get the id of the editor associated with the given <code>IFileStore</code>. |
1095 |
* |
1096 |
* @param workbench |
1097 |
* the Workbench to use to determine the appropriate editor's id |
1098 |
* @param fileStore |
1099 |
* the <code>IFileStore</code> representing the file for which the editor id is desired |
1100 |
* @return the id of the appropriate editor |
1101 |
* @since 3.3 |
1102 |
*/ |
1103 |
private static String getEditorId(IFileStore fileStore) { |
1104 |
IEditorDescriptor descriptor; |
1105 |
try { |
1106 |
descriptor = IDE.getEditorDescriptor(fileStore.getName()); |
1107 |
} catch (PartInitException e) { |
1108 |
return null; |
1109 |
} |
1110 |
if (descriptor != null) |
1111 |
return descriptor.getId(); |
1112 |
return null; |
1113 |
} |
1114 |
|
1052 |
/** |
1115 |
/** |
1053 |
* Save all dirty editors in the workbench whose editor input is a child |
1116 |
* Save all dirty editors in the workbench whose editor input is a child |
1054 |
* resource of one of the <code>IResource</code>'s provided. Opens a |
1117 |
* resource of one of the <code>IResource</code>'s provided. Opens a |