|
1 | 1 | package de.fraunhofer.ipa.ros.sirius; |
2 | 2 |
|
| 3 | +import java.util.ArrayList; |
3 | 4 | import java.util.Collection; |
4 | 5 | import java.util.Map; |
5 | 6 |
|
| 7 | +import javax.swing.JOptionPane; |
| 8 | + |
6 | 9 | import org.eclipse.core.commands.ExecutionEvent; |
7 | 10 | import org.eclipse.core.resources.IFile; |
8 | 11 | import org.eclipse.emf.common.util.URI; |
|
17 | 20 | import org.eclipse.swt.widgets.Shell; |
18 | 21 | import org.eclipse.ui.IWorkbench; |
19 | 22 | import org.eclipse.ui.dialogs.ElementListSelectionDialog; |
| 23 | +import org.eclipse.jface.dialogs.InputDialog; |
| 24 | +import org.eclipse.jface.dialogs.TitleAreaDialog; |
20 | 25 | import ros.Parameter; |
21 | 26 | import ros.ParameterBoolean; |
22 | 27 | import ros.ParameterStringType; |
23 | 28 | import ros.ParameterType; |
| 29 | +import ros.impl.ParameterArrayTypeImpl; |
| 30 | +import ros.impl.ParameterBase64TypeImpl; |
24 | 31 | import ros.impl.ParameterBooleanImpl; |
25 | 32 | import ros.impl.ParameterBooleanTypeImpl; |
26 | 33 | import ros.impl.ParameterDateTypeImpl; |
27 | 34 | import ros.impl.ParameterDoubleTypeImpl; |
28 | 35 | import ros.impl.ParameterImpl; |
29 | 36 | import ros.impl.ParameterIntegerTypeImpl; |
| 37 | +import ros.impl.ParameterListTypeImpl; |
30 | 38 | import ros.impl.ParameterStringImpl; |
31 | 39 | import ros.impl.ParameterStringTypeImpl; |
| 40 | +import ros.impl.ParameterStructTypeImpl; |
32 | 41 | import ros.impl.ParameterTypeImpl; |
33 | 42 |
|
34 | 43 |
|
35 | 44 | public class ExternalJavaActionNewParameter implements IExternalJavaAction { |
| 45 | + |
36 | 46 | public IFile modelFile; |
37 | 47 | protected IWorkbench workbench; |
38 | 48 | protected IStructuredSelection selection; |
@@ -60,28 +70,67 @@ public void execute(Collection<? extends EObject> arg0, Map<String, Object> arg1 |
60 | 70 | Parameter param = param_collection.iterator().next(); |
61 | 71 | ParameterType type = null; |
62 | 72 |
|
63 | | - dlg.setElements( new Object[] {"Boolean","String","Integer","Date","Double"}); |
| 73 | + dlg.setElements( new Object[] {"Boolean","String","Integer","Date","Double","Base64", "List", "Array","Struc"}); |
64 | 74 | dlg.open(); |
65 | 75 |
|
66 | 76 | Object selected_type = dlg.getFirstResult(); |
67 | | - if (selected_type.toString() == "Boolean") { |
| 77 | + type = GetSelectedType(selected_type.toString(), activeShell); |
| 78 | + |
| 79 | + /**if (selected_type.toString() == "List") { |
| 80 | + type = new ParameterListTypeImpl(); |
| 81 | + } |
| 82 | + if (selected_type.toString() == "Struc") { |
| 83 | + type = new ParameterStructTypeImpl(); |
| 84 | + }*/ |
| 85 | + param.setType(type); |
| 86 | +} |
| 87 | + |
| 88 | + public ParameterType GetSelectedType(String selected_type, Shell activeShell) { |
| 89 | + ParameterType type = null; |
| 90 | + if (selected_type== "Boolean") { |
68 | 91 | type = new ParameterBooleanTypeImpl(); |
69 | 92 | } |
70 | | - if (selected_type.toString() == "String") { |
| 93 | + if (selected_type == "String") { |
71 | 94 | type = new ParameterStringTypeImpl(); |
72 | 95 | } |
73 | | - if (selected_type.toString() == "Integer") { |
| 96 | + if (selected_type == "Integer") { |
74 | 97 | type = new ParameterIntegerTypeImpl(); |
75 | 98 | } |
76 | | - if (selected_type.toString() == "Date") { |
| 99 | + if (selected_type == "Date") { |
77 | 100 | type = new ParameterDateTypeImpl(); |
78 | 101 | } |
79 | 102 | if (selected_type.toString() == "Double") { |
80 | 103 | type = new ParameterDoubleTypeImpl(); |
81 | 104 | } |
82 | | - param.setType(type); |
| 105 | + if (selected_type.toString() == "Base64") { |
| 106 | + type = new ParameterBase64TypeImpl(); |
| 107 | + } |
| 108 | + if (selected_type.toString() == "Array") { |
| 109 | + ParameterType subtype = null; |
| 110 | + type = new ParameterArrayTypeImpl(); |
| 111 | + ElementListSelectionDialog dlg = new ElementListSelectionDialog(activeShell, new LabelProvider()); |
| 112 | + dlg.setTitle("ArraySubtype"); |
| 113 | + dlg.setMessage("Select a type for the elements of your Array:"); |
| 114 | + dlg.setElements( new Object[] {"Boolean","String","Integer","Date","Double","Base64", "List", "Array","Struc"}); |
| 115 | + dlg.open(); |
| 116 | + Object selected_subtype = dlg.getFirstResult(); |
| 117 | + subtype = GetSelectedType(selected_subtype.toString(), activeShell); |
| 118 | + ((ParameterArrayTypeImpl) type).setType(subtype); |
| 119 | + } |
| 120 | + if (selected_type.toString() == "List") { |
| 121 | + ArrayList<ParameterType> subtypes = null; |
| 122 | + type = new ParameterListTypeImpl(); |
83 | 123 |
|
| 124 | + InputDialog dlg = new InputDialog(activeShell, "Lenght of the list parameter", null, "2",null); |
| 125 | + if (dlg.open() == 0) { |
| 126 | + String param = dlg.getValue(); |
| 127 | + } |
84 | 128 |
|
85 | | -} |
| 129 | + /**Object selected_subtype = dlg. |
| 130 | + subtype = GetSelectedType(selected_subtype.toString(), activeShell); |
| 131 | + ((ParameterArrayTypeImpl) type).setType(subtype);*/ |
| 132 | + } |
| 133 | + return type; |
| 134 | + } |
86 | 135 | } |
87 | 136 |
|
0 commit comments