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