Java Reference
In-Depth Information
public void
run(IAction action) {
try
{
EObject source = getInput();
if
(source ==
null
) {
String title =
Messages.RunInterpretedTransformationAction_title;
String message =
Messages.RunInterpretedTransformationAction_message;
MessageDialog.openInformation(getShell(), title,
NLS.bind(message, fileURI.toString()));
}
else
{
URI transfUri = URI.createURI("platform:/plugin/
org.eclipse.requirements.ui/transformations/
mindmap2requirements.qvto"); //$NON-NLS-1$
ArrayList<URI> paramUris =
new
ArrayList<URI>();
paramUris.add(fileURI);
IWizard wizard = (IWizard)
new
RunInterpretedTransformationWizardDelegate(
transfUri, paramUris);
WizardDialog wizardDialog =
new
WizardDialog(getShell(), wizard);
wizardDialog.open();
}
}
catch
(Exception ex) {
handleError(ex);
}
}
private
EObject getInput() {
ResourceSetImpl rs =
new
ResourceSetImpl();
return
rs.getEObject(fileURI.appendFragment("/"),
true
);
}
private void
handleError(Throwable ex) {
MessageDialog.openError(getShell(), "Transformation failed",
MessageFormat.format("{0}: {1}",
ex.getClass().getSimpleName(), ex.getMessage()
==
null
? "no message" : ex.getMessage()));
}
private
Shell getShell() {
return
targetPart.getSite().getShell();
}
}
The action used to invoke a workflow for Model-to-Text Transformation
(M2T) is largely the same. The following
run()
method is an example of how
the two differ.
Search WWH ::
Custom Search