How do I close the splash screen in an eclipse RCP application? - eclipse

In an eclipse RCP application, a splash.bmp is used as the splash screen. It closes after about 5-6 minutes of the application being run. I want it to close as soon as some UI displays. I tried using Platform.endSplash() and also applicationRunning() of the application context just before PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()).
It fails to close the splash screen.
Any suggestions would be helpful. It would also be okay if I could close the splash screen after about 10 -15 seconds.
public Object start(IApplicationContext arg0) throws Exception {
Display display = PlatformUI.createDisplay();
int returnCode = 0;
try {
//arg0.applicationRunning();
Platform.endSplash();
returnCode = PlatformUI.createAndRunWorkbench(display,
new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return PlatformUI.RETURN_RESTART;
}
return PlatformUI.RETURN_OK;
} finally {
//some other code here.
display.dispose();
}
}

I would expect the splash screen to close when everything is initialized, not after a set amount of seconds. Otherwise you don't even need one.
According to this thread, you should make sure to call the Platform.endSplash() method in the right context, meaning the method start(IApplicationContext context)
If you already do this, please provide some code to help us understand your problem

The closing of a splash screen is handled by the created StartupMonitor in Workbench.
After the workbench part is created (as you say, "as soon as some UI displays"), it will be cycling through all registered startup services. The fact that you have your workbench visible and have to wait ~5-6 minutes (or seconds) for your splash screen to close means you have another startup monitor preventing your desired UI transition.

Related

When $ionicView.enter is really triggered

