blob: 9616e097809612fbd17d86e12fc148b6c7079ce1 [file] [log] [blame]
/*******************************************************************************
* 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.DeleteAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.actions.ActionFactory;
import org.polarsys.esf.core.common.ui.actions.ActionBarContributorUtils;
/**
* This is the empty action bar contributor.
* It doesn't allow to add or delete elements from the input model.
*
* It's primary used is for the propagation tree editor, and overridden
* for the archived file editors.
*
* @author $Author: jdumont $
* @version $Revision: 83 $
*/
public class EmptyActionBarContributor
extends AbstractActionBarContributor {
/**
* Default constructor.
*/
public EmptyActionBarContributor() {
// Call the parent constructor
super();
}
/**
* {@inheritDoc}
*
* Overridden to avoid the creation of new elements in the model.
* This implementation disable the creation of action in the context menu
* and in the editor tool bar.
*/
@Override
protected void addCreateSelectChildActions(final ISelection pSelection) {
// Do nothing voluntary
}
/**
* {@inheritDoc}
*
* Overridden to ensure there is no delete action possible.
*/
@Override
protected DeleteAction createDeleteAction() {
DeleteAction vAction = new DeleteAction(removeAllReferencesOnDelete()) {
/**
* {@inheritDoc}
*/
@Override
public Command createCommand(final Collection<?> pSelection) {
return UnexecutableCommand.INSTANCE;
}
};
vAction.setId(ActionFactory.DELETE.getId());
return vAction;
}
/**
* {@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);
}
}