Skip to content

Commit

Permalink
update graphical interface for parameters and added Arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-nhg committed Jun 2, 2020
1 parent 2b1dd02 commit 60b4e8c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 72 deletions.
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
@@ -1,28 +1,17 @@
package de.fraunhofer.ipa.ros.sirius;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;

import javax.swing.JOptionPane;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.sirius.tools.api.ui.IExternalJavaAction;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
Expand All @@ -35,7 +24,6 @@
import ros.impl.ParameterDateTypeImpl;
import ros.impl.ParameterDoubleTypeImpl;
import ros.impl.ParameterIntegerTypeImpl;
import ros.impl.ParameterListTypeImpl;
import ros.impl.ParameterStringTypeImpl;


Expand All @@ -48,6 +36,8 @@ public class ExternalJavaActionNewParameter implements IExternalJavaAction {
protected ExecutionEvent event;
EList<ParameterType> subtypes;
EList<String> subtypes_;
EList<Combo> combos;
EList<String> subtypes_string;


public ExternalJavaActionNewParameter() {
Expand All @@ -71,12 +61,11 @@ 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","Base64", "List", "Array","Struc"});
dlg.setElements( new Object[] {"Boolean","String","Integer","Double","Base64", "Array"});/** "List","Struc","Date"*/
dlg.open();

Object selected_type = dlg.getFirstResult();
type = GetSelectedType(selected_type.toString(), activeShell);

/**if (selected_type.toString() == "List") {
type = new ParameterListTypeImpl();
}
Expand All @@ -86,16 +75,6 @@ public void execute(Collection<? extends EObject> arg0, Map<String, Object> arg1
param.setType(type);
}

public void AddTotheList (String newType) {
System.out.println(newType);
subtypes_.add(newType);
//subtypes.add(GetSelectedType(newType,activeShell));
System.out.println("!!!!!!!!");
System.out.println(subtypes_);
}



@SuppressWarnings("null")
public ParameterType GetSelectedType(String selected_type, Shell activeShell) {
ParameterType type = null;
Expand All @@ -108,9 +87,9 @@ public ParameterType GetSelectedType(String selected_type, Shell activeShell) {
if (selected_type == "Integer") {
type = new ParameterIntegerTypeImpl();
}
if (selected_type == "Date") {
/**if (selected_type == "Date") {
type = new ParameterDateTypeImpl();
}
}*/
if (selected_type.toString() == "Double") {
type = new ParameterDoubleTypeImpl();
}
Expand All @@ -129,63 +108,51 @@ public ParameterType GetSelectedType(String selected_type, Shell activeShell) {
subtype = GetSelectedType(selected_subtype.toString(), activeShell);
((ParameterArrayTypeImpl) type).setType(subtype);
}
if (selected_type.toString() == "List") {

/**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;
int lenght = 0;
if (dlg.open() == 0) {
String param = dlg.getValue();
try {
lenght = Integer.parseInt(param);
} catch (NumberFormatException e){
lenght = 1;
}
//activeShell.setSize(250,250);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
activeShell.setLayout(gridLayout);
new Label(activeShell, SWT.NULL).setText("List parameter definition: ");

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 c = new Combo(activeShell, SWT.NULL);
c.setItems(items);
c.setLayoutData(gridData);
c.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!!!!!!!!!!!!!!!!!!!!!!!!!!!");
//subtypes.add(GetSelectedType(c.getText(),activeShell));
AddTotheList(c.getText());

}
});
lenght = 1;
}
}
for (int i=1;i<lenght+1;i++) {
subtypes.add(GetSelectedType("String",activeShell));
}
activeShell.pack();
activeShell.open();
while (!activeShell.isDisposed()) {
if (!activeShell.getDisplay().readAndDispatch ())
activeShell.getDisplay().sleep ();

}

activeShell.getDisplay().dispose();

//subtypes.add(GetSelectedType(c.getText(),activeShell));
//activeShell.setText("Set types for a List Parameter");
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 ();
}
//c1.getText();
//new SetListParameterTypesDialog(activeShell);
}
for (int i=0; i<subtypes.size(); i++) {
((ParameterListTypeImpl) type).getSequence().add(subtypes.get(i));
}
}
}*/

return type;
}
}
Expand Down

0 comments on commit 60b4e8c

Please sign in to comment.