1 /*******************************************************************************
\r
2 * Copyright (c) 2013 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * Semantum Oy - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.modeling.ui.componentTypeEditor;
\r
14 import java.util.Map;
\r
16 import org.eclipse.jface.dialogs.IDialogSettings;
\r
17 import org.eclipse.jface.layout.GridDataFactory;
\r
18 import org.eclipse.jface.layout.GridLayoutFactory;
\r
19 import org.eclipse.jface.resource.ImageDescriptor;
\r
20 import org.eclipse.swt.SWT;
\r
21 import org.eclipse.swt.events.SelectionEvent;
\r
22 import org.eclipse.swt.events.SelectionListener;
\r
23 import org.eclipse.swt.widgets.Button;
\r
24 import org.eclipse.swt.widgets.Composite;
\r
25 import org.eclipse.swt.widgets.Control;
\r
26 import org.eclipse.swt.widgets.Shell;
\r
27 import org.simantics.db.Resource;
\r
28 import org.simantics.modeling.ui.componentTypeEditor.LiftPropertiesDialog.LiftedProperty;
\r
29 import org.simantics.scl.runtime.tuple.Tuple3;
\r
30 import org.simantics.ui.workbench.dialogs.ResourceSelectionDialog3;
\r
31 import org.simantics.utils.datastructures.Pair;
\r
33 public class LiftPropertiesDialog extends ResourceSelectionDialog3<LiftedProperty> {
\r
35 private boolean mapProperties = false;
\r
36 private Button checkbox;
\r
38 public static class LiftedProperty extends Tuple3 {
\r
40 public LiftedProperty(Resource component, Resource componentType, Resource predicate) {
\r
41 super(component, componentType, predicate);
\r
44 public Resource getComponent() {
\r
45 return (Resource)get(0);
\r
48 public Resource getComponentType() {
\r
49 return (Resource)get(1);
\r
52 public Resource getPredicate() {
\r
53 return (Resource)get(2);
\r
58 public LiftPropertiesDialog(Shell shell,
\r
59 Map<LiftedProperty, Pair<String, ImageDescriptor>> parameter, String title) {
\r
60 super(shell, parameter, title);
\r
64 protected IDialogSettings getBaseDialogSettings() {
\r
69 protected Control createExtendedContentArea(Composite parent) {
\r
70 Composite c = new Composite(parent, SWT.NONE);
\r
71 GridDataFactory.fillDefaults().grab(true, false).applyTo(c);
\r
72 GridLayoutFactory.swtDefaults().numColumns(2).applyTo(c);
\r
73 // Label l = new Label(c, SWT.NONE);
\r
74 // l.setText("Map lifted properties into interface");
\r
75 // GridDataFactory.fillDefaults().grab(false, false).applyTo(l);
\r
76 checkbox = new Button(c, SWT.CHECK);
\r
77 checkbox.setText("Map lifted properties into interface");
\r
78 checkbox.addSelectionListener(new SelectionListener() {
\r
81 public void widgetSelected(SelectionEvent e) {
\r
82 widgetDefaultSelected(e);
\r
86 public void widgetDefaultSelected(SelectionEvent e) {
\r
87 mapProperties = checkbox.getSelection();
\r
90 GridDataFactory.fillDefaults().grab(true, false).applyTo(checkbox);
\r
91 return super.createExtendedContentArea(parent);
\r
95 public void create() {
\r
97 checkbox.setFocus();
\r
100 public boolean getMapProperties() {
\r
101 return mapProperties;
\r