diff options
Diffstat (limited to 'eclipse')
-rwxr-xr-x | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java | 28 |
1 files changed, 27 insertions, 1 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 c0e69b1..e5113f8 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 @@ -83,6 +83,8 @@ import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.w3c.dom.Node; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -710,7 +712,31 @@ class LayoutCanvas extends Canvas { IPath workspacePath = workspace.getLocation(); IEditorSite editorSite = graphicalEditor.getEditorSite(); if (workspacePath.isPrefixOf(filePath)) { - IPath relativePath = filePath.makeRelativeTo(workspacePath); + // This apparently doesn't work in 3.4: + // IPath relativePath = filePath.makeRelativeTo(workspacePath); + // Use reflection as a build hotfix. + // FIXME: This won't work on 3.4 but we're talking about dropping 3.4 support + // shortly since most Eclipse users have migrated to 3.5 + 3.6. + IPath relativePath = null; + try { + Method method = IPath.class.getDeclaredMethod("makeRelativeTo", //$NON-NLS-1$ + new Class<?>[] { + IPath.class + }); + relativePath = (IPath) method.invoke(filePath, new Object[] { + workspacePath + }); + } catch (SecurityException e) { + } catch (NoSuchMethodException e) { + } catch (IllegalArgumentException e) { + } catch (IllegalAccessException e) { + } catch (InvocationTargetException e) { + } + + if (relativePath == null) { + return; + } + IResource xmlFile = workspace.findMember(relativePath); try { EditorUtility.openInEditor(xmlFile, true); |