diff options
author | Tor Norbye <tnorbye@google.com> | 2011-05-18 12:15:17 -0700 |
---|---|---|
committer | Android Code Review <code-review@android.com> | 2011-05-18 12:15:17 -0700 |
commit | 758e373712078144ddcc1e2ecb6913f733aa5e52 (patch) | |
tree | ecdee4926cadfe273abaf05a67d28308fab26ae4 /eclipse/plugins | |
parent | 662482b4663c267798ac8c3926f8cf823f057a86 (diff) | |
parent | 74e6dd111f5e037e4ecda1f9cd7ab9cc37ebdff8 (diff) | |
download | sdk-758e373712078144ddcc1e2ecb6913f733aa5e52.zip sdk-758e373712078144ddcc1e2ecb6913f733aa5e52.tar.gz sdk-758e373712078144ddcc1e2ecb6913f733aa5e52.tar.bz2 |
Merge "Fix bug in editor open utility" into tools-adt_r11
Diffstat (limited to 'eclipse/plugins')
2 files changed, 55 insertions, 47 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java index c87b669..4c5aaf6 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java @@ -38,7 +38,6 @@ import com.android.sdklib.SdkConstants; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -902,53 +901,56 @@ public class LayoutCanvas extends Canvas { page.saveEditor(mLayoutEditor, false); IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot(); + IFile xmlFile = null; IPath workspacePath = workspace.getLocation(); if (workspacePath.isPrefixOf(filePath)) { IPath relativePath = filePath.makeRelativeTo(workspacePath); - IResource xmlFile = workspace.findMember(relativePath); - if (xmlFile != null) { - IFile leavingFile = graphicalEditor.getEditedFile(); - Reference next = Reference.create(graphicalEditor.getEditedFile()); - - try { - IEditorPart openAlready = EditorUtility.isOpenInEditor(xmlFile); - - // Show the included file as included within this click source? - if (openAlready != null) { - if (openAlready instanceof LayoutEditor) { - LayoutEditor editor = (LayoutEditor)openAlready; - GraphicalEditorPart gEditor = editor.getGraphicalEditor(); - if (gEditor.renderingSupports(Capability.EMBEDDED_LAYOUT)) { - gEditor.showIn(next); - } + xmlFile = (IFile) workspace.findMember(relativePath); + } else if (filePath.isAbsolute()) { + xmlFile = workspace.getFileForLocation(filePath); + } + if (xmlFile != null) { + IFile leavingFile = graphicalEditor.getEditedFile(); + Reference next = Reference.create(graphicalEditor.getEditedFile()); + + try { + IEditorPart openAlready = EditorUtility.isOpenInEditor(xmlFile); + + // Show the included file as included within this click source? + if (openAlready != null) { + if (openAlready instanceof LayoutEditor) { + LayoutEditor editor = (LayoutEditor)openAlready; + GraphicalEditorPart gEditor = editor.getGraphicalEditor(); + if (gEditor.renderingSupports(Capability.EMBEDDED_LAYOUT)) { + gEditor.showIn(next); } - } else { + } + } else { + try { + // Set initial state of a new file + // TODO: Only set rendering target portion of the state + QualifiedName qname = ConfigurationComposite.NAME_CONFIG_STATE; + String state = AdtPlugin.getFileProperty(leavingFile, qname); + xmlFile.setSessionProperty(GraphicalEditorPart.NAME_INITIAL_STATE, + state); + } catch (CoreException e) { + // pass + } + + if (graphicalEditor.renderingSupports(Capability.EMBEDDED_LAYOUT)) { try { - // Set initial state of a new file - // TODO: Only set rendering target portion of the state - QualifiedName qname = ConfigurationComposite.NAME_CONFIG_STATE; - String state = AdtPlugin.getFileProperty(leavingFile, qname); - xmlFile.setSessionProperty(GraphicalEditorPart.NAME_INITIAL_STATE, - state); + xmlFile.setSessionProperty(GraphicalEditorPart.NAME_INCLUDE, next); } catch (CoreException e) { - // pass - } - - if (graphicalEditor.renderingSupports(Capability.EMBEDDED_LAYOUT)) { - try { - xmlFile.setSessionProperty(GraphicalEditorPart.NAME_INCLUDE, next); - } catch (CoreException e) { - // pass - worst that can happen is that we don't - //start with inclusion - } + // pass - worst that can happen is that we don't + //start with inclusion } } - - EditorUtility.openInEditor(xmlFile, true); - return; - } catch (PartInitException ex) { - AdtPlugin.log(ex, "Can't open %$1s", url); //$NON-NLS-1$ } + + EditorUtility.openInEditor(xmlFile, true); + return; + } catch (PartInitException ex) { + AdtPlugin.log(ex, "Can't open %$1s", url); //$NON-NLS-1$ } } else { // It's not a path in the workspace; look externally diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java index 069d475..ae84f13 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java @@ -540,16 +540,22 @@ public class Hyperlinks { IWorkbenchPage page = sourceEditor.getEditorSite().getPage(); IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot(); IPath workspacePath = workspace.getLocation(); + IFile file = null; if (workspacePath.isPrefixOf(filePath)) { IPath relativePath = filePath.makeRelativeTo(workspacePath); - IResource file = workspace.findMember(relativePath); - if (file instanceof IFile) { - try { - AdtPlugin.openFile((IFile) file, region); - return; - } catch (PartInitException ex) { - AdtPlugin.log(ex, "Can't open %$1s", filePath); //$NON-NLS-1$ - } + IResource member = workspace.findMember(relativePath); + if (member instanceof IFile) { + file = (IFile) member; + } + } else if (filePath.isAbsolute()) { + file = workspace.getFileForLocation(filePath); + } + if (file != null) { + try { + AdtPlugin.openFile(file, region); + return; + } catch (PartInitException ex) { + AdtPlugin.log(ex, "Can't open %$1s", filePath); //$NON-NLS-1$ } } else { // It's not a path in the workspace; look externally |