Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add graphical support to define parameters with sirius #104

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions plugins/de.fraunhofer.ipa.ros.sirius/description/ros.odesign
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ownedRepresentations xsi:type="description_1:DiagramDescription" name="Artifact diagram" domainClass="ros::Artifact" enablePopupBars="true">
<metamodel href="../../de.fraunhofer.ipa.ros/model/ros.ecore#/"/>
<defaultLayer name="Default">
<containerMappings name="Node" semanticCandidatesExpression="feature:eAllContents" domainClass="ros::Node">
<containerMappings name="Node" semanticCandidatesExpression="feature:eAllContents" domainClass="ros::Node" childrenPresentation="List">
<borderedNodeMappings name="RosPublisher" semanticCandidatesExpression="feature:eAllContents" domainClass="ros::Publisher">
<style xsi:type="style:SquareDescription" labelSize="10" showIcon="false" tooltipExpression="Topic" resizeKind="NSEW" width="2" height="2">
<borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
Expand Down Expand Up @@ -71,8 +71,8 @@
<color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_green']"/>
</style>
</borderedNodeMappings>
<subNodeMappings name="ParametersNode" semanticCandidatesExpression="feature:parameter" domainClass="ros::Parameter">
<style xsi:type="style:WorkspaceImageDescription" labelSize="10" showIcon="false" iconPath="/de.fraunhofer.ipa.ros.sirius/icons/parameters.png" tooltipExpression="ComponentParameters" sizeComputationExpression="5" resizeKind="NSEW" workspacePath="/de.fraunhofer.ipa.ros.sirius/icons/parameters_scale.png">
<subNodeMappings name="ParametersNode" semanticCandidatesExpression="feature:parameter" doubleClickDescription="//@ownedViewpoints[name='component']/@ownedRepresentations[name='Artifact%20diagram']/@defaultLayer/@toolSections.0/@ownedTools[name='ParametersConfiguratorDoubleClick']" synchronizationLock="true" domainClass="ros::Parameter">
<style xsi:type="style:WorkspaceImageDescription" borderSizeComputationExpression="2" labelSize="10" iconPath="/de.fraunhofer.ipa.ros.sirius/icons/parameters.png" labelAlignment="LEFT" tooltipExpression="ComponentParameters" hideLabelByDefault="true" sizeComputationExpression="5" resizeKind="NSEW" workspacePath="/de.fraunhofer.ipa.ros.sirius/icons/parameters_scale.png">
<borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
<labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
</style>
Expand Down Expand Up @@ -199,6 +199,16 @@
</initialOperation>
</ownedTools>
<ownedTools xsi:type="tool_1:ExternalJavaAction" name="NewParameter" id="de.fraunhofer.ipa.ros.sirius.javaActionsNewParameter"/>
<!--ownedTools xsi:type="tool:DoubleClickDescription" name="ParametersConfiguratorDoubleClick" mappings="//@ownedViewpoints[name='component']/@ownedRepresentations[name='Artifact%20diagram']/@defaultLayer/@containerMappings[name='Node']/@subNodeMappings[name='ParametersNode']">
<element name="element"/>
<elementView name="elementView"/>
<initialOperation>
<firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:element">
<subModelOperations xsi:type="tool_1:ExternalJavaActionCall" name="Parameter Configurator" forceRefresh="true" elementsToSelect="var:element" icon="/de.fraunhofer.ipa.ros.sirius/icons/parameters_scale.png" action="//@ownedViewpoints[name='component']/@ownedRepresentations[name='Artifact%20diagram']/@defaultLayer/@toolSections.0/@ownedTools[name='ParameterEditor']"/>
</firstModelOperations>
</initialOperation>
</ownedTools>
<ownedTools xsi:type="tool_1:ExternalJavaAction" name="ParameterEditor" elementsToSelect="var:self" id="de.fraunhofer.ipa.ros.sirius.javaActionsParameterEditor"/-->
</toolSections>
</defaultLayer>
</ownedRepresentations>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,40 @@

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.sirius.tools.api.ui.IExternalJavaAction;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;

import ros.Parameter;
import ros.ParameterBoolean;
import ros.ParameterStringType;
import ros.ParameterType;
import ros.impl.ParameterBooleanImpl;
import ros.impl.ParameterArrayTypeImpl;
import ros.impl.ParameterBase64TypeImpl;
import ros.impl.ParameterBooleanTypeImpl;
import ros.impl.ParameterDateTypeImpl;
import ros.impl.ParameterDoubleTypeImpl;
import ros.impl.ParameterImpl;
import ros.impl.ParameterIntegerTypeImpl;
import ros.impl.ParameterStringImpl;
import ros.impl.ParameterStringTypeImpl;
import ros.impl.ParameterTypeImpl;


