Home » Modeling » M2T (model-to-text transformation) » [JET2] Using MessageDialog in custom Tag
[JET2] Using MessageDialog in custom Tag [message #22536] |
Tue, 19 June 2007 09:46 |
Eclipse User |
|
|
|
Originally posted by: vincent.lg.voila.fr
Hi everyone,
I wrote some custom tags for my application and I wanted to display a
MessageDialog to ask users for something, but
MessageDialog.openInformation() throws a nullPointerException.
Here is a sample code :
public class AutoDeployTag extends AbstractEmptyTag {
public AutoDeployTag() {
// TODO Auto-generated constructor stub
}
@Override
public void doAction(TagInfo td, JET2Context context, JET2Writer
out)
throws JET2TagException {
MessageDialog.openInformation(null, "Test", "Test");
}
}
The dialog fails because it can't find any active shell to be displayed
on. I tried to pass
Activator.getDefault().getWorkbench().getDisplay().getActive Shell()
instead of null, but it doesn't work.
Does anyone have an idea ?
Many Thanks.
|
|
| |
Re: [JET2] Using MessageDialog in custom Tag [message #22709 is a reply to message #22580] |
Tue, 19 June 2007 13:48 |
Eclipse User |
|
|
|
Originally posted by: vincent.lg.voila.fr
Thanks a lot for the quick answer Paul,
Indeed, I've found that one couldn't create a MessageDialog outside the UI
thread, as you mentioned it in your answer. And I think I will give up
because you're right saying JET should be able to run without the UI.
I've one more question : I would like to be able to make a copy of some
files at the end of the transformation. In the workspace tags, it is only
proposed to create/copy files and folders in the current workspace, but
I'd like to copy them outside the workspace, say in my 'homedir' for
example. As it was impossible with standard tags, I've created a new tag
to copy the generated files (those in workspace) in my 'homedir', but it
is also impossible because JET uses a transaction system and actually
writes files on the disk when the transformation has ended, and the copy
doesn't work since files does not yet exist.
Can you give me some information about how I can do that ? Maybe there's a
way to chain 2 transformations, one that writes files in the workspace,
and the other that deploy those files elsewhere.
Many thanks,
Vincent.
|
|
|
Re: [JET2] Using MessageDialog in custom Tag [message #23015 is a reply to message #22709] |
Wed, 20 June 2007 12:36 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
Vincent:
Your tag can participate in JET's transactin by adding an 'action' via the
WorkspaceContextExtender:
WorkspaceContextExtender.getInstance(context).addAction( ...an
implementation of IWorkspaceAction or a subclass of
AbstractWorkspaceAction...)
Although this is targetted at writting to the Eclipse workspace, I think you
could make them work for your purposes. If you subclass
AbstractWorkspaceAction, you must implement three methods:
* performAction, which would actually write your file (and which would have
access to all previously written files)
* requiresValidateEdit, which can return false, as files outside the
workspace are not affected by the team system.
* getResource(), which can return null (or throw an
UnsupportedOperationException) - it will not be called if
requiresValidateEdit returns false.
Actions added via addAction are executed in the order in which they are
added. WorkspaceContextExtender also has a method addFinalAction, which
causes the action to be executed after all actions added by addAction.
Paul
"vincent" <vincent.lg@voila.fr> wrote in message
news:b52f08b4fe4c4a642c7ffb134a729203$1@www.eclipse.org...
> Thanks a lot for the quick answer Paul,
> Indeed, I've found that one couldn't create a MessageDialog outside the UI
> thread, as you mentioned it in your answer. And I think I will give up
> because you're right saying JET should be able to run without the UI.
>
> I've one more question : I would like to be able to make a copy of some
> files at the end of the transformation. In the workspace tags, it is only
> proposed to create/copy files and folders in the current workspace, but
> I'd like to copy them outside the workspace, say in my 'homedir' for
> example. As it was impossible with standard tags, I've created a new tag
> to copy the generated files (those in workspace) in my 'homedir', but it
> is also impossible because JET uses a transaction system and actually
> writes files on the disk when the transformation has ended, and the copy
> doesn't work since files does not yet exist.
>
> Can you give me some information about how I can do that ? Maybe there's a
> way to chain 2 transformations, one that writes files in the workspace,
> and the other that deploy those files elsewhere.
>
> Many thanks, Vincent.
|
|
|
Goto Forum:
Current Time: Thu Dec 26 17:03:15 GMT 2024
Powered by FUDForum. Page generated in 0.03511 seconds
|