How the feature "different/associated file views" is implemented - Eclipse - java

I am curious in knowing how a file could have different views or be associated to different files in eclipse.
What I basically mean is how eclipse is providing associated files/views as tabs at the bottom of a file while in editing mode. (I am attaching an image for understanding purposes)
What's the place to look into in case that I want to implement something like this for my files.

Related

Getting System Icon Without Path [duplicate]

I list some filenames with their icons (like the ones in the Windows Explorer) in a JTable. I know the two ways to get the icon if I have a File object from the local file system:
javax.swing.filechooser.FileSystemView.getFileSystemView().getSystemIcon( file )
for a 16x16 icon or for a bigger one:
sun.awt.shell.ShellFolder.getShellFolder( file ).getIcon( true ) )
Since my files are stored in a database, I don't have the File object. My workaround is to create a temp file with the specific filename extension, use one of the two methods above and cache the icon to display it in a CellRenderer.
I searched for a solution without temporary files and found two I don't like either:
org.eclipse.swt.program.Program.findProgram(String extension).getImageData(), but I don't want to use SWT
org.jdesktop.jdic.icons.IconService from the Incubator of the JDIC project. The last changes on the IconService are 6 years ago, on JDIC 2 years ago and I can't find a downloadable jar.
Is there another solution?
Looks like you already discovered the way to do it, unless you want to dive into native libraries etc.
FileSystemView uses Win32ShellFolder internally so they are basically the same.
I also dug up the Source for org.eclipse.swt.program.Program and with it org.eclipse.swt.internal.win32.OS. The OS class then uses a native call for the Icon. At this point unless you really really cannot create a Temp File i would not go down that path.
For JDIC i only found http://kickjava.com/src/org/jdesktop/jdic/tray/internal/impl/WinTrayIconService.java.htm with a little bit of digging(may not be related but does icony things :D). Also calls native.
Do you really need the temporary file to use the first option? A File does not have to denote a file that actually exists...

Copy File vs Copy File Information

I am creating my own custom IDE for my programming language, and I came upon a problem. In any IDE, you always want to be able to import images, other projects, and other files. Therefore, I would definitely love to have that in my IDE. I am using JavaFX for my GUI. I have already created a FileChooser, and a user can successfully choose a File they want to import into my IDE.
Here's My Question
When a user selects a File, should I use the File.copy() method to copy the File over to the IDE, or should I copy all the bytes from the File onto a resources file in my IDE? Copying the File directly would lead me to have a Resources folder attached to the Project, but I do not know if that would be the most optimal way of importing Files into my IDE. Is there a preferred way of importing and saving Files in Java? What would be the best way for me to do it in this case?
Thanks in advance!
Ideally user should have have both options and IDEs tend to support both ways.
Practically, don't get stack on this. Implement either one, and move one with other tasks to have a working prototype earlier.
It is more important to check if your language has design flaws before you devote too much time decorating gui.

How to get the icon for a file extension or filetype without creating a temp file?

I list some filenames with their icons (like the ones in the Windows Explorer) in a JTable. I know the two ways to get the icon if I have a File object from the local file system:
javax.swing.filechooser.FileSystemView.getFileSystemView().getSystemIcon( file )
for a 16x16 icon or for a bigger one:
sun.awt.shell.ShellFolder.getShellFolder( file ).getIcon( true ) )
Since my files are stored in a database, I don't have the File object. My workaround is to create a temp file with the specific filename extension, use one of the two methods above and cache the icon to display it in a CellRenderer.
I searched for a solution without temporary files and found two I don't like either:
org.eclipse.swt.program.Program.findProgram(String extension).getImageData(), but I don't want to use SWT
org.jdesktop.jdic.icons.IconService from the Incubator of the JDIC project. The last changes on the IconService are 6 years ago, on JDIC 2 years ago and I can't find a downloadable jar.
Is there another solution?
Looks like you already discovered the way to do it, unless you want to dive into native libraries etc.
FileSystemView uses Win32ShellFolder internally so they are basically the same.
I also dug up the Source for org.eclipse.swt.program.Program and with it org.eclipse.swt.internal.win32.OS. The OS class then uses a native call for the Icon. At this point unless you really really cannot create a Temp File i would not go down that path.
For JDIC i only found http://kickjava.com/src/org/jdesktop/jdic/tray/internal/impl/WinTrayIconService.java.htm with a little bit of digging(may not be related but does icony things :D). Also calls native.
Do you really need the temporary file to use the first option? A File does not have to denote a file that actually exists...

