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 parameters tool for Sirius #35

Merged
merged 2 commits into from
Mar 20, 2019
Merged
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
29 changes: 27 additions & 2 deletions plugins/de.fraunhofer.ipa.ros.sirius/description/ros.odesign
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,42 @@
</firstModelOperations>
</initialOperation>
</ownedTools>
<ownedTools xsi:type="tool:NodeCreationDescription" name="Add ROS Parameter" nodeMappings="//@ownedViewpoints[name='component']/@ownedRepresentations[name='Artifact%20diagram']/@defaultLayer/@containerMappings[name='Node']/@subNodeMappings[name='ParametersNode']" iconPath="/de.fraunhofer.ipa.ros.sirius/icons/parameters.png">
<ownedTools xsi:type="tool:NodeCreationDescription" name="Add ROS Parameter" forceRefresh="true" inverseSelectionOrder="true" nodeMappings="//@ownedViewpoints[name='component']/@ownedRepresentations[name='Artifact%20diagram']/@defaultLayer/@containerMappings[name='Node']/@subNodeMappings[name='ParametersNode']" iconPath="/de.fraunhofer.ipa.ros.sirius/icons/parameters.png">
<variable name="container"/>
<viewVariable name="containerView"/>
<initialOperation>
<firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:container">
<subModelOperations xsi:type="tool_1:CreateInstance" typeName="ros::Parameter" referenceName="parameter">
<subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="NewParameter"/>
<subModelOperations xsi:type="properties:DialogModelOperation" titleExpression="New Parameter">
<buttons labelExpression="Cancel" closeDialogOnClick="true" rollbackChangesOnClose="true">
<initialOperation/>
</buttons>
<buttons labelExpression="OK" default="true" closeDialogOnClick="true">
<initialOperation/>
</buttons>
<page name="RosParameter" labelExpression="RosParameter" semanticCandidateExpression="var:self" groups="//@ownedViewpoints[name='component']/@ownedRepresentations[name='Artifact%20diagram']/@defaultLayer/@toolSections.0/@ownedTools[name='Add%20ROS%20Parameter']/@initialOperation/@firstModelOperations/@subModelOperations.0/@subModelOperations.0/@groups.0"/>
<groups name="Parameter" labelExpression="Parameter Description" semanticCandidateExpression="var:self">
<controls xsi:type="properties:TextDescription" name="Name" labelExpression="Name" helpExpression="Parameter Name" valueExpression="aql:instance.name">
<initialOperation>
<firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:instance">
<subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="aql:newValue"/>
</firstModelOperations>
</initialOperation>
</controls>
<controls xsi:type="properties:ButtonDescription" name="ParameterType" labelExpression="Type" helpExpression="Parameter Type">
<initialOperation>
<firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:instance">
<subModelOperations xsi:type="tool_1:ExternalJavaActionCall" name="NewParameter" action="//@ownedViewpoints[name='component']/@ownedRepresentations[name='Artifact%20diagram']/@defaultLayer/@toolSections.0/@ownedTools[name='NewParameter']"/>
</firstModelOperations>
</initialOperation>
</controls>
</groups>
</subModelOperations>
</subModelOperations>
</firstModelOperations>
</initialOperation>
</ownedTools>
<ownedTools xsi:type="tool_1:ExternalJavaAction" name="NewParameter" id="de.fraunhofer.ipa.ros.sirius.javaActionsNewParameter"/>
</toolSections>
</defaultLayer>
</ownedRepresentations>
Expand Down
7 changes: 7 additions & 0 deletions plugins/de.fraunhofer.ipa.ros.sirius/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@
id="de.fraunhofer.ipa.ros.sirius.javaActionsNewComponent">
</javaActions>
</extension>
<extension
point="org.eclipse.sirius.externalJavaAction">
<javaActions
actionClass="de.fraunhofer.ipa.ros.sirius.ExternalJavaActionNewParameter"
id="de.fraunhofer.ipa.ros.sirius.javaActionsNewParameter">
</javaActions>
</extension>
</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package de.fraunhofer.ipa.ros.sirius;

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

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.util.URI;
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.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.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;

public ExternalJavaActionNewParameter() {
// TODO Auto-generated constructor stub
}

@Override
public boolean canExecute(Collection<? extends EObject> arg0) {
// TODO Auto-generated method stub
return true;
}

@Override
public void execute(Collection<? extends EObject> arg0, Map<String, Object> arg1) {
Display display = Display.getDefault();
Shell activeShell = display.getActiveShell();
ElementListSelectionDialog dlg = new ElementListSelectionDialog(activeShell, new LabelProvider());
dlg.setTitle("ParameterType");
dlg.setMessage("Select a type for your parameter (* = any string, ? = any char):");
Collection <Parameter> param_collection = (Collection<Parameter>) arg0;
Parameter param = param_collection.iterator().next();
ParameterType type = null;

dlg.setElements( new Object[] {"Boolean","String","Integer","Date","Double"});
dlg.open();

Object selected_type = dlg.getFirstResult();
if (selected_type.toString() == "Boolean") {
type = new ParameterBooleanTypeImpl();
}
if (selected_type.toString() == "String") {
type = new ParameterStringTypeImpl();
}
if (selected_type.toString() == "Integer") {
type = new ParameterIntegerTypeImpl();
}
if (selected_type.toString() == "Date") {
type = new ParameterDateTypeImpl();
}
if (selected_type.toString() == "Double") {
type = new ParameterDoubleTypeImpl();
}
param.setType(type);


}
}

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

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

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

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

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

Expand Down