]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java
Enable model loading using an existing transaction.
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / dialog / ComponentSelectionDialog.java
index 720d88cec826729ba748870ace5a4acb7472b02a..030cce9f12d47c89c8d5d12dcea1a716372c60fb 100644 (file)
@@ -34,6 +34,8 @@ import org.eclipse.swt.widgets.ExpandItem;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
+import org.simantics.Simantics;
+import org.simantics.db.Session;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.plant3d.Activator;
 import org.simantics.plant3d.ontology.Plant3D;
@@ -53,6 +55,8 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
        private static final String DIALOG = "ComponentSelectionDialog"; //$NON-NLS-1$
 
        private IDialogSettings dialogSettings;
+       
+       private double lengthFactor = 1.0;
 
        private ResourceManager resourceManager;
 
@@ -126,6 +130,10 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                if (dialogSettings == null)
                        dialogSettings = settings.addNewSection(DIALOG);
        }
+       
+       public void setLengthFactor(double lengthFactor) {
+               this.lengthFactor = lengthFactor;
+       }
 
        @Override
        protected IDialogSettings getDialogBoundsSettings() {
@@ -143,12 +151,13 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
        }
 
        protected List<Item> getItems(Class<?> c, String libUri) throws DatabaseException {
+               Session session = Simantics.getSession();
                if (InlineComponent.class.equals(c)) {
-                       return P3DUtil.getInlines(libUri);
+                       return P3DUtil.getInlines(session, libUri);
                } else if (TurnComponent.class.equals(c)) {
-                       return P3DUtil.getTurns(libUri);
+                       return P3DUtil.getTurns(session, libUri);
                } else if (EndComponent.class.equals(c)) {
-                       return P3DUtil.getEnds(libUri);
+                       return P3DUtil.getEnds(session, libUri);
                } else {
                        return null;
                }
@@ -317,7 +326,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                        @Override
                        public void keyReleased(KeyEvent e) {
                                try {
-                                       length = Double.parseDouble(lengthText.getText());
+                                       length = Double.parseDouble(lengthText.getText()) / lengthFactor;
                                } catch (NumberFormatException err) {
                                        length = null;
                                }
@@ -353,7 +362,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                        @Override
                        public void keyReleased(KeyEvent e) {
                                try {
-                                       diameter = Double.parseDouble(diameterText.getText());
+                                       diameter = Double.parseDouble(diameterText.getText()) / lengthFactor;
                                } catch (NumberFormatException err) {
                                        diameter = null;
                                }
@@ -365,7 +374,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                        @Override
                        public void keyReleased(KeyEvent e) {
                                try {
-                                       turnRadius = Double.parseDouble(turnRadiusText.getText());
+                                       turnRadius = Double.parseDouble(turnRadiusText.getText()) / lengthFactor;
                                } catch (NumberFormatException err) {
                                        turnRadius = null;
                                }