-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.graphviz.ui;\r
-\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Status;\r
-import org.eclipse.core.runtime.jobs.Job;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.ui.IEditorInput;\r
-import org.eclipse.ui.IEditorSite;\r
-import org.eclipse.ui.PartInitException;\r
-import org.eclipse.ui.part.EditorPart;\r
-import org.simantics.graphviz.Graph;\r
-\r
-public abstract class AbstractGraphvizEditorPart extends EditorPart {\r
-\r
- GraphvizComponent component;\r
- \r
- @Override\r
- public void doSave(IProgressMonitor monitor) {\r
- }\r
-\r
- @Override\r
- public void doSaveAs() {\r
- }\r
-\r
- @Override\r
- public void init(IEditorSite site, IEditorInput input)\r
- throws PartInitException {\r
- setSite(site);\r
- setInput(input);\r
- }\r
-\r
- @Override\r
- public boolean isDirty() {\r
- return false;\r
- }\r
-\r
- @Override\r
- public boolean isSaveAsAllowed() {\r
- return false;\r
- }\r
-\r
- @Override\r
- public void createPartControl(Composite parent) { \r
- component = new GraphvizComponent(parent, 0);\r
- }\r
- \r
- /**\r
- * Sets a new graph to be drawn. This operation may take a while. It can\r
- * be called from any thread.\r
- * @param graph\r
- */\r
- public void setGraph(Graph graph) {\r
- component.setGraph(graph);\r
- }\r
- \r
- public void setGraph(Graph graph, String algorithm) {\r
- component.setGraph(graph, algorithm);\r
- }\r
-\r
- /**\r
- * Sets a new graph to be drawn. The graph is layouted in a Eclipse job.\r
- * The component is redrawn after the layout is complete.\r
- * @param graph\r
- */\r
- public void asyncSetGraph(final Graph graph) {\r
- Job job = new Job("Layouting a graph") {\r
-\r
- @Override\r
- protected IStatus run(IProgressMonitor monitor) {\r
- setGraph(graph);\r
- return Status.OK_STATUS;\r
- }\r
- \r
- };\r
- job.schedule();\r
- }\r
- \r
- @Override\r
- public void setFocus() {\r
- if(component != null)\r
- component.requestFocus();\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * 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();
+ }
+
+}