File Explorer - Altering File/Folder associated icon programmatically - java

Have you noticed modifications to the icons associated with files and folders when using file explorer in windows/linux while having a svn client installed (e.g., TortoiseSVN). Basically, when a folder is saved in a SVN repository, normally there is a tiny green tick icon added to the associated file icon. I want to know how TortoiseSVN/Dropbox/... do this and whether I can achieve similar results using Java6 JDIC ?
Thanks,
-A

Those are called "icon overlays" in Shell jargon. Here's a start:
http://msdn.microsoft.com/en-us/library/cc144123(v=VS.85).aspx
-scott

This should help you out..
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/jdic_assoc/
org.jdesktop.jdic.filetypes.Association
The Association class allows
programmers to create new file types
or edit existing ones. The class
includes methods to edit the file
extension type, the MIME extension
type, the icon that goes with the file
type, and the actions that are
associated with the file type.associated with the file type.

Related

Opening filetype using java and a specific .jar

I work in computational chemistry, so I need to view a lot of files (.cell, .geom, .castep, etc.) using JMol, a .jar molecular viewer. Is there any way I can set these filetypes to open in JMol by default in Windows 10, so that I can simply double click them like I can with other molecule viewers? Obviously setting them to open with Java or the .jar file individually doesn't work, and I can't figure out how to open the files with both.
You can set-up new filetype handlers within Windows Explorer for each filetype you specified, BUT only if you can work out the command that launches JMol to example file of each type as:
C:\absolutepathto\jmol.bat file
You will need to fix your PATH to reference javahome\bin directory and set JMOL_HOME. Alternatively you can edit your version of jmol.bat or make your own a copy of jmol.bat which calls the original with the settings of JMOL_HOME / PATH, or add:
set JMOL_HOME=\pathto\jmol
set JAVA_HOME=\pathto\javahome
rem Replace java ... with:
%JAVA_HOME%\bin\java ...
Then to register these scripts, right mouse on example of each file type and choose -> Properties to see the dialog, click Open with... "Change" and browse to pick your own version C:\absolutepathto\jmol.bat.
Hopefully then at next double-click from Explorer your script is launched. If it doesn't run add this as last line of the jmol.bat:
pause

Is it possible to load an external file/class in a programmatic into the eclipse editor that is located outside the work space?

I'm attempting to load an external class into the Eclipse editor that is not located inside of the local workspace. I should clarify that I am attempting to do this in an Eclipse plugin I am creating.
How this needs to work for me:
I have a double-click event on a view that I have created.
On that double-click, I am getting a database field from SQL that returns an absolute path. (e.g. C:\objects\sourceCode\class.java)
Once the absolute path has been received from the database, I need to open the file inside of an instance of the Eclipse editor.
NOTE: I did attempt to read all the lines of the class I am attempting to open and create a temporary file inside of the Eclipse workspace directory and open that. However, I cannot seem to get this working.
Therefore my question is:
Does anyone know if this is even possible? If it is, can you point me to an article about doing something similar to this or provide the location of an example that may help me in my endeavours?
First note that not all Eclipse editors support external files (the class file editor for example).
If the editor does support external files it does so by supporting IURIEditorInput as the editor input.
FileStoreEditorInput is the standard implementation of IURIEditorInput, use it like this:
File file = .... the file to open
IFileStore fileStore = EFS.getStore(file.getURI());
IEditorInput editorInput = new FileStoreEditorInput(fileStore);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.openEditor(editorInput, "id of editor to open");
As an alternative to the editor input and page.openEditor you can use the IDE.openInternalEditorOnFileStore method which will try and work out the id of the editor to open:
IDE.openInternalEditorOnFileStore(page, fileStore);
IDE is org.eclipse.ui.ide.IDE in the org.eclipse.ui.ide plug-in. EFS is org.eclipse.core.filesystem.EFS in the org.eclipse.core.filesystem plug-in.

how to make program i made by java know certain file types?

