Dynamic language switching in an Eclipse RCP application - java

I am working on an Eclipse RCP application with localization. A user should be able to change the language used in the application on the fly. A restart of the application should not take place during this language switch. It should also be possible to switch between languages written from left to right and languages written from right to left.
Is there a (good) way to solve this problem?

According to this thread:
Most of the eclipse libraries load up their language info on widget creation. If you change your locale afterwards you need to restart eclipse to have it take effect.
You could write that kind of dynamic behaviour into your own SWT program, however (when the locale switches, you'd need to call setText(*) on everything :-)
So this is not currently managed dynamically unless you program it yourself...
Other rcp/plugins application like Birt specify the same instructions (i.e. "Restart Eclipse" at the end...)
That said, a slightly different problem was set in this thread:
switch the language setting, restart, and then run in that language
I got it to work by reading bug 222023 and mimicking org.eclipse.ui.internal.ide.actions.OpenWorkspaceAction
I tried it manually:
added "-configuration #user.home/.myapp/configuration" to the launcher.ini
added "osgi.nl" to the users config.ini residing there and it worked.
Since I can access the config-Location via Platform.getConfigurationLocation() I guess that could be the way.
Note: adding "osgi.nl" to the webstart jnlp works too.

You would need to call setText on each widget, with the respective text. Since there is no text variable mapping on the widgets, you would have to do that completely manually as well.

Related

Changing the default icon in Netbeans' native deployment feature for Java apps

I know the question is very long, but in a nutshell it's just that. As you know Netbeans has a feature with the help of inno setup that allows the creation of .exe installers of Java applications. The problem is that I would like to change the default icon it has (a grey java icon) for a custom one.
I have searched a lot through both Stack and Google and I haven't found anything. The closest it got is to change it via Launch4j. The thing is if it is possible to do it within Netbeans.
Furthermore, I was wondering if there is a possibility to add several languages to the installer and some other features like the creation of a desktop icon. I guess if the option exists it would be in the same place as the change-icon... but I am completely lost regarding this issue.

Can be done with JavaFX alone

I have app that uses jintellitype.jar and DLL with Java environment. This is because I need sometimes full not showing of app.
Can be done in JavaFX just using Java and not DLL?
If I understand correctly, the question is about having the application changed to full screen mode using keyboard shortcuts (and not using JIntellitype.dll).
It seems possible in JavaFX using the approach I found here. The example considers to have a MenuBar and its items, e.g. the MenuItem for FullScreenMode. Haven't tried it, but it seems not be dependent on the presence of an equivalent for JIntellitype.dll or anything else.

Refreshing Swing application with Eclipse/MyEclipse

Say that we are writing a Java Swing application and we use Eclipse or MyEclipse to develop it. In web applications, you make code changes, you save and your ant deployment file takes care of the deployment of the changed files. Then you just refresh or hard refresh the web page and the changes appear there. Can we do the same thing for a Swing applications so that we don't have to close and open the program from the beginning every time we make a change?
I don't think so because you need hot code replacement ! Maybee using another framework.
You can't simply do that because once JVM is started, it loads the class files once and will not reload it untill next loading request. But you can use ClassLoader to load modified class files dynamically.
The following two articles may help:
IBM article on "hot class swap"
"Who Said Runtime Class Reloading Is Hard in Java?"
The first one is in Chinese, but you can look at the code and the result. I think the second article is more helpful for a GUI application.
In MyEclipse you can start your application in debug mode instead of run mode and changes you make will be pushed to the target VM; if changes you make cannot be replaced you'll see a dialog informing you the replace failed and you will need to restart your application. You don't need to place any breakpoints in the application, just starting in debug mode is sufficient.
As Guillaume states above, changes to the class structure will typically not be hot-synched, but changes within existing methods should be fine.
Obviously, how successfully hot-synched changes affect your running application would depend on your application design.

How to programmatically load a desired plugin on eclipse start up

Is there any method in SWT to programmatically set my plugin as default whenever the eclipse IDE starts i.e. when the eclipse starts a desired plugin is set as perspective.
If I remember correctly, it should be possible with setDefaultPerspective(String id).
You can access this via:
PlatformUI.getWorkbench().getPerspectiveRegistry().setDefaultPerspective(id);
However, be careful when doing this. I can imagine that a lot of people might uninstall your plugin, just because they are annoyed by this small change.

Being in Debug View, and after program termination, switch back to Java View in Eclipse

I am looking for a way to come back to the standard Java View in Eclipse after the application I'm debugging is over.
Is it possible to accomplish that? That is the default behaviour in some other IDEs (Visual Studio, for instance) and I'd prefer to have it that way. It's so boring to have to go an manually switch the view again to the initial one :(
Thanks
Eclipse is a generic platform where you can have a dozen type of different launch configurations, so a good and usable 'generic' implementation of this feature is not trivial.
However, there is an open bug report for this feature, which has some activity recently so there is a chance that this feature will be included after Eclipse 3.7.
I wrote a plugin that does what you want. Here's the update site:
http://backtojava.s3-website-us-east-1.amazonaws.com/
I didn't categorize the feature, so when you look for it, unselect the "Group items by category" checkbox.
And here's the project on Eclipse Labs I made to host the source:
https://hg.codespot.com/a/eclipselabs.org/backtojava
I haven't checked the Feature project in; just the plugin.
I personally have never seen such a feature. I also wouldn't consider such a feature desirable. Rare would be the occasion where I would be in debug mode for only a single run. Typically, the editing window provided in the debug mode is sufficient for any edits I would make during a debugging session.
Do you have to use Eclipse? There are other Java IDEs, for example in Intellij IDEA you can set the debug window 'unpinned', so it hides when you click on the editor. Personally I would find that behaviour annoying but it might work for you.

Categories