diff --git a/plugins/de.fraunhofer.ipa.ros.sirius/description/ros.odesign b/plugins/de.fraunhofer.ipa.ros.sirius/description/ros.odesign index 06fa8c1a5..616adb96c 100644 --- a/plugins/de.fraunhofer.ipa.ros.sirius/description/ros.odesign +++ b/plugins/de.fraunhofer.ipa.ros.sirius/description/ros.odesign @@ -4,7 +4,7 @@ - + - - @@ -199,6 +199,16 @@ + diff --git a/plugins/de.fraunhofer.ipa.ros.sirius/src/de/fraunhofer/ipa/ros/sirius/ExternalJavaActionNewParameter.java b/plugins/de.fraunhofer.ipa.ros.sirius/src/de/fraunhofer/ipa/ros/sirius/ExternalJavaActionNewParameter.java index 8b22a9037..8ffef6878 100644 --- a/plugins/de.fraunhofer.ipa.ros.sirius/src/de/fraunhofer/ipa/ros/sirius/ExternalJavaActionNewParameter.java +++ b/plugins/de.fraunhofer.ipa.ros.sirius/src/de/fraunhofer/ipa/ros/sirius/ExternalJavaActionNewParameter.java @@ -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 FILE_EXTENSIONS = Collections.unmodifiableList(Arrays.asList(ComponentInterfaceEditorPlugin.INSTANCE.getString("_UI_ComponentInterfaceEditorFilenameExtensions").split("\\s*,\\s*"))); protected ExecutionEvent event; + EList subtypes; + EList subtypes_; + EList combos; + EList subtypes_string; + public ExternalJavaActionNewParameter() { // TODO Auto-generated constructor stub @@ -60,28 +61,99 @@ public void execute(Collection arg0, Map 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 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 arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public void execute(Collection arg0, Map arg1) { + for (EObject diagram : arg0) { + List owned_views = ConnectionsCheckUtils.getDiagramViews(diagram); + for (DView view : owned_views) { + for (EObject rossystemEObj : view.getModels()) { + NodeImpl rosnode = ((NodeImpl)rossystemEObj); + System.out.println(rosnode.getParameter()); + } + }} + Display display = Display.getDefault(); + Shell activeShell = display.getActiveShell(); + System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + System.out.println(arg0.toString()); + System.out.println(arg1.toString()); + + /**ParametersWizard wizard = new ParametersWizard(); + wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(), arg0, arg1); + WizardDialog dialog = new WizardDialog(activeShell,wizard); + dialog.create(); + dialog.getShell().setText(wizard.getWindowTitle()); + dialog.open();*/ + } +} diff --git a/plugins/de.fraunhofer.ipa.ros.sirius/src/de/fraunhofer/ipa/ros/sirius/ParametersWizard.java b/plugins/de.fraunhofer.ipa.ros.sirius/src/de/fraunhofer/ipa/ros/sirius/ParametersWizard.java new file mode 100644 index 000000000..8d890f04c --- /dev/null +++ b/plugins/de.fraunhofer.ipa.ros.sirius/src/de/fraunhofer/ipa/ros/sirius/ParametersWizard.java @@ -0,0 +1,130 @@ +package de.fraunhofer.ipa.ros.sirius; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.common.util.EList; +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.wizard.Wizard; +import org.eclipse.jface.wizard.WizardSelectionPage; +import org.eclipse.sirius.business.api.session.Session; +import org.eclipse.sirius.business.api.session.SessionManager; +import org.eclipse.sirius.viewpoint.DAnalysis; +import org.eclipse.sirius.viewpoint.DView; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.actions.WorkspaceModifyOperation; + +import componentInterface.ComponentInterface; +import componentInterface.RosActionClient; +import componentInterface.RosActionServer; +import componentInterface.RosParameter; +import componentInterface.RosPublisher; +import componentInterface.RosServiceClient; +import componentInterface.RosServiceServer; +import componentInterface.RosSubscriber; +import componentInterface.impl.RosActionClientImpl; +import componentInterface.impl.RosActionServerImpl; +import componentInterface.impl.RosParameterImpl; +import componentInterface.impl.RosPublisherImpl; +import componentInterface.impl.RosServiceClientImpl; +import componentInterface.impl.RosServiceServerImpl; +import componentInterface.impl.RosSubscriberImpl; +import ros.ActionClient; +import ros.ActionServer; +import ros.Artifact; +import ros.Node; +import ros.Package; +import ros.PackageSet; +import ros.Publisher; +import ros.ServiceClient; +import ros.ServiceServer; +import ros.Subscriber; +import ros.Parameter; +import rossystem.RosSystem; + +/** + * This is a simple wizard for creating a new model file. + * + * + * @generated + */ +public class ParametersWizard extends Wizard implements INewWizard { + + protected IStructuredSelection selection; + protected IWorkbench workbench; + public FileDialog fDialog; + public String ComponentName; + public String ComponentNameSpace; + public String NameSpaceInterfaces; + //public ComponentInterface CI_input; + public IProject project; + public EObject eobject; + + + public void init(IWorkbench workbench, IStructuredSelection selection, Collection node, Map nameSpace) { + this.workbench = workbench; + this.selection = selection; + try { + + project = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput().getAdapter(IResource.class).getProject(); + setWindowTitle("Ros node parameters"); + }finally{ + + } + } + + @Override + public boolean performFinish() { + try { + + + WorkspaceModifyOperation operation = + new WorkspaceModifyOperation() { + @Override + protected void execute(IProgressMonitor progressMonitor) { + try { + + }catch (Exception exception) { + } + finally { + progressMonitor.done(); + } + }}; + getContainer().run(false, false, operation); + return true; + }catch (Exception exception) { + return false; + } + } + + + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + // TODO Auto-generated method stub + + } + +} diff --git a/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterArrayTypeImpl.java b/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterArrayTypeImpl.java index 504be8f55..9febb0fba 100644 --- a/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterArrayTypeImpl.java +++ b/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterArrayTypeImpl.java @@ -55,7 +55,7 @@ public class ParameterArrayTypeImpl extends ParameterTypeImpl implements Paramet * * @generated */ - protected ParameterArrayTypeImpl() { + public ParameterArrayTypeImpl() { super(); } diff --git a/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterBase64TypeImpl.java b/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterBase64TypeImpl.java index 2ded72d34..746fce600 100644 --- a/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterBase64TypeImpl.java +++ b/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterBase64TypeImpl.java @@ -43,7 +43,7 @@ public class ParameterBase64TypeImpl extends ParameterTypeImpl implements Parame * * @generated */ - protected ParameterBase64TypeImpl() { + public ParameterBase64TypeImpl() { super(); } diff --git a/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterListTypeImpl.java b/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterListTypeImpl.java index 619a1a30a..1ffa7a6ff 100644 --- a/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterListTypeImpl.java +++ b/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterListTypeImpl.java @@ -62,7 +62,7 @@ public class ParameterListTypeImpl extends ParameterTypeImpl implements Paramete * * @generated */ - protected ParameterListTypeImpl() { + public ParameterListTypeImpl() { super(); } diff --git a/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterStructTypeImpl.java b/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterStructTypeImpl.java index b154e82ed..f2376dbf7 100644 --- a/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterStructTypeImpl.java +++ b/plugins/de.fraunhofer.ipa.ros/src/ros/impl/ParameterStructTypeImpl.java @@ -47,7 +47,7 @@ public class ParameterStructTypeImpl extends ParameterTypeImpl implements Parame * * @generated */ - protected ParameterStructTypeImpl() { + public ParameterStructTypeImpl() { super(); }