1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g3d.vtk.property;
14 import org.eclipse.jface.viewers.ISelection;
15 import org.eclipse.jface.viewers.ISelectionProvider;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.layout.FillLayout;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.Display;
21 import org.eclipse.swt.widgets.Text;
22 import org.eclipse.ui.IWorkbenchSite;
23 import org.simantics.db.management.ISessionContext;
24 import org.simantics.selectionview.IPropertyTab;
25 import org.simantics.selectionview.PropertyTabContributor;
26 import org.simantics.utils.threads.IThreadWorkQueue;
27 import org.simantics.utils.threads.ThreadUtils;
30 import vtk.vtkAlgorithm;
31 import vtk.vtkAlgorithmOutput;
35 public class VTKPropertyTabContributor implements PropertyTabContributor{
37 private IThreadWorkQueue tq;
38 public VTKPropertyTabContributor(IThreadWorkQueue tq) {
42 public org.simantics.selectionview.IPropertyTab create(Composite parent, IWorkbenchSite site, ISessionContext context, Object input) {
43 IPropertyTab tab = new VTKPropertyTab((vtkProp)input);
44 tab.createControl(parent, context);
49 public class VTKPropertyTab implements IPropertyTab {
50 private Composite composite;
54 public VTKPropertyTab(vtkProp prop) {
59 public void createControl(Composite parent, ISessionContext context) {
61 composite = new Composite(parent, SWT.NONE);
62 composite.setLayout(new FillLayout());
63 text = new Text(composite, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
64 ThreadUtils.asyncExec(tq, new Runnable() {
69 if (prop instanceof vtkActor) {
70 vtkActor act = (vtkActor)prop;
71 vtkMapper mapper = act.GetMapper();
72 vtkAlgorithmOutput out = mapper.GetInputConnection(0, 0);
73 vtkAlgorithm producer = out.GetProducer();
74 string += producer.GetClassName() +"\n";
79 string += prop.Print();
80 final String s = string;
81 Display.getDefault().asyncExec(new Runnable() {
84 if (!text.isDisposed())
95 public void requestFocus() {
100 public void dispose() {
105 public boolean isDisposed() {
106 return composite.isDisposed();
110 public Control getControl() {
115 public void setInput(ISessionContext context, ISelection selection,
121 public ISelectionProvider getSelectionProvider() {