ListGrid / ListGridField - Hover message while editing - gwt

Is there a way to show a hover message on an editable cell/ListGridField while in Edit mode?
Was able to have a hover message over a cell in non-edit mode by :
cusipField.setShowHover(true);
cusipField.setHoverCustomizer(getCusipHoverCustomizer());
Thank you

You should be able to manipulate the properties of the editor that is created when you enter edit mode for a field through an appropriate FormItem and the ListGridField.setEditorProperties(FormItem editorProperties) method. For example, if your field is storing texts, you shall create a TextItem and define the hover text using its setPrompt(java.lang.String prompt) method. Then use that TextItem to set the editor properties for the field.

Related

Jface Text with predefined input and suggestion for user

Problem Statement:
I as a user needs text box that selects from one of the existing options that is pulled from database and also give suggestions as the user is typing in the text box.
Possible Solution:
I know one possible solution is combo box but I do not user to have a large dropdown every time he wants to input in a text box and at same time I need user not to add new value. Also I want user to have suggestions for user from possible input values.
You can use AutoCompleteField to add automatic completion suggestions to various types of control such as Text.
For example:
String [] proposals = .... array of completion proposals
Text text = new Text(parent, SWT.BORDER);
new AutoCompleteField(text, new TextContentAdapter(), proposals);
As the user types in the text field matching proposals will be shown in a drop down. They can select the one they want or just continue to type.
Use ComboContentAdapter instead of TextContentAdapter to make this work with a Combo control.
You can also use ContentProposalAdapter if you need more control of the proposal behaviour, AutoCompleteField just provides a simpler interface to this.

Get notified when cursor position changed in Eclipse TextEditor

I am developing a plugin to eclipse and I want to add some actions to the context menu. But actually I wanted to prepare results beforehead according to the text selection in the editor and just show them when the menu item will be selected.
I followed that article http://www.eclipse.org/articles/Article-WorkbenchSelections/article.html - all interfaces (ISelectionListener, ISelectionChangedListener etc) allow to handle the SelectionChanged event, but editor counts changing only when length of selection also changes - so the simple click in the editor doesn't fire the event, although I want to get the word (for example) as a selection if cursor is inside the word now and lenght is 0.
So the question is - what is the simpliest solution for traking down cursor position/offset/selections with zero lengh value changing?
In that case you have to use KeyListener and MouseListener as well. For e.g take a look at org.eclipse.jface.text.PaintManager, and it listens to all these events.
If you are extending TextEditor you can override handleCursorPositionChanged() method to fire your event and use getCursorPosition() to get the cursor position as a String.

How can I create a read-only SWT text that is impossible to select? (by keybord and mouse)

How can I create a read-only SWT text that is impossible to select? (by keyboard and mouse)
for example:
Text text = new Text(shell, SWT.BORDER | SWT.READ_ONLY);
text.append("text text text text text text text text text text text text text ");
text.setSelection(10, 60); // If only I could write here something that could turn the text impossible to select, just like if it were a label.
Use a Label instead. Or use Text's setEnabled and setEditable methods.
In case Enablad property using you can`t copy text from it.
I advise to make tihs. You can create yor own widjet that contain two text box. We may name it OurTextBox. The First created as usaly, second as readonly (with SWT.READONLY flag). You may use StackLayout for layout. Then you should define some properties and methods.
Main of this:
SetText(); getText();
SetReadonly();
When SetReadonly is invoked you can show one of two internal TextBox.
Unfortunately, this is the only solution to dynamically ReadOnly

Default value/Item for SWT Combo

A would like to add default text when the drop-down menu is loaded on my view. How can I do this in SWT and JFace?
I'm guessing what you want to do is to show something in the combo when it has been added to the view (it's blank by default until something is selected or typed).
If you want to set a default text displayed until a selection has been made / until the field has been edited, e.g. - Select option -, then you can use:
Combo.setText(String string)
Note, this is not possible if the Combo is SWT.READ_ONLY
If you want to set one of the values in the drop-down as default use the select method:
Combo.select(int index)

How do you change the mouse over highlighting?

In GWT, I am using CellTable.
When you mouse over the CellTable it highlights each row.
How do change the behavior of the highlighting from the mouse over? Specifically:
change the color of highlighting
disable/enable
make it highlight only the specific grid item at your cursor (instead of the entire row)
( The current hack I have is to create a bunch of 1 column wide CellTables and add them to a VerticalPanel layout... creating the illusion that there is one CellTable and it highlights each grid according to your cursor. Is this bad? Why? performance? )
You will notice the CellTable uses a ResourceBundle, which means all the css styles get obfuscated ... this makes it more difficult to override styles.
The CellTable constructor will actually allow you to override the default ResourceBundle. So first, you need to create your own resource bundle like this:
public interface CellTableResources extends Resources {
public CellTableResources INSTANCE =
GWT.create(CellTableResources.class);
/**
* The styles used in this widget.
*/
#Source("CellTable.css")
CellTable.Style cellTableStyle();
}
Then you need to create your own CSS file. I recommend copying the CellTable style directly into your project and use that as a starting point. You can find it here:
http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/cellview/client/CellTable.css
Make sure the style is injected first, and then you just feed it into the CellTable's constructor like this:
CellTableResources.INSTANCE.cellTableStyle().ensureInjected();
myCellTable = new CellTable<T>(Integer.MAX_VALUE,CellTableResources.INSTANCE);
Specifically, you'll want to tweak these styles:
cellTableKeyboardSelectedRow
cellTableKeyboardSelectedRowCell
cellTableSelectedRow
cellTableSelectedRowCell
cellTableKeyboardSelectedCell
It is important to note that the cell table differentiates between the 'selected row' and the 'keyboard selected row'. The selected row is the actual row selected (ie via SelectionModel). The keyboard selected row refers to what is highlighted when the user is pressing the up / down key, but does not mean the row is actually selected (if that makes sense).
I'll just add for number 2) on your list, you can simply do
cellList.setSkipRowHoverStyleUpdate(true)
That completely disables highlighting. There are also two more setSkip-functions on CellList related to hovering.
CellTable can be styled via CSS: How do I style a gwt 2.1 CellTables headers?
To disable highlighting just set the hover CSS property to nothing.
Possibly - try tweaking the .cellTableSelectedRow and .cellTableSelectedRowCell.
Here is the original CellTable.css: http://www.google.com/codesearch/p?hl=en#A1edwVHBClQ/user/src/com/google/gwt/user/cellview/client/CellTable.css&q=cellTableLastColumn&d=8