]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/property/VTKPropertyTabContributor.java
Fix removed nodes leaving visible graphical elements.
[simantics/3d.git] / org.simantics.g3d.vtk / src / org / simantics / g3d / vtk / property / VTKPropertyTabContributor.java
index 10176616a37149569fc045a81686428774473818..7686aaa19c6059da5d47d8070dc1bbcdb1670050 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
- * 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.g3d.vtk.property;\r
-\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.ISelectionProvider;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.layout.FillLayout;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Text;\r
-import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.db.management.ISessionContext;\r
-import org.simantics.selectionview.IPropertyTab;\r
-import org.simantics.selectionview.PropertyTabContributor;\r
-import org.simantics.utils.threads.AWTThread;\r
-import org.simantics.utils.threads.ThreadUtils;\r
-\r
-import vtk.vtkActor;\r
-import vtk.vtkAlgorithm;\r
-import vtk.vtkAlgorithmOutput;\r
-import vtk.vtkMapper;\r
-import vtk.vtkProp;\r
-\r
-public class VTKPropertyTabContributor implements PropertyTabContributor{\r
-       \r
-       public org.simantics.selectionview.IPropertyTab create(Composite parent, IWorkbenchSite site, ISessionContext context, Object input) {\r
-               IPropertyTab tab = new VTKPropertyTab((vtkProp)input);\r
-               tab.createControl(parent, context);\r
-               return tab;\r
-       };\r
-       \r
-       \r
-       public class VTKPropertyTab implements IPropertyTab {\r
-               private Composite composite;\r
-               private Text text;\r
-               private vtkProp prop;\r
-               \r
-               public VTKPropertyTab(vtkProp prop) {\r
-                       this.prop = prop;\r
-               }\r
-               \r
-               @Override\r
-               public void createControl(Composite parent, ISessionContext context) {\r
-                       \r
-                       composite = new Composite(parent, SWT.NONE);\r
-                       composite.setLayout(new FillLayout());\r
-                       text = new Text(composite, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);\r
-                       ThreadUtils.asyncExec(AWTThread.getThreadAccess(), new Runnable() {\r
-                               \r
-                               @Override\r
-                               public void run() {\r
-                                       String string = "";\r
-                                       if (prop instanceof vtkActor) {\r
-                                               vtkActor act = (vtkActor)prop;\r
-                                               vtkMapper mapper = act.GetMapper();\r
-                                               vtkAlgorithmOutput out = mapper.GetInputConnection(0, 0);\r
-                                               vtkAlgorithm producer = out.GetProducer();\r
-                                               string += producer.GetClassName() +"\n";\r
-                                               out.Delete();\r
-                                               mapper.Delete();\r
-                                               producer.Delete();\r
-                                       }\r
-                                       string += prop.Print();\r
-                                       final String s = string;\r
-                                       Display.getDefault().asyncExec(new Runnable() {\r
-                                               @Override\r
-                                               public void run() {\r
-                                                       if (!text.isDisposed())\r
-                                                               text.setText(s);\r
-                                               }\r
-                                       });\r
-                               }\r
-                       });;\r
-                       \r
-                       \r
-               }\r
-               \r
-               @Override\r
-               public void requestFocus() {\r
-                       composite.setFocus();\r
-               }\r
-               \r
-               @Override\r
-               public void dispose() {\r
-                       composite.dispose();\r
-               }\r
-               \r
-               @Override\r
-               public boolean isDisposed() {\r
-                       return composite.isDisposed();\r
-               }\r
-               \r
-               @Override\r
-               public Control getControl() {\r
-                       return composite;\r
-               }\r
-               \r
-               @Override\r
-               public void setInput(ISessionContext context, ISelection selection,\r
-                               boolean force) {\r
-                       \r
-               }\r
-               \r
-               @Override\r
-               public ISelectionProvider getSelectionProvider() {\r
-                       return null;\r
-               }\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 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.g3d.vtk.property;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchSite;
+import org.simantics.db.management.ISessionContext;
+import org.simantics.selectionview.IPropertyTab;
+import org.simantics.selectionview.PropertyTabContributor;
+import org.simantics.utils.threads.IThreadWorkQueue;
+import org.simantics.utils.threads.ThreadUtils;
+
+import vtk.vtkActor;
+import vtk.vtkAlgorithm;
+import vtk.vtkAlgorithmOutput;
+import vtk.vtkMapper;
+import vtk.vtkProp;
+
+public class VTKPropertyTabContributor implements PropertyTabContributor{
+       
+       private IThreadWorkQueue tq;
+       public VTKPropertyTabContributor(IThreadWorkQueue tq) {
+               this.tq = tq;
+       }
+       
+       public org.simantics.selectionview.IPropertyTab create(Composite parent, IWorkbenchSite site, ISessionContext context, Object input) {
+               IPropertyTab tab = new VTKPropertyTab((vtkProp)input);
+               tab.createControl(parent, context);
+               return tab;
+       };
+       
+       
+       public class VTKPropertyTab implements IPropertyTab {
+               private Composite composite;
+               private Text text;
+               private vtkProp prop;
+               
+               public VTKPropertyTab(vtkProp prop) {
+                       this.prop = prop;
+               }
+               
+               @Override
+               public void createControl(Composite parent, ISessionContext context) {
+                       
+                       composite = new Composite(parent, SWT.NONE);
+                       composite.setLayout(new FillLayout());
+                       text = new Text(composite, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
+                       ThreadUtils.asyncExec(tq, new Runnable() {
+                               
+                               @Override
+                               public void run() {
+                                       String string = "";
+                                       if (prop instanceof vtkActor) {
+                                               vtkActor act = (vtkActor)prop;
+                                               vtkMapper mapper = act.GetMapper();
+                                               vtkAlgorithmOutput out = mapper.GetInputConnection(0, 0);
+                                               vtkAlgorithm producer = out.GetProducer();
+                                               string += producer.GetClassName() +"\n";
+                                               out.Delete();
+                                               mapper.Delete();
+                                               producer.Delete();
+                                       }
+                                       string += prop.Print();
+                                       final String s = string;
+                                       Display.getDefault().asyncExec(new Runnable() {
+                                               @Override
+                                               public void run() {
+                                                       if (!text.isDisposed())
+                                                               text.setText(s);
+                                               }
+                                       });
+                               }
+                       });;
+                       
+                       
+               }
+               
+               @Override
+               public void requestFocus() {
+                       composite.setFocus();
+               }
+               
+               @Override
+               public void dispose() {
+                       composite.dispose();
+               }
+               
+               @Override
+               public boolean isDisposed() {
+                       return composite.isDisposed();
+               }
+               
+               @Override
+               public Control getControl() {
+                       return composite;
+               }
+               
+               @Override
+               public void setInput(ISessionContext context, ISelection selection,
+                               boolean force) {
+                       
+               }
+               
+               @Override
+               public ISelectionProvider getSelectionProvider() {
+                       return null;
+               }
+       }
+
+}