Having this function in a controller:
$scope.$on('$ionicView.enter', function() {
seemed to be good. Everytime I open the app in the real device, this functions is actually triggered. But then, after a while I realized that this is not always true.
If I open my app, and then close it. And then some time goes, maybe a few minutes. And I open the app again. Well, then the app doesnt start from scratch. It goes back to latest screen/controller I was. And, worst of all, the $ionicView.enter is NOT fired.
If the app is closed and I open again after a while (maybe 5 minutes) then it starts from beginning (showing splash etc).
So, is there a way to solve this issue? How to make the app react going into $ionicView.enter each time it is opened again? Even if picked up from background?
You could use resume event when the app picked up from background, like below:
document.addEventListener("resume", onResume, false);
function onResume() {
setTimeout(function() {
// TODO: do your thing
}, 0);
}

Splash screen & login dialog box doesn't stick together

I am working on Eclipse RCP application in which I load the splash screen first and then login which asks for credentials and then my main application. But here what problem occurs is "Splash screen & login dialog box don't stick together" like Eclipse's "Splash screen and workspace launcher" when we open Eclipse. Why do I need such mechanism because if I use "Alt"+"Tab" then any of windows get hidden behind current thread so sometime it's very hard to find where is my login box or splash screen.
To behave like the Eclipse splash screen and workspace launcher you need to use the standard Eclipse splash screen mechanism and write your own IApplication.
In the IApplication start method do something like:
#Override
public Object start(IApplicationContext appContext) throws Exception {
Display display = PlatformUI.createDisplay();
try {
// look and see if there's a splash shell we can parent off of
Shell shell = WorkbenchPlugin.getSplashShell(display);
if (shell != null) {
shell.setText("Login window title");
shell.setImages(Window.getDefaultImages());
}
new LoginDialog(shell); // Use splash shell as the parent shell
// TODO call PlatformUI.createAndRunWorkbench in the usual way
}
finally {
if (display != null) {
display.dispose();
}
}

Eclipse RAP multi-window/tab

I would like to have a multi-tab/windowed Eclipse RAP application.
I am able to open a second window using
UrlLauncher launcher = RWT.getClient().getService(UrlLauncher.class);
launcher.openURL("/gasf?foo=other_perspective");
Where I use the foo paramter to select the perspetive I want. However using this method will create a speparate http session, thus the various listeners and so on won't communicate with my first window.
I also tried opening a second window/page using
PlatformUI.getWorkbench().getActiveWorkbenchWindow().openPage("other_perspective" , null);
But this merely changes the current window perspective but does not open a second window or tab in my browser.
Has anyone achieved a multi-tab RAP application with working selectionlisteners between the tabs?
Thanks for any help you can provide
EDIT:
THANKS a lot ralfstx, as you pointed out, I can share the listeners or anything using the shared HTTP session, so far so good. Now the next step is to be able to update a tab based on an external event.
To try my idea of refresh from another tab, I did a dummy timer that does something 2 seconds later (i.e. simulate something triggered from another tab) with:
final ServerPushSession pushSession = new ServerPushSession();
pushSession.start();
Display display = Display.getDefault();
NavigationView navigationView = ((NavigationView) window.getActivePage().findView(NavigationView.ID));
timer.schedule(new TimerTask() {
#Override
public void run() {
display.asyncExec(new Runnable() {
public void run() {
navigationView.doSomething();
}
});
}
}, 2000);
This works! The pushSession.start() forces the UI to refresh without any user interaction. So now the action doSomething() is executed on the navigationView as soon as the 2 seconds are reached.
My only remaining concern is how much load this puts on the server, but its a reasonable solution at least. I validated your answer.
EDIT2:
Just to be complete, to make sure not bump in an invalid Thread access error since we are updating a display from another display, in the doSomething() method we must execute actions using display.asyncExec:
Display display = Display.getCurrent();
public void doSomething() {
display.asyncExec(new Runnable() {
public void run() {
treeViewer.refresh();
}
});
}
With the current architecture of RAP, you can't spread workbench windows over different browser tabs. Every new browser starts a new UISession which implies another Display (see Scopes in RAP).
However, the HttpSession should be the same (unless you have cookies turned off), so you could use this as a means of communicating between different browser tabs.

WebView not reflecting changes on server until clearing data

I found an interesting bug that I can not replicate, but think someone here could provide some insight.
I have an activity that for now is partially native, partially web-based. By that I mean one element is simply a WebView until implementation on a native level can be achieved.
When I made a change in the page I am loading, I saw an immediate change using Chrome Developer Tools in a mobile interface. However, I was unable to immediately see the change in my WebView in my MainApp. As a test, I installed a new app that loaded the page in a WebView where I saw the changes. After clearing the data in my MainApp, I was able to see said changes.
I made a few more changes, but now these are being reflected immediately in my WebView (upon backing out of the activity and re-entering).
These are my WebView settings, can you see a reason for me not initially seeing these changes? I'm not very savvy (yet :) ) when dealing with how data is stored in a WebView and want to ensure that updates I make to my webpage are reflected immediately in the app. Thank you!
// Initialize WebView
if (Build.VERSION.SDK_INT >= 19)
mWebView.setWebContentsDebuggingEnabled(false);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient() {
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
// Hide ProgressBar
mProgressBar.setVisibility(View.GONE);
}
});
final ActionBarActivity activity = this;
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
mProgressBar.setProgress(progress);
}
});
// Settings for WebView data
WebSettings ws = mWebView.getSettings();
ws.setSaveFormData(false);
ws.setSavePassword(false); // Not needed for API level 18 or greater (deprecated)
You probably need to disable the cache for your webview. When your data changes you need to reload the webview using mWebView.reload()
In case if you want to reload the the webview every time when you reopen.
use this setting for webview
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
This will not load the cache and the requirement will get fulfilled.

Compact-Framework: Minimise and restore isn't working

I've written an application with the following in the Program.cs:
rsCursor.Wait();
// Load the settings
rsAppConfig.LoadConfig("iVirtualDocket.exe.config");
fSplash splash = new fSplash(IvdConfig.VERSION);
splash.Initialise();
DialogResult result = splash.ShowDialog();
rsCursor.Go();
if (result == DialogResult.Yes)
{
IvdInstances.Main.Initialise();
Application.Run(IvdInstances.Main);
}
I use full screen on all my forms, so there is no X button, however I thought using Form.Close() performed the same function?
I want to be able to minimise my application from my main menu (Main) and then have it instantly appear again when the user re-runs the application. At the moment, my application executes the loading screen every time I re-run the application.
What am I doing wrong?
Thanks in advance.
EDIT: I need to be able to detect when my application is running and then restore the main menu when it is so that it's not constantly loading itself into memory.
Form.Close closes the Form. There is no Minimize - use Hide and Show.
[System.Runtime.InteropServices.DllImport("coredll.dll")]
static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
ShowWindow(this.Handle, SW_MINIMIZED);
This did the trick, this.Hide() didn't work as it didn't maximise the window again when I re-ran the app.