Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Splash Screen Client Swing
Splash Screen Client Swing [message #520926] Mon, 15 March 2010 19:33 Go to next message
Eclipse UserFriend
People asking how to change the splash screen of Swing-Scout-Clients.

'DefaultSwingEnvironment.createIconUIResource("splash")' is called to
create the splash screen. The fist way to change the default splash is
to override this method in your Environment implementation. An other one
quite easier is to put a 'splash.(png|gif|jpg)' in the
'resources/icons/'f folder of your applications swing bundle (e.g.
org.eclipse.scout.sample.ui.swing).

Enjoy
andy
Re: Splash Screen Client Swing [message #544991 is a reply to message #520926] Tue, 06 July 2010 09:48 Go to previous messageGo to next message
Daniel Wiehl is currently offline Daniel WiehlFriend
Messages: 1
Registered: May 2016
Junior Member
Here some more details:

1. Put an image (png, gif, jpg) into the folder 'resources/icons/' of your Swing Bundle. If this folder structure does not exist yet, create it.
For the following lines of code I assume an image 'your_custom_splash.png' is placed in that folder.

2. Do the following changes in the class SwingEnvironment:

public class SwingEnvironment extends DefaultSwingEnvironment {
...
/**
* To change the Splash screen overwrite the following method as follows
*/
@Override
public void interceptUIDefaults(UIDefaults defaults) {
// see UIDefaultsInjector
defaults.put("Splash.icon", createIconUIResource("your_custom_splash"));
super.interceptUIDefaults(defaults);
}


/**
* helper method to be used to change the splash screen
*/
private IconUIResource createIconUIResource(String resourceSimpleName) {
Icon icon = getIcon(resourceSimpleName);
if (icon != null) {
return new IconUIResource(icon);
} else {
return null;
}
}

}
Re: Splash Screen Client Swing [message #581361 is a reply to message #520926] Tue, 06 July 2010 09:48 Go to previous messageGo to next message
Daniel Wiehl is currently offline Daniel WiehlFriend
Messages: 1
Registered: May 2016
Junior Member
Here some more details:

1. Put an image (png, gif, jpg) into the folder 'resources/icons/' of your Swing Bundle. If this folder structure does not exist yet, create it.
For the following lines of code I assume an image 'your_custom_splash.png' is placed in that folder.

2. Do the following changes in the class SwingEnvironment:

public class SwingEnvironment extends DefaultSwingEnvironment {
...
/**
* To change the Splash screen overwrite the following method as follows
*/
@Override
public void interceptUIDefaults(UIDefaults defaults) {
// see UIDefaultsInjector
defaults.put("Splash.icon", createIconUIResource("your_custom_splash"));
super.interceptUIDefaults(defaults);
}

/**
* helper method to be used to change the splash screen
*/
private IconUIResource createIconUIResource(String resourceSimpleName) {
Icon icon = getIcon(resourceSimpleName);
if (icon != null) {
return new IconUIResource(icon);
} else {
return null;
}
}
}
Re: Splash Screen Client Swing [message #990475 is a reply to message #544991] Wed, 12 December 2012 16:12 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Trying this fails with the exception listed below. Stepping through the code I found that stepping into getIcon(resourceSimpleName) leads to AbstractSwingEnvironment.getIcon() calling m_iconLocator.getIcon(name) with m_iconLocator being null. What do I need to do to fix this?

Root exception:
java.lang.NullPointerException
at org.eclipse.scout.rt.ui.swing.AbstractSwingEnvironment.getIcon(AbstractSwingEnvironment.java:166)
at org.eclipse.minicrm.ui.swing.SwingEnvironment.createIconUIResource(SwingEnvironment.java:26)
at org.eclipse.minicrm.ui.swing.SwingEnvironment.interceptUIDefaults(SwingEnvironment.java:21)
Re: Splash Screen Client Swing [message #990492 is a reply to message #990475] Wed, 12 December 2012 17:30 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I am not sure if the post from Andreas Hoegger is still OK for Juno.


Beat Schwarzentrub provides some other inputs on org.eclipse.scout.rt.ui.swing.splash.SplashWindow at:
http://www.eclipse.org/forums/index.php/mv/msg/263003/778302/#msg_778302

But I am not sure that It will solve your problem.


I need to check at my own code to see how I made it. I will keep you informed.


We should write a new section "Splash Screen" on this page:
http://wiki.eclipse.org/Scout/HowTo/3.8/Branding_the_Swing_Client
Re: Splash Screen Client Swing [message #990558 is a reply to message #990492] Thu, 13 December 2012 07:22 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
The method proposed by Andreas does not seem to work (I placed an image called 'Splash.png' in my ui.swing/resources/icons folder but that gets ignored.
That's the reason why I tried the method suggested by Daniel, but that causes the nullpointerexception I mentioned in my post above.

I'd already seen the other thread with Beat's post but in effect that only lays the background for Daniel's solution (unless I'm missing something crucial).

So I'm looking forward to hearing how you solved this issue.
Re: Splash Screen Client Swing [message #990757 is a reply to message #990558] Fri, 14 December 2012 06:44 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 202
Registered: November 2010
Senior Member
Hi Urs

The NullPointerException you get is because the variable m_iconLocator is not set until showGUI() is called - which is after interceptUIDefaults(). So you cannot use the getIcon() method to load your image.

But the solution is not that far. Have a look at the code of org.eclipse.scout.rt.ui.swing.inject.UIDefaultsInjector.

...
putIfUndefined(defaults, "Splash.icon", getSplashUIResource());
...


The method getSplashUIResource() actually implements the default behaviour Andreas mentioned in his post (put an image called "splash" in your plug-in). It uses different methods to find and load such an image.

I suggest that you try loading your icon with the Activator's iconLocator (which should be ready at that time): org.eclipse.scout.rt.ui.swing.Activator.getIcon(String)

Your snippet (in your SwingEnvironment) would then look like:
  public void interceptUIDefaults(UIDefaults defaults) {
    super.interceptUIDefaults(defaults);  
    defaults.put("Splash.icon", createIconUIResource("your_custom_splash"));
  }

  protected IconUIResource createIconUIResource(String resourceSimpleName) {
    Icon icon = Activator.getIcon(resourceSimpleName);
    if (icon != null) {
      return new IconUIResource(icon);
    }
    else {
      return null;
    }
  }


Note that I copied the method createIconUiResource from the class UIDefaultsInjector. Try creating your own injector class, then you can use the method directly.
Re: Splash Screen Client Swing [message #991054 is a reply to message #990757] Mon, 17 December 2012 08:45 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Beat,

Thanks for your response. I've tried this approach, however, I can't quite get it to work yet.

First of all, my swing client plugin's Activator does *not* have a getIcon() method. Its signature is
public class Activator implements BundleActivator{

and the only methods it has are start(), stop() and getDefault().

To work around this, I've tried modifying SwingEnvironment.createIconUIResource() as follows:
  private IconUIResource createIconUIResource(String resourceSimpleName) {
    Icon icon = org.eclipse.scout.rt.ui.swing.Activator.getIcon(resourceSimpleName);
    if (icon != null) {
      return new IconUIResource(icon);
    }
    else {
      return null;
    }
  }


However, when running my client, I just get a grey rectangle instead of the splash screen and a line in the console saying:
!MESSAGE org.eclipse.scout.rt.ui.swing.SwingIconLocator.warnImageNotFound(SwingIconLocator.java:141) could not find image 'Splash'


So, for some reason, my splash screen image cannot be found (despite there being a Splash.png file in *.ui.swing/resources/icons).

Do I need something else to allow the icon resolution? Or is my attempt at directly accessing the org.eclipse.scout.rt.ui.swing.Activator what is causing this problem?

I'd appreciate any hints on where I go wrong.
Re: Splash Screen Client Swing [message #991091 is a reply to message #991054] Mon, 17 December 2012 10:42 Go to previous messageGo to next message
Matthias Villiger is currently offline Matthias VilligerFriend
Messages: 232
Registered: September 2011
Senior Member
Hi Urs,

In general you have two possibilities:

1. OSGi convention:
In the config.ini file of your client swing products you will find a property called 'osgi.splashPath' pointing to your swing bundle. Scout will then try to find an image called 'splash.(png|jpg|bmp)' in the root of this plugin. Using this convention you must store the splash image on the swing plugin root and you have to name it according to this convention.

2. Manual locating:
If you don't want to follow that convention you can add the following code to your SwingEnvironment class:
public class SwingEnvironment extends DefaultSwingEnvironment {

  private SwingIconLocator m_splashIconLocator;

  @Override
  public void interceptUIDefaults(UIDefaults defaults) {
    super.interceptUIDefaults(defaults);

    /* 'your_custom_splash' is the name of your image (e.g. your_custom_splash.png) */
    defaults.put("Splash.icon", createIconUIResource("your_custom_splash"));
  }

  private SwingIconLocator getIconLocator() {
    if (m_splashIconLocator == null) {
      /* this is the activator of your swing bundle containing your splash image */
      Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);

      BundleIconLocator iconLocator = new BundleIconLocator(bundle);

      /* this is the folder inside the bundle given above specifying where to search for the images */
      iconLocator.getIconLocatorService().setFolderName("resources/splash");

      m_splashIconLocator = new SwingIconLocator(iconLocator);
    }
    return m_splashIconLocator;
  }

  protected IconUIResource createIconUIResource(String resourceSimpleName) {
    Icon icon = getIconLocator().getIcon(resourceSimpleName);
    if (icon != null) {
      return new IconUIResource(icon);
    }
    else {
      return null;
    }
  }
}
This way you can modify the plugin, folder path and the image file name.

Depending on where you place your image, you may also need to add the resource to the build.properties file to ensure the splash image will be exported to the jar.

Did this work for you?

kind regards
matthias
Re: Splash Screen Client Swing [message #991120 is a reply to message #991091] Mon, 17 December 2012 12:17 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Hi Matthias

Thank your for your help. Trying option 1 didn't work. I tried to things:

1.a
I modified the osgi.splashPath in the config.ini file to point to the directory where my Splash.png file resides:
osgi.splashPath=platform\:/base/plugins/org.eclipse.minicrm.ui.swing/resources/icons


1.b
As that didn't work, I reverted this change, so the splash path is defined as:
osgi.splashPath=platform\:/base/plugins/org.eclipse.minicrm.ui.swing

I then copied the Splash.png file to
D:\workspaces\scout-tutorial\org.eclipse.minicrm.ui.swing
Unfortunately, that didn't work either.

However, using approach 2 worked, so I'm happy enough to have a working solution. Still, I'm wondering why approach 1 doesn't work...

I'll try to see if I can modify the SWT splash screen next Smile

While we're discussing the splash screen: Is there any way to modify the positioning of the version string that is being shown?
Re: Splash Screen Client Swing [message #991141 is a reply to message #991120] Mon, 17 December 2012 13:33 Go to previous messageGo to next message
Matthias Villiger is currently offline Matthias VilligerFriend
Messages: 232
Registered: September 2011
Senior Member
Hi Urs,

Yes, 1.a cannot work. As explained, by convention the splash.png is only searched in the root of this plugin. So subfolders are not possible with option 1 (see getSplashUIResource() in org.eclipse.scout.rt.ui.swing.inject.UIDefaultsInjector).

But 1.b should work. Please note that some platforms are case-sensitive. So it may help if you rename the file to 'splash.png' (lower case)?

Yes, there is. The following code (also pasted to interceptUIDefaults() in your SwingEnvironment) changes the position and also the text color:
defaults.put("Splash.versionLocation", new Point(100, 100));
defaults.put("Splash.text", new ColorUIResource(0x000000));

Please refer to the class org.eclipse.scout.rt.ui.swing.inject.UIDefaultsInjector for more constants.

Kind regards,
m
Re: Splash Screen Client Swing [message #991160 is a reply to message #991141] Mon, 17 December 2012 15:18 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Matthias

Thanks for clarifying. I had misunderstood you and thought that with the default value for splashPath it would look in the root, but that changing the value in the ini file would allow other locations. As to why 1b didn't work, I'll have another look, though I am pretty sure that I had consistently used the form "Splash" (with capital S) both in code and naming the file. I'll retry with a lower case s to check if this makes a difference.

Thanks for the pointer to "Splash.versionLocation" and UIDefaultsInjector for more variables.
Previous Topic:ScoutInfoForm
Next Topic:Jax Webservice LogHandler
Goto Forum:
  


Current Time: Thu Mar 28 16:55:28 GMT 2024

Powered by FUDForum. Page generated in 0.04703 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top