/******************************************************************************* | |
* <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 java.net.MalformedURLException; | |
import org.eclipse.core.runtime.Status; | |
import org.eclipse.fmc.blockdiagram.editor.clipboard.PasteFromClipboard; | |
import org.eclipse.gef.MouseWheelHandler; | |
import org.eclipse.gef.MouseWheelZoomHandler; | |
import org.eclipse.graphiti.ui.editor.DiagramBehavior; | |
import org.eclipse.graphiti.ui.editor.DiagramEditor; | |
import org.eclipse.swt.SWT; | |
import org.eclipse.ui.statushandlers.StatusManager; | |
/** | |
* The diagram editor represents the editor to Eclipse and is a Graphiti editor. | |
* It defines a custom palette behavior to add new tool entries. Registers all | |
* clipboard images to the image provider. Mouse wheel is enabled for zooming. | |
* Registers additional key handlers for deletion and direct editing. | |
* | |
* | |
* @author Benjamin Schmeling | |
* @author Rainer Thome | |
*/ | |
public class BlockDiagramEditor extends DiagramEditor { | |
/** | |
* Default Constructor. | |
*/ | |
public BlockDiagramEditor() { | |
} | |
@Override | |
public void initializeGraphicalViewer() { | |
try { | |
PasteFromClipboard.registerClipImages(this); | |
} catch (MalformedURLException e) { | |
StatusManager | |
.getManager() | |
.handle(new Status( | |
Status.ERROR, | |
Activator.PLUGIN_ID, | |
"Cannot register clip images to the image provider", | |
e)); | |
} | |
super.initializeGraphicalViewer(); | |
getGraphicalViewer().setProperty( | |
MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), | |
MouseWheelZoomHandler.SINGLETON); | |
} | |
@Override | |
protected DiagramBehavior createDiagramBehavior() { | |
return new BlockDiagramBehavior(this); | |
} | |
} |