2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.eclipse.org/org/documents/epl-v10.php
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.ide.eclipse.adt.internal.editors.manifest;
19 import org.eclipse.jface.action.IAction;
20 import org.eclipse.ui.IActionBars;
21 import org.eclipse.ui.IEditorPart;
22 import org.eclipse.ui.actions.ActionFactory;
23 import org.eclipse.ui.ide.IDEActionFactory;
24 import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
25 import org.eclipse.ui.texteditor.ITextEditor;
26 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
29 * Manages the installation/deinstallation of global actions for multi-page
30 * editors. Responsible for the redirection of global actions to the active
31 * editor. Multi-page contributor replaces the contributors for the individual
32 * editors in the multi-page editor.
34 * TODO: Doesn't look like we need this. Remove it if not needed.
37 final class ManifestEditorContributor extends MultiPageEditorActionBarContributor {
38 private IEditorPart mActiveEditorPart;
41 * Creates a multi-page contributor.
43 * Marked as Private so it can't be instanciated. This is a cheap way to make sure
44 * it's not being used. As noted in constructor, should be removed if not used.
47 private ManifestEditorContributor() {
52 * Returns the action registed with the given text editor.
54 * @return IAction or null if editor is null.
56 protected IAction getAction(ITextEditor editor, String actionID) {
57 return (editor == null ? null : editor.getAction(actionID));
61 * (non-JavaDoc) Method declared in
62 * AbstractMultiPageEditorActionBarContributor.
66 public void setActivePage(IEditorPart part) {
67 if (mActiveEditorPart == part)
70 mActiveEditorPart = part;
72 IActionBars actionBars = getActionBars();
73 if (actionBars != null) {
76 (part instanceof ITextEditor) ? (ITextEditor)part : null;
78 actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(),
79 getAction(editor, ITextEditorActionConstants.DELETE));
80 actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(),
81 getAction(editor, ITextEditorActionConstants.UNDO));
82 actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(),
83 getAction(editor, ITextEditorActionConstants.REDO));
84 actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(),
85 getAction(editor, ITextEditorActionConstants.CUT));
86 actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(),
87 getAction(editor, ITextEditorActionConstants.COPY));
88 actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(),
89 getAction(editor, ITextEditorActionConstants.PASTE));
90 actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(),
91 getAction(editor, ITextEditorActionConstants.SELECT_ALL));
92 actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(),
93 getAction(editor, ITextEditorActionConstants.FIND));
94 actionBars.setGlobalActionHandler(
95 IDEActionFactory.BOOKMARK.getId(), getAction(editor,
96 IDEActionFactory.BOOKMARK.getId()));
97 actionBars.updateActionBars();