Does anyone know if its possible to do NLS to some SWT Widgets in SWT\RCP application?
remark:
With JFace components its possible if you create own equinox fragment to plugin org.eclipse.jface, (contains messages.properties), so let me say if I want to make Slovak NLS to JFace components I create messages_sk.properties in my fragment.
Does anyone knows if this could be done also to SWT which is part of plugin org.eclipse.ui ?
I am developing application which uses SWT FileDialog, which has default english buttons etc.
I want to make them other language without making my own dialog, but changing NLS..
I don't think that you have a chance to internationalize the text of the buttons of org.eclipse.swt.widgets.FileDialog.
SWT is using the system file dialog here. For me with a german win32 system the text is in german. This indicates that the button texts are also system dependent.
PS:
SWT is not part of the plugin org.eclipse.ui. FileDialog is part of the plugin org.eclipse.swt.<ws>.<os>.<arch>_<version>.jar
where:
ws - window system: gtk, win32, etc.
os - operating system: win32, linux, solaris etc.
arch - architecture: x86, x86_64
version - version id (something like 3.100.1.v4234e)
Most of the parts in org.eclipse.swt can be localized. I don't know about an option to localize FileDialog and similar "widgets", because the library calls directly some Win32 API (or similar API on other OSes) to create it. Therefore this part is highly OS dependent and wouldn't be portable if you change it somehow.
If you want to localize other parts of org.eclipse.swt, it's relatively simple. Just create a fragment (e.g. org.eclipse.swt.nls), where host would be org.eclipse.swt. Create a package org.eclipse.swt.internal.
Than copy a file SWTMessages.properties from org.eclipse.swt.<ws>.<os>.<arch>_<version>.jar/org/eclipse/swt/internal to the new package and rename it to _SWTMessages.properties.
Then you can create localized SWTMessages_<lang>.properties files (where <lang> is the language abbreviation: e.g. sk, de, fr).
Related
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.
Is there a Linux equivalent to the Apple application extensions for Java (com.apple.eawt), as well as bundling a standalone application (defining an app bundle with Info.plist on OS X). Specifically I would like to be able to:
provide an application icon for the desktop/dock
specify JVM parameters, such as -Xmx
define custom document types with icons and roles (viewer, editor)
be able to listen to file-open events for these documents, if the user double-clicks them on the desktop
I think the closest thing to what you are looking for is the Desktop Entry. See these two questions for more info:
Register file extensions / mime types in Linux
Embedding an icon in a Linux executable
provide an application icon for the desktop/dock
Another option here is to simply set the application icon in code: myFrame.setIconImage(). This will show my application icon in the Ubuntu dock.
specify JVM parameters, such as -Xmx
Another simple option: create a shell script that starts your Java program and sets all the necessary parameters.
First of all, this is not a duplicate of the very common question of making an EXE from Java classes. I do not need to do that.
To solve NetBeans RFE #64612 without manual steps I need a Java (6+) library which can take an existing Windows *.exe file and replace its icon with a substitute in a common format. The executable, which is generic and prebuilt (distributed in binary form), already knows how to load an application-specific config file and then start the JRE with various application JARs etc.; the only problem is that it has a generic icon, and I would like to replace that icon as part of a pure Java build with an application-specific icon, so it looks prettier.
The library must be available under a nonviral open-source license; cross-platform (must run on Windows, Linux, Mac, Solaris) so cannot fork some OS-specific helper tool; and must accept PNG input, though the EXE must work on XP so according to Wikipedia should embed BMP format. At a high level, supposing Ant as a build tool, I would like something like this:
<replaceicon from="app.exe" to="hello.exe" icon="hello.png"/>
Does anyone know if a tool matching these specifications already exists? From various web searches I found Launch4J, but this appears to just fork windres for the real work, thus not trivially portable. I found JSmooth which looks more promising - appears to include Java code to handle the ICO codec and manipulate PE files - but it is GPL. WinRun4J looks to use native code for icon manipulation, though I had a hard time following its sources. Jimi supposedly handles the ICO format (for that matter the standard javax.imageio seems to as well) but I guess has no facility for updating PE resources.
According to my Eclipse Rich Client Platform product builder,
Linux requires an XPM icon
MacOSX requires an ICNS file
Solaris requires 4 PM icons, Large, Medium, Small, and Tiny
Windows (32 bit) requires 6 separate BMP images, or an ICO file.
Your distribution package is going to have to contain all of these files to be platform independent.
I've not worked with the other platforms, but on Windows, you can change the program icon by right clicking on the existing icon and left clicking on Properties. Left click on the Shortcut tab, and left click on the Change Icon button. Browse over to the distribution directory, and select the ICO file.
I'm sure it's possible to automate the Windows icon change when you deliver the distribution package. I imagine it's possible on the other platforms.
There's the PE/COFF 4J project which seems to be able to do what you want. It is licensed under the Common Public License (CPL).
Some notes on that:
The author seems to be the same as for WinRunJ. This project actually has a PE resource editor in it, called RCEDIT.exe, but it uses native windows calls as you point out yourself. Why the author didn't use his own project (PE/COFF 4J) to accomplish this beats me. It gives me some concern that perhaps the PE/COFF 4J project is abandoned.
The documentation page for PE/COFF 4J only mentions that the project is able to parse a PE file but as file as I can tell you can parse, then change something (e.g. an icon resource) and then write the image back to disk.
Like you I've also been searching for a pure Java solution that could manipulate resources in an .EXE (PE file) and have come up empty handed. This is the best bet so far.
Replacing an icon resource in an .EXE file is rather simple when using the native Win32 calls. When doing it from pure Java you have to make bloody sure that the PE file is consistent when you write it back to disk. I haven't scrutinized the PE file format in depth but I suppose that many references will change when replacing/adding a resource, not just the one related to the resource you're replacing/adding.
This is very long overdue, but we just released an open-source Maven plugin that can do this since we had the same problem.
Disclaimer: I am the author of this project
The documentation for this is available at:
https://zephyr.sunshower.io/site/
Hope this helps for folks who stumble across this as I did.
It looks like the eclipse project has written a small java application to replace the icons.
IconExe from the eclipse project
The app.exe and app64.exe in Netbeans seem to have the follow icons in the resource section:
48 x 48 32bit
32 x 31 32bit
48 x 48 8bit
31 x 31 8bit
16 x 16 8bit
I'm guessing the 32 x 31 is a mistake
You simply have to replace the first ICO or BMP in the executables resource section. That one is automatically picked by explorer as the icon to display.
I read that via
System.setProperty("apple.awt.fileDialogForDirectories", "true");
users can select directories via a FileDialog, now the FileDialog evoces the native file chooser, so that is exactly what i want but in the line above it reads: apple.awt..., does this mean this option will only work on Mac OSX?
if(no) {
great
} else {
what can i do to implement this on other operating systems than?
}
Thanks for any help!
PS: I know a lot of people suggest the use of a JFileChooser, but in this case i'd very much prefer the FileDialog, except if that's impossible
It is exactly as you feared.
AWT used native libs underneath. OSX has the feature to look for directories only, windows does not.
So youre only change is to use a dialog not based on AWT, i.e. Swing or SWT.
You can define an interface with platform specifc implementations. This gives a good looking dialog on OSX and something that works on other platforms. That's what I do.
To my knowledge, FileDialog does not support (in-code) using a directory dialog on all platforms.
You're already mentioned Swing's JFileChooser, but you may want to consider SWT for your widgets instead.
SWT is Eclipse (originally IBM)'s project to create an updated Java GUI Toolkit that still uses native widgets when they are available.
The major downside of SWT is that it is not part of the standard Java distribution... and each platform has its own SWT jar file.
Incidentally, SWT has a DirectoryDialog widget.
I am displaying a list of files; i.e. xls, doc, pdf, odt etc., in my Java application (Eclipse RCP). When the user clicks on the file, I want to launch the appropriate (according to what the OS thinks) native application, just like it happens in Windows Explorer or the Finder.
And while I am here: It would be nice to also display the same icons that Finder or Explorer use for the different file types.
Is there a library or Eclipse plugin for this?
What you want is java.awt.Desktop:
Desktop.getDesktop().open( file );
I have found an API in Eclipse's SWT now that seems to do the trick:
org.eclipse.swt.program.Program "provides access to facilities for discovering operating system specific aspects of external program launching."
It has methods to find the program for a given file extension, get the program's icon, and even launch the program.
Sounds like you're after the Java Activation Framework ("JAF"). This API lets you determine what files are and what actions you can do on them. Or alternatively the Java Desktop Integration Component ("JDIC"). JDIC allows you to create and no doubt query file associations.
Both projects seem to be in a semi-abandoned state howeer (sigh). But that's par for the course for Sun these days. Only other thing I know of is some Windows specific third party library that's based on JNI called Winpack. It does a bunch of other things too.
You can get the associated icon using the FileSystemView class (Java 1.4+).