Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » AMW » ATLLauncher
ATLLauncher [message #470310] Sat, 04 July 2009 16:09 Go to next message
Amine is currently offline Amine
Messages: 1
Registered: July 2009
Junior Member
Hi guys , i am programming with java the launching of atltransfrormation
i have written a code based on this link
http://wiki.eclipse.org/JWT_Transformations#About_ATL

unfortunately i got the error

java.lang.NullPointerException
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:104)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:81)
at ATLTransformation.uml22mmc(fffg.java:106)
at fffg$2.actionPerformed(fffg.java:261)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unk nown
Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown
Source)actionPerformed()

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)





THE PRINCIPLE CODE IS HERE

import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.Rectangle;
import javax.swing.JTabbedPane;
import java.awt.GridBagConstraints;
import javax.swing.JToggleButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JSlider;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import java.awt.event.KeyEvent;

import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;



import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.common.util.URI;
import org.eclipse.uml2.uml.UMLPackage;



import org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel;
import org.eclipse.m2m.atl.engine.AtlEMFModelHandler;
import org.eclipse.m2m.atl.engine.AtlLauncher;
import org.eclipse.m2m.atl.engine.AtlModelHandler;

import org.eclipse.m2m.atl.engine.vm.nativelib.ASMModel;



class ATLTransformation {





private AtlEMFModelHandler modelHandler;
private URI MMC_ModelResource;
private URI UML2_ModelResource;
private URL UML22MMC_TransfoResource;
private ASMEMFModel uml2Metamodel;
private ASMEMFModel mmcMetamodel;









private void createResources() {
modelHandler = (AtlEMFModelHandler) AtlModelHandler
.getDefault(AtlModelHandler.AMH_EMF);

MMC_ModelResource =
URI.createPlatformPluginURI("../ComposeUMLClass/metamodels/MMC.ecore ",
false);
UML2_ModelResource=URI.createPlatformPluginURI("../ComposeUMLClass/UML.ecore ",
false);

UML22MMC_TransfoResource =
ATLTransformation.class.getResource("../ComposeUMLClass/UML2Corresp.asm ");

}

private void initMetamodels(Map<String, Object> models) {





EPackage.Registry.INSTANCE.put("http://www.eclipse.org/uml2/2.1.0/UML",
UMLPackage.eINSTANCE);

uml2Metamodel = (ASMEMFModel) modelHandler.loadModel(
"UML2",
modelHandler.getMof(),"uri:http://www.eclipse.org/uml2/2.1.0/UML");
mmcMetamodel = (ASMEMFModel) modelHandler.loadModel(
"MMC", modelHandler.getMof(),
"../ComposeUMLClass/metamodels/MMC.ecore");



models.put("UML2", uml2Metamodel);
models.put("MMC", mmcMetamodel);

}


public void uml22mmc(String inFilePath1,String inFilePath2, String
outFilePath) {
try {
Map<String, Object> models = new HashMap<String, Object>();
createResources();
initMetamodels(models);

// get/create models
ASMEMFModel uml21InputModel = (ASMEMFModel)
modelHandler.loadModel("MPV1", uml2Metamodel,
URI.createFileURI(inFilePath1));
ASMEMFModel uml22InputModel = (ASMEMFModel)
modelHandler.loadModel("MPV2", uml2Metamodel,
URI.createFileURI(inFilePath2));
ASMEMFModel mmcOutputModel = (ASMEMFModel) modelHandler.newModel("MC",
URI.createFileURI(outFilePath).toFileString(), mmcMetamodel);
// load models
models.put("MPV1", uml21InputModel);
models.put("MPV2", uml22InputModel);
models.put("OUT", mmcOutputModel);
// launch
AtlLauncher.getDefault().launch(
this.UML22MMC_TransfoResource,
Collections.EMPTY_MAP, models, Collections.EMPTY_MAP,
Collections.EMPTY_LIST, Collections.EMPTY_MAP);

modelHandler.saveModel(mmcOutputModel, outFilePath,false);
dispose(models);
} catch (Exception e) {
e.printStackTrace();
}
}





private void dispose(Map<String, Object> models) {
for (Object model : models.values())
((ASMEMFModel)model).dispose();
}

}

