Home » Eclipse Projects » Remote Application Platform (RAP) » adding a Text widget to the ToolBar
adding a Text widget to the ToolBar [message #8338] |
Thu, 15 March 2007 17:03  |
Eclipse User |
|
|
|
Originally posted by: roberto.sanchez.autonomind.com
Hi all,
Is It possible to add a Control (A Text widget for example) to a ToolBar ?
I'm trying to do it with ContributionItem but it doesn't work. I read in
wiki.eclipse.org related to ToolBars and Menus that "Basic behavior is
implemented", but I'm not sure about the meaning of "Basic".
I've tried different implementations of method:
"ContributionItem.fill(ToolBar parent, int index)", but nothing works
Any help will be welcome. :-)
My code:
toolbar.add(new ContributionItem("dummy.id") {
protected Control createControl(Composite parent)
{
Composite panel = new Composite(parent, RWT.NONE);
panel.setLayout(new FillLayout());
new Text(panel, RWT.BORDER).setText("A Test Field");
return panel;
}
public final void fill(ToolBar parent, int index) {
createControl(parent);
}
/*
// I've tried different implementations of this method, but nothing works
public final void fill(ToolBar parent, int index) {
Control control = createControl(parent);
ToolItem ti = new ToolItem(parent, SWT.SEPARATOR, index);
ti.setControl(control);
ti.setWidth(computeWidth(control));
}
*/
public final void fill(Composite parent) {
createControl(parent);
}
});
toolbar.update(true);
}
|
|
| |
Re: adding a Text widget to the ToolBar [message #8463 is a reply to message #8402] |
Fri, 16 March 2007 07:55   |
Eclipse User |
|
|
|
Originally posted by: roberto.sanchez.autonomind.com
Hi Ralf, thank you for your response, but I'm not sure about if I can
use it because It is the Workbench Toolbar which I want to configure, I
didn't give this info before (I'm sorry :-( ).
In all examples I saw It's used a IToolBarManager. I think that the
reason to use it and not a ToolBar directly is that we still haven't got
a Shell parent object.
I was seeing this interface (IToolBarManager) and It's EMPTY :-o, there
is another one called
org.eclipse.rap.jface.internal.provisional.actionIToolBarMan ager2 that
make me think that something isn't complete with ToolBarManagers stuffs.
I need to do this in an "ActionBarAdvisor" subclass in method
"createToolBar":
private void createToolBar( ICoolBarManager coolBar, final String name) {
IToolBarManager toolbar = new ToolBarManager( RWT.FLAT | RWT.RIGHT);
coolBar.add( new ToolBarContributionItem( toolbar, name ) );
// "action1" is an object org.eclipse.rap.jface.action.Action
toolbar.add(this.action1);
toolbar.add(this.action2);
toolbar.add(new ContributionItem("dummy.id") { ... } );
}
Ralf Sternberg wrote:
> Hi Roberto,
>
> Roberto schrieb:
>> Is It possible to add a Control (A Text widget for example) to a
>> ToolBar ?
>
> You can add a Control to a ToolBar just like in SWT:
>
> ToolBar toolBar = new ToolBar( shell, RWT.FLAT );
> ...
> Text text = new Text( toolBar, RWT.BORDER );
> text.setText( "A Test Field" );
> text.setSize( 95, 20 );
> ToolItem itemText = new ToolItem( toolBar, RWT.SEPARATOR );
> itemText.setControl( text );
> itemText.setWidth( 100 );
>
> However, for whatever reasons the Control is only displayed if you set
> the RWT.FLAT style bit on the ToolBar. I filed a bug for this problem:
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=177728
>
> You must also set the size of the Control manually.
>
> Hope that helps,
>
> Ralf
|
|
| |
Re: adding a Text widget to the ToolBar [message #9582 is a reply to message #8525] |
Mon, 19 March 2007 06:05   |
Eclipse User |
|
|
|
Originally posted by: roberto.sanchez.autonomind.com
Hi Ralf, I'm using RWT/RAP and I suppose that this functionality isn't
implemented yet in RAP, I'm already looking for other alternatives.
If I'm right and RAP isn't yet ready for including Controls in workbench
toolbar I would like to know when It will be ready to be used.
It's something important for my UI
In any case, my complete class code is this (It's possible that I'm
wrong and I'm not using the API in the correct way ):
package com.autonomind.amvitae;
import org.eclipse.rap.jface.action.*;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.layout.FillLayout;
import org.eclipse.rap.rwt.widgets.*;
import org.eclipse.rap.ui.*;
import org.eclipse.rap.ui.entrypoint.*;
import com.autonomind.amvitae.actions.*;
public class AMVitaeActionBarAdvisor extends ActionBarAdvisor {
private Action action1 = new ActionAction1();
public AMVitaeActionBarAdvisor(final IActionBarConfigurer configurer ) {
super( configurer );
}
protected void makeActions( final IWorkbenchWindow window ) {
register( this.action1 );
}
protected void fillMenuBar( final IMenuManager menuBar ) {
MenuManager fileMenu = new MenuManager( "File",
IWorkbenchActionConstants.M_FILE );
menuBar.add( action1 );
fileMenu.add( this.action1 );
}
protected void fillCoolBar( ICoolBarManager coolBar ) {
createToolBar( coolBar, "main" );
}
private void createToolBar( ICoolBarManager coolBar, final String
name ) {
IToolBarManager toolbar = new ToolBarManager( RWT.FLAT | RWT.RIGHT);
coolBar.add( new ToolBarContributionItem( toolbar, name ) );
toolbar.add(this.action1);
toolbar.add(new ContributionItem("dummy.id") {
protected Control createControl(Composite parent)
{
Composite panel = new Composite(parent, RWT.FLAT);
panel.setLayout(new FillLayout());
new Text(panel, RWT.BORDER | RWT.FLAT).setText("A Test Field");
return panel;
}
public final void fill(ToolBar parent, int index) {
Control control = createControl(parent);
ToolItem ti = new ToolItem(parent, RWT.SEPARATOR |
RWT.FLAT, index);
ti.setControl(control);
ti.setWidth(100);
}
});
toolbar.update(true);
}
}
Best Regards.
Roberto.
Ralf Sternberg wrote:
> Hi Roberto,
>
>> Hi Ralf, thank you for your response, but I'm not sure about if I can
>> use it because It is the Workbench Toolbar which I want to configure,
>> I didn't give this info before (I'm sorry :-( ).
>
> I see. I'm not sure if I can help you right now as I'm more focused on
> RWT. Can you provide a working example for what you're trying to achieve
> in RCP? I think that you have to implement an IContributionItem and add
> it to the ToolBarManager, but I' not sure.
>
>> In all examples I saw It's used a IToolBarManager. I think that the
>> reason to use it and not a ToolBar directly is that we still haven't
>> got a Shell parent object.
>> I was seeing this interface (IToolBarManager) and It's EMPTY :-o,
>> there is another one called
>> org.eclipse.rap.jface.internal.provisional.actionIToolBarMan ager2 that
>> make me think that something isn't complete with ToolBarManagers stuffs.
>
> There's nothing wrong with an empty interface. Both interfaces are
> (nearly) exact copies from JFace.
>
> Regards,
> Ralf
|
|
|
Re: adding a Text widget to the ToolBar [message #10305 is a reply to message #9582] |
Tue, 20 March 2007 10:05  |
Eclipse User |
|
|
|
Originally posted by: rsternberg.innoopract.com
Hi Roberto,
> Hi Ralf, I'm using RWT/RAP and I suppose that this functionality isn't
> implemented yet in RAP, I'm already looking for other alternatives.
>
> If I'm right and RAP isn't yet ready for including Controls in workbench
> toolbar I would like to know when It will be ready to be used.
> It's something important for my UI
we've fixed the "controls in toolbars" bug, which also affected the
Workbench.
With the latest version from CVS (and also with the upcoming M3
release), the following code works with RCP and RAP alike:
protected void fillCoolBar( ICoolBarManager coolBar ) {
IToolBarManager toolbar = new ToolBarManager( RWT.FLAT | RWT.RIGHT );
coolBar.add( new ToolBarContributionItem( toolbar, "main" ) );
toolbar.add( aboutAction );
...
toolbar.add( new TextContributionItem( "text" ) );
}
public class TextContributionItem extends ContributionItem {
public TextContributionItem( String id ) {
super( id );
}
public final void fill( ToolBar parent, int index ) {
Text text = new Text( parent, SWT.SINGLE | SWT.BORDER );
text.setText( "A Text Field" );
ToolItem ti = new ToolItem( parent, SWT.SEPARATOR, index );
ti.setControl( text );
ti.setWidth( 100 );
}
}
Regards,
Ralf
|
|
|
Goto Forum:
Current Time: Thu May 08 03:42:43 EDT 2025
Powered by FUDForum. Page generated in 0.04435 seconds
|