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.graphviz.ui;
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.eclipse.ui.IEditorInput;
20 import org.eclipse.ui.IEditorSite;
21 import org.eclipse.ui.PartInitException;
22 import org.eclipse.ui.part.EditorPart;
23 import org.simantics.graphviz.Graph;
25 public abstract class AbstractGraphvizEditorPart extends EditorPart {
27 GraphvizComponent component;
30 public void doSave(IProgressMonitor monitor) {
34 public void doSaveAs() {
38 public void init(IEditorSite site, IEditorInput input)
39 throws PartInitException {
45 public boolean isDirty() {
50 public boolean isSaveAsAllowed() {
55 public void createPartControl(Composite parent) {
56 component = new GraphvizComponent(parent, 0);
60 * Sets a new graph to be drawn. This operation may take a while. It can
61 * be called from any thread.
64 public void setGraph(Graph graph) {
65 component.setGraph(graph);
68 public void setGraph(Graph graph, String algorithm) {
69 component.setGraph(graph, algorithm);
73 * Sets a new graph to be drawn. The graph is layouted in a Eclipse job.
74 * The component is redrawn after the layout is complete.
77 public void asyncSetGraph(final Graph graph) {
78 Job job = new Job("Layouting a graph") {
81 protected IStatus run(IProgressMonitor monitor) {
83 return Status.OK_STATUS;
91 public void setFocus() {
93 component.requestFocus();