Swing designer and copying/pasting

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Swing designer and copying/pasting

Postby Bronek » Tue Oct 26, 2004 11:32 pm

I tried to copy a piece (a panel with components, or some components) of one form to another one - and it's imposible. I can't take a panel and reuse it. So - for example - I want a piece of a form to become a component - so I want to create a new JPanel and to put the components from my 'old' form (a whole panel for example). And I can't do that.
And I can't also copy/paste my custom components inside one form. They work fine in NetBeans, but can't be copied in SwingDesigner.
It would be great, if SwingDesigner had copying and pasting of custom components feature and copying from one form to another. Without it - when you have a form, and a panel on it - you can't easily make this panel a component - so that you can reuse it. When you have a custom component, and want to copy it because you set some properties and dont' want to do this again for a new component, or if you want to copy a group of three components - a JLabel, a CustomEdit and a JCheckBox - you can't. Copying / pasting is I think very basic operation in for example NetBeans - SwingDesigner lacks it...
Bronek
 

Re: Swing designer and copying/pasting

Postby Eric Clayberg » Wed Oct 27, 2004 4:42 am

Bronek wrote:I tried to copy a piece (a panel with components, or some components) of one form to another one - and it's imposible.

Impossible? I tried it and it worked just fine. I was able to copy a panel containing various widgets within the same form and into another form. Here's a screen shot showing the same panel duplicated within the same form after pasting...

    Image

Bronek wrote:I can't take a panel and reuse it. So - for example - I want a piece of a form to become a component - so I want to create a new JPanel and to put the components from my 'old' form (a whole panel for example). And I can't do that.

I did not have a problem doing that, so it does not seem to be a general problem. It may certainly be a problem specific to some combination of widgets. Can you send a test case or describe in more detail what kinds of widgets you are copying and pasting? If you have a panel containing a JButton, JLabel and JTextField, can you copy it within the same form or to another form? Were any exceptions recorded to your Eclipse ".log" file? If you encounter a problem that triggers an exception, you should include the stack trace.

Bronek wrote:And I can't also copy/paste my custom components inside one form.

There is indeed a problem copying custom widgets (e.g., those added using Choose Bean or added from the Custom Controls palette). The problem is not with the copying itelf but with the classpath resolution during the paste operation. This should be fixed soon.

Bronek wrote:They work fine in NetBeans, but can't be copied in SwingDesigner. It would be great, if SwingDesigner had copying and pasting of custom components feature and copying from one form to another. Without it - when you have a form, and a panel on it - you can't easily make this panel a component - so that you can reuse it. When you have a custom component, and want to copy it because you set some properties and dont' want to do this again for a new component, or if you want to copy a group of three components - a JLabel, a CustomEdit and a JCheckBox - you can't. Copying / pasting is I think very basic operation in for example NetBeans - SwingDesigner lacks it...

Your conclusion is incorrect. This is a basic operation and Swing Designer does include it. In general, it works just fine. There is a problem in the current build in handling custom, non-standard components, but you shoudn't generalize that to conclude that Designer doesn't support copying and pasting in general. As you would have also encountered an exception when the operation failed, you should include the stack trace when describing the problem.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Swing designer and copying/pasting

Postby Eric Clayberg » Wed Oct 27, 2004 11:31 am

Eric Clayberg wrote:There is indeed a problem copying custom widgets (e.g., those added using Choose Bean or added from the Custom Controls palette). The problem is not with the copying itelf but with the classpath resolution during the paste operation. This should be fixed soon.

This has now been fixed in the latest v2.1.1 build.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

copying and another error.

Postby Bronek » Wed Oct 27, 2004 10:37 pm

I didn't write that Swing Designer does not include copying in general. It just does not work in my project ;))
I can't copy from one form to another only, if I had previously tried to copy a CustomComponent, or, when I use not the standard JInternalFrame. I repeated the steps, so that i noticed that now it does not work only in this situation. Using base class for your frames is a very common manner - I don't imagine not doing this ;)
So - I have located the problem - it's not only the custom components/widgets that are impossible to be copied but ALSO the copying is impossible when you have a base class for your form other than standard JInternalFrame or JFrame - which is very often. It may be the same problem with classpaths that is when you try to copy a custom widget.

