Home » Eclipse Projects » Remote Application Platform (RAP) » Move some coolbar actions location to the right most
Move some coolbar actions location to the right most [message #80031] |
Sun, 30 March 2008 23:36  |
Eclipse User |
|
|
|
Hi all,
Our app has its perspective switcher hidden and we want to change the
location of coolbar actions that has generic functionality (like Help,
Preferences, etc) to the right most. What classes should we override for
this ?
Thanks in advanced for any help.
Best Regards,
Setya
|
|
| | |
Re: Move some coolbar actions location to the right most [message #80241 is a reply to message #80185] |
Mon, 31 March 2008 07:12   |
Eclipse User |
|
|
|
Tiago,
> I've done a similar thing sometime ago using the
> WorkbenchWindowAdvisor#createWindowContents() like Frank said with
> success. Just override it, and set your own layout for the shell. If you
> need any more details just let me know.
Thank you.
I've tried to override WorkbenchWindowAdvisor#createWindowContents() using
some snippet I found from this newsgroup:
@Override
public void createWindowContents(Shell shell)
{
final IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
if (configurer.getShowMenuBar())
{
final Menu menu = configurer.createMenuBar();
shell.setMenuBar(menu);
}
shell.setLayout(new FormLayout());
Composite banner = createUpperBannerArea(shell);
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.bottom = new FormAttachment(10, 0);
banner.setLayoutData(data);
Control coolbar = createCoolbar(shell,banner);
Control page = configurer.createPageComposite(shell);
data = new FormData();
data.top = new FormAttachment(coolbar, 5, SWT.BOTTOM);
data.left = new FormAttachment(0, 5);
data.right = new FormAttachment(100, -5);
data.bottom = new FormAttachment(100, -5);
page.setLayoutData(data);
Control statusLine = configurer.createStatusLineControl(shell);
data = new FormData();
data.top = new FormAttachment(page, 5, SWT.BOTTOM);
data.left = new FormAttachment(0, 5);
data.right = new FormAttachment(100, -5);
statusLine.setLayoutData(data);
}
private Control createCoolbar(Shell shell,Control sibling)
{
Composite coolBarContainer = new Composite(shell,SWT.NONE);
FormData formData = new FormData();
formData.top = new FormAttachment(sibling, 5, SWT.BOTTOM);
formData.left = new FormAttachment(0, 5);
formData.right = new FormAttachment(100, -5);
formData.bottom = new FormAttachment(15, 0);
coolBarContainer.setLayoutData(formData);
GridLayout layout = new GridLayout(2,false);
layout.marginHeight = 0;
layout.marginWidth = 0;
coolBarContainer.setLayout(layout);
//The left most coolbar
getWindowConfigurer().createCoolBarControl(coolBarContainer) ;
//The right most coolbar
CoolBar coolBar = new CoolBar(coolBarContainer,SWT.NONE);
coolBar.setLayoutData(new GridData(SWT.END,SWT.CENTER,true,true));
ICoolBarManager coolBarManager = new CoolBarManager(coolBar);
IAction action = new
HelpAction(HelpAction.ID_MENU_HELP,CorePlugin.getPluginResou rceString(HelpAction.CAPTION_MENU_HELP));
action.setImageDescriptor(CorePlugin.getInstance().getImageD escriptor(CorePlugin.getPluginResourceString(HelpAction.ICON _MENU_FILE_HELP)));
action.setActionDefinitionId(HelpAction.DEFINITION_ID_MENU_H ELP);
action.setToolTipText(CorePlugin.getPluginResourceString(Hel pAction.TOOLTIP_MENU_HELP));
action.setEnabled(true);
getWindowConfigurer().getActionBarConfigurer().registerGloba lAction(action);
coolBarManager.add(action);
return coolBarContainer;
}
The actions on the left coolbar were displayed, but not actions on the
right.
Also the status line won't show up either.
Best Regards,
Setya
|
|
|
Re: Move some coolbar actions location to the right most [message #80377 is a reply to message #80241] |
Mon, 31 March 2008 10:32   |
Eclipse User |
|
|
|
Try the following code:
@Override
public final void preWindowOpen() {
final IWorkbenchWindowConfigurer configurer =
getWindowConfigurer();
configurer.setShowStatusLine(true);
}
In there you can set other properties like setShowProgressIndicator and
others.
Tiago
Setya wrote:
> Tiago,
>
>> I've done a similar thing sometime ago using the
>> WorkbenchWindowAdvisor#createWindowContents() like Frank said with
>> success. Just override it, and set your own layout for the shell. If
>> you need any more details just let me know.
>
> Thank you.
>
> I've tried to override WorkbenchWindowAdvisor#createWindowContents()
> using some snippet I found from this newsgroup:
>
> @Override
> public void createWindowContents(Shell shell) {
> final IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
> if (configurer.getShowMenuBar()) {
> final Menu menu = configurer.createMenuBar();
> shell.setMenuBar(menu);
> }
> shell.setLayout(new FormLayout());
>
> Composite banner = createUpperBannerArea(shell);
> FormData data = new FormData();
> data.top = new FormAttachment(0, 0);
> data.left = new FormAttachment(0, 0);
> data.right = new FormAttachment(100, 0);
> data.bottom = new FormAttachment(10, 0);
> banner.setLayoutData(data);
>
> Control coolbar = createCoolbar(shell,banner);
> Control page = configurer.createPageComposite(shell);
> data = new FormData();
> data.top = new FormAttachment(coolbar, 5, SWT.BOTTOM);
> data.left = new FormAttachment(0, 5);
> data.right = new FormAttachment(100, -5);
> data.bottom = new FormAttachment(100, -5);
> page.setLayoutData(data);
>
> Control statusLine = configurer.createStatusLineControl(shell);
> data = new FormData();
> data.top = new FormAttachment(page, 5, SWT.BOTTOM);
> data.left = new FormAttachment(0, 5);
> data.right = new FormAttachment(100, -5);
> statusLine.setLayoutData(data);
> }
>
> private Control createCoolbar(Shell shell,Control sibling)
> {
> Composite coolBarContainer = new Composite(shell,SWT.NONE);
>
> FormData formData = new FormData();
> formData.top = new FormAttachment(sibling, 5, SWT.BOTTOM);
> formData.left = new FormAttachment(0, 5);
> formData.right = new FormAttachment(100, -5);
> formData.bottom = new FormAttachment(15, 0);
> coolBarContainer.setLayoutData(formData);
>
> GridLayout layout = new GridLayout(2,false);
> layout.marginHeight = 0;
> layout.marginWidth = 0;
> coolBarContainer.setLayout(layout);
> //The left most coolbar
> getWindowConfigurer().createCoolBarControl(coolBarContainer) ;
> //The right most coolbar
> CoolBar coolBar = new CoolBar(coolBarContainer,SWT.NONE);
> coolBar.setLayoutData(new GridData(SWT.END,SWT.CENTER,true,true));
>
> ICoolBarManager coolBarManager = new CoolBarManager(coolBar);
>
> IAction action = new
> HelpAction(HelpAction.ID_MENU_HELP,CorePlugin.getPluginResou rceString(HelpAction.CAPTION_MENU_HELP));
>
> action.setImageDescriptor(CorePlugin.getInstance().getImageD escriptor(CorePlugin.getPluginResourceString(HelpAction.ICON _MENU_FILE_HELP)));
>
> action.setActionDefinitionId(HelpAction.DEFINITION_ID_MENU_H ELP);
>
> action.setToolTipText(CorePlugin.getPluginResourceString(Hel pAction.TOOLTIP_MENU_HELP));
>
> action.setEnabled(true);
>
> getWindowConfigurer().getActionBarConfigurer().registerGloba lAction(action);
>
> coolBarManager.add(action);
> return coolBarContainer;
> }
>
> The actions on the left coolbar were displayed, but not actions on the
> right.
> Also the status line won't show up either.
>
> Best Regards,
>
> Setya
>
>
>
|
|
| |
Re: Move some coolbar actions location to the right most [message #81097 is a reply to message #80435] |
Thu, 03 April 2008 05:07   |
Eclipse User |
|
|
|
Setya wrote:
> Tiago,
>
>> @Override
>> public final void preWindowOpen() {
>> final IWorkbenchWindowConfigurer configurer =
>> getWindowConfigurer();
>> configurer.setShowStatusLine(true);
>> }
>
> Thanks.
>
> I'm aware of those settings. But by default status line is shown as long
> as we don't override WorkbenchWindowAdvisor#createWindowContents(Shell).
> From my code I gave earlier it turns out that I have to change :
> Control page = configurer.createPageComposite(shell);
> [..]
> data.bottom = new FormAttachment(100, -5);
> [..]
>
> into :
>
> Control page = configurer.createPageComposite(shell);
> [..]
> data.bottom = new FormAttachment(100, -25);
> [..]
>
> But I'm not sure if this really does the trick, it only reserves some
> space at the bottom most for the status line to fill.
>
> How's your implementation to move some coolbar actions to the right most ?
>
> Best Regards,
>
> Setya
>
Hi,
What I do is I set the Shell layout to GridLayout:
public final void createWindowContents(final Shell shell) {
shell.setLayout(new GridLayout());
[...]
Then I create a new Composite where I'm putting the cool bar and align
it to the right like:
[...]
final Composite toolComposite = new Composite(shell, SWT.NONE);
toolComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
true, false));
final Control toolbar =
configurer.createCoolBarControl(toolComposite);
[...]
Hope it helps.
Tiago
|
|
|
Re: Move some coolbar actions location to the right most [message #81126 is a reply to message #81097] |
Thu, 03 April 2008 06:30  |
Eclipse User |
|
|
|
Hi,
> What I do is I set the Shell layout to GridLayout:
> public final void createWindowContents(final Shell shell) {
> shell.setLayout(new GridLayout());
> [...]
> Then I create a new Composite where I'm putting the cool bar and align
> it to the right like:
> [...]
> final Composite toolComposite = new Composite(shell, SWT.NONE);
> toolComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
> true, false));
> final Control toolbar =
> configurer.createCoolBarControl(toolComposite);
> [...]
I've got it.
Thank you very much for the snippets.
Regards,
Setya
|
|
|
Goto Forum:
Current Time: Sun Aug 31 16:32:52 EDT 2025
Powered by FUDForum. Page generated in 0.03474 seconds
|