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