X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fdialog%2FComponentSelectionDialog.java;h=7c124eb0ecb269076d4979bc1155305befc385dd;hb=refs%2Fchanges%2F58%2F3558%2F1;hp=93a305bb9d74ea67fddb1ed35c088c09044d12e4;hpb=bdc6f4000e1d4c4cd3c8d4bbf1af16490d019692;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java b/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java index 93a305bb..7c124eb0 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java @@ -97,6 +97,18 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange this.libUri = libUri; } + protected List getItems(Class c, String libUri) throws DatabaseException{ + if (InlineComponent.class.equals(c)) { + return P3DUtil.getInlines(libUri); + } else if (TurnComponent.class.equals(c)) { + return P3DUtil.getTurns(libUri); + } else if (EndComponent.class.equals(c)) { + return P3DUtil.getEnds(libUri); + } else { + return null; + } + } + @Override protected Control createDialogArea(Composite parent) { resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent); @@ -123,9 +135,9 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange List turns = null; List inlines = null; try { - ends = P3DUtil.getEnds(libUri); - turns= P3DUtil.getTurns(libUri); - inlines = P3DUtil.getInlines(libUri); + ends = getItems(EndComponent.class, libUri); + turns= getItems(TurnComponent.class, libUri); + inlines = getItems(InlineComponent.class, libUri); } catch (DatabaseException e) { Label label = new Label(composite, SWT.NONE); label.setText("Cannot load pipeline components: " + e.getMessage()); @@ -334,7 +346,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange } else if (selected.isCode()) {// TODO : instead of disabling the button, we should filter the content. ok = false; } else { - lenghtAdjustable = ((selected.getType() == Type.INLINE) && selected.isVariable()); + lenghtAdjustable = ((selected.getType() == Type.INLINE) && (selected.isVariable() || selected.isModifiable())); if (insertAdjustable) { switch (selected.getType()) { case END: @@ -393,7 +405,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange middleButton.setEnabled(false); endButton.setEnabled(true); } - if (selected.isVariable()) { + if (selected.isVariable() || selected.isModifiable()) { if (selected.getType() == Type.INLINE) { filterAllowed.add(PositionType.NEXT); filterAllowed.add(PositionType.PREVIOUS);