| /******************************************************************************* |
| * 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.editor; |
| |
| 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.PasteAction; |
| import org.eclipse.emf.edit.ui.action.RedoAction; |
| import org.eclipse.emf.edit.ui.action.UndoAction; |
| import org.eclipse.jface.action.IMenuManager; |
| import org.eclipse.jface.action.Separator; |
| import org.polarsys.esf.core.common.ui.actions.ActionBarContributorUtils; |
| |
| /** |
| * This is the action bar contributor used to edit the archived files. |
| * |
| * This contributor avoid any action which can modify the archive content. |
| * |
| * @author $Author: jdumont $ |
| * @version $Revision: 83 $ |
| */ |
| public class ArchiveActionBarContributor |
| extends EmptyActionBarContributor { |
| |
| /** |
| * Default constructor. |
| */ |
| public ArchiveActionBarContributor() { |
| // Call the parent constructor |
| super(); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * Overridden to hide all the edit actions like undo, redo, cut, copy, paste, etc. |
| */ |
| @Override |
| public void menuAboutToShow(final IMenuManager pMenuManager) { |
| // Add the standard addition marker at the beginning if needed |
| if ((style & ADDITIONS_LAST_STYLE) == 0) { |
| pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_SEPARATOR_ID)); |
| } |
| |
| // Add the standard edit marker but not all the related actions |
| pMenuManager.add(new Separator(ActionBarContributorUtils.EDIT_SEPARATOR_ID)); |
| |
| // Add the standard addition marker at the end if needed |
| if ((style & ADDITIONS_LAST_STYLE) != 0) { |
| pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_SEPARATOR_ID)); |
| } |
| |
| // Add the standard additions-end marker |
| pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_END_SEPARATOR_ID)); |
| |
| // Finally add all the global actions |
| addGlobalActions(pMenuManager); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * Avoid the copy action. |
| */ |
| @Override |
| protected CopyAction createCopyAction() { |
| |
| CopyAction vAction = new CopyAction() { |
| /** |
| * {@inheritDoc} |
| */ |
| @Override |
| public Command createCommand(final Collection<?> pSelection) { |
| return UnexecutableCommand.INSTANCE; |
| } |
| }; |
| |
| return vAction; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * Avoid the paste action. |
| */ |
| @Override |
| protected PasteAction createPasteAction() { |
| |
| PasteAction vAction = new PasteAction() { |
| /** |
| * {@inheritDoc} |
| */ |
| @Override |
| public Command createCommand(final Collection<?> pSelection) { |
| return UnexecutableCommand.INSTANCE; |
| } |
| }; |
| |
| return vAction; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * Avoid the cut action. |
| */ |
| @Override |
| protected CutAction createCutAction() { |
| |
| CutAction vAction = new CutAction() { |
| /** |
| * {@inheritDoc} |
| */ |
| @Override |
| public Command createCommand(final Collection<?> pSelection) { |
| return UnexecutableCommand.INSTANCE; |
| } |
| }; |
| |
| return vAction; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * Avoid the undo action. |
| */ |
| @Override |
| protected UndoAction createUndoAction() { |
| |
| // Create the action and disable it |
| UndoAction vAction = super.createUndoAction(); |
| vAction.setEnabled(false); |
| |
| return vAction; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * Avoid the redo action. |
| */ |
| @Override |
| protected RedoAction createRedoAction() { |
| |
| // Create the action and disable it |
| RedoAction vAction = super.createRedoAction(); |
| vAction.setEnabled(false); |
| |
| return vAction; |
| } |
| } |