import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.Session;
+import org.simantics.db.common.request.ParametrizedRead;
import org.simantics.db.common.request.ReadRequest;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.request.combinations.Combinators;
import org.simantics.g3d.scenegraph.NodeMap;
import org.simantics.g3d.scenegraph.RenderListener;
import org.simantics.g3d.scenegraph.base.INode;
import org.simantics.ui.workbench.IPropertyPage;
import org.simantics.ui.workbench.IResourceEditorInput;
import org.simantics.ui.workbench.ResourceEditorPart;
+import org.simantics.ui.workbench.editor.input.InputValidationCombinators;
import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.ExceptionUtils;
public static final int X = 0, Y = 1, Z = 2;
protected int upDirection = 1;
-
+
+ ParametrizedRead<IResourceEditorInput, Boolean> INPUT_VALIDATOR =
+ Combinators.compose(
+ InputValidationCombinators.hasURI(),
+ InputValidationCombinators.extractInputResource()
+ );
+
+ @Override
+ protected ParametrizedRead<IResourceEditorInput, Boolean> getInputValidator() {
+ return INPUT_VALIDATOR;
+ }
+
@Override
public void createPartControl(Composite parent) {
this.parent = parent;
- //parent.setLayout (new FillLayout ());
-
-
-// component = new SWTAWTComponent(parent,SWT.NONE) {
-//
-// @Override
-// protected Component createSwingComponent() {
-// if (panel == null) {
-// panel = new InteractiveVtkPanel();
-// vtkPanelUtil.registerPanel(panel);
-// createScene();
-// }
-// return panel;
-// }
-// };
+
+ activateValidation();
IResourceEditorInput rei = (IResourceEditorInput)getEditorInput();
input = rei.getResource();
ExceptionUtils.logAndShowError("Failed to load model correctly", e);
}
- List<vtkProp3D> props = new ArrayList<vtkProp3D>();
+ List<vtkProp3D> props = new ArrayList<>();
collectProps(rootNode, props);
fitToWindow(props);
}
}
}
+ private class FitToWindow extends Action {
+ private List<INode> selected;
+ public FitToWindow(List<INode> selected) {
+ super("Fit to Window");
+ this.selected = selected;
+ //setAccelerator('1');
+ }
+ @Override
+ public void run() {
+ List<vtkProp3D> props = new ArrayList<>();
+ final Collection<INode> collection = !selected.isEmpty() ? selected : getRootNode().getChild();
+ for (INode n : collection)
+ collectProps(n, props);
+
+ fitToWindow(props);
+ getPanel().refresh();
+ }
+ }
+
protected void createFocusMenu(IMenuManager m, List<INode> selected) {
- m.add(new Action("Fit to Window") {
- @Override
- public void run() {
- List<vtkProp3D> props = new ArrayList<>();
- final Collection<INode> collection = !selected.isEmpty() ? selected : getRootNode().getChild();
- for (INode n : collection)
- collectProps(n, props);
-
- fitToWindow(props);
- getPanel().refresh();
- }
- });
+ m.add(new FitToWindow(selected));
if (!selected.isEmpty()) {
List<vtkProp3D> actors = new ArrayList<>();