BcmxToPsmHandler.java
Go to the documentation of this file.
00001 package org.best_of_robotics.transform.bcmx.to.ros.handler;
00002 
00003 import org.best_of_robotics.transform.bcmx.to.ros.Activator;
00004 import org.best_of_robotics.transform.service.ITransformService;
00005 import org.best_of_robotics.transform.service.access.TransformAccessActivator;
00006 import org.best_of_robotics.transform.service.parameter.IEtlTransformParameter;
00007 import org.best_of_robotics.transform.service.parameter.TransformParameterFactory;
00008 import org.eclipse.core.commands.AbstractHandler;
00009 import org.eclipse.core.commands.ExecutionEvent;
00010 import org.eclipse.core.commands.ExecutionException;
00011 import org.eclipse.core.resources.IFile;
00012 import org.eclipse.jface.viewers.ISelection;
00013 import org.eclipse.jface.viewers.ITreeSelection;
00014 import org.eclipse.swt.SWT;
00015 import org.eclipse.swt.widgets.FileDialog;
00016 import org.eclipse.ui.IWorkbenchWindow;
00017 import org.eclipse.ui.PlatformUI;
00018 import org.eclipse.ui.handlers.HandlerUtil;
00019 
00020 public class BcmxToPsmHandler extends AbstractHandler {
00021 
00022         public BcmxToPsmHandler() {
00023         }
00024 
00025         @Override
00026         public Object execute(ExecutionEvent event) throws ExecutionException {
00027                 //get the selected source file
00028                 IWorkbenchWindow window = HandlerUtil
00029                                 .getActiveWorkbenchWindowChecked(event);
00030                 ISelection selection = window.getSelectionService().getSelection();
00031                 ITreeSelection structuredSelection = (ITreeSelection) selection;
00032                 Object element = structuredSelection.getFirstElement();
00033                 IFile sourceModelFilePath = (IFile) element;
00034                 
00035 
00036                 
00037                 //configure new transform parameter
00038                 IEtlTransformParameter etlTransformParameter = TransformParameterFactory.createEtlTransformParameter();
00039                 etlTransformParameter.setTransformName("BCM to ROS");
00040                 etlTransformParameter.setEtlTransformPath("epsilon/bcmToRos.etl");
00041                 etlTransformParameter.setPluginID(Activator.PLUGIN_ID);
00042                 etlTransformParameter.setSourceMetaModelURI("org.best_of_robotics.model.bcmx");
00043                 etlTransformParameter.setSourceModelFilePath(sourceModelFilePath.getLocation().toOSString());
00044                 etlTransformParameter.setSourceName("Source");
00045                 etlTransformParameter.setSourceReadOnLoad(true);
00046                 etlTransformParameter.setSourceStoreOnDisposal(false);
00047                 etlTransformParameter.setTargetMetaModelURI("http://ros/1.0");
00048                 
00049                 FileDialog fileDialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE);
00050                 fileDialog.setText("ROS Model File Name");
00051                 fileDialog.setFilterPath(sourceModelFilePath.getProject().getLocation().toOSString());
00052                 String targetModelFilePath = fileDialog.open();
00053                 
00054                 etlTransformParameter.setTargetModelFilePath(targetModelFilePath);
00055                 etlTransformParameter.setTargetName("Target");
00056                 etlTransformParameter.setTargetReadOnLoad(false);
00057                 etlTransformParameter.setTargetStoreOnDisposal(true);
00058                 
00059                 //get transform service
00060                 
00061                 ITransformService transformService = TransformAccessActivator.getDefault().getTransformService();
00062                 
00063                 //do transform
00064                 transformService.doTransform(etlTransformParameter);
00065                 
00066                 return null;
00067         }
00068 
00069 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


bride_plugin_source
Author(s): Alexander Bubeck
autogenerated on Wed Aug 14 2013 10:06:09