New child menu entry for EMap and custom dialog [message #896093] |
Tue, 17 July 2012 09:02 |
John M. Messages: 198 Registered: July 2010 |
Senior Member |
|
|
Hello,
I have modelled a StringToIntegerMap and trying to add a menu item for creating an entry.
My idea was to edit the generated method collectNewChildDescriptors and add following:
newChildDescriptors.add(createChildParameter(Package.Literals.STRING_TO_INTEGER_MAP__VALUE, Factory.eINSTANCE.create(Package.Literals.STRING_TO_INTEGER_MAP)));
But I get a NPE in the ActionBarContributor.
Can I add on that way an item?
[Updated on: Tue, 17 July 2012 15:29] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: New child menu entry for EMap and custom dialog [message #896216 is a reply to message #896093] |
Tue, 17 July 2012 15:31 |
John M. Messages: 198 Registered: July 2010 |
Senior Member |
|
|
My command implementation with the InputDialog looks like following:
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandWrapper;
import org.eclipse.emf.edit.command.CommandActionDelegate;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.ui.PlatformUI;
public class DefinitionCreateCommand extends CommandWrapper implements CommandActionDelegate {
public DefinitionCreateCommand(Command command) {
super(command);
}
@Override
public void execute() {
InputDialog dialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "test",
"test message", "", null);
dialog.open();
}
@Override
public Object getImage() {
return ((CommandActionDelegate) super.command).getImage();
}
@Override
public String getText() {
return ((CommandActionDelegate) super.command).getText();
}
@Override
public String getToolTipText() {
return ((CommandActionDelegate) super.command).getToolTipText();
}
}
I have overwritten the method createCreateChildCommand with following content:
return new DefinitionCreateCommand(super.createCreateChildCommand(domain, owner, feature, value, index, collection));
It works so long, but how can I pass the result back?
|
|
|
Re: New child menu entry for EMap and custom dialog [message #896340 is a reply to message #896216] |
Wed, 18 July 2012 06:51 |
Ed Merks Messages: 33236 Registered: July 2009 |
Senior Member |
|
|
Command.getResult generally does the trick, after the command has been
executed.
On 17/07/2012 5:31 PM, Missing name Mising name wrote:
> My command implementation with the InputDialog looks like following:
>
> import org.eclipse.emf.common.command.Command;
> import org.eclipse.emf.common.command.CommandWrapper;
> import org.eclipse.emf.edit.command.CommandActionDelegate;
> import org.eclipse.jface.dialogs.InputDialog;
> import org.eclipse.ui.PlatformUI;
>
> public class DefinitionCreateCommand extends CommandWrapper implements
> CommandActionDelegate {
> public DefinitionCreateCommand(Command command) {
> super(command);
> }
>
> @Override
> public void execute() {
> InputDialog dialog = new
> InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
> "test",
> "test message", "", null);
> dialog.open();
> }
>
> @Override
> public Object getImage() {
> return ((CommandActionDelegate) super.command).getImage();
> }
>
> @Override
> public String getText() {
> return ((CommandActionDelegate) super.command).getText();
> }
>
> @Override
> public String getToolTipText() {
> return ((CommandActionDelegate) super.command).getToolTipText();
> }
> }
>
> I have overwritten the method createCreateChildCommand with following
> content:
> return new
> DefinitionCreateCommand(super.createCreateChildCommand(domain, owner,
> feature, value, index, collection));
>
> It works so long, but how can I pass the result back?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05793 seconds