public class fffg extends JFrame {

private static final long serialVersionUID = 1L;

private JPanel jContentPane = null;

private JPanel jPanel = null;

private JTabbedPane jTabbedPane = null;

private JPanel jPanel1 = null;

private JPanel jPanel2 = null;

private JPanel jPanel3 = null;

private JButton jButton = null;

private JButton EXECUTE = null;

private JFileChooser choix =null;

private static ATLTransformation instance = null;


public fffg() {
super();
initialize();
setVisible(true);
}


private void initialize() {
this.setSize(547, 248);
this.setContentPane(getJPanel());
this.setTitle("JFrame");
}


private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
}
return jContentPane;
}


private JPanel getJPanel() {
if (jPanel == null) {
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.add(getJTabbedPane(), null);
}
return jPanel;
}


private JTabbedPane getJTabbedPane() {
if (jTabbedPane == null) {
jTabbedPane = new JTabbedPane();
jTabbedPane.setBounds(new Rectangle(130, 30, 547, 419));
jTabbedPane.addTab(null, null, getJPanel1(), null);
jTabbedPane.addTab(null, null, getJPanel2(), null);
jTabbedPane.addTab(null, null, getJPanel3(), null);
}
return jTabbedPane;
}


private JPanel getJPanel1() {
if (jPanel1 == null) {
jPanel1 = new JPanel();
jPanel1.setLayout(new GridBagLayout());
}
return jPanel1;
}


private JPanel getJPanel2() {
if (jPanel2 == null) {
jPanel2 = new JPanel();
jPanel2.setLayout(new GridBagLayout());
}
return jPanel2;
}


private JPanel getJPanel3() {
if (jPanel3 == null) {
jPanel3 = new JPanel();
jPanel3.setLayout(null);
jPanel3.add(getJButton(), null);
jPanel3.add(getEXECUTE(), null);
}
return jPanel3;
}


private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(18, 17, 110, 23));
jButton.setText("FICHIER1");
jButton.setMnemonic(KeyEvent.VK_UNDEFINED);

jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
JFileChooser choix = new JFileChooser();
int retour = choix.showOpenDialog(null);
if (retour == JFileChooser.APPROVE_OPTION) {

choix.getSelectedFile().getName();

String nameff =choix.getSelectedFile().getAbsolutePath();
System.out.println ( nameff);
} else ;


System.out.println("actionPerformed()");
}
});
}
return jButton;
}
private JButton getEXECUTE() {
if (EXECUTE == null) {
EXECUTE = new JButton();
EXECUTE.setBounds(new Rectangle(52, 84, 106, 42));
EXECUTE.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
instance = new ATLTransformation();
instance.uml22mmc("../ComposeUMLClass/models/Medecin.uml", "../ComposeUMLClass/models/patient.uml","../ComposeUMLClass/essai.ecore ");
System.out.println("actionPerformed()");
}
});
}
return EXECUTE;
}

public static void main(String []agrs){
new fffg();
}
}


Hope u coukd help me

thnaks in advance
Re: ATLLauncher [message #470312 is a reply to message #470310] Mon, 06 July 2009 05:45 Go to previous message
Marcos Didonet Del Fabro is currently offline Marcos Didonet Del Fabro
Messages: 84
Registered: July 2009
Member
Hi,

This question is related to launching ATL programmatically. You should
check the Modeling M2M newsgroup:
news://news.eclipse.org/eclipse.modeling.m2m.


Marcos.
Previous Topic:Programmatically launching a composition: java.lang.reflect.InvocationTargetException
Next Topic:Problem in Transfromation
Goto Forum:
  


Current Time: Thu Aug 21 06:22:49 EDT 2014

Powered by FUDForum. Page generated in 0.02099 seconds