Background Image on CoolBar [message #57882] |
Tue, 06 November 2007 10:08 |
Eclipse User |
|
|
|
Originally posted by: dkusch.intersoft.de
Hi everyone,
I want to put a JPG image as Background of my CoolBar (like these thing
with the globe in the RapDemo), but I have no idea how to do this.
Anyone here who can help me?
Thanks, Dan.
|
|
|
Re: Background Image on CoolBar [message #57909 is a reply to message #57882] |
Tue, 06 November 2007 11:32 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
the demo uses a little hack in the postWindowOpen method of the
WorkbenchWindowAdvisor. Note that this is a Q&D implementation which was
created after the main application already was working, so it fullfills its
purpose but it isn't really a nice solution - anyway it may inspires you...
public class RMSWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
private static final Color COLOR_WHITE
= Display.getDefault().getSystemColor( SWT.COLOR_WHITE );
private boolean introActive = true;
public RMSWorkbenchWindowAdvisor(
final IWorkbenchWindowConfigurer configurer )
{
super( configurer );
}
@Override
public ActionBarAdvisor createActionBarAdvisor(
final IActionBarConfigurer configurer )
{
return new RMSActionBarAdvisor( configurer );
}
@Override
public void preWindowOpen() {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setShowPerspectiveBar( true );
configurer.setShowMenuBar( true );
configurer.setShowCoolBar( true );
configurer.setShowStatusLine( false );
configurer.setTitle( "RAP Workbench Demo" );
configurer.setShellStyle( SWT.NONE );
Rectangle bounds = Display.getDefault().getBounds();
configurer.setInitialSize( new Point( bounds.width, bounds.height ) );
}
@Override
public void postWindowOpen() {
final IWorkbenchWindow window = getWindowConfigurer().getWindow();
Shell shell = window.getShell();
shell.setMaximized( true );
final Composite mainBanner = createMainBanner( shell );
setMainBannerSize( mainBanner );
final Composite secondaryBanner = createSecondaryBanner( shell );
final WorkbenchPage page = ( WorkbenchPage )window.getActivePage();
setSecondaryBannerSize( secondaryBanner, page );
shell.addControlListener( new ControlAdapter() {
@Override
public void controlResized( final ControlEvent evt ) {
setMainBannerSize( mainBanner );
setSecondaryBannerSize( secondaryBanner, page );
setPageBounds( page );
}
} );
final Composite secondBanner = new Composite( shell, SWT.NONE );
secondBanner.setLayout( new FormLayout() );
window.addPerspectiveListener( new PerspectiveAdapter() {
public void perspectiveActivated( IWorkbenchPage page,
IPerspectiveDescriptor perspective )
{
String idIntro
= "org.eclipse.rap.rms.ui.internal.startup.IntroPerspective";
introActive = idIntro.equals( perspective.getId() );
secondaryBanner.setVisible( !introActive );
setPageBounds( page );
}
} );
}
private void setSecondaryBannerSize( final Composite secondaryBanner,
final WorkbenchPage page )
{
Composite clientComposite = page.getClientComposite();
Rectangle bounds = clientComposite.getBounds();
Display display = Display.getCurrent();
Point location = display.map( clientComposite.getParent(),
secondaryBanner.getShell(),
new Point( 0, 0 ) );
secondaryBanner.setBounds( location.x,
location.y,
bounds.width,
bounds.height );
}
private Composite createSecondaryBanner( final Shell shell ) {
final Composite result = new Composite( shell, SWT.NONE );
result.setLayout( new FormLayout() );
Label lblBackground = new Label( result, SWT.NONE );
String imgBanner = Activator.IMG_BANNER_SECONDARY;
Activator activator = Activator.getDefault();
lblBackground.setImage( activator.getImage( imgBanner ) );
FormData fdBackground = new FormData();
fdBackground.top = new FormAttachment( 0, 0 );
fdBackground.left = new FormAttachment( 0, 0 );
fdBackground.right = new FormAttachment( 100, 0 );
fdBackground.bottom = new FormAttachment( 100, 0 );
lblBackground.setLayoutData( fdBackground );
String imgOverview = Activator.IMG_INTRO_OVERVIEW;
Label lblOverview = new Label( result, SWT.NONE );
lblOverview.setImage( activator.getImage( imgOverview ) );
FormData fdOverview = new FormData();
fdOverview.top = new FormAttachment( 0, 2 );
fdOverview.left = new FormAttachment( 0, 4 );
fdOverview.right = new FormAttachment( 0, 68 );
fdOverview.bottom = new FormAttachment( 0, 66 );
lblOverview.setLayoutData( fdOverview );
lblOverview.moveAbove( lblBackground );
lblOverview.setBackground( Graphics.getColor( 225, 234, 241 ) );
String imgOvTxt = Activator.IMG_BANNER_SECONDARY_TXT;
Label lblOvTxt = new Label( result, SWT.NONE );
lblOvTxt.setImage( activator.getImage( imgOvTxt ) );
lblOvTxt.pack();
FormData fdOvTxt = new FormData();
fdOvTxt.top = new FormAttachment( 0, 26 );
fdOvTxt.left = new FormAttachment( 0, 79 );
lblOvTxt.setLayoutData( fdOvTxt );
lblOvTxt.moveAbove( lblBackground );
return result;
}
private Composite createMainBanner( final Shell shell ) {
final Composite result = new Composite( shell, SWT.NONE );
result.setBackground( COLOR_WHITE );
result.setLayout( new FormLayout() );
Label lblBackground = new Label( result, SWT.NONE );
String imgBanner = Activator.IMG_INTRO_BANNER;
Activator activator = Activator.getDefault();
lblBackground.setImage( activator.getImage( imgBanner ) );
lblBackground.setBackground( COLOR_WHITE );
FormData fdBackground = new FormData();
fdBackground.top = new FormAttachment( 0, 0 );
fdBackground.left = new FormAttachment( 0, 0 );
fdBackground.right = new FormAttachment( 100, 0 );
fdBackground.bottom = new FormAttachment( 100, 0 );
lblBackground.setLayoutData( fdBackground );
return result;
}
private void setMainBannerSize( final Composite banner ) {
Rectangle clientArea = banner.getShell().getClientArea();
banner.setBounds( clientArea.x + 3,
0,
clientArea.width - 6,
clientArea.y - 1 );
}
private void setPageBounds( final IWorkbenchPage page ) {
WorkbenchPage wPage = ( WorkbenchPage )page;
Composite clientComposite = wPage.getClientComposite();
if( !introActive ) {
Rectangle bounds = clientComposite.getBounds();
clientComposite.setBounds( bounds.x + 100,
bounds.y + 100,
bounds.width - 100,
bounds.height - 100 );
} else {
Composite parent = clientComposite.getParent();
clientComposite.setBounds( parent.getClientArea() );
}
}
}
Hope that helps!
Ciao
Frank
"Dan" <dkusch@intersoft.de> schrieb im Newsbeitrag
news:5253223c9dd39ae22b72e13bdd26fc10$1@www.eclipse.org...
> Hi everyone,
>
> I want to put a JPG image as Background of my CoolBar (like these thing
> with the globe in the RapDemo), but I have no idea how to do this.
>
> Anyone here who can help me?
>
> Thanks, Dan.
>
>
|
|
|
Re: Background Image on CoolBar [message #63448 is a reply to message #57909] |
Wed, 28 November 2007 09:55 |
Christian Messages: 31 Registered: July 2009 |
Member |
|
|
Hi,
i've tested this code; i ask you if it's possible to move the y
coordinate of the coolbar in order to increase the height of the main
banner.
Ciao
Christian
Frank Appel ha scritto:
> Hi,
>
> the demo uses a little hack in the postWindowOpen method of the
> WorkbenchWindowAdvisor. Note that this is a Q&D implementation which was
> created after the main application already was working, so it fullfills its
> purpose but it isn't really a nice solution - anyway it may inspires you...
>
>
> public class RMSWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
> private static final Color COLOR_WHITE
> = Display.getDefault().getSystemColor( SWT.COLOR_WHITE );
>
> private boolean introActive = true;
>
> public RMSWorkbenchWindowAdvisor(
> final IWorkbenchWindowConfigurer configurer )
> {
> super( configurer );
> }
>
> @Override
> public ActionBarAdvisor createActionBarAdvisor(
> final IActionBarConfigurer configurer )
> {
> return new RMSActionBarAdvisor( configurer );
> }
>
> @Override
> public void preWindowOpen() {
> IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
> configurer.setShowPerspectiveBar( true );
> configurer.setShowMenuBar( true );
> configurer.setShowCoolBar( true );
> configurer.setShowStatusLine( false );
> configurer.setTitle( "RAP Workbench Demo" );
> configurer.setShellStyle( SWT.NONE );
> Rectangle bounds = Display.getDefault().getBounds();
> configurer.setInitialSize( new Point( bounds.width, bounds.height ) );
> }
>
> @Override
> public void postWindowOpen() {
> final IWorkbenchWindow window = getWindowConfigurer().getWindow();
> Shell shell = window.getShell();
> shell.setMaximized( true );
>
> final Composite mainBanner = createMainBanner( shell );
> setMainBannerSize( mainBanner );
>
> final Composite secondaryBanner = createSecondaryBanner( shell );
> final WorkbenchPage page = ( WorkbenchPage )window.getActivePage();
> setSecondaryBannerSize( secondaryBanner, page );
>
> shell.addControlListener( new ControlAdapter() {
> @Override
> public void controlResized( final ControlEvent evt ) {
> setMainBannerSize( mainBanner );
> setSecondaryBannerSize( secondaryBanner, page );
> setPageBounds( page );
> }
> } );
>
> final Composite secondBanner = new Composite( shell, SWT.NONE );
> secondBanner.setLayout( new FormLayout() );
>
> window.addPerspectiveListener( new PerspectiveAdapter() {
> public void perspectiveActivated( IWorkbenchPage page,
> IPerspectiveDescriptor perspective )
> {
> String idIntro
> = "org.eclipse.rap.rms.ui.internal.startup.IntroPerspective";
> introActive = idIntro.equals( perspective.getId() );
> secondaryBanner.setVisible( !introActive );
> setPageBounds( page );
> }
> } );
>
> }
>
> private void setSecondaryBannerSize( final Composite secondaryBanner,
> final WorkbenchPage page )
> {
> Composite clientComposite = page.getClientComposite();
> Rectangle bounds = clientComposite.getBounds();
> Display display = Display.getCurrent();
> Point location = display.map( clientComposite.getParent(),
> secondaryBanner.getShell(),
> new Point( 0, 0 ) );
> secondaryBanner.setBounds( location.x,
> location.y,
> bounds.width,
> bounds.height );
>
> }
>
> private Composite createSecondaryBanner( final Shell shell ) {
> final Composite result = new Composite( shell, SWT.NONE );
> result.setLayout( new FormLayout() );
>
> Label lblBackground = new Label( result, SWT.NONE );
> String imgBanner = Activator.IMG_BANNER_SECONDARY;
> Activator activator = Activator.getDefault();
> lblBackground.setImage( activator.getImage( imgBanner ) );
> FormData fdBackground = new FormData();
> fdBackground.top = new FormAttachment( 0, 0 );
> fdBackground.left = new FormAttachment( 0, 0 );
> fdBackground.right = new FormAttachment( 100, 0 );
> fdBackground.bottom = new FormAttachment( 100, 0 );
> lblBackground.setLayoutData( fdBackground );
>
> String imgOverview = Activator.IMG_INTRO_OVERVIEW;
> Label lblOverview = new Label( result, SWT.NONE );
> lblOverview.setImage( activator.getImage( imgOverview ) );
> FormData fdOverview = new FormData();
> fdOverview.top = new FormAttachment( 0, 2 );
> fdOverview.left = new FormAttachment( 0, 4 );
> fdOverview.right = new FormAttachment( 0, 68 );
> fdOverview.bottom = new FormAttachment( 0, 66 );
> lblOverview.setLayoutData( fdOverview );
> lblOverview.moveAbove( lblBackground );
> lblOverview.setBackground( Graphics.getColor( 225, 234, 241 ) );
>
> String imgOvTxt = Activator.IMG_BANNER_SECONDARY_TXT;
> Label lblOvTxt = new Label( result, SWT.NONE );
> lblOvTxt.setImage( activator.getImage( imgOvTxt ) );
> lblOvTxt.pack();
> FormData fdOvTxt = new FormData();
> fdOvTxt.top = new FormAttachment( 0, 26 );
> fdOvTxt.left = new FormAttachment( 0, 79 );
> lblOvTxt.setLayoutData( fdOvTxt );
> lblOvTxt.moveAbove( lblBackground );
>
> return result;
> }
>
> private Composite createMainBanner( final Shell shell ) {
> final Composite result = new Composite( shell, SWT.NONE );
> result.setBackground( COLOR_WHITE );
> result.setLayout( new FormLayout() );
>
> Label lblBackground = new Label( result, SWT.NONE );
> String imgBanner = Activator.IMG_INTRO_BANNER;
> Activator activator = Activator.getDefault();
> lblBackground.setImage( activator.getImage( imgBanner ) );
> lblBackground.setBackground( COLOR_WHITE );
> FormData fdBackground = new FormData();
> fdBackground.top = new FormAttachment( 0, 0 );
> fdBackground.left = new FormAttachment( 0, 0 );
> fdBackground.right = new FormAttachment( 100, 0 );
> fdBackground.bottom = new FormAttachment( 100, 0 );
> lblBackground.setLayoutData( fdBackground );
> return result;
> }
>
> private void setMainBannerSize( final Composite banner ) {
> Rectangle clientArea = banner.getShell().getClientArea();
> banner.setBounds( clientArea.x + 3,
> 0,
> clientArea.width - 6,
> clientArea.y - 1 );
> }
>
> private void setPageBounds( final IWorkbenchPage page ) {
> WorkbenchPage wPage = ( WorkbenchPage )page;
> Composite clientComposite = wPage.getClientComposite();
> if( !introActive ) {
> Rectangle bounds = clientComposite.getBounds();
> clientComposite.setBounds( bounds.x + 100,
> bounds.y + 100,
> bounds.width - 100,
> bounds.height - 100 );
> } else {
> Composite parent = clientComposite.getParent();
> clientComposite.setBounds( parent.getClientArea() );
> }
> }
> }
>
>
> Hope that helps!
>
> Ciao
> Frank
>
>
> "Dan" <dkusch@intersoft.de> schrieb im Newsbeitrag
> news:5253223c9dd39ae22b72e13bdd26fc10$1@www.eclipse.org...
>> Hi everyone,
>>
>> I want to put a JPG image as Background of my CoolBar (like these thing
>> with the globe in the RapDemo), but I have no idea how to do this.
>>
>> Anyone here who can help me?
>>
>> Thanks, Dan.
>>
>>
>
>
|
|
|
Re: Background Image on CoolBar [message #63921 is a reply to message #63448] |
Mon, 03 December 2007 13:49 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
as I mentioned the code-snippet was just a quick and dirty hack. The proper
solution is to override the WorkbenchWindowAdvisor#createWindowContents like
described in the newsgroup entry at
http://dev.eclipse.org/newslists/news.eclipse.technology.rap /msg01708.html.
With this approach you should have more freedom positioning the coolbar.
Ciao
Frank
"Christian" <zerostress@libero.it> schrieb im Newsbeitrag
news:fijduq$3lm$1@build.eclipse.org...
> Hi,
> i've tested this code; i ask you if it's possible to move the y
> coordinate of the coolbar in order to increase the height of the main
> banner.
>
> Ciao
> Christian
>
>
> Frank Appel ha scritto:
>> Hi,
>>
>> the demo uses a little hack in the postWindowOpen method of the
>> WorkbenchWindowAdvisor. Note that this is a Q&D implementation which was
>> created after the main application already was working, so it fullfills
>> its
>> purpose but it isn't really a nice solution - anyway it may inspires
>> you...
>>
>>
>> public class RMSWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
>> private static final Color COLOR_WHITE
>> = Display.getDefault().getSystemColor( SWT.COLOR_WHITE );
>>
>> private boolean introActive = true;
>>
>> public RMSWorkbenchWindowAdvisor(
>> final IWorkbenchWindowConfigurer configurer )
>> {
>> super( configurer );
>> }
>>
>> @Override
>> public ActionBarAdvisor createActionBarAdvisor(
>> final IActionBarConfigurer configurer )
>> {
>> return new RMSActionBarAdvisor( configurer );
>> }
>>
>> @Override
>> public void preWindowOpen() {
>> IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
>> configurer.setShowPerspectiveBar( true );
>> configurer.setShowMenuBar( true );
>> configurer.setShowCoolBar( true );
>> configurer.setShowStatusLine( false );
>> configurer.setTitle( "RAP Workbench Demo" );
>> configurer.setShellStyle( SWT.NONE );
>> Rectangle bounds = Display.getDefault().getBounds();
>> configurer.setInitialSize( new Point( bounds.width,
>> bounds.height ) );
>> }
>>
>> @Override
>> public void postWindowOpen() {
>> final IWorkbenchWindow window = getWindowConfigurer().getWindow();
>> Shell shell = window.getShell();
>> shell.setMaximized( true );
>>
>> final Composite mainBanner = createMainBanner( shell );
>> setMainBannerSize( mainBanner );
>>
>> final Composite secondaryBanner = createSecondaryBanner( shell );
>> final WorkbenchPage page = ( WorkbenchPage )window.getActivePage();
>> setSecondaryBannerSize( secondaryBanner, page );
>>
>> shell.addControlListener( new ControlAdapter() {
>> @Override
>> public void controlResized( final ControlEvent evt ) {
>> setMainBannerSize( mainBanner );
>> setSecondaryBannerSize( secondaryBanner, page );
>> setPageBounds( page );
>> }
>> } );
>>
>> final Composite secondBanner = new Composite( shell, SWT.NONE );
>> secondBanner.setLayout( new FormLayout() );
>>
>> window.addPerspectiveListener( new PerspectiveAdapter() {
>> public void perspectiveActivated( IWorkbenchPage page,
>> IPerspectiveDescriptor
>> perspective )
>> {
>> String idIntro
>> = "org.eclipse.rap.rms.ui.internal.startup.IntroPerspective";
>> introActive = idIntro.equals( perspective.getId() );
>> secondaryBanner.setVisible( !introActive );
>> setPageBounds( page );
>> }
>> } );
>>
>> }
>>
>> private void setSecondaryBannerSize( final Composite secondaryBanner,
>> final WorkbenchPage page )
>> {
>> Composite clientComposite = page.getClientComposite();
>> Rectangle bounds = clientComposite.getBounds();
>> Display display = Display.getCurrent();
>> Point location = display.map( clientComposite.getParent(),
>> secondaryBanner.getShell(),
>> new Point( 0, 0 ) );
>> secondaryBanner.setBounds( location.x,
>> location.y,
>> bounds.width,
>> bounds.height );
>>
>> }
>>
>> private Composite createSecondaryBanner( final Shell shell ) {
>> final Composite result = new Composite( shell, SWT.NONE );
>> result.setLayout( new FormLayout() );
>>
>> Label lblBackground = new Label( result, SWT.NONE );
>> String imgBanner = Activator.IMG_BANNER_SECONDARY;
>> Activator activator = Activator.getDefault();
>> lblBackground.setImage( activator.getImage( imgBanner ) );
>> FormData fdBackground = new FormData();
>> fdBackground.top = new FormAttachment( 0, 0 );
>> fdBackground.left = new FormAttachment( 0, 0 );
>> fdBackground.right = new FormAttachment( 100, 0 );
>> fdBackground.bottom = new FormAttachment( 100, 0 );
>> lblBackground.setLayoutData( fdBackground );
>>
>> String imgOverview = Activator.IMG_INTRO_OVERVIEW;
>> Label lblOverview = new Label( result, SWT.NONE );
>> lblOverview.setImage( activator.getImage( imgOverview ) );
>> FormData fdOverview = new FormData();
>> fdOverview.top = new FormAttachment( 0, 2 );
>> fdOverview.left = new FormAttachment( 0, 4 );
>> fdOverview.right = new FormAttachment( 0, 68 );
>> fdOverview.bottom = new FormAttachment( 0, 66 );
>> lblOverview.setLayoutData( fdOverview );
>> lblOverview.moveAbove( lblBackground );
>> lblOverview.setBackground( Graphics.getColor( 225, 234, 241 ) );
>>
>> String imgOvTxt = Activator.IMG_BANNER_SECONDARY_TXT;
>> Label lblOvTxt = new Label( result, SWT.NONE );
>> lblOvTxt.setImage( activator.getImage( imgOvTxt ) );
>> lblOvTxt.pack();
>> FormData fdOvTxt = new FormData();
>> fdOvTxt.top = new FormAttachment( 0, 26 );
>> fdOvTxt.left = new FormAttachment( 0, 79 );
>> lblOvTxt.setLayoutData( fdOvTxt );
>> lblOvTxt.moveAbove( lblBackground );
>>
>> return result;
>> }
>>
>> private Composite createMainBanner( final Shell shell ) {
>> final Composite result = new Composite( shell, SWT.NONE );
>> result.setBackground( COLOR_WHITE );
>> result.setLayout( new FormLayout() );
>>
>> Label lblBackground = new Label( result, SWT.NONE );
>> String imgBanner = Activator.IMG_INTRO_BANNER;
>> Activator activator = Activator.getDefault();
>> lblBackground.setImage( activator.getImage( imgBanner ) );
>> lblBackground.setBackground( COLOR_WHITE );
>> FormData fdBackground = new FormData();
>> fdBackground.top = new FormAttachment( 0, 0 );
>> fdBackground.left = new FormAttachment( 0, 0 );
>> fdBackground.right = new FormAttachment( 100, 0 );
>> fdBackground.bottom = new FormAttachment( 100, 0 );
>> lblBackground.setLayoutData( fdBackground );
>> return result;
>> }
>>
>> private void setMainBannerSize( final Composite banner ) {
>> Rectangle clientArea = banner.getShell().getClientArea();
>> banner.setBounds( clientArea.x + 3,
>> 0,
>> clientArea.width - 6,
>> clientArea.y - 1 );
>> }
>>
>> private void setPageBounds( final IWorkbenchPage page ) {
>> WorkbenchPage wPage = ( WorkbenchPage )page;
>> Composite clientComposite = wPage.getClientComposite();
>> if( !introActive ) {
>> Rectangle bounds = clientComposite.getBounds();
>> clientComposite.setBounds( bounds.x + 100,
>> bounds.y + 100,
>> bounds.width - 100,
>> bounds.height - 100 );
>> } else {
>> Composite parent = clientComposite.getParent();
>> clientComposite.setBounds( parent.getClientArea() );
>> }
>> }
>> }
>>
>>
>> Hope that helps!
>>
>> Ciao
>> Frank
>>
>>
>> "Dan" <dkusch@intersoft.de> schrieb im Newsbeitrag
>> news:5253223c9dd39ae22b72e13bdd26fc10$1@www.eclipse.org...
>>> Hi everyone,
>>>
>>> I want to put a JPG image as Background of my CoolBar (like these thing
>>> with the globe in the RapDemo), but I have no idea how to do this.
>>>
>>> Anyone here who can help me?
>>>
>>> Thanks, Dan.
>>>
>>>
>>
>>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|