workbench layout [message #45862] |
Mon, 10 September 2007 14:21  |
Tiago Messages: 55 Registered: July 2009 |
Member |
|
|
Hi,
I'm trying to customize the layout of a workbench to include an image and
other stuff. So far I managed to override the method
"createWindowContents(Shell)" from the WorkbenchWindowAdvisor class and had
success in changing the place of the toolbar and create a label with an
image. Now I'm trying to place the PerspectiveBar but without success it
always gives me the following exception:
java.lang.NullPointerException
at
org.eclipse.ui.internal.PerspectiveSwitcher.createControlFor Location(Unknown
Source)
at
org.eclipse.ui.internal.PerspectiveSwitcher.setPerspectiveBa rLocation(Unknown
Source)
at org.eclipse.ui.internal.PerspectiveSwitcher.createControl(Un known Source)
Here is part of my code:
@Override
public void createWindowContents(final Shell shell) {
final IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
final WorkbenchWindow window = (WorkbenchWindow) configurer.getWindow();
final Workbench workbench = (Workbench) window.getWorkbench();
shell.setLayout(new GridLayout(2, false));
...
CBanner pbar = new CBanner(shell, SWT.NONE);
pbar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2,
1));
PerspectiveSwitcher perspectiveSwitcher = new PerspectiveSwitcher(window,
pbar, SWT.FLAT | SWT.WRAP | SWT.RIGHT | SWT.HORIZONTAL);
perspectiveSwitcher.createControl(shell);
...
}
If anyone can help me out I would apreciate. Thanks
Tiago
|
|
|
Re: workbench layout [message #45983 is a reply to message #45862] |
Mon, 10 September 2007 17:43   |
Eclipse User |
|
|
|
Originally posted by: b.muskalla.gmx.net
Hi Tiago,
first: Use internal stuff at your own risk. Neither Workbench,
WorkbenchWindow nor PerspectiveSwitcher are API (as in RCP).
The NPE is caused as you are calling methods without setting up the
enviroment correctly first. Please take a look at the workbench code
(WorkbenchWindowAdvisor etc) how this is done.
In RCP you will get the same exception with your code. Normally you
would set the according preference to modify location of the perspective
switcher which is (sorry) not yet possible with RAP.
Greets
Benny
Tiago wrote:
> Hi,
> I'm trying to customize the layout of a workbench to include an image and
> other stuff. So far I managed to override the method
> "createWindowContents(Shell)" from the WorkbenchWindowAdvisor class and had
> success in changing the place of the toolbar and create a label with an
> image. Now I'm trying to place the PerspectiveBar but without success it
> always gives me the following exception:
>
> java.lang.NullPointerException
> at
> org.eclipse.ui.internal.PerspectiveSwitcher.createControlFor Location(Unknown
> Source)
> at
> org.eclipse.ui.internal.PerspectiveSwitcher.setPerspectiveBa rLocation(Unknown
> Source)
> at org.eclipse.ui.internal.PerspectiveSwitcher.createControl(Un known Source)
>
> Here is part of my code:
>
> @Override
> public void createWindowContents(final Shell shell) {
> final IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
> final WorkbenchWindow window = (WorkbenchWindow) configurer.getWindow();
> final Workbench workbench = (Workbench) window.getWorkbench();
> shell.setLayout(new GridLayout(2, false));
> ...
> CBanner pbar = new CBanner(shell, SWT.NONE);
> pbar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2,
> 1));
>
> PerspectiveSwitcher perspectiveSwitcher = new PerspectiveSwitcher(window,
> pbar, SWT.FLAT | SWT.WRAP | SWT.RIGHT | SWT.HORIZONTAL);
> perspectiveSwitcher.createControl(shell);
> ...
> }
>
> If anyone can help me out I would apreciate. Thanks
>
> Tiago
>
>
|
|
|
Re: workbench layout [message #46061 is a reply to message #45983] |
Tue, 11 September 2007 09:31  |
Tiago Messages: 55 Registered: July 2009 |
Member |
|
|
Hi,
Thanks for your reply. I'm going to do a little more investigation on the
workbench code. Meanwhile I got around the problem by implementing my own
toolbar and populating it with entries in the perspective registry.
Thanks.
Tiago
"Benjamin Muskalla" <b.muskalla@gmx.net> wrote in message
news:fc3vn8$sib$1@build.eclipse.org...
> Hi Tiago,
>
> first: Use internal stuff at your own risk. Neither Workbench,
> WorkbenchWindow nor PerspectiveSwitcher are API (as in RCP).
>
> The NPE is caused as you are calling methods without setting up the
> enviroment correctly first. Please take a look at the workbench code
> (WorkbenchWindowAdvisor etc) how this is done.
>
> In RCP you will get the same exception with your code. Normally you would
> set the according preference to modify location of the perspective
> switcher which is (sorry) not yet possible with RAP.
>
>
> Greets
> Benny
>
> Tiago wrote:
>> Hi,
>> I'm trying to customize the layout of a workbench to include an image and
>> other stuff. So far I managed to override the method
>> "createWindowContents(Shell)" from the WorkbenchWindowAdvisor class and
>> had success in changing the place of the toolbar and create a label with
>> an image. Now I'm trying to place the PerspectiveBar but without success
>> it always gives me the following exception:
>>
>> java.lang.NullPointerException
>> at
>> org.eclipse.ui.internal.PerspectiveSwitcher.createControlFor Location(Unknown
>> Source)
>> at
>> org.eclipse.ui.internal.PerspectiveSwitcher.setPerspectiveBa rLocation(Unknown
>> Source)
>> at org.eclipse.ui.internal.PerspectiveSwitcher.createControl(Un known
>> Source)
>>
>> Here is part of my code:
>>
>> @Override
>> public void createWindowContents(final Shell shell) {
>> final IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
>> final WorkbenchWindow window = (WorkbenchWindow)
>> configurer.getWindow();
>> final Workbench workbench = (Workbench) window.getWorkbench();
>> shell.setLayout(new GridLayout(2, false));
>> ...
>> CBanner pbar = new CBanner(shell, SWT.NONE);
>> pbar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2,
>> 1));
>>
>> PerspectiveSwitcher perspectiveSwitcher = new
>> PerspectiveSwitcher(window, pbar, SWT.FLAT | SWT.WRAP | SWT.RIGHT |
>> SWT.HORIZONTAL);
>> perspectiveSwitcher.createControl(shell);
>> ...
>> }
>>
>> If anyone can help me out I would apreciate. Thanks
>>
>> Tiago
|
|
|
Powered by
FUDForum. Page generated in 0.01819 seconds