1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.modeling.ui.diagramEditor;
14 import java.util.Collections;
17 import org.simantics.db.common.request.ParametrizedRead;
18 import org.simantics.db.layer0.request.combinations.Combinators;
19 import org.simantics.diagram.participant.PointerInteractor2;
20 import org.simantics.g2d.canvas.ICanvasContext;
21 import org.simantics.g2d.diagram.DiagramHints;
22 import org.simantics.g2d.diagram.IDiagram;
23 import org.simantics.g2d.diagram.participant.pointertool.PointerInteractor;
24 import org.simantics.g2d.layers.ILayer;
25 import org.simantics.g2d.layers.ILayers;
26 import org.simantics.g2d.layers.ILayersEditor;
27 import org.simantics.modeling.ui.diagramEditor.handlers.StructuralBrowsingHandler;
28 import org.simantics.ui.workbench.IResourceEditorInput;
29 import org.simantics.ui.workbench.editor.input.InputValidationCombinators;
32 * @author Tuukka Lehtonen
34 public class PlainDiagramViewer extends org.simantics.modeling.ui.diagramEditor.DiagramViewer {
36 ParametrizedRead<IResourceEditorInput, Boolean> INPUT_VALIDATOR =
38 InputValidationCombinators.hasURI(),
39 InputValidationCombinators.extractInputResource()
42 protected String getPopupId() {
43 return "#PlainDiagramViewerPopup";
46 public ParametrizedRead<IResourceEditorInput, Boolean> getInputValidator() {
47 return INPUT_VALIDATOR;
51 protected PointerInteractor getPointerInteractor() {
52 return new PointerInteractor2(true, true, true, false, false, false, synchronizer.getElementClassProvider());
55 protected void addStructureParticipants(ICanvasContext ctx) {
56 ctx.add(new StructuralBrowsingHandler(getSite(), sessionContext, getResourceInput2()));
57 addWorkbenchSelectionProvider(ctx);
63 getEditorSite().getActionBars().getStatusLineManager(),
64 new DefaultTerminalNamingStrategy()
70 protected void beforeSetDiagram(IDiagram diagram) {
74 protected void setupLayers(IDiagram diagram) {
75 diagram.setHint(DiagramHints.KEY_LAYERS, new ILayers() {
78 public boolean isActive(ILayer layer) {
83 public Set<ILayer> getVisibleLayers() {
84 return Collections.emptySet();
88 public Set<ILayer> getLayers() {
89 return Collections.emptySet();
93 public boolean getIgnoreVisibilitySettings() {
98 public boolean getIgnoreFocusSettings() {
104 // Disable roles (layers) by default in symbol editor to show everything.
105 ILayersEditor le = diagram.getHint(DiagramHints.KEY_LAYERS_EDITOR);
107 le.setIgnoreFocusSettings(true);
108 le.setIgnoreVisibilitySettings(true);
113 protected EditorState getSavedEditorState(ICanvasContext ctx) {
114 return DiagramEditorStates.toEditorState(ctx, true, true, false);