I'm writing an SWT/JFace application and was wondering if it is possible to use the Progress Monitor Window from Eclipse in my standalone application. For clarification: I'm speaking of this:
and not the ProgressMonitorDialog.
If this is not easily achievable, what would be an easy way to implement this for my own?
You can try using this:
Dialog.getBlockedHandler().showBlocked(IProgressMonitor, IStatus, String)
I have used it in the past to show that a job of mine needs to wait for another job to complete.
I think this dialog is org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog
Although you won't be able to use it directly, you could download the source from Eclipse.org or via the Source link on this page:
http://javasourcecode.org/html/open-source/eclipse/eclipse-3.5.2/org/eclipse/ui/internal/progress/ProgressMonitorJobsDialog.html
Related
I have headless (CLI) RCP app, normally handling command line options, but i'd occasionally need to show parts of the a gui anyway.
Is there a way to open a view part standalone(detached is fine) when PlatformUI/Workbench is not running?
WorkbenchPage.showView(the one I'd normally use to open the view) normally throws "workbench is not running" exception, which is expected of course in headless mode.
Is there some reasonable hack to do this? I tried running the RCP workbench with the event loop - the problem is that it's blocking execution and it seems too heavyweight.
I know I can create new Shell embedding the widget of the view, for it but then I'd miss the toolbars/menus that come with the proper view.
All the UI code is completely dependent on the workbench running. The workbench must be started with PlatformUI.createandRunWorkbench. So it is not possible to show a UI without doing this.
The simple SWT only Shell seems the easiest way.
Exclude the concept of RCP, and work with SWT/JFace components only.
Build some factory methods that simulate PlatformUI.createandRunWorkbench. Instead, they will create Shells and run the event loops themselves.
To me, this seems like a bit of an overkill if the app is going to be large. It it's not THAT enterprise-ish, then I guess you could do without the workbench framework. Be careful for dangling resources, though.
How can we create a separate thread to perform an operation until it is stopped (using say, a button) in Eclipse? I read that you need to use asyncExec() function (because I need the UI to be updated simultaneously). But for some reason, the Display class is not recognized in my IDE.
You should read this tutorial: Eclipse Jobs and Background Processing. The website also has a lot of good tutorials for other eclipse-related topics.
How to make your desktop Java app looks like Open Office or Eclipse etc ?
Installation process looks like any Windpws app. installation. There is no Java logo on the to on a app window. You run it by .exe file. How it is done? Is this jar->exe conversion?
Is there any free tool to do that?
For the native look, you can obviously go the SWT way, like Eclipse does, however it's a painful one. You could/should prefer the Swing look'n'feel, by using, as an example, the Substance Look'n'Feel.
For the installation part, you can use
InstallAnywhere
IzPack
For the exe wrapper, you can use
Launch4J
JSmooth
or others ...
However, I think that, by doing so, you're doing it wrong.
indeed, instead of the classical download/install step, which is cumbersome, you can go the Java Web Start way : user only has to click one webpage link to install application to its machine (with an update mechanism directly integrated in), an install that go as far as potentially including desktop and start menu shortcuts, and an element in the Windows install panel to remove installed software.
I tried Jar2Exe, and JSmooth, they both produce exe files from jar archives.
The question is a little unclear, but I think that what you're after is making your java app behave like a native app (stuff like running it when an icon is double-clicked, etc...). There is an excellent tutorial on this here.
Note that, for the graphic part, Eclipse uses a library called SWT, which is a set of widgets that feel and behave in a different way that Java Swing or AWT.
Anyway, if you go the normal Java (Swing) way, the Java logo on the top of an app window is setIconImage() method in JFrame components.
Riduidel already told you about .exe wrappers and installers you can use. For the installer, I also suggest you to consider Java Web Start instead of a normal Windows installer.
I think it uses LookAndFeel, I let you read: http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e){}
EDIT: I didn't read the entire question ^^' Maybe it will be useful to someone...
How do you turn on and off a monitor from within a Java application?
In case you're wondering why, this is a kiosk style application where it would be great to turn off the monitors at night. Yes you can do it within the screensaver settings of the machine, but it would be great to do it programatically and avoid having to configure it on each machine.
Assuming you deploy your Java Applications on Windows, you can use this WIN32API functions:
// turn off monitor
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);
// turn on monitor
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) -1);
Then you write a little C-JNI wrapper to functions that call the mentioned SendMessage and use the little wrapper to turn off the monitor from Java.
While you can query the monitor configurations with Java, there is no way to turn the monitors on and off programatically without using JNI.
I have seen this exe named nircmd on the net. It is a freeware and can be used on by anyone.It has a built in function for doing this.
nircmd.exe monitor off
A detailed help is also found in the website.
Just use it in your program and call it using
Runtime.getRuntime().exec(this.getClass().getResource("nircmd.exe").getPath());
or put it to the windows directory and run it from there.
You can open a full screen swing window, make it completely black, so the monitor, as far as observable behavior is concerned, is turned off.
I need some genius advice on this one.
I have a Java Swing application that needs to launch a word processor in order to allow the user to complete some work, and then retrieve the output of that work and evaluate it later.
In my head I am thinking my application can look in the normal places for Open Office or Word executables to see if one of those programs is installed, and then create a process and block the Swing window until that process returns. Is this really the best way to go? Also, how can I pass data back and forth?
I looked into the Open office java bean already, but alas I do not think there is Mac/Linux support.
So, to sum up my question:
is creating a process for the word processor the best way to do this?
how can I pass info between my app and the word processor (more specifically, when they have finished creating their document, how can the Swing app get it)
Thanks,
Ben
Use the open office sdk, which is available for Linux. You might want to use open office in server mode.
You could integrate docx4all (Swing based docx word processor) into your app.