Home » Archived » Visual Editor (VE) » Using VE to layout a View?
Using VE to layout a View? [message #80280] |
Wed, 16 February 2005 12:29  |
Eclipse User |
|
|
|
Originally posted by: michael.refactored-networks.com
I'm working on building an RCP application and I'd like to use VE to help
layout the SWT stuff inside the various Views I'm creating. I eventually
figured out the bit about adding the SWT widgets to the parent Composite
in ViewPart:createPartControl(). So I figured it should be fairly easy to
use VE to help layout the SWT stuff. But when I create a new Visual Class
and specify it as an Application who's class extends ViewPart VE throws a
NullPointerException saying "Error trying to set new file in editor".
Here's the class that causes the error:
package com.refactored_networks.foo.views;
public class SillyClass {
private org.eclipse.swt.widgets.Shell sShell = null;
private void createSShell() {
sShell = new org.eclipse.swt.widgets.Shell();
sShell.setSize(new org.eclipse.swt.graphics.Point(300,200));
sShell.setText("Shell");
}
}
Am I even doing this right? Is there any FAQ somewhere on how to use VE
for the Views inside an RCP or Plugin project?
|
|
| |
Re: Using VE to layout a View? [message #80455 is a reply to message #80412] |
Thu, 17 February 2005 16:50   |
Eclipse User |
|
|
|
Originally posted by: michael.refactored-networks.com
On Thu, 17 Feb 2005 09:08:57 -0500, Gili Mendel wrote:
> Use VE to create a class that extends a Composite... and build a
> customed container.
Ok, I created a new Visual Class using the wizard and specified Composite
instead of Application. That created this:
package com.refactored_networks.epc.epcbrowser.views;
import org.eclipse.swt.widgets.Composite;
public class SampleComposite extends Composite {
public SampleComposite(Composite parent, int style) {
super(parent, style);
initialize();
}
private void initialize() {
setSize(new org.eclipse.swt.graphics.Point(300,200));
}
}
But I can't put anything SWT related onto the canvas. No matter what I
pick, widget or container, nothing ends up appearing on the canvas or
in the code. Plus, no VE related properties (like layout) appear in
the properties for this class. I can drop Swing and AWT stuff on their all
day long, but nothing SWT related.
-MM
|
|
|
Re: Using VE to layout a View? [message #80468 is a reply to message #80455] |
Thu, 17 February 2005 17:21   |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
The canvas (I assume you mean the white area) can only handle the
subclassed object and shells. You can't drop any other SWT widget on the
white area because they require a parent. We don't currently support SWT
widgets that don't have a parent except for the class being subclassed.
Michael Mealling wrote:
> On Thu, 17 Feb 2005 09:08:57 -0500, Gili Mendel wrote:
>
>>Use VE to create a class that extends a Composite... and build a
>>customed container.
>
>
> Ok, I created a new Visual Class using the wizard and specified Composite
> instead of Application. That created this:
>
> package com.refactored_networks.epc.epcbrowser.views;
>
> import org.eclipse.swt.widgets.Composite;
>
> public class SampleComposite extends Composite {
>
> public SampleComposite(Composite parent, int style) {
> super(parent, style);
> initialize();
> }
> private void initialize() {
> setSize(new org.eclipse.swt.graphics.Point(300,200));
> }
> }
>
> But I can't put anything SWT related onto the canvas. No matter what I
> pick, widget or container, nothing ends up appearing on the canvas or
> in the code. Plus, no VE related properties (like layout) appear in
> the properties for this class. I can drop Swing and AWT stuff on their all
> day long, but nothing SWT related.
>
> -MM
--
Thanks,
Rich Kulp
|
|
| |
Re: Using VE to layout a View? [message #80493 is a reply to message #80481] |
Thu, 17 February 2005 23:45  |
Eclipse User |
|
|
|
No--take a look at Gili's message again.
You can't use Visual Editor with your ViewPart class directly, but you
can include a Composite in your ViewPart class by adding it in the
createPartControl() method. Then create your Composite as a visual class
For example, subclass ViewPart and add code as follows:
public class SampleView extends ViewPart {
private SampleComposite sampleComposite;
// ...
public void createPartControl(Composite parent) {
sampleComposite = new SampleComposite(parent, SWT.CENTER);
}
// ...
}
Then right-click on your source directory and select
New->Other->Java->Visual class. Name it SampleComposite, and choose
SWT->Composite as the style.
You'll need to add more code to set focus, etc., but this should get you
started.
@D
Michael Mealling wrote:
> So does all of that mean that I can't use VE to build a View with SWT
> widgets for use in a plugin or RCP app?
>
> -MM
>
> On Thu, 17 Feb 2005 17:21:58 -0500, Rich Kulp wrote:
>
>>The canvas (I assume you mean the white area) can only handle the
>>subclassed object and shells. You can't drop any other SWT widget on the
>>white area because they require a parent. We don't currently support SWT
>>widgets that don't have a parent except for the class being subclassed.
>>
>>Michael Mealling wrote:
>>
>>>But I can't put anything SWT related onto the canvas. No matter what I
>>>pick, widget or container, nothing ends up appearing on the canvas or
>>>in the code. Plus, no VE related properties (like layout) appear in
>>>the properties for this class. I can drop Swing and AWT stuff on their all
>>>day long, but nothing SWT related.
>
>
|
|
|
Re: Using VE to layout a View? [message #605319 is a reply to message #80280] |
Thu, 17 February 2005 09:08  |
Eclipse User |
|
|
|
Michael Mealling wrote:
> I'm working on building an RCP application and I'd like to use VE to
> help layout the SWT stuff inside the various Views I'm creating. I
> eventually figured out the bit about adding the SWT widgets to the
> parent Composite in ViewPart:createPartControl(). So I figured it should
> be fairly easy to use VE to help layout the SWT stuff. But when I create
> a new Visual Class and specify it as an Application who's class extends
> ViewPart VE throws a NullPointerException saying "Error trying to set
> new file in editor".
>
> Here's the class that causes the error:
>
> package com.refactored_networks.foo.views;
>
> public class SillyClass {
>
> private org.eclipse.swt.widgets.Shell sShell = null;
>
> private void createSShell() {
> sShell = new org.eclipse.swt.widgets.Shell();
> sShell.setSize(new org.eclipse.swt.graphics.Point(300,200));
> sShell.setText("Shell");
> }
> }
>
> Am I even doing this right? Is there any FAQ somewhere on how to use VE
> for the Views inside an RCP or Plugin project?
>
>
Use VE to create a class that extends a Composite... and build a
customed container.
In your ViewPart:createPartControl() just instantiate your VE generated
container.
|
|
|
Re: Using VE to layout a View? [message #605331 is a reply to message #80412] |
Thu, 17 February 2005 16:50  |
Eclipse User |
|
|
|
Originally posted by: michael.refactored-networks.com
On Thu, 17 Feb 2005 09:08:57 -0500, Gili Mendel wrote:
> Use VE to create a class that extends a Composite... and build a
> customed container.
Ok, I created a new Visual Class using the wizard and specified Composite
instead of Application. That created this:
package com.refactored_networks.epc.epcbrowser.views;
import org.eclipse.swt.widgets.Composite;
public class SampleComposite extends Composite {
public SampleComposite(Composite parent, int style) {
super(parent, style);
initialize();
}
private void initialize() {
setSize(new org.eclipse.swt.graphics.Point(300,200));
}
}
But I can't put anything SWT related onto the canvas. No matter what I
pick, widget or container, nothing ends up appearing on the canvas or
in the code. Plus, no VE related properties (like layout) appear in
the properties for this class. I can drop Swing and AWT stuff on their all
day long, but nothing SWT related.
-MM
|
|
|
Re: Using VE to layout a View? [message #605334 is a reply to message #80455] |
Thu, 17 February 2005 17:21  |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
The canvas (I assume you mean the white area) can only handle the
subclassed object and shells. You can't drop any other SWT widget on the
white area because they require a parent. We don't currently support SWT
widgets that don't have a parent except for the class being subclassed.
Michael Mealling wrote:
> On Thu, 17 Feb 2005 09:08:57 -0500, Gili Mendel wrote:
>
>>Use VE to create a class that extends a Composite... and build a
>>customed container.
>
>
> Ok, I created a new Visual Class using the wizard and specified Composite
> instead of Application. That created this:
>
> package com.refactored_networks.epc.epcbrowser.views;
>
> import org.eclipse.swt.widgets.Composite;
>
> public class SampleComposite extends Composite {
>
> public SampleComposite(Composite parent, int style) {
> super(parent, style);
> initialize();
> }
> private void initialize() {
> setSize(new org.eclipse.swt.graphics.Point(300,200));
> }
> }
>
> But I can't put anything SWT related onto the canvas. No matter what I
> pick, widget or container, nothing ends up appearing on the canvas or
> in the code. Plus, no VE related properties (like layout) appear in
> the properties for this class. I can drop Swing and AWT stuff on their all
> day long, but nothing SWT related.
>
> -MM
--
Thanks,
Rich Kulp
|
|
|
Re: Using VE to layout a View? [message #605337 is a reply to message #80468] |
Thu, 17 February 2005 17:53  |
Eclipse User |
|
|
|
Originally posted by: michael.refactored-networks.com
So does all of that mean that I can't use VE to build a View with SWT
widgets for use in a plugin or RCP app?
-MM
On Thu, 17 Feb 2005 17:21:58 -0500, Rich Kulp wrote:
> The canvas (I assume you mean the white area) can only handle the
> subclassed object and shells. You can't drop any other SWT widget on the
> white area because they require a parent. We don't currently support SWT
> widgets that don't have a parent except for the class being subclassed.
>
> Michael Mealling wrote:
>> But I can't put anything SWT related onto the canvas. No matter what I
>> pick, widget or container, nothing ends up appearing on the canvas or
>> in the code. Plus, no VE related properties (like layout) appear in
>> the properties for this class. I can drop Swing and AWT stuff on their all
>> day long, but nothing SWT related.
|
|
|
Re: Using VE to layout a View? [message #605338 is a reply to message #80481] |
Thu, 17 February 2005 23:45  |
Eclipse User |
|
|
|
No--take a look at Gili's message again.
You can't use Visual Editor with your ViewPart class directly, but you
can include a Composite in your ViewPart class by adding it in the
createPartControl() method. Then create your Composite as a visual class
For example, subclass ViewPart and add code as follows:
public class SampleView extends ViewPart {
private SampleComposite sampleComposite;
// ...
public void createPartControl(Composite parent) {
sampleComposite = new SampleComposite(parent, SWT.CENTER);
}
// ...
}
Then right-click on your source directory and select
New->Other->Java->Visual class. Name it SampleComposite, and choose
SWT->Composite as the style.
You'll need to add more code to set focus, etc., but this should get you
started.
@D
Michael Mealling wrote:
> So does all of that mean that I can't use VE to build a View with SWT
> widgets for use in a plugin or RCP app?
>
> -MM
>
> On Thu, 17 Feb 2005 17:21:58 -0500, Rich Kulp wrote:
>
>>The canvas (I assume you mean the white area) can only handle the
>>subclassed object and shells. You can't drop any other SWT widget on the
>>white area because they require a parent. We don't currently support SWT
>>widgets that don't have a parent except for the class being subclassed.
>>
>>Michael Mealling wrote:
>>
>>>But I can't put anything SWT related onto the canvas. No matter what I
>>>pick, widget or container, nothing ends up appearing on the canvas or
>>>in the code. Plus, no VE related properties (like layout) appear in
>>>the properties for this class. I can drop Swing and AWT stuff on their all
>>>day long, but nothing SWT related.
>
>
|
|
|
Goto Forum:
Current Time: Thu Jul 17 19:33:49 EDT 2025
Powered by FUDForum. Page generated in 0.05927 seconds
|