$search
00001 package org.ros.model.ros.diagram.edit.helpers; 00002 00003 import org.eclipse.gmf.runtime.common.core.command.ICommand; 00004 import org.eclipse.core.runtime.NullProgressMonitor; 00005 import org.eclipse.emf.common.command.Command; 00006 import org.eclipse.emf.common.command.CompoundCommand; 00007 import org.eclipse.emf.common.util.URI; 00008 import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; 00009 import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; 00010 import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; 00011 import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; 00012 import org.eclipse.gmf.tooling.runtime.edit.helpers.GeneratedEditHelperBase; 00013 import org.eclipse.swt.widgets.Display; 00014 import org.eclipse.ui.PlatformUI; 00015 import org.ros.model.ros.RosPackage; 00016 import org.eclipse.emf.ecore.resource.Resource; 00017 import org.eclipse.emf.ecore.resource.ResourceSet; 00018 import org.eclipse.emf.edit.command.AddCommand; 00019 import org.eclipse.emf.edit.command.CopyCommand; 00020 import org.eclipse.emf.edit.command.CreateCopyCommand; 00021 import org.eclipse.emf.edit.command.ReplaceCommand; 00022 import org.eclipse.emf.edit.command.SetCommand; 00023 import org.ros.model.ros.diagram.MyAddCommand; 00024 import org.ros.model.ros.diagram.providers.RosElementTypes; 00025 00029 public class RosBaseEditHelper extends GeneratedEditHelperBase { 00030 @Override 00031 protected ICommand getConfigureCommand(ConfigureRequest req) { 00032 //System.out.println("WAAH!"); 00033 //if (req.getElementToConfigure(). == RosElementTypes.Package_2001) { 00034 CompoundCommand compoundCommand = new CompoundCommand(); 00035 ResourceSet resourceSet = req.getEditingDomain().getResourceSet(); 00036 Resource res = resourceSet.getResource(URI.createURI("platform:/resource/turtle_client_package/model/turtle_client.ros_package"), true); 00037 Command command = new MyAddCommand(req.getEditingDomain(), res.getContents(), req.getElementToConfigure()); 00038 00039 compoundCommand.append(command); 00040 System.out.println("EditingDomain: " + req.getEditingDomain().toString()); 00041 System.out.println("Trying to execute stuff"); 00042 System.out.println(command.toString()); 00043 if(compoundCommand.canExecute()) { 00044 System.out.println("Executing stuff"); 00045 compoundCommand.execute(); 00046 try { 00047 Display.getDefault().syncExec(new Runnable() { 00048 public void run() { 00049 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor()); 00050 } 00051 }); 00052 } catch (Exception e) { 00053 e.printStackTrace(); 00054 } 00055 } 00056 00057 //} 00058 System.out.println(req.getElementToConfigure().toString()); 00059 //return new SetValueCommand(new SetRequest(req.getElementToConfigure(), RosPackage.Literals.PACKAGE__NAME, "WAAH")); 00060 return null; 00061 } 00062 00063 @Override 00064 protected ICommand getCreateCommand(CreateElementRequest req) { 00065 00066 return super.getCreateCommand(req); 00067 } 00068 }