I am trying to create a panel which opens to the left of the rest of my GUI. I am working in Eclipse. I added swingx-core-1.6.2.jar to my build path. I can import org.jdesktop.swingx.JXCollapsiblePane and then make a new JXCollapsiblePane, but in order to set the orientation of the pane, I need to do something like:
JXCollapsiblePane myCollapsingPane = new JXCollapsiblePane();
mycollapsingPane.setOrientation(JXCollapsiblePane.Orientation.HORIZONTAL);
However, this fails saying that Orientation cannot be resolved. So, I tried importing
org.jdesktop.swingx.JXCollapsiblePane.Orientation, which also fails saying that it cannot be resolved.
I'm probably missing something silly here; how do I set the panel to open to the side rather than vertically?
JXCollapsiblePanel at 1.6.2 has no setOrientation method. Also, there is JXCollapsiblePane.Orientation enum any more. It was probably dropped.
However, there is JXCollapsiblePane.Direction and there JXCollapsiblePanel.setDirection(), it is probably a replacement.
Here is a thread about this.
Related
Simplifying, I have this structure
Form {
tab=Container(BoxLayout.y());
other stuff
}
The Form is not scrollable (and it is not supposed to be), tab is.
At some point I want to redraw the Form to keep it up to date with some new info added, and I do that creating a new one and showing it.
But I want to scroll down the Container tab to its predecessor's Y-coordinate.
I can easily save the Y coordinate in a static variable using
scrolledToY=tab.getScrollY();
But I can't find a way to set it back when I create the new form.
setScrollY seems to be protected, and indeed if I try to run the program using it, I get an error
error: setScrollY(int) has protected access in Component
tab.setScrollY(scrolledToY);
What is the correct function to use, instead?
Thanks.
You can use scrollRectToVisible().
FYI you can just modify the container and call revalidate to update the UI. This will prevent a nasty refresh problem you might experience. Also check out InfiniteContainer which might be what you're really looking for.
I need to show something very similiar to source code, but it shouldn't be possible to modify it (but i still need funcionality as paint annotation etc.). The use case is more like - you click on some line and something will happen, some annotation will be shown etc.).
So i decided to try to use eclipse application platform, because its jface.text looks very good.
I am trying to use SourceViewer for my purposes. It could be configured to not be editable, but it is still drawing the caret if you click into it.
QUESTION: How to disable painting of the caret?
EDIT: If you know something better than SourceViewer, which could fit to what i need, tell me please.
SourceViewer sv = new SourceViewer(parent, new CompositeRuler(), 0);
sv.setEditable(false);
sv.configure(new SourceViewerConfiguration());
sv.addVerticalRulerColumn(new LineNumberRulerColumn());
sv.setDocument(new Document(""));
Looks like you should be able to set the caret to null with:
sv.getTextWidget().setCaret(null);
I have successfully created a new view, passing in the primary ID from my plugin.xml and a unique secondary ID. All is well. It pops up as one would want.
However ... it pops up in completely the wrong folder.
I want it to go along side the other one's that are of the same type. It is the main folder center panel I want it created in. Now I can manually move it (as a user) and put it where I want it.
Feel so close to this.
What am I missing?
I am not clear by "wrong folder"?
Two things here.
First, if it's showing up in the wrong place in the workbench, then you need to use org.eclipse.ui.perspectiveExtensions extension to place it in the right place in the perspective.
Second, if it's not grouping with set of views, then you need to add "category" in the view extension to show up in the right category in "Show View".
Hope these two points will help you out. Please let me know if I completely missed your point.
Create a perspective extension and use the "relative" attribute of the view definition there.
I found the solution. When laying out the folders in the perspectiveExtensions extended class, I need to tell it where additional views will end up. You do this by calling the IFolderLayout.addPlaceholder() passing in the necessary wildcards where necessary.
bodyleft.addPlaceholder( "MyViewId:*" );
This works a charm.
i am having trouble with custom quick-fixes, which i want to provide in my Eclipse plug-in, and i'm hoping for someone more experienced than me in Eclipse PDE to have some hints for me on this issue.
As i have understood, i can provide custom so-called "quick fixes" (or "resolutions", in Eclipse inside terminology), by extending the extension point org.eclipse.ui.ide.markerResolution for a specific marker id, such as for example some default Eclipse marker, org.eclipse.core.resources.problemmarker.
This works for me for the default marker types and for custom marker types, BUT:
The QuickFixes, which my IMarkerResolutionGenerator provides, are only accessible from the "Problems"-View, not from the Editor, in which my markers show up.
What i have: I create markers in the default text editor, which causes (1) an icon with the markers tooltip message to show up on the left editor ruler at the line, which the marker is assigned to, (2) a marker on the right side of the editor, (3) some underlined characters in the editor, and (4) an entry in the "Problems"-view.
What i want: Just like in Java IDE support, i want to press Strg+1, or Context-Menu->Quick Fix, or to click at the error icon on the left-side-ruler, to see the available quick-fixes and to select one.
However: Only in the Problems-View am i able to get the Quick-Fixes, by pressing Strg+1 or from the context menu.
Is this the normal behaviour, and do i have to access another extension point, or the specific editors features, to hook my quick fixes into them? I haven't found anything much detailed about it, except that everybody seems to be pretty happy with this only extension point that i have mentioned above. What am i missing?
For completion, here is my extension point definition:
<extension point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
class="com.markers.test.MarkerResolutionGenerator"
markerType="org.eclipse.core.resources.problemmarker">
</markerResolutionGenerator>
</extension>
I have the same problem and I'm not sure, if this is the right way, but at least it works:
If you want to see your quick fixes in the source viewer you have to set an QuickAssistAssistant for it. In your class implementing SourceViewerConfiguration override getQuickAssistAssistant. You can instantiate org.eclipse.jface.text.quickassist.QuickAssistAssistant, but you have to set a QuickAssistProcessor, so implement the org.eclipse.jface.text.quickassist.IQuickAssistProcessor interface, especially computeQuickAssistProposals to return your quick fix proposals.
public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
IQuickAssistAssistant quickAssist = new QuickAssistAssistant();
quickAssist.setQuickAssistProcessor(new MyQuickAssistProcessor());
quickAssist.setInformationControlCreator(getInformationControlCreator(sourceViewer));
return quickAssist;
}
Also have a look at the code in the last post here, it is a bit messy, but you will get it. And look at this code here for an example implementation of ICompletionProposal, which you will have to return in your QuickAssistProcessor.
If you simply add one line to the marker extension point:
<super type="org.eclipse.core.resources.textmarker"/>
and add attributes to the marker
marker.setAttribute(IMarker.CHAR_START, ...);
marker.setAttribute(IMarker.CHAR_END, ...);
You will be able get this:
But I still can't found how to change marker icon (to variant with bulb) a show possible quick fix also after click on the annotation icon.
I'm rethinking the design of my GUI. I designed a few JFrame with Netbeans automated GUI (yes, I'm lazy, and this generated code is often awful, I know !), but now I want them to be JPanel (actually, to inherit from another class that inherits JPanel). But I had the "setDefaultCloseOperation" modified, so my code is broken : setDefaultCloseOperation is impossible for a JPanel. Since I can't modify the generated code, I was wondering : is there a way to make Netbeans understand I changed my mind, and regenerate the code ?
When I run into this (I've done the same thing before) I usually end up having to modify the generated code XML file (.form file) or just copying all of the controls I've added and paste into a new JPanel. Just my $0.02 but beware that this can break your code...
IMHO, nb won't manage automatic refactoring in this case; it's easier to add new panel and copy-paste all elements from Your old JFrame (their methods will be copied as well).
BEFORE DOING THIS, close the file in Netbeans AND BACK UP the .java and the .form file you are about to edit.
I just had this problem, and fixed it by changing the .form file, that follows with your .java file for the given type.
In the top of this XML file you will see a:
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
Just change this to:
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
Notice that i just changed this part:
type="org.netbeans.modules.form.forminfo.JPanelFormInfo"
After you have done this, reopen the file in netbeans, it will now tell you that there is an error, this is because you might have set some properties, that aren't available for a JPanel, but was for the JFrame. Just hit Edit, and then change one value in your GUI, this will force it to rebuild the generated code, and this way it will remove the properties that aren't applicable.
It should now be fixed for you..
I hope this helped a bit!
' Cheers!
You might look in Team > Local History to see if you can revert.
Can't you just remove the setDefaultCloseOperation() and any other calls to methods that are no longer in the super class? Making this call definitely doesn't make sense now that the class is not a JFrame.
I don't now what you broke, but I can tell you this: You can not tell Netbeans to change his own generated code the way you described it.
You can try the following (be sure to make a backup before):
Open YourPanel.java in some editor
Delete the line with setDefaultCloseOperation....
Replace all getContentPane() with this
Delete pack(); at the last line.
Open YourPanel.form in some editor
Delete the node <Properties> (and everything within)
Delete the node <SyntheticProperties>.
In root node change from <Form ... type="...JPanelFormInfo"> into <Form ... type="...JFrameFormInfo">
As far as I observed, everything within the forms file can be deleted apart from the stuff within <Layout>.
Good Luck.
Yes, you can simply copy and paste it to the JPanel. Make sure that, you JPanel size must greater or equal to the existing JFrame container size. :)
I just had the same problem and it turns out the solution was fairly simple.
As others have said, make a backup of your file.
Open your JFrame class and edit it to extend JPanel rather than JFrame.
Cut your main method method and put it into another class.
Close your netbeans project and netbeans IDE
Open your .form file in a text editer that is located in the src folder and change the first line from this:
Form="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"
to this:
Form="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"
After youve saved that. Open the netbeans project again.(it will open with an error)
Modify one of the properties of the JPanel.
Run the programme. Netbeans will automatically get rid of all methods that are only associated with a JFrame. and it will run fine.
Hope that helps someone!