1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.graphviz.ui;
\r
14 import org.eclipse.core.runtime.IProgressMonitor;
\r
15 import org.eclipse.core.runtime.IStatus;
\r
16 import org.eclipse.core.runtime.Status;
\r
17 import org.eclipse.core.runtime.jobs.Job;
\r
18 import org.eclipse.swt.widgets.Composite;
\r
19 import org.eclipse.ui.IEditorInput;
\r
20 import org.eclipse.ui.IEditorSite;
\r
21 import org.eclipse.ui.PartInitException;
\r
22 import org.eclipse.ui.part.EditorPart;
\r
23 import org.simantics.graphviz.Graph;
\r
25 public abstract class AbstractGraphvizEditorPart extends EditorPart {
\r
27 GraphvizComponent component;
\r
30 public void doSave(IProgressMonitor monitor) {
\r
34 public void doSaveAs() {
\r
38 public void init(IEditorSite site, IEditorInput input)
\r
39 throws PartInitException {
\r
45 public boolean isDirty() {
\r
50 public boolean isSaveAsAllowed() {
\r
55 public void createPartControl(Composite parent) {
\r
56 component = new GraphvizComponent(parent, 0);
\r
60 * Sets a new graph to be drawn. This operation may take a while. It can
\r
61 * be called from any thread.
\r
64 public void setGraph(Graph graph) {
\r
65 component.setGraph(graph);
\r
68 public void setGraph(Graph graph, String algorithm) {
\r
69 component.setGraph(graph, algorithm);
\r
73 * Sets a new graph to be drawn. The graph is layouted in a Eclipse job.
\r
74 * The component is redrawn after the layout is complete.
\r
77 public void asyncSetGraph(final Graph graph) {
\r
78 Job job = new Job("Layouting a graph") {
\r
81 protected IStatus run(IProgressMonitor monitor) {
\r
83 return Status.OK_STATUS;
\r
91 public void setFocus() {
\r
92 if(component != null)
\r
93 component.requestFocus();
\r