| /******************************************************************************* |
| * <copyright> |
| * |
| * Copyright (c) 2013, 2013 SAP AG. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * SAP AG - initial API, implementation and documentation |
| * |
| * </copyright> |
| * |
| *******************************************************************************/ |
| package org.eclipse.fmc.blockdiagram.editor; |
| |
| import org.eclipse.gef.KeyHandler; |
| import org.eclipse.gef.KeyStroke; |
| import org.eclipse.gef.ui.actions.GEFActionConstants; |
| import org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior; |
| import org.eclipse.graphiti.ui.editor.DiagramBehavior; |
| import org.eclipse.graphiti.ui.editor.IDiagramContainerUI; |
| import org.eclipse.graphiti.ui.internal.action.RemoveAction; |
| |
| /** |
| * Change delete key behavior from DeleteAction to RemoveAction and enables |
| * direct editing with return key. |
| * |
| * @author Benjamin Schmeling |
| * |
| */ |
| @SuppressWarnings("restriction") |
| public class BlockDiagramBehavior extends DiagramBehavior{ |
| |
| public BlockDiagramBehavior(IDiagramContainerUI diagramContainer) { |
| super(diagramContainer); |
| } |
| |
| @Override |
| protected DefaultPaletteBehavior createPaletteBehaviour() { |
| return new BlockDiagramPaletteBehavior(this); |
| } |
| |
| @Override |
| public KeyHandler getCommonKeyHandler() { |
| KeyHandler handler = super.getCommonKeyHandler(); |
| if (getDiagramTypeProvider().getFeatureProvider() |
| .getDeleteFeature(null) == null) { |
| handler.remove(KeyStroke.getPressed((char) 127, 127, 0)); |
| handler.put(KeyStroke.getPressed((char) 127, 127, 0), |
| getDiagramContainer().getActionRegistry().getAction(RemoveAction.ACTION_ID)); |
| } |
| handler.put(KeyStroke.getPressed((char) 13, 13, 0), getDiagramContainer().getActionRegistry() |
| .getAction(GEFActionConstants.DIRECT_EDIT)); |
| return handler; |
| } |
| |
| } |