]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/LiftPropertiesDialog.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / componentTypeEditor / LiftPropertiesDialog.java
diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/LiftPropertiesDialog.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/LiftPropertiesDialog.java
new file mode 100644 (file)
index 0000000..2e120f3
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modeling.ui.componentTypeEditor;\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.jface.dialogs.IDialogSettings;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.simantics.db.Resource;\r
+import org.simantics.modeling.ui.componentTypeEditor.LiftPropertiesDialog.LiftedProperty;\r
+import org.simantics.scl.runtime.tuple.Tuple3;\r
+import org.simantics.ui.workbench.dialogs.ResourceSelectionDialog3;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class LiftPropertiesDialog extends ResourceSelectionDialog3<LiftedProperty> {\r
+\r
+       private boolean mapProperties = false;\r
+       private Button checkbox;\r
+\r
+       public static class LiftedProperty extends Tuple3 {\r
+\r
+               public LiftedProperty(Resource component, Resource componentType, Resource predicate) {\r
+                       super(component, componentType, predicate);\r
+               }\r
+               \r
+               public Resource getComponent() {\r
+                       return (Resource)get(0);\r
+               }\r
+\r
+               public Resource getComponentType() {\r
+                       return (Resource)get(1);\r
+               }\r
+\r
+               public Resource getPredicate() {\r
+                       return (Resource)get(2);\r
+               }\r
+\r
+       }\r
+       \r
+       public LiftPropertiesDialog(Shell shell,\r
+                       Map<LiftedProperty, Pair<String, ImageDescriptor>> parameter, String title) {\r
+               super(shell, parameter, title);\r
+       }\r
+\r
+       @Override\r
+       protected IDialogSettings getBaseDialogSettings() {\r
+               return null;\r
+       }\r
+\r
+       @Override\r
+       protected Control createExtendedContentArea(Composite parent) {\r
+               Composite c = new Composite(parent, SWT.NONE);\r
+               GridDataFactory.fillDefaults().grab(true, false).applyTo(c);\r
+               GridLayoutFactory.swtDefaults().numColumns(2).applyTo(c);\r
+//             Label l = new Label(c, SWT.NONE); \r
+//             l.setText("Map lifted properties into interface");\r
+//             GridDataFactory.fillDefaults().grab(false, false).applyTo(l);\r
+               checkbox = new Button(c, SWT.CHECK);\r
+               checkbox.setText("Map lifted properties into interface");\r
+               checkbox.addSelectionListener(new SelectionListener() {\r
+                       \r
+                       @Override\r
+                       public void widgetSelected(SelectionEvent e) {\r
+                               widgetDefaultSelected(e);\r
+                       }\r
+                       \r
+                       @Override\r
+                       public void widgetDefaultSelected(SelectionEvent e) {\r
+                               mapProperties = checkbox.getSelection();\r
+                       }\r
+               });\r
+               GridDataFactory.fillDefaults().grab(true, false).applyTo(checkbox);\r
+               return super.createExtendedContentArea(parent);\r
+       }\r
+\r
+       @Override\r
+       public void create() {\r
+               super.create();\r
+               checkbox.setFocus();\r
+       }\r
+\r
+       public boolean getMapProperties() {\r
+               return mapProperties;\r
+       }\r
+\r
+}
\ No newline at end of file