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.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.core.runtime.jobs.Job;
18 import org.eclipse.swt.widgets.Composite;
19 import org.simantics.db.procedure.Listener;
20 import org.simantics.graphviz.Graph;
21 import org.simantics.graphviz.ui.GraphvizComponent;
22 import org.simantics.ui.SimanticsUI;
23 import org.simantics.ui.workbench.ResourceEditorPart;
25 public class CompositeViewer extends ResourceEditorPart {
27 GraphvizComponent component;
28 private boolean disposed = false;
31 public void createPartControl(Composite parent) {
32 component = new GraphvizComponent(parent, 0);
33 component.waitUntilInitialized();
37 private void readGraph() {
38 SimanticsUI.getSession().asyncRequest(new CreateCompositeGraph(
39 getResourceInput().getResource()),
40 new Listener<Graph>() {
43 public void exception(Throwable e) {
48 public void execute(final Graph graph) {
49 Job job = new Job("Layout composite graph") {
52 protected IStatus run(IProgressMonitor monitor) {
53 component.setGraph(graph, "neato");
54 return Status.OK_STATUS;
62 public boolean isDisposed() {
69 public void setFocus() {
70 if (component != null && !component.isDisposed()) {
72 component.requestFocus();
77 public void dispose() {