X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graphviz.ui%2Fsrc%2Forg%2Fsimantics%2Fgraphviz%2Fui%2FAbstractGraphvizEditorPart.java;fp=bundles%2Forg.simantics.graphviz.ui%2Fsrc%2Forg%2Fsimantics%2Fgraphviz%2Fui%2FAbstractGraphvizEditorPart.java;h=2c39d32a7c6da4197e9f480437f634f1f440e782;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=cd14c7137b1350ddcb2812d7ba9fb0cddce0a03c;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.graphviz.ui/src/org/simantics/graphviz/ui/AbstractGraphvizEditorPart.java b/bundles/org.simantics.graphviz.ui/src/org/simantics/graphviz/ui/AbstractGraphvizEditorPart.java index cd14c7137..2c39d32a7 100644 --- a/bundles/org.simantics.graphviz.ui/src/org/simantics/graphviz/ui/AbstractGraphvizEditorPart.java +++ b/bundles/org.simantics.graphviz.ui/src/org/simantics/graphviz/ui/AbstractGraphvizEditorPart.java @@ -1,96 +1,96 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.graphviz.ui; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.EditorPart; -import org.simantics.graphviz.Graph; - -public abstract class AbstractGraphvizEditorPart extends EditorPart { - - GraphvizComponent component; - - @Override - public void doSave(IProgressMonitor monitor) { - } - - @Override - public void doSaveAs() { - } - - @Override - public void init(IEditorSite site, IEditorInput input) - throws PartInitException { - setSite(site); - setInput(input); - } - - @Override - public boolean isDirty() { - return false; - } - - @Override - public boolean isSaveAsAllowed() { - return false; - } - - @Override - public void createPartControl(Composite parent) { - component = new GraphvizComponent(parent, 0); - } - - /** - * Sets a new graph to be drawn. This operation may take a while. It can - * be called from any thread. - * @param graph - */ - public void setGraph(Graph graph) { - component.setGraph(graph); - } - - public void setGraph(Graph graph, String algorithm) { - component.setGraph(graph, algorithm); - } - - /** - * Sets a new graph to be drawn. The graph is layouted in a Eclipse job. - * The component is redrawn after the layout is complete. - * @param graph - */ - public void asyncSetGraph(final Graph graph) { - Job job = new Job("Layouting a graph") { - - @Override - protected IStatus run(IProgressMonitor monitor) { - setGraph(graph); - return Status.OK_STATUS; - } - - }; - job.schedule(); - } - - @Override - public void setFocus() { - if(component != null) - component.requestFocus(); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.graphviz.ui; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.EditorPart; +import org.simantics.graphviz.Graph; + +public abstract class AbstractGraphvizEditorPart extends EditorPart { + + GraphvizComponent component; + + @Override + public void doSave(IProgressMonitor monitor) { + } + + @Override + public void doSaveAs() { + } + + @Override + public void init(IEditorSite site, IEditorInput input) + throws PartInitException { + setSite(site); + setInput(input); + } + + @Override + public boolean isDirty() { + return false; + } + + @Override + public boolean isSaveAsAllowed() { + return false; + } + + @Override + public void createPartControl(Composite parent) { + component = new GraphvizComponent(parent, 0); + } + + /** + * Sets a new graph to be drawn. This operation may take a while. It can + * be called from any thread. + * @param graph + */ + public void setGraph(Graph graph) { + component.setGraph(graph); + } + + public void setGraph(Graph graph, String algorithm) { + component.setGraph(graph, algorithm); + } + + /** + * Sets a new graph to be drawn. The graph is layouted in a Eclipse job. + * The component is redrawn after the layout is complete. + * @param graph + */ + public void asyncSetGraph(final Graph graph) { + Job job = new Job("Layouting a graph") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + setGraph(graph); + return Status.OK_STATUS; + } + + }; + job.schedule(); + } + + @Override + public void setFocus() { + if(component != null) + component.requestFocus(); + } + +}