| /******************************************************************************* |
| * Copyright (c) 2016 ALL4TEC & CEA LIST. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * ALL4TEC & CEA LIST - initial API and implementation |
| ******************************************************************************/ |
| package org.polarsys.esf.core.common.ui.actions; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.emf.common.command.Command; |
| import org.eclipse.emf.common.command.UnexecutableCommand; |
| import org.eclipse.emf.edit.ui.action.CopyAction; |
| import org.eclipse.emf.edit.ui.action.CutAction; |
| import org.eclipse.emf.edit.ui.action.DeleteAction; |
| import org.eclipse.emf.edit.ui.action.PasteAction; |
| import org.eclipse.jface.action.ActionContributionItem; |
| import org.eclipse.jface.action.IMenuManager; |
| import org.eclipse.jface.action.Separator; |
| |
| |
| /** |
| * |
| * Action bar contributor |
| * |
| * Overridden to remove all editions action, and clean popmenu. |
| * |
| * @author $Author: jdumont $ |
| * @version $Revision: 83 $ |
| */ |
| public class NoModifiesActionBarContributor |
| extends ViewActionBarContributor { |
| |
| /** |
| * Default constructor. |
| */ |
| public NoModifiesActionBarContributor() { |
| super(); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @return an unexecutable command, to handle global delete action. |
| */ |
| @Override |
| protected DeleteAction createDeleteAction() { |
| return new DeleteAction() { |
| |
| /** |
| * {@inheritDoc} |
| */ |
| @Override |
| public Command createCommand(final Collection<?> pSelection) { |
| return UnexecutableCommand.INSTANCE; |
| } |
| }; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @return an unexecutable command, to handle global cut action. |
| */ |
| @Override |
| protected CutAction createCutAction() { |
| return new CutAction() { |
| |
| /** |
| * {@inheritDoc} |
| */ |
| @Override |
| public Command createCommand(final Collection<?> pSelection) { |
| return UnexecutableCommand.INSTANCE; |
| } |
| }; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @return an unexecutable command, to handle global paste action. |
| */ |
| @Override |
| protected PasteAction createPasteAction() { |
| return new PasteAction() { |
| |
| /** |
| * {@inheritDoc} |
| */ |
| @Override |
| public Command createCommand(final Collection<?> pSelection) { |
| return UnexecutableCommand.INSTANCE; |
| } |
| }; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @return an unexecutable command, to handle global copy action. |
| */ |
| @Override |
| protected CopyAction createCopyAction() { |
| return new CopyAction() { |
| |
| /** |
| * {@inheritDoc} |
| */ |
| @Override |
| public Command createCommand(final Collection<?> pSelection) { |
| return UnexecutableCommand.INSTANCE; |
| } |
| }; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * Customise the add global action to remove the Show Properties |
| * which is not useful in this context. |
| */ |
| @Override |
| protected void addGlobalActions(final IMenuManager pMenuManager) { |
| |
| // Call the parent method |
| super.addGlobalActions(pMenuManager); |
| |
| // Remove the show properties action |
| pMenuManager.remove(ActionBarContributorUtils.SHOW_PROPERTIES_ACTION_ID); |
| } |
| |
| /** |
| * {@inheritDoc} |
| */ |
| @Override |
| public void menuAboutToShow(final IMenuManager pMenuManager) { |
| // Add our standard marker. |
| if ((style & ADDITIONS_LAST_STYLE) == 0) { |
| pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_SEPARATOR_ID)); |
| } |
| pMenuManager.add(new Separator(ActionBarContributorUtils.EDIT_SEPARATOR_ID)); |
| |
| pMenuManager.add(new ActionContributionItem(undoAction)); |
| pMenuManager.add(new ActionContributionItem(redoAction)); |
| pMenuManager.add(new Separator()); |
| |
| if ((style & ADDITIONS_LAST_STYLE) != 0) { |
| pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_SEPARATOR_ID)); |
| pMenuManager.add(new Separator()); |
| } |
| // Add our other standard marker. |
| pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_END_SEPARATOR_ID)); |
| |
| addGlobalActions(pMenuManager); |
| } |
| } |