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);
Related
As I'm modifying an existing Look and Feel, I also want to change how the "buttons" of a PopUpMenu behave. Right now it behaves like this, when I hover my mouse over it. As you can see it behaves very "3D":
And I want to let it behave like the buttons I made below them:
I've looked trough alot of documentation of Java Swing but I can't seem to find it. So if someone knows, please help me out. I have tried to change every property I could find.
The correct answer here is, as I found out, not everything can be managed by the LaF. Therefore, sometimes you have to get your hands dirty.
In this case I created my own CSTMButton, because in Swing one is also able to add buttons to a menubar. Now I can create it's own listener to generate the behaviour I want.
Please do not confuse this with 'selecting code' like selecting code with a mouse.
When my debug device hits a break point I want to highlight the specific line of code.
I am using the CDT Plugin.
I already got the lineNumber and all I want to do now is to tell
editor.highlightLine(lineNumber);
to get something like this:
I already tried this:
marker = resource.createMarker(IMarker.TEXT);
marker.setAttribute(IMarker.LINE_NUMBER, 10);
marker.setAttribute(IMarker.CHAR_START, 0);
marker.setAttribute(IMarker.CHAR_END, 10);
but it didn't work.
Since there are already predefined annotations provided by Eclipse and/or the CDT Plugin I'd like to reuse them. But how to access and use them inside sourcecode?
You can create your own marker using an extension point "org.eclipse.core.resources.markers" and adding super attribute of type "org.eclipse.core.resources.textmarker". After setting up your marker, you still need to describe its look and feel by adding the annotation extension point "org.eclipse.ui.editors.annotationTypes"
I am not exactly sure of your intentions but this link might help http://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-plugin-guide/section3.html
Marker is the thing on your ruler. You need to look at the editor background painting. Take a look at InstructionPointerManager.java
I had the same problem. And I solve it by creating my own marker. I follow the step of this blog http://cubussapiens.hu/2011/05/custom-markers-and-annotations-the-bright-side-of-eclipse/ and create a marker when the lineNumber changed. It will highlight this line.
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.
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.
Is there any way to include a Text Box inside a draw2d figure? (a code example would be nice)
Not easily, and if you're just using Draw2d without GEF, then I don't think it's possible.
With GEF, you can make use of a DirectEditManager in an Edit Part, and create an Edit Policy (extending DirectEditPolicy, installed with the key EditPolicy.DIRECT_EDIT_ROLE) to allow a direct edit to be performed on a figure.
You could create a figure which extends Label that is styled to look like a text box, and activate (by overriding performRequest in the Edit Part) editing upon selection.
This Schema Diagram example contains this type of functionality (and more importantly, the code!), although the figure used for edit (EditableLabel) isn't styled to look like a text box, and the activation itself is on double-click rather than selection.
It may point you in the right direction though.