Ok - and one more thing ;))) I think you'll hate me for that - I have found a mistake in your parser - the one that parses java code and displays the form. When I have some component modifications in a method that is BELOW the constructor - the designer can not parse the file and I can't see the form (and I can't design it). I find no mistakes in the constructor code, so I was very astonished when I saw it the first time. After some time i tried to move the method that accesses the widget ABOVE the constructor - and the form could be displayed again. I'll try to recreate the probem using common components - i have some of custom ones on my form so I want to exclude the problem. But - happily -if the problem occurs - you just have to move the method up ;)
Bronek
 

parsing and custom components

Postby Bronek » Wed Oct 27, 2004 11:04 pm

I now know what the problem exactly is about.
I have a component - a custom ComboBox - that can have a checkBox connected to it (it has a property of a type JCheckBox).
When i try to set this property (in a block of 'if ... else' ) in a method that is below the constructor - I can't see the form, and the designer wants me to contact support by an e-mail. The solution I use now is moving the method au (above the contstrucor) or making constructor the latest method in a class. O - and another problem - I have a component (not a visual one) that can be a container for several 'common' Swing components (not custom ones). When I use method myCustomContainer.addKomponent(someStandardSwingComponent), and the useage is below the constructor - the someStandardSwingComponent disapears from the form ;)

that's all for know. And just to remind - I really like your tool although it is sometimes iritating. Speaking of iritating - in the properties panel Ctrl+V does not work - right button and 'paste' works. It's a simple thing to solve but a great change of the way of working ;)

Best regards
Bronek
Bronek
 

the problem with custom components and copying is not fixed

Postby Bronek » Wed Oct 27, 2004 11:09 pm

I'm afraid to say so -but the problem is not fixed. I have some custom components, on a form that is MyCustomInternalFrame - and I cant copy MyCustomComboBox. The 'paste' option does not appear. I also tried to put MyCustomComboBox on a simple JInternalFrame - I can't do that.
The version of Swing Designer: 2.1.1, build 2004.10.27
Bronek
 

Re: the problem with custom components and copying is not fi

Postby Eric Clayberg » Thu Oct 28, 2004 5:39 am

I tried a couple dozen different combinations of copying and pasting widgets (both standard and custom) between various forms (both subclassed from standard base classes and custom classes). With the latest v2.1.1 build, I could not reproduce any of the copy/paste problems you describe.

As suggested by the error message you encountered, you need to send us all of the relevant exceptions from your Eclipse ".log" file. We also need a test case (ideally the source for the class(es) you are working on or a reasonable approximation) that can be used to reproduce the problem. The classes MyCustomComboBox and MyCustomInternalFrame would be useful, for example.

As to the parser problem you indentified, we need to see a test case for that as well as any relevant exceptions from your log. Designer is very resilient in the face of almost any refactoring or any hand written code (better than any other GUI builder that I am aware of), but it isn't perfect. On the rare occassions where it does have a problem, we need to see a real test case illustrating the exact problem, so that we can fix it.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: the problem with custom components and copying is not fi

Postby Eric Clayberg » Thu Oct 28, 2004 6:42 pm

We found and fixed one more problem involving copying and pasting custom JPanel subclasses. There is a new v2.1.1 build, if you want to give it a try. I still need an example of the parsing problem you reported.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

parsing

Postby Bronek » Fri Oct 29, 2004 4:48 am

OK - I'm sending you the '.log' file after the problem using e-mail.
Bronek
 

Re: parsing

Postby Eric Clayberg » Mon Nov 01, 2004 11:31 am

Bronek wrote:OK - I'm sending you the '.log' file after the problem using e-mail.

A new v2.1.1 build is available that should solve the parsing problem you encountered.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

The last build made all my custom components disapear

Postby Bronek » Tue Nov 02, 2004 1:01 am

