aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java10
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java29
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());