ColumnViewerTooltipSupport in SWT - java

What is the exact use of ColumnViewerTooltipSupport? I know that it provides tooltip support for ColumnViewers but does it mean that it provides tooltip for treeViewers? How can I use this feature to provide tooltip support individually different tooltips for my each tree item when the mouse hovers over each item? Do I require a MouseListener for this or does the ColumnViewerTooltipSupport class provide it by default? Can someone please help me out here as I'm relatively new to SWT concepts.
My tooltip has multiple lines, How can I wrap the text and display it neatly? It seems like ColumnViewerToolTipSupport class does not wrap the tooltip text if the text is too long. I would like to use a tooltip window with a vertical scroll bar just like the InformationControl Windows in eclipse? If something like eclipse is not possible then just a tooltip window with wrapped up text.
Please show me an example snippet?

ColumnViewerToolTipSupport adds support for individual tooltips to TableViewer and TreeViewer (and other ColumnViewers), you enable this using:
ColumnViewerToolTipSupport.enableFor(viewer);
The support expects that the label provider(s) for the viewer are based on CellLabelProvider (or one of its subclasses).
CellLabelProvider has getToolTipImage, getToolTipText, getToolTipBackgroundColor, getToolTipForegroundColor, getToolTipFont and getToolTipShift methods that you can override to control the tooltips.
Note: All this is JFace code not pure SWT

Related

How to enable/disable SWT Text WRAP in runtime

I have a SWT button (with SWT.CHECK flag) and SWT Text.
Upon pressed, SWT button should enable/disable the wrapping of the SWT text.
I am aware that text wrapping capability is specified in the constructor as follow:
new Text(parent, SWT.WRAP)
But I couldn't find a method such as setWrap(false) to programmatically enable/disable it in runtime.
Is there a way to do this in SWT?
Or the only solution is to dispose the old text, and create a new one with different flag?
In general SWT styles can't be changed and this is the case for the Wrap style of the Text control.
The StyledText control does have a setWordWrap(boolean) method, you should be able to use that.

Vertical document points-of-interest highlighter component of an IDE. What's it called?

Both Eclipse an Netbeans provide a vertical points of interest highlighter next to document scroll bars, which appears to be a part of an extended JScrollPane or is simply a standalone custom component.
I've marked it on the picture below (Netbeans and Eclipse version, in that order).
It highlights lots of different things and represents a flat view of the entire document.
What is this area/component called in general?
I've been looking around on pointers on how to implement such a thing in swing or abuse an existing implementation to my liking but I don't even know what to search for. Both implementations of this thing appear to be quite similar, so I'm hoping they are based on the same piece of code.
It's an extend JScrollPane which has implemted some kind of column footer.
The default JScrollPane provides row and column headers by default, check out How to use scroll panes for more details
Try taking a look at JideScrollPane from jidesoft
Eclipse just calls these vertical rulers (they are implemented with SWT in Eclipse).

Is it possible to prevent dragging the shell in SWT for Mac OS when using Shell.getToolBar()?

It is possible to place any type of custom control into the shell's trim area in SWT using Shell.getToolBar() introduced in SWT 3.7. One needs to create a ToolItem with SWT.SEPARATOR style and assign it a custom control. My "custom control" is the entire tool bar area including some Composite based custom widgets.
See this bug comment for what I have done roughly:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=222859#c124
The problem is that the user may drag the shell by clicking into an "empty" area of the unified tool bar. And it appears my custom control is regarded as "empty space". One of my controls supports drag&drop. However, when it's placed in the unified tool bar area, dragging drags the shell, not the widget contents that are supposed to be draggable. Actually, both happens at the same time. So all I would need is to somehow stop the event from being processed any further. Attaching a Listener for SWT.MouseDown to my custom control and setting event.doit to false doesn't work.

Send accelerator with mouse to perform selection of text

I need to make selection of text using mouse instead of ctrl+A
I tried:
sendAcceleratorKey(MouseEvent.BUTTON1, "");
but I don't know which argument could I set to say make a click with mouse and let the mouse enforced to select the text.
If the text is in a JTextComponent, selectAll() may be a suitable choice in your MouseListener.
Addendum: You may also be able to leverage the select-all Action, which is bound to control-A or meta-A by default on various platforms.
Your sscce may be helpful in deciding. There's a related example here.

TextBox inside eclipse's draw2d figure

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.

Categories

Resources