as in the subject - the last build made all my custom components disapear. And - we don't have the previous build - we've overwritten the old file with the designer :((
Bronek
 

Re: The last build made all my custom components disapear

Postby Eric Clayberg » Tue Nov 02, 2004 5:01 am

Bronek wrote:as in the subject - the last build made all my custom components disapear.

That's very strange as this latest version handles custom widgets much better than the previous version (and we have had that confirmed by several users so far). Are there any relevant exceptions recorded to your Eclipse ".log" file? Where are the custom components defined relative to your main project? It would be helpful, if you could send us a test case (as you did with the last problem you reported). It doesn't need to be the exact window you are working on...it could be a smaller, contrived example illustrating the problem with a single custom component. As long as we can reproduce it, we can fix it.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

custom components disapear

Postby Bronek » Tue Nov 02, 2004 6:14 am

Now I can't even add a custom component to a spring layout for example.
Our custom components can be handled by NetBeans - so it's done without errors - and, they could be handled by the previous build. So - I could not make a small example. I'm sending you by e-mail the .log file and the source file.
Bronek
 

Re: custom components disapear

Postby Eric Clayberg » Tue Nov 02, 2004 6:34 am

Bronek wrote:Now I can't even add a custom component to a spring layout for example.
Our custom components can be handled by NetBeans - so it's done without errors - and, they could be handled by the previous build. So - I could not make a small example. I'm sending you by e-mail the .log file and the source file.

This is a great example of why it is important to include the log entries immediately when you report a problem. I know exactly what is happening and it isn't a Designer problem. You are running into a known Eclipse 3.x plugin cache problem. Delete your Eclipse "configuration" directory (it is recreated at startup), re-start Eclipse and you should be back up and running again. The Designer build you have loaded is fine.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

the designer build does not seem to be fine

Postby Bronek » Wed Nov 03, 2004 2:11 am

Well - there is a problem in the designer - as far, as I can see. Having done what you told me (deleting the 'configuration' directory) I stardet the Eclipse againg, it was OK, but when I wanted to see a form - I had about 10 minutes of 100%busy processor, and after that the form looked like on the attached screenshot. Instead of the form I can now see "Not a Java bean. java.lang.InstantiationException null" . The file worked before (and even using the previous version of the 'configuration' directory I could see the form - although without custom components), there were no changes in the custom components - the custom components inherit from JFormattedTextField or a JComboBox, they have constructors with no parameters. They can be used in NetBeans. The log is:

!ENTRY org.eclipse.ui 4 4 lis 03, 2004 09:56:25.17
!MESSAGE Unhandled event loop exception

!ENTRY org.eclipse.ui 4 0 lis 03, 2004 09:56:25.33
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
at org.eclipse.gef.tools.AbstractTool.isInputSynched(AbstractTool.java:813)
at org.eclipse.gef.tools.AbstractTool.mouseMove(AbstractTool.java:970)
at org.eclipse.gef.tools.SelectionTool.mouseMove(SelectionTool.java:494)
at com.swtdesigner.gef.DesignerEditDomain.keyDown(SourceFile:68)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchKeyPressed(DomainEventDispatcher.java:231)
at org.eclipse.draw2d.LightweightSystem$EventHandler.keyPressed(LightweightSystem.java:461)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:121)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805)
at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1734)
at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1730)
at org.eclipse.swt.widgets.Control.WM_SYSKEYDOWN(Control.java:4404)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3041)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:3338)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1467)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2429)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1435)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1406)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:263)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.basicRun(Main.java:183)
at org.eclipse.core.launcher.Main.run(Main.java:644)
at org.eclipse.core.launcher.Main.main(Main.java:628)

!ENTRY org.eclipse.ui 4 4 lis 03, 2004 09:56:25.158
!MESSAGE Unhandled event loop exception

!ENTRY org.eclipse.ui 4 0 lis 03, 2004 09:56:25.158
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
at org.eclipse.gef.tools.AbstractTool.isInputSynched(AbstractTool.java:813)
at org.eclipse.gef.tools.AbstractTool.mouseMove(AbstractTool.java:970)
at org.eclipse.gef.tools.SelectionTool.mouseMove(SelectionTool.java:494)
at com.swtdesigner.gef.DesignerEditDomain.keyUp(SourceFile:88)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchKeyReleased(DomainEventDispatcher.java:244)
at org.eclipse.draw2d.LightweightSystem$EventHandler.keyReleased(LightweightSystem.java:466)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:127)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805)
at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1734)
at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1730)
at org.eclipse.swt.widgets.Control.WM_KEYUP(Control.java:3603)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:2998)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:3338)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1467)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2429)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1435)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1406)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:263)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.basicRun(Main.java:183)
at org.eclipse.core.launcher.Main.run(Main.java:644)
at org.eclipse.core.launcher.Main.main(Main.java:628)
Bronek
 

Next

Return to Swing Designer

Who is online

Users browsing this forum: Google [Bot] and 1 guest