Netbeans GUI editor: How to create a form with JScrollPane top level component? - netbeans

The Netbeans GUI Editor offers "New -> JPanel form...", but how do I get a JScrollPane as top level component instead of the JPanel?
Of course, a JScrollPane could be put directly under a JPanel, but why using such an unnecessary level?

Yes! if you can follow these simple steps:
Let come in Tools->Templates->Swing GUI Forms
Duplicate the template "JPanel Form"
Rename the duplicate to "JScrollPane Form"
Open the duplicate in the editor
"javax.swing.JPanel" changed in "javax.swing.JScrollPane" ... save the file
Add a new Swing component to project (Wow! now on the list appear to us our new template file)
Chose this template and enjoy!

Related

Multiple decorator columns in Eclipse text editor

Is there a way to add more than one column for decorators in an Eclipse editor.
For example, a breakpoint and a search arrow on the same line dosen't play nice with each other.
You can add new columns there using the extension point, assuming you are an eclipse plugin developer.
You cannot change this as an eclipse user, however.

Jface TreeViewer nodes Link with files

I writing an eclipse plugin to analyze files for some defects, I get the list of java files, their classes and methods in a jface tree view, I need to open the file in the editor when I double click on the file node of the tree view.
please help me with this.
thanks,
Shasinda
You should either use a common navigator framework with corresponding filters that already has the link and open function built-in for Eclipse Resources, however, is much trickier to set up - see the blog post series starting with http://cvalcarcel.wordpress.com/2009/07/08/writing-an-eclipse-plug-in-part-1-what-im-going-to-do/
Alternatively, you could add a double click listener that opens an editor (or checks existing editors of the current workbenchpage) by looking the open editors. For the basic idea, see the corresponding Eclipse FAQ entry.
Use IDE.openEditor to open the editor.

Embedding a text editor within another Eclipse editor

Is it possible to embed a text editor (with syntax coloring and content assist) within my own custom Eclipse editor? I am under the impression that a text editor (with features like syntax coloring) needs to extend IEditorPart or one of its subclasses, but am I correct in thinking that an IEditorPart subclass can't be embedded because it's not part of Eclipse SWT? And if that's true, is there another way to get that functionality?
To expand on this "custom Eclipse editor": I'm referring to an editor with multiple tabs, and in one of the tabs I want to embed a text editor with syntax coloring, and possibly content assist.
Yes, using a MultiPageEditorPart, where every page is either an IEditorPart or an SWT control. Keep in mind that the text editor you're embedding has to have been written to still function correctly in that situation.
Right, you cannot embed IEditorPart, instead you could inherit your editor from a concrete IEditorPart implementor and override custom aspects thereof.
You can add your editor to MultiPageEditPArt.
final IEditorPart = new YourEditor();
int editorIndex = addPage(formJSEditor, editorInput);
setPageText(editorIndex, "Your Editor");

Exporting Eclipse Snippets

How can I export my Eclipse Snippets so that I can re-use them on another machine?
Display the snippets view: Window -> Show View -> Other ... -> General -> Snippets
Right click in snippets view -> Customize ...
Select Snippet Category
Export
If you add a new snippet a wizard opens. In that window you can export your snippets!
Depends on exactly what you mean by snippets. For Java (and other languages) you can define custom templates, as well as the default ones created by Eclipse.
In Window... Preferences, filter for templates. In the dialog on the right-hand side are buttons for import and export. Select the templates you'd like to export, and click Export...
Save them to a file.
In the other workspace, go to the same location, but do an import, and select the file you created above. This will add the saved templates to the list.
Java also has Code Templates defined (i.e. pieces of code that get put in when you create a new method, class etc). The process is similar here for import/export.

How to get from an EditPart to its Editor in Eclipse? (Eclipse plug-in development)

I am writing an eclipse plug-in that extends editor. Inside the editor I put some EditParts. From some of these edit parts I need a reference to their encapsulating editor (so that for example, when clicking an instance of MyEditPart, I want to programmatically close the editor).
Please advise on the API to get from an EditPart instance to the Editor it is in.
Thanks.
You can try:
IEditorPart editor = ((DefaultEditDomain) getViewer().getEditDomain()).getEditorPart();
from the EditPart.