|
Re: insert more than one element at once [message #177877 is a reply to message #177833] |
Fri, 15 April 2005 14:34 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Maybe the viewer is null because you have lost focus? Does the diagram lose
focus on creation?
"FreeGroup" <a.herz@FreeGroup.de> wrote in message
news:d3o7p7$gfd$1@news.eclipse.org...
> Hi
>
> I have implemented a command that insert more than one element at once
> (see below).
> It work fine.....but!
>
>
> java.lang.NullPointerException
> at
> org.eclipse.gef.tools.CreationTool.selectAddedObject(Creatio nTool.java:247)
> at
> org.eclipse.gef.tools.CreationTool.performCreation(CreationT ool.java:236)
> at
> org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTo ol.java:159)
> at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java :1054)
> at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:245)
>
> The GEF Framework can't select the EditPart. Why?
> I have inserted the inital templateModel and added additional objects
> to the model.
>
> Why can't the GEF find the EditPart for the inserted templateModel?
> I can see them in my GEF-Editor.
>
> At least the EditPart of the templateModel should be selected...or?
>
>
> Greetings
>
> Andreas
>
> Additional Question: It is possible(/allowed) to open a dialog in the
> execute method
> of an command?
|
|
|
Re: insert more than one element at once [message #177916 is a reply to message #177833] |
Fri, 15 April 2005 18:00 |
Eclipse User |
|
|
|
Originally posted by: etiennet16.hotmail.com
The default behavior when you Create an object is that the creation tool
will try to select the edit part it created the object for... So in your
command are you using the object created by your palette factory? If you
don't use the object the creation tool createed, then the creation tool
won't be able to select it after and will throw a NullPointer exception.
--
Etienne
"FreeGroup" <a.herz@FreeGroup.de> wrote in message
news:d3o7p7$gfd$1@news.eclipse.org...
> Hi
>
> I have implemented a command that insert more than one element at once
(see below).
> It work fine.....but!
>
>
> java.lang.NullPointerException
> at
org.eclipse.gef.tools.CreationTool.selectAddedObject(Creatio nTool.java:247)
> at
org.eclipse.gef.tools.CreationTool.performCreation(CreationT ool.java:236)
> at
org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTo ol.java:159)
> at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java :1054)
> at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:245)
>
> The GEF Framework can't select the EditPart. Why?
> I have inserted the inital templateModel and added additional objects
> to the model.
>
> Why can't the GEF find the EditPart for the inserted templateModel?
> I can see them in my GEF-Editor.
>
> At least the EditPart of the templateModel should be selected...or?
>
>
> Greetings
>
> Andreas
>
> Additional Question: It is possible(/allowed) to open a dialog in the
execute method
> of an command?
>
>
============================================================ ================
===========
>
============================================================ ================
===========
>
> public class CreateMyElementCommand extends Command
> {
> private MyModel templateModel;
> private MyGroupModel group;
> private Point location;
> private Dimension size;
> private List newModels=new ArrayList();
>
> public CreateGroupDBElementCommand(MyGroupModel group, MyModel
templateModel, Point
> location, Dimension size)
> {
> this.location = location;
> this.size = size;
> this.templateModel = templateModel;
> this.group = group;
> }
>
>
> // 1. Open a dialog to select more than one element
> // 2. insert the original model element
> // 3. create n clones from the templateModel and add them too
> //
> public void execute()
> {
> ElementListSelectionDialog dialog = new
ElementListSelectionDialog(null....)
> dialog.setElements(anyArray....);
> dialog.setTitle("Select the table columns for the GUI element");
> dialog.setMessage("Select the table columns for the GUI element.");
> dialog.setMultipleSelection(true);
> dialog.create();
> if(dialog.open()==Window.OK)
> {
> Object[] fields= dialog.getResult();
> if(size != null)
> {
> if(size.height<=0)
> size.height=20;
> if(size.width<=0)
> size.width=100;
> }
>
> // add the initial model from the toolbar
> //
> templateModel.setSize(size);
> templateModel.setLocation(location);
> templateModel.setData(field[0]);
> group.addChild(model);
>
> for (int i = 1; i < fields.length; i++)
> {
> String field = (String)fields[i];
> MyModel model = (MyModel)templateModel.getClass().newInstance();
> model.setSize(size);
>
model.setLocation(location.getTranslated(0,(model.getSize(). height+10)*i));
> model.setData(field);
> group.addChild(model);
> }
> }
> }
>
> public boolean canUndo()
> {
> return newModels.size()>0;
> }
>
> public void redo()
> {
> Iterator iter = newModels.iterator();
> while (iter.hasNext())
> {
> MyModel obj = (MyModel) iter.next();
> group.addElement(obj);
> }
> }
>
> public void undo()
> {
> Iterator iter = newModels.iterator();
> while (iter.hasNext())
> {
> MyModel obj = (MyModel) iter.next();
> group.removeElement(obj);
> }
> }
> }
|
|
|
|
|
Re: insert more than one element at once [message #178085 is a reply to message #178004] |
Mon, 18 April 2005 14:24 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Tools release any references to the viewer to avoid potential short-term
memory leaks. This problem seems to come up again and again, so maybe we
will provide some kind of workaround such as using a weak reference or
creating a runnable block of code which does not require calling back to the
tools viewer.
"FreeGroup" <a.herz@FreeGroup.de> wrote in message
news:d3qgqh$aat$1@news.eclipse.org...
> Hi
>
> Yes - the editor lost the focus. Is the a workaround
> available.....like "setFocus(getLastViewWithFocus())".
>
> greetings
>
> Andreas
>
|
|
|
|
Re: insert more than one element at once [message #178131 is a reply to message #178094] |
Mon, 18 April 2005 17:54 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Open a bugzilla to track this.
"FreeGroup" <a.herz@FreeGroup.de> wrote in message
news:d40htf$n6l$1@news.eclipse.org...
> Randy Hudson wrote:
>> Tools release any references to the viewer to avoid potential short-term
>> memory leaks. This problem seems to come up again and again, so maybe we
>> will provide some kind of workaround such as using a weak reference or
>> creating a runnable block of code which does not require calling back to
>> the tools viewer.
>
> Hi,
>
> FINE! - any release date in mind ;-)
>
>
>
>
> .....a way to go is to provide a class "DialogEnabledCommand"
> which handles the 'lost focus' with a weak reference.
>
> or - can I ignore the error, and the next release of the GEF
> handle this feature?
>
> greetings
>
> Andreas
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04270 seconds