How to write an editor that shows the content of a folder in eclipse?

Motivation
I have written an eclipse plugin that shows me a list of all files and folders with unreviewed content. When selecting a folder, I want an editor to open showing all files and subfolders that this folder contains. It has to work for versioned items, too. So I have to create the content of the editor within my plugin (no backing IResource).
What I currently have
Right now I'm opening a RemoteFileEditorInput for a versioned file (subclipse) or I'm using IWorkbenchPage.openEditor() for a FileEditorInput.
Question
What's an easy way to visualize dynamic content (directory listing) inside of an text editor?
EDIT 2010-04-13:
More Context
I want to be able to create some code review comments on a directory listing. For this I want to be able to open a diff viewer to see which elements were removed or added between two revisions of the directory.
I'd like to enter a comment for a directory the same way I do for a text file. That's why I try to display the directory content as a text file - I've already implemented the mechanisms for commenting a text file.
I call the content of the directory editor "dynamic", because it's not really backed by an existing directory in the filesystem. For older versions of a directory I will create the editor content within my program code.
I'm afraid I don't totally understand your question (and I lack the rep to comment on it).
Is this right?: You want to be able to open one of three editors in support of your goal:
An editor for unversioned files (you say you have this)
An editor for versioned files (you say you have this)
An editor for directories (this is what you need?)
What does the user do here? What does it look like?
I'm confused by "What's an easy way to visualize dynamic content (directory listing) inside of an text editor?"
Knowing that I probably completely miss your point, I would note that your editor can contain whatever controls you want it to (cf. some of the "forms" editors in PDE, like for editing a plug-in manifest) - you'd probably extend EditorPart, maybe create a ManagedForm in your createPartControl(), create a ListViewer, TableViewer, or TreeViewer in there, give it an appropriate content provider, and give it an appropriate label provider.
I'm also confused by "What's an easy way to visualize dynamic content (directory listing) inside of an text editor?"
I can only assume that you want to somehow poll or listen to some events and tell your viewer to update() or refresh().
Finally I would question whether the directory listing really belongs in an editor . . . most navigation happens in views. Will the user actually be performing edits to the directory somehow, and possibly "saving" them at some later time?
I hope this helps us all narrow down into whatever will help you.

Convert Java GUI Builder .form files to Source Code?

I have created a fairly substantial Java GUI application with many form windows where the settings are locked up in .form files. I am wondering is there any way to convert or refactor these .form files into real Java source code that I can modify?
The GUI was created using Netbeans 6.5.
My understanding is that the ".form" files are only used by the Netbeans GUI builder to keep track of where the GUI components are. When you add components in the design view, Netbeans automatically updates the actual source (.java) files. You can actually modify these .java files directly to, say, change the label on a button, but if you do it within Netbeans, it will use the .form files to automatically regenerate the source files, destroying your manual changes.
In my experience, once you make the decision to modify the .java files manually, the .form files become out of sync and you will no longer be able to use the Netbeans GUI builder properly.
kazanaki is right, the java files that are generated can be modified but the resulting .java files are notoriously messy, large and hard to interpret. Also, you cannot change some things (as noted in the comments in the generated .java file) without rendering matisse useless because it expects the file to have things in a certain way. That being said, if you are careful not to step on Matisse's toes you can code away and it will not touch your code which is nice.
Outlaw is right too, if you change anything that is already in Matisse's perview it will be overwritten. Any changes that you make outside of matisse must be outside of any element that is covered by the xml that matisse uses to generate the code.
I have tried this kind of thing before with limited success and eventually just rewrote the interface to avoid these maddening headaches.
I can edit the source, I discovered the solution. THe problem was that I was using the "AbsoluteLayout" in the GUI builder. Netbeans was creating some hidden AbsoluteLayout class that was inside the .form files. IF I deleted the .form files the project would no longer build. The solution was to change the form to be of "FreeForm" layout and then I could delete the .form files and remove the GUI builder comments.
Thank you for the help guys, I give you both +1.

Categories