Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » Remove allocation code if cancel
Remove allocation code if cancel [message #128447] Tue, 11 July 2006 21:01 Go to next message
hung is currently offline hungFriend
Messages: 117
Registered: July 2009
Senior Member
Hello,
I have code to bring up our dialog when dropping our component to the VE
from Palette. If cancel is pressed, it will not generate any code.
However, VE continues generating code to allocate the object. Is there a
way to tell VE to not generate the allocation code? For example:

private void initialize()
{
GridLayout layout = new GridLayout(1,false);
setLayout(layout);
createComponentRendering(); // need to remove this if cancel
}


// need to remove this if cancel
private void createComponentRendering()
{
componentRendering = new ComponentRendering(this,SWT.NONE);
}

Hope this makes sense. Thank you.
Re: Remove allocation code if cancel [message #128463 is a reply to message #128447] Tue, 11 July 2006 23:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

If your dialog is called from within a command you can't stop processing
at that point. It is too late because there isn't anyway to tell it to
undo all that was just done previously to it.

Basically you can't allow cancel at that point if it means you need to
undo other commands.

--
Thanks,
Rich Kulp
Re: Remove allocation code if cancel [message #132118 is a reply to message #128463] Tue, 10 October 2006 19:03 Go to previous messageGo to next message
Will Smythe is currently offline Will SmytheFriend
Messages: 41
Registered: July 2009
Member
Rich Kulp wrote:
> If your dialog is called from within a command you can't stop processing
> at that point. It is too late because there isn't anyway to tell it to
> undo all that was just done previously to it.
>
> Basically you can't allow cancel at that point if it means you need to
> undo other commands.
>

Rich - Does VE provide the ability to extend the EMFCreationToolEntry
class so a custom creation tool can be created that would display the
dialog prior to a command being created? The dialog would be initiated
from the tool class (as opposed to from the command) - clicking cancel
in the dialog would prevent any command from being created or executed.
GEF provides a way to specify a tool class name or to contribute your
own creation tool entry class:

<children xsi:type="org.eclipse.ve.internal.cde.palette:ToolEntry"
icon16Name="platform:/plugin/org.eclipse.ve.cde/images/marquee16.gif "

toolClassName="org.eclipse.gef/org.eclipse.gef.tools.MarqueeSelectionTool ">
Re: Remove allocation code if cancel [message #132286 is a reply to message #132118] Wed, 18 October 2006 15:59 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

If you don't need to know where you are dropping it (i.e. the dialog
comes up immediately upon selecting the palette entry to allow you to
decide what class to drop, and then allow the user to move the mouse to
where to drop it), then you can use a SelectionCreationToolEntry to do
this. Look at org.eclipse.ve.java.core/java_palette.xmi for

<children
xsi:type=" org.eclipse.ve.internal.cde.palette:SelectionCreationToolEnt ry "
icon16Name=" platform:/plugin/org.eclipse.ve.java.core/icons/full/cview16 /selectbean_view.gif "

selectorClassName=" org.eclipse.ve.java.core/org.eclipse.ve.internal.java.choose bean.ChooseBeanSelector ">
<entryLabel
xsi:type="org.eclipse.ve.internal.cde.utility:TranslatableString "
key="entry.ChooseJavaBean"
bundle="#jcm_bundle"/>
</children>

The selector classname (ChooseBeanSelector) returns the class to drop.
You can replace it with a different selector.

----------

There's no direct way supported to bring up the dialog BEFORE the
command executes but after the mouse button has been pressed for
dropping. You would need to do some overriding. You would need to do
many of the things that the CDECreationTool does (it should subclass
that). Then you would need to override the
AbstractTool.handleButtonUp(int) to put up your dialog, get your
information, and then probably need to do setCommand(getCommand()) again
to have the EditParts recontribute the command for however your dialog
modified the CreationRequest. Then do the super.handleButtonUp(int) to
actually cause it to work. There may be other problems that you will
need to handle.

--
Thanks,
Rich Kulp
Re: Remove allocation code if cancel [message #613518 is a reply to message #128447] Tue, 11 July 2006 23:00 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

If your dialog is called from within a command you can't stop processing
at that point. It is too late because there isn't anyway to tell it to
undo all that was just done previously to it.

Basically you can't allow cancel at that point if it means you need to
undo other commands.

--
Thanks,
Rich Kulp
Re: Remove allocation code if cancel [message #614704 is a reply to message #128463] Tue, 10 October 2006 19:03 Go to previous message
Will Smythe is currently offline Will SmytheFriend
Messages: 41
Registered: July 2009
Member
Rich Kulp wrote:
> If your dialog is called from within a command you can't stop processing
> at that point. It is too late because there isn't anyway to tell it to
> undo all that was just done previously to it.
>
> Basically you can't allow cancel at that point if it means you need to
> undo other commands.
>

Rich - Does VE provide the ability to extend the EMFCreationToolEntry
class so a custom creation tool can be created that would display the
dialog prior to a command being created? The dialog would be initiated
from the tool class (as opposed to from the command) - clicking cancel
in the dialog would prevent any command from being created or executed.
GEF provides a way to specify a tool class name or to contribute your
own creation tool entry class:

<children xsi:type="org.eclipse.ve.internal.cde.palette:ToolEntry"
icon16Name="platform:/plugin/org.eclipse.ve.cde/images/marquee16.gif "

toolClassName="org.eclipse.gef/org.eclipse.gef.tools.MarqueeSelectionTool ">
Re: Remove allocation code if cancel [message #614715 is a reply to message #132118] Wed, 18 October 2006 15:59 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

If you don't need to know where you are dropping it (i.e. the dialog
comes up immediately upon selecting the palette entry to allow you to
decide what class to drop, and then allow the user to move the mouse to
where to drop it), then you can use a SelectionCreationToolEntry to do
this. Look at org.eclipse.ve.java.core/java_palette.xmi for

<children
xsi:type=" org.eclipse.ve.internal.cde.palette:SelectionCreationToolEnt ry "
icon16Name=" platform:/plugin/org.eclipse.ve.java.core/icons/full/cview16 /selectbean_view.gif "

selectorClassName=" org.eclipse.ve.java.core/org.eclipse.ve.internal.java.choose bean.ChooseBeanSelector ">
<entryLabel
xsi:type="org.eclipse.ve.internal.cde.utility:TranslatableString "
key="entry.ChooseJavaBean"
bundle="#jcm_bundle"/>
</children>

The selector classname (ChooseBeanSelector) returns the class to drop.
You can replace it with a different selector.

----------

There's no direct way supported to bring up the dialog BEFORE the
command executes but after the mouse button has been pressed for
dropping. You would need to do some overriding. You would need to do
many of the things that the CDECreationTool does (it should subclass
that). Then you would need to override the
AbstractTool.handleButtonUp(int) to put up your dialog, get your
information, and then probably need to do setCommand(getCommand()) again
to have the EditParts recontribute the command for however your dialog
modified the CreationRequest. Then do the super.handleButtonUp(int) to
actually cause it to work. There may be other problems that you will
need to handle.

--
Thanks,
Rich Kulp
Previous Topic:code generation/reverse engineering principle
Next Topic:Preventing the generation of default constructor
Goto Forum:
  


Current Time: Thu Apr 25 12:22:41 GMT 2024

Powered by FUDForum. Page generated in 0.03050 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top