diff options
author | Tor Norbye <tnorbye@google.com> | 2010-11-23 20:50:33 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2010-11-23 20:52:55 -0800 |
commit | 6678720fd8c27f10389efede23ee44a29b8fbd3d (patch) | |
tree | 4dd8fb5c0a35f75b6fd1d25de5b364f3728eb33a /eclipse/plugins/com.android.ide.eclipse.adt/src/com | |
parent | 40bba5bf796b982b941359032645c2cfea1561dc (diff) | |
download | sdk-6678720fd8c27f10389efede23ee44a29b8fbd3d.zip sdk-6678720fd8c27f10389efede23ee44a29b8fbd3d.tar.gz sdk-6678720fd8c27f10389efede23ee44a29b8fbd3d.tar.bz2 |
Replace IPath.makeRelativeTo call with reflection
I broke the build because on Eclipse 3.4 there is no makeRelativeTo
method on IPath. This replaces that call with reflection. This won't
work on 3.4, but it's a quick fix for the broken build.
Change-Id: Ia917cf5a745f76bbb96f59fae93e2a4fc4f5f900
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com')
-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); |