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.structural.ui.compositeViewer;
14 import org.simantics.browsing.ui.BuiltinKeys;
15 import org.simantics.browsing.ui.NodeContext;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.structural.ui.modelBrowser.nodes.CompositeNode;
20 import org.simantics.ui.workbench.ResourceEditorInput;
21 import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter;
22 import org.simantics.utils.ui.AdaptionUtils;
24 public class CompositeViewerAdapter extends AbstractResourceEditorAdapter {
26 public CompositeViewerAdapter() {
27 super("Composite Viewer", null, 10);
31 public boolean canHandle(ReadGraph g, Object input)
32 throws DatabaseException {
33 NodeContext context = AdaptionUtils.adaptToSingle(input, NodeContext.class);
35 Object obj = context.getConstant(BuiltinKeys.INPUT);
36 if(obj instanceof CompositeNode) {
44 public void openEditor(Resource r) throws Exception {
45 String editorId = "org.simantics.structural.ui.compositeViewer";
46 openEditorWithId(editorId, new ResourceEditorInput(editorId, r));