How to make program i made by java know certain file types and make windows open that certain extension by it ?
How i can put a picture to put it for that extension when it's the default program ?
As example when i setup a FOX-IT reader it terns all PDFs files into FOX-IT reader & the FOX-IT picture putted on the PDFs files also ?
if there is a class that access a certain file in windows ?
You're talking about changing Windows settings, rather than anything to do with your program itself.
This is a question about Windows, not about Java.
Normally, you would hold shift while right-clicking on the file, select "Open With" and then pick the program that you want to use to open the file type.
However, since you are talking about a Java program, you probably don't have an executable to run.
In this case, you will need to create the association in the registry yourself.
As always when dealing with the registry, don't change things there unless you know what you are doing, as you can break your system.
Under HKEY_CLASSES_ROOT, create a new key for your file type. I'll use the ".abc" extension for this example, so first create a new key with the name ".abc".
Set the (Default) value of your key to "abcfile"
Now, create another key (again under HKEY_CLASSES_ROOT) named "abcfile". The (Default) value here is the name you will see in the Type column.
Add the following tree of keys underneath abcfile:
abcfile
| shell
+-| open
--+--| command
In the (Default) value of "command", put in the command that you wish to run when opening the file. Use quotes for paths with spaces, and "%1" in place of the filename.
For example:
"C:\Program Files\Java\jre7\bin\java.exe" -jar "C:\path\to\jar\MyJar.jar" "%1"
To change the icon, you will need to make another key under "abcfile" named "DefaultIcon".
Set the (Default) value of this key to the path to your icon file.
To open an application associated with the file extension you'll need to use the java.awt.Desktop class. Oracle has a tutorial with sample code.
Getting the icon for an application is more difficult. Your best course of action is to include standard icons as resources in your application; that should cover most scenarios.

How to find the path of the uploaded files on Weebly?

I'm trying to make my own website using Weebly. I want to include a Java Applet I made and therefore I must use an HTML snippet on the website. In the snippet I have to include the path of my uploaded Applet in order for it to run. How can I get this path, because I do not know where the files end up after uploading them. I saw in one post that each user gets a very specific path with each upload but how did they find this out? Is there a way?
not sure if you still need an answer to this....the path for uploaded files into your weebly site (via the Design Tab, then "edit HTML/CSS" menu is "/files/theme/yourfilename.js"
Weebly by default gives it's subdomain sites the ability to control content so when you upload anything to weebly via Code Editor (Weebly main -> Design -> Edit Html/CSS -> Add New Files)
the default address is
yoursubdomain.weebly.com/files/theme/filename.extension
For example if my file name is social-grey and is png extension and my subdomain is geniusknight ( http://geniusknight.weebly.com ) then the link would be:
geniusknight.weebly.com/files/theme/social-grey.png
Similarly for Javascript extension with name test would be
http://geniusknight.weebly.com/files/theme/test.js
and make sure in the source use the complete url and not the short ones like test.js because that doesn't work in subdomain sites for weebly.
Go to Design > Edit HTML/CSS > Assets folder.
Go to the image or file you'd like to reference and grab the URL.
e.g. http://www.weebly.com/editor/uploads/3/4/0/9/34091/custom_themes/647127941726820885/files/homelogos/codehs.jpg
To use a relative path instead of an absolute path, remove everything before /uploads...
e.g. /uploads/3/4/0/9/34091/custom_themes/647127941726820885/files/homelogos/codehs.jpg
Hope that helps!
Go to Weebly then design and edit html.
Left click a pre existing .png image, then in that same window right click over the image that pops up and go to open image in new tab.
In the new tab you will see the address in the address bar. It will look something like this...
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/yilogo.rar?1407684265479
You can drop the ?1407684265479 bit to have a direct url for your file!!!!
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/yilogo.rar
Then replace that file name in this case yilogo.rar with the file you have just uploaded or wish to use from your existing collection. E.g.
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/flags.exe

Changing "Favorites" Tooltip in Java Help

In my helpset file, I'm declaring a favorites view, using
<view>
<name>Lesezeichen</name>
<label>Lesezeichen</label>
<type>javax.help.FavoritesView</type>
<data></data>
</view>
This automatically adds an appropriate button to the toolbar (in the swing application). Unfortunately, the tooltip of the button reads "Add to favorites". I would like to replace this by my own text, but didn't find anything about this in the documentation or using a google search. Any ideas or pointers?
Disclaimer: I already posted this question to JavaRanch, didn't get an answer yet, though.
If you extract the src.jar (rename it to src.zip and extract) and open the java class jh2.0/src/src/javax/help/resources/Constants.java you will notice that in the section
// Tooltips for Actions
is located entry for localization:
{ "tooltip.FavoritesAction", "Add to Favorites"},
This constant is missing from the jh2.0/src/src/javax/help/resources/Constants_de.java which is used in your case. Just add the right translation, compile the source or just this class and add it to the jh.jar (you may treat the jar as a simple zip archive)
Yes, I know this is dirty hack, but generally JavaHelp is quite useful
Now this sounds weird.
The ResourceBundle mechanism supports to "override" the class resource content by using a .properties file with the resource bundle.
Try placing the looked up resource bundle as a properties file in the respective folder denoted by the bundle name.
E.g. if HelpUtilities looks after javax.help.resources.Constants by calling
ResourceBundle.getBundle("javax.help.resources.Constants", locale);
you'd be placing your file in a folder structure at /javax/help/resources/Constants_de_DE.properties. This must be located in your applications "working directory".

Categories