| Table Viewer Editing and Selection questions [message #525351] |
Tue, 06 April 2010 06:18  |
|
1. I have a table viewer with 1 column. The table lists only strings. Above the table are some buttons to control the contents of the table: 'add string', 'copy string', 'rename string' and 'delete string'.
a) When the 'add string' button is pressed a new entry should be added to the table with a predefined string (e.g.: PredefinedString) and the string should be editable with a distinct border around it.
How can I achieve this? I know that I should set the editing support for the table column but I do not know how to make the editing active only when the button is pressed and how to display the border around the text.
b) When the 'rename string' button is pressed the selected entry from the table becomes editable with a border around it.
It as almost the same as the above with the difference that the editing is done on a existing entry.
2. I have a table with three columns: the first column is a check box, the second displays a image and the third displays a string.
By default the check box is not 'checked' and no image is displayed in the second column. When the check box becomes 'checked' then the second column displays a image. When the user clicks on the image from the second column the image is changed to another one. (the second column displays only to images: ascending order and descending order ... i know that a workaround here is to use a check box but i do not want to do this).
Further more when the row is selected in the table (regardless of the 'checked' state of the check box) the selection is visible in the first and the third column.
a) How can I make the second column to become 'active' when the check box becomes 'checked'?
b) How can I make the second column change the displayed images?
c) How can I achieve the selection effect only for the first and the third column?
Sorry if I probably ask dumb and obviously questions but probably I am missing some basic things about the Jface viewers. I will provide more information if needed.
I will appreciate any help about this.
Time is what you make of it.
|
|
|
|
| Re: Table Viewer Editing and Selection questions [message #526273 is a reply to message #525355] |
Fri, 09 April 2010 08:36   |
|
Hello Tom
Thank you for your hints.
1. a) With a little help from Lars Vogel's article http://www.vogella.de/articles/EclipseJFaceTable/article.htm l I successfully managed to edit the edit newly added entry in my table viewer.
And indeed viewer.editElement(object,0) was the missing line from my code.
Now I have two additional problems:
First: All my table entries are editable when I click in the table. I need to make them editable only when I click on the 'rename string' button or when the user clicks again in the selected table entry. Any clues how to achieve this?
Second: The border effect I needed around the edited text is not present. Instead I have the cell selection effect. Any clues were to achieve this?
The effect is the red border from http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet244.java?view=co (there are two words with red border around them). But again this border effect should be present only when the table entry is edited.
For the first half one I think that the code bellow solves the problem:
TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(
tableViewer, new FocusCellOwnerDrawHighlighter(tableViewer));
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(
tableViewer) {
protected boolean isEditorActivationEvent(
ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};
TableViewerEditor.create(tableViewer, focusCellManager, actSupport,
ColumnViewerEditor.DEFAULT);
Is the above code correct? If yes what needs to be added in order to edit the table entry when the user clicks again on the current selected entry?
But for the border effect I think I have to create a new class that extends FocusCellHighlighter but I have no clue how get the border effect in it only when the table entry is edited.
2. a) Yes. Active means respond to clicks. Only when the check box from the first column becomes 'checked' then the cell from the second column should respond to clicks. Do I need to add a listener on the cell from the second column? If yes, what type of listener?
I hope that you understood now what I am trying to achieve. If not let me know and I will try to make it more clear.
Time is what you make of it.
|
|
|
|
| Re: Table Viewer Editing and Selection questions [message #713249 is a reply to message #526273] |
Mon, 08 August 2011 05:09  |
malek.mahersi Messages: 2 Registered: August 2011 |
Junior Member |
|
|
Good Question:
First: All my table entries are editable when I click in the table. I need to make them editable only when I click on the 'rename string' button or when the user clicks again in the selected table entry. Any clues how to achieve this?
Second: The border effect I needed around the edited text is not present. Instead I have the cell selection effect. Any clues were to achieve this?
Did you manage to solve it?
Please Let me know if you did because I have the same problem
Thanks a lot
|
|
|
Powered by
FUDForum. Page generated in 0.01857 seconds