]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/property/P3DSelectionProcessor.java
Tag user modifiable length
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / property / P3DSelectionProcessor.java
index 3bef85b501ddcfb0cb4a4e99f341596af5d18fef..e48f33201a5c3cb120c946c4dca5925273640fe8 100644 (file)
@@ -3,6 +3,7 @@ package org.simantics.plant3d.property;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.function.Consumer;
 
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.swt.widgets.Composite;
@@ -26,7 +27,6 @@ import org.simantics.selectionview.BasicPropertyTab;
 import org.simantics.selectionview.ComparableTabContributor;
 import org.simantics.selectionview.PropertyTabContributorImpl;
 import org.simantics.selectionview.SelectionProcessor;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.threads.SWTThread;
 
 import vtk.vtkProp;
@@ -70,7 +70,7 @@ public class P3DSelectionProcessor implements SelectionProcessor<Object, ReadGra
                                        throw new NullPointerException();
                                result.add(new ComparableTabContributor(new VTKPropertyTabContributor(SWTThread.getThreadAccess()), -2, prop, "VTK"));
                        }
-
+                       
                        if (resourceCollection.size() > 0) {
                                if (resourceCollection.size() > 1)
                                        result.add(new ComparableTabContributor(new MultiSelectionTabContibutor(),0, resourceCollection, "Graph"));
@@ -83,9 +83,18 @@ public class P3DSelectionProcessor implements SelectionProcessor<Object, ReadGra
                                                e.printStackTrace();
                                        }
                                }
-                       }  
+                       }
                }
 
+               if (resourceCollection.size() == 1){
+                       try {
+                               Resource r = resourceCollection.iterator().next();
+                               result.add(new ComparableTabContributor(new P3DBasicPropertyTab(!readOnly), 0, r, "Properties"));
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       }
+               }
+               
                if(result.size() == 0) {
                        result.add(new ComparableTabContributor(new NoneSelectionTabContributor(),0, resourceCollection, "Empty"));
                }
@@ -99,14 +108,20 @@ public class P3DSelectionProcessor implements SelectionProcessor<Object, ReadGra
                public P3DBasicPropertyTab(boolean enabled) {
                        this.enabled = enabled;
                }
-               public void updatePartName(ISelection forSelection, Callback<String> updateCallback) {
+               
+               
+
+               @Override
+               public void updatePartName(ISelection forSelection, Consumer<String> updateCallback) {
                        Read<String> read = getPartNameReadRequest(forSelection);
                        if (read == null) {
-                               updateCallback.run("Override to control part name (PropertyTabContributorImpl.updatePartName)");
+                               updateCallback.accept("Override to control part name (PropertyTabContributorImpl.updatePartName)");
                        } else {
                                Simantics.getSession().asyncRequest(read, new PartNameListener(updateCallback));
                        }
                }
+
+               @Override
                public Read<String> getPartNameReadRequest(ISelection forSelection) {
                        final Resource r  =  AdaptationUtils.adaptToSingle(forSelection, Resource.class);
                        if (r == null)
@@ -131,10 +146,12 @@ public class P3DSelectionProcessor implements SelectionProcessor<Object, ReadGra
 
 
        public class MultiSelectionTabContibutor extends PropertyTabContributorImpl {
+               @Override
                public void createControls(org.eclipse.swt.widgets.Composite body, org.eclipse.ui.IWorkbenchSite site, org.simantics.db.management.ISessionContext context, org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport support) {
                        //Composite composite = new Composite(body, SWT.NONE);
                }
 
+               @Override
                public Read<String> getPartNameReadRequest(ISelection forSelection) {
                        final Collection<Resource> coll =  AdaptationUtils.adaptToCollection(forSelection, Resource.class);
                        if (coll.size() == 0)
@@ -161,8 +178,9 @@ public class P3DSelectionProcessor implements SelectionProcessor<Object, ReadGra
 
                }
 
-               public void updatePartName(ISelection forSelection, Callback<String> updateCallback) {
-                       updateCallback.run("No Selection");
+               //@Override
+               public void updatePartName(ISelection forSelection, Consumer<String> updateCallback) {
+                       updateCallback.accept("No Selection");
                }
        }