]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/internal/TGEditorAdapter.java
a941ecbc39b920435c1869368e6baf336443003c
[simantics/platform.git] / bundles / org.simantics.debug.ui / src / org / simantics / debug / ui / internal / TGEditorAdapter.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.debug.ui.internal;
13
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.common.request.PossibleIndexRoot;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.layer0.Layer0;
19 import org.simantics.ui.SimanticsUI;
20 import org.simantics.ui.workbench.ResourceEditorInput;
21 import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter;
22
23 /**
24  * @author Antti Villberg
25  */
26 public class TGEditorAdapter extends AbstractResourceEditorAdapter {
27
28         public static final String EDITOR_ID = "org.simantics.modeling.ui.pgraphEditor";
29         
30     public TGEditorAdapter() {
31         super("Ontology Viewer", SimanticsUI.getImageDescriptor("icons/etool16/bug.png"));
32     }
33
34     @Override
35     public boolean canHandle(ReadGraph g, Resource r) throws DatabaseException {
36         Resource indexRoot = g.syncRequest(new PossibleIndexRoot(r));
37         if(indexRoot == null) return false;
38         Layer0 L0 = Layer0.getInstance(g);
39         return g.isInstanceOf(indexRoot, L0.Ontology);
40     }
41
42     @Override
43     public void openEditor(Resource r) throws Exception {
44         openEditorWithId(EDITOR_ID, new ResourceEditorInput(EDITOR_ID,r));
45     }
46     
47 }