diff options
author | Tor Norbye <tnorbye@google.com> | 2012-05-30 18:17:59 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-05-30 18:17:59 -0700 |
commit | 86b00e87888bfce42b1d05dbf7cdec8295144fd8 (patch) | |
tree | a062f3d9b1d3237d397a4ac42a8a947f1265064d | |
parent | 7578d4af99c266f36ed961d91bc2cd5b69c8c4ed (diff) | |
download | sdk-86b00e87888bfce42b1d05dbf7cdec8295144fd8.zip sdk-86b00e87888bfce42b1d05dbf7cdec8295144fd8.tar.gz sdk-86b00e87888bfce42b1d05dbf7cdec8295144fd8.tar.bz2 |
Fix cut & paste in XML editors for Eclipse 4.x
Change-Id: Ie30c362c71eff0d62e177e06687c362802d416b1
2 files changed, 32 insertions, 7 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java index 8d7b02e..f904f6e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java @@ -687,6 +687,16 @@ public class LayoutEditorDelegate extends CommonXmlDelegate public void delegatePostPageChange(int newPageIndex) { super.delegatePostPageChange(newPageIndex); + if (mGraphicalEditor != null) { + LayoutCanvas canvas = mGraphicalEditor.getCanvasControl(); + if (canvas != null) { + IActionBars bars = getEditor().getEditorSite().getActionBars(); + if (bars != null) { + canvas.updateGlobalActions(bars); + } + } + } + IFormPage page = getEditor().getActivePageInstance(); updateOutline(page); } 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 2154179..371852c 100644 --- 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 @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gle2; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.Margins; import com.android.ide.common.api.Point; @@ -1213,16 +1214,30 @@ public class LayoutCanvas extends Canvas { * * @param bars the action bar for this canvas */ - public void updateGlobalActions(IActionBars bars) { + public void updateGlobalActions(@NonNull IActionBars bars) { updateMenuActionState(); - assert bars != null; - bars.setGlobalActionHandler(ActionFactory.CUT.getId(), mCutAction); - bars.setGlobalActionHandler(ActionFactory.COPY.getId(), mCopyAction); - bars.setGlobalActionHandler(ActionFactory.PASTE.getId(), mPasteAction); - bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), mDeleteAction); - bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), mSelectAllAction); ITextEditor editor = mEditorDelegate.getEditor().getStructuredTextEditor(); + boolean graphical = getEditorDelegate().getEditor().getActivePage() == 0; + if (graphical) { + bars.setGlobalActionHandler(ActionFactory.CUT.getId(), mCutAction); + bars.setGlobalActionHandler(ActionFactory.COPY.getId(), mCopyAction); + bars.setGlobalActionHandler(ActionFactory.PASTE.getId(), mPasteAction); + bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), mDeleteAction); + bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), mSelectAllAction); + } else { + bars.setGlobalActionHandler(ActionFactory.CUT.getId(), + editor.getAction(ActionFactory.CUT.getId())); + bars.setGlobalActionHandler(ActionFactory.COPY.getId(), + editor.getAction(ActionFactory.COPY.getId())); + bars.setGlobalActionHandler(ActionFactory.PASTE.getId(), + editor.getAction(ActionFactory.PASTE.getId())); + bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), + editor.getAction(ActionFactory.DELETE.getId())); + bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), + editor.getAction(ActionFactory.SELECT_ALL.getId())); + } + IAction undoAction = editor.getAction(ActionFactory.UNDO.getId()); bars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction); IAction redoAction = editor.getAction(ActionFactory.REDO.getId()); |