X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.vtk%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fvtk%2Fproperty%2FVTKPropertyTabContributor.java;h=7686aaa19c6059da5d47d8070dc1bbcdb1670050;hb=cf6b9ba427c210e1074d51bbc5712486f80930ec;hp=10176616a37149569fc045a81686428774473818;hpb=289aaab900078ef56efc8779e4b15830e472149e;p=simantics%2F3d.git diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/property/VTKPropertyTabContributor.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/property/VTKPropertyTabContributor.java index 10176616..7686aaa1 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/property/VTKPropertyTabContributor.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/property/VTKPropertyTabContributor.java @@ -1,121 +1,126 @@ -/******************************************************************************* - * 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.AWTThread; -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{ - - 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(AWTThread.getThreadAccess(), 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; - } - } - -} +/******************************************************************************* + * 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; + } + } + +}