]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/LiftPropertiesDialog.java
Externalize strings
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / componentTypeEditor / LiftPropertiesDialog.java
1 /*******************************************************************************
2  * Copyright (c) 2013 Association for Decentralized Information Management in
3  * Industry THTH ry.
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
8  *
9  * Contributors:
10  *     Semantum Oy - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.modeling.ui.componentTypeEditor;
13
14 import java.util.Map;
15
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;
32
33 public class LiftPropertiesDialog extends ResourceSelectionDialog3<LiftedProperty> {
34
35         private boolean mapProperties = false;
36         private Button checkbox;
37
38         public static class LiftedProperty extends Tuple3 {
39
40                 public LiftedProperty(Resource component, Resource componentType, Resource predicate) {
41                         super(component, componentType, predicate);
42                 }
43                 
44                 public Resource getComponent() {
45                         return (Resource)get(0);
46                 }
47
48                 public Resource getComponentType() {
49                         return (Resource)get(1);
50                 }
51
52                 public Resource getPredicate() {
53                         return (Resource)get(2);
54                 }
55
56         }
57         
58         public LiftPropertiesDialog(Shell shell,
59                         Map<LiftedProperty, Pair<String, ImageDescriptor>> parameter, String title) {
60                 super(shell, parameter, title);
61         }
62
63         @Override
64         protected IDialogSettings getBaseDialogSettings() {
65                 return null;
66         }
67
68         @Override
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(Messages.LiftPropertiesDialog_MapLiftedPropertiesIntoInterface);
78                 checkbox.addSelectionListener(new SelectionListener() {
79                         
80                         @Override
81                         public void widgetSelected(SelectionEvent e) {
82                                 widgetDefaultSelected(e);
83                         }
84                         
85                         @Override
86                         public void widgetDefaultSelected(SelectionEvent e) {
87                                 mapProperties = checkbox.getSelection();
88                         }
89                 });
90                 GridDataFactory.fillDefaults().grab(true, false).applyTo(checkbox);
91                 return super.createExtendedContentArea(parent);
92         }
93
94         @Override
95         public void create() {
96                 super.create();
97                 checkbox.setFocus();
98         }
99
100         public boolean getMapProperties() {
101                 return mapProperties;
102         }
103
104 }