This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 32019 - Cannot copy-paste a container with a custom layout manager
Summary: Cannot copy-paste a container with a custom layout manager
Status: VERIFIED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P2 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-14 18:37 UTC by chiss
Modified: 2004-03-03 23:19 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The custom layout manager I use. (3.52 KB, text/plain)
2003-03-14 18:39 UTC, chiss
Details

Note You need to log in before you can comment on or make changes to this bug.
Description chiss 2003-03-14 18:37:10 UTC
Dev Build 200303132350

When you right-click an existing container to copy and 
paste it elsewhere, it doesn't work if the container is 
layed-out using a custom layoutmanager. Works ok with any 
other "default" layout managers. This used to work on 
3.4.1 and before.

Steps to reproduce :

1) Install a custom layout manager (I'll include the one I 
use as an attachment) using the Explorer-right-click-add 
to component palette-LayoutManagers. This layout manager 
is now available in the form editor.

2) Design a JPanel, add a JPanel, add stuff in it.

3) Right-click the JPanel, copy and paste it. Works ok.

4) Change its layout manager to the custom layout manager.

5) Repeat step 3. Nothing happens in the Form editor. No 
code is generated. Well, *something* happened, but its not 
apparent : say you JPanel was named "jPanel2", this last 
copy-paste should have created "jPanel3". Try 
renaming "jPanel2" to "jPanel3", and you have an error 
that says that 2 components can't have the same name. 
Still, this "jPanel3" is nowhere to be found.

Keep up the great work, its a pleasure to use NetBeans. 
Only glad to help hammer down a few bugs.
Comment 1 chiss 2003-03-14 18:39:54 UTC
Created attachment 9413 [details]
The custom layout manager I use.
Comment 2 Tomas Pavek 2003-03-17 15:43:44 UTC
I get following exceptions (printed in console):

java.lang.InstantiationException:
org.netbeans.modules.form.layoutsupport.DefaultLayoutSupport
 at java.lang.Class.newInstance0(Class.java:281)
 at java.lang.Class.newInstance(Class.java:249)
 at
org.netbeans.modules.form.layoutsupport.AbstractLayoutSupport.cloneLayoutSupport(AbstractLayoutSupport.java:753)
 at
org.netbeans.modules.form.layoutsupport.LayoutSupportManager.copyLayoutDelegateFrom(LayoutSupportManager.java:227)
 at
org.netbeans.modules.form.MetaComponentCreator.makeCopy(MetaComponentCreator.java:519)
 at
org.netbeans.modules.form.MetaComponentCreator.copyComponent2(MetaComponentCreator.java:294)
...


java.lang.NullPointerException
 at
org.netbeans.modules.form.layoutsupport.LayoutSupportManager.copyLayoutDelegateFrom(LayoutSupportManager.java:230)
 at
org.netbeans.modules.form.MetaComponentCreator.makeCopy(MetaComponentCreator.java:519)
 at
org.netbeans.modules.form.MetaComponentCreator.copyComponent2(MetaComponentCreator.java:294)
...
Comment 3 Tomas Pavek 2003-03-17 17:04:22 UTC
The immediate problem is in that class
org.netbeans.modules.form.layoutsupport.DefaultLayoutSupport
cannot be instantiated using Class.newInstance().

There is also architectural flaw behind - it's not taken into account
that copying of layout may fail...
Comment 4 Tomas Pavek 2003-03-17 17:15:36 UTC
Fixed in trunk.

/cvs/form/src/org/netbeans/modules/form/layoutsupport/AbstractLayoutSupport.java
new revision: 1.37; previous revision: 1.36
/cvs/form/src/org/netbeans/modules/form/layoutsupport/DefaultLayoutSupport.java
new revision: 1.4; previous revision: 1.3

Now thinking if this should go to NB 3.5.
Comment 5 chiss 2003-03-17 17:23:07 UTC
Wow, that was fast !
About your comment on if it should go to 3.5 or not, I 
would say yes because other people like me going from 
3.4.1 to 3.5 (when its officially released) will most 
likely report the problem.... But I understand there are 
probably a dozens of steps to take to make sure your fix 
doesn't affect anything else, QA and stuff... Your call.

Thanks again,
Francis 
Comment 6 Tomas Pavek 2003-03-18 08:07:03 UTC
It would be no problem to put this to NB 3.5 - if it was last week.
But now we are already in stage when only P1 bugs ("showstoppers") can
be fixed. This is surely ugly bug, P2 at least, but I'm not sure if it
is showstopper. Otherwise the fix is quite simple.
Comment 7 chiss 2003-03-18 12:25:54 UTC
Doh !

Oh well.. Maybe we can put something in the release notes 
about it, or something... There is an easy workaround : 
just change the layout to a "default" one, like 
FlowLayout, do the copy, and then put back the 
desired "custom" layout.

Until next bug ;-)
Comment 8 Tomas Pavek 2003-03-18 16:38:42 UTC
Okay, let's add this to release notes (readme.html):

It is not possible to copy/paste containers with custom (i.e.
non-standard) layout managers. A workaround is to set the layout e.g.
to FlowLayout first, then do the copy, and then set the right layout
back again.
Comment 9 Patrick Keegan 2003-04-02 14:32:13 UTC
adding to the 3.5 readme. Thanks for the text, Tomas.
Comment 10 Jaromir Uhrik 2003-04-15 15:05:35 UTC
The issue is not regression, I successfully reproduced it 
in release 3.4.1 build. Now it works fine with the fix in 
trunk - verified in dev build #200304150100.
Comment 11 Patrick Keegan 2004-03-03 23:19:31 UTC
removing RELNOTE keyword