public class ExternalJavaActionNewParameter implements IExternalJavaAction {

public IFile modelFile;
protected IWorkbench workbench;
protected IStructuredSelection selection;
//public static final List<String> FILE_EXTENSIONS = Collections.unmodifiableList(Arrays.asList(ComponentInterfaceEditorPlugin.INSTANCE.getString("_UI_ComponentInterfaceEditorFilenameExtensions").split("\\s*,\\s*")));
protected ExecutionEvent event;
EList<ParameterType> subtypes;
EList<String> subtypes_;
EList<Combo> combos;
EList<String> subtypes_string;


public ExternalJavaActionNewParameter() {
// TODO Auto-generated constructor stub
Expand All @@ -60,28 +61,99 @@ public void execute(Collection<? extends EObject> arg0, Map<String, Object> arg1
Parameter param = param_collection.iterator().next();
ParameterType type = null;

dlg.setElements( new Object[] {"Boolean","String","Integer","Date","Double"});
dlg.setElements( new Object[] {"Boolean","String","Integer","Double","Base64", "Array"});/** "List","Struc","Date"*/
dlg.open();

Object selected_type = dlg.getFirstResult();
if (selected_type.toString() == "Boolean") {
type = GetSelectedType(selected_type.toString(), activeShell);
/**if (selected_type.toString() == "List") {
type = new ParameterListTypeImpl();
}
if (selected_type.toString() == "Struc") {
type = new ParameterStructTypeImpl();
}*/
param.setType(type);
}

@SuppressWarnings("null")
public ParameterType GetSelectedType(String selected_type, Shell activeShell) {
ParameterType type = null;
if (selected_type== "Boolean") {
type = new ParameterBooleanTypeImpl();
}
if (selected_type.toString() == "String") {
if (selected_type == "String") {
type = new ParameterStringTypeImpl();
}
if (selected_type.toString() == "Integer") {
if (selected_type == "Integer") {
type = new ParameterIntegerTypeImpl();
}
if (selected_type.toString() == "Date") {
/**if (selected_type == "Date") {
type = new ParameterDateTypeImpl();
}
}*/
if (selected_type.toString() == "Double") {
type = new ParameterDoubleTypeImpl();
}
param.setType(type);
if (selected_type.toString() == "Base64") {
type = new ParameterBase64TypeImpl();
}
if (selected_type.toString() == "Array") {
ParameterType subtype = null;
type = new ParameterArrayTypeImpl();
ElementListSelectionDialog dlg = new ElementListSelectionDialog(activeShell, new LabelProvider());
dlg.setTitle("ArraySubtype");
dlg.setMessage("Select a type for the elements of your Array:");
dlg.setElements( new Object[] {"Boolean","String","Integer","Date","Double","Base64", "List", "Array","Struc"});
dlg.open();
Object selected_subtype = dlg.getFirstResult();
subtype = GetSelectedType(selected_subtype.toString(), activeShell);
((ParameterArrayTypeImpl) type).setType(subtype);
}
/**if (selected_type.toString() == "List") {
EList<Combo> combos = null;
type = new ParameterListTypeImpl();

InputDialog dlg = new InputDialog(activeShell, "Lenght of the list parameter", null, "2",null);
int lenght = 0;
if (dlg.open() == 0) {
String param = dlg.getValue();
try {
lenght = Integer.parseInt(param);
} catch (NumberFormatException e){
lenght = 1;
}
}
for (int i=1;i<lenght+1;i++) {
subtypes.add(GetSelectedType("String",activeShell));
}

GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
activeShell.setLayout(gridLayout);
new Label(activeShell, SWT.NULL).setText("List parameter definition: ");
Combo combo = new Combo(activeShell, SWT.DOWN);

}
for (int i=1;i<lenght+1;i++) {
String items[] = { "Boolean","String","Integer","Date","Double","Base64"};
GridData gridData = new GridData(GridData.CENTER);
gridData.horizontalSpan = 1;
new Label(activeShell, SWT.NULL).setText("Type element "+ i +" :");
combo.setItems(items);
combo.setLayoutData(gridData);
activeShell.pack();
activeShell.open();
}

while (!activeShell.isDisposed()) {
if (!activeShell.getDisplay().readAndDispatch ())
activeShell.getDisplay().sleep ();
}

for (int i=0; i<subtypes.size(); i++) {
((ParameterListTypeImpl) type).getSequence().add(subtypes.get(i));
}
}*/

return type;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class ParameterArrayTypeImpl extends ParameterTypeImpl implements Paramet
* <!-- end-user-doc -->
* @generated
*/
protected ParameterArrayTypeImpl() {
public ParameterArrayTypeImpl() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ParameterBase64TypeImpl extends ParameterTypeImpl implements Parame
* <!-- end-user-doc -->
* @generated
*/
protected ParameterBase64TypeImpl() {
public ParameterBase64TypeImpl() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class ParameterListTypeImpl extends ParameterTypeImpl implements Paramete
* <!-- end-user-doc -->
* @generated
*/
protected ParameterListTypeImpl() {
public ParameterListTypeImpl() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ParameterStructTypeImpl extends ParameterTypeImpl implements Parame
* <!-- end-user-doc -->
* @generated
*/
protected ParameterStructTypeImpl() {
public ParameterStructTypeImpl() {
super();
}

Expand Down