This is about wrapping text in a table item, I know table item doesn't support WRAP. But I am looking at possibility of embedding a StyledText inside the tableitem. Is it possible?
You can't do it like that, but there is a facility called owner draw that allows you to paint tree and table items however you like.
http://www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html
Related
Does anyone know how to disable a single row of a JFace TableViwer? I have a TableViwer constructed as follows:
TableViwer tv = new TableViwer(composite, SWT.NONE| SWT.FULL_SELECTION | SWT.BORDER);
tv can have many rows, but I am adding a particular unique row to the table dynamically(when an external button is clicked) and I need to make only that row disabled (grayed out and not selectable. Not selectable can also be achieved through existing handler, if there is no other option).
I searched in google but did not get much information. I am new to SWT/JFace, so any help would be appreciated.
You would have to do something in the selection listener to reject selection of the row.
To make the row gray you can make your Label Provider implement IColorProvider which lets you define the two methods:
public Color getForeground(Object element);
public Color getBackground(Object element);
which can color the row.
You could also use a label provider derived from StyledCellLabelProvider which lets you define more complex coloring.
I am adding a SWT Table in Eclipse Form, but I want to remove the outer border of the Table.
How to do the needful.
Above is the Table I created, But I dont want the Boundary/Border around it.
Don't know if this is the case, but from the picture the outer border looks like the one painted when SWT.Border flag is used. Maybe you are adding your table to composite that has this flag used as style constant. Remove this constant and the outer border will be gone
This border is rendered even if you don't use SWT.BORDER.
But if there is no TableColumn, no border is rendered.
Just remove TableColumn, if you want to remove border.
Try to look for SWT.BORDER and replace it with something else, like SWT.NONE
It could be where you create the table or the container.
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
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
I have a well populated Object which has properties like color,size,weight etc.
I need to get these object properties and place them in a TextBox.
So i want to do something like
`textBox.getLine1.setText(Object.getColor());
textBox.getLine2.setText(Object.getWeight());`
That is i need a textBox in which i can edit individual lines.
I am planning to have a widget which has a FlexTable inside the TextBox but i am not sure how to work on it.
Can someone please help me on this?
Thanks
Probably you're looking for the RichTextArea widget
You can check the documentation here: RichTextArea
And an old, but nice tutorial here: Tutorial
I did something similar: I needed to let user select one or several text rows and let each row be clickable to perform an action.
So I used a VerticalPanel with Labels.
VerticalPanel labelPanel = new VerticalPanel();
For a given index Label:
Label selectedLabel = (Label) labelPanel.getWidget(index);
DOM.setElementAttribute(selectedLabel.getElement(), "id", "label-selected");
CSS code as you wish!
If you must use a TextArea, which is a standard <input type="text"> element, you would have to find line breaks and create a Selection, and then replace it with whatever you want. You could also read the entire text, change it, and then update the entire TextArea value again.
I would recommend splitting your widget into multiple single line TextBoxes.