JFace - How can I make only one column editable in TreeViewer based on checkbox value from another column in the same row?

jface tableviewer example
jface treeviewer
jface table viewer editor example
jface imagedescriptor
swt table
jface viewers
jface comboviewer example
jface tutorial

I have a TreeViewer which has two columns: ProximityClustersColumn: which has names as String, selectionColumn: which has checkbox as shown in the figure TreeViewer

I have two questions:

  1. On clicking the selection column's checkbox, the corresponding name of ProximityClustersColumn should become editable. For eg: When I click on the checkbox corresponding to "Studium organisieren-Formelles", the cell "Studium organisieren-Formelles" should become editable.

  2. Also, as seen in the figure, a check must be made such that only one value in the group, whose checkbox is checked becomes editable. In other words, for each group, only one category name can be checked and that corresponding name should be editable. For eg: If you look at the second group, there are two proximity Cluster names, i.e "Infos für Studis" and "Finanzielles im Studium", along with their respective checkboxes. Now, I can choose one among the two names, by selecting the corresponding checkbox. Suppose, I click on the checkbox corresponding to "Infos für Studis", only that cell should become editable.

The main idea is that : I should be able to select only one name from each group and edit it.

I have tried EditingSupport as suggested by @keyur, but the "canEdit" method is not called at all.

My LabelProvider extends ColumnLabelProvider and implements ITableLabelProvider. My ContentProvider implements ITreeContentProvider.

Is there any reason why EditingSupport will fail?

public class ProximityClustersEditingSupport extends EditingSupport{
    private TreeViewer viewer;
    private CellEditor editor;

      public ProximityClustersEditingSupport(ColumnViewer columnViewer, TreeViewer treeViewer) {
        super(columnViewer);
        this.viewer = treeViewer;
        this.editor = new TextCellEditor(treeViewer.getTree());
      }

      @Override
      protected CellEditor getCellEditor(Object element) {
        return new TextCellEditor();
      }

      @Override
      protected boolean canEdit(Object element) {
        return true;
      }

      @Override
      protected Object getValue(Object element) {
          if(element instanceof ProbeSort)
                return ((ProximityClusters)element).proximityClusterNames;
                return element;
      }

      @Override
      protected void setValue(Object element, Object value) {
          if (element instanceof ProbeSort)
            {
                 ((ProximityClusters)element).setProximityClusterNames(String.valueOf(value));
            }
            viewer.update(element, null);
      }
}

I think I need more information to answer it completely. First of all is that Treeviewer or Tableviewer. To me it looks like TableViewer.

  1. What is the expected behavior of the cell when you mean editable. Those cells which are not editable should have disable type foreground colored text and the one which is editable can have normal foreground color say black. Only when user changes to focus (if tab is supported) or by clicking on the cell it is better to show the editable text where user can select the text and change/edit it. And pressing Enter key or Tab Key program can accept the change. Is that what you are looking for?

  2. I guess I didnt get the question. Can you give example from the above figure. Like what is group?

java - JFace, java - JFace - How can I make only one column editable in TreeViewer based on checkbox value from another column in the same row? -. On clicking the selection column's checkbox, the corresponding name of ProximityClustersColumn should become editable. For eg: When I click on the checkbox corresponding to "Studium organisieren-Formelles", the cell "Studium organisieren-Formelles" should become editable.

I think EditingSupport will be useful for you.

You can create your concrete EditingSupport class and assign it to your column. It has method "canEdit" through which you can control the editing dynamically.

So what you have to do is to store the boolean flag in the model from checkbox status or read the check box status directly and return false/true value , which will enable/disable editing.

Eclipse JFace Tree - Tutorial, Optional exercise: Add multiple columns to a tree viewer. 4.1. This tutorial explains the usage of Eclipse JFace TreeViewer. Plug-in Project to create a new Eclipse 4 application without sample data called com.example.e4. filebrowser. via a TreeViewer has been done, since this exercise is based on it. In case a TreeViewer has multiple columns it does not look good, if the first column, which contains the expandable items is clipped. In order to let a column fit to it’s contents width you can invoke the columns pack method like that.

The program in the link shows all possible Tree viewer related implementations. Copy paste the program into a new java class and run as java application. This one example solved all tree related issues i had in my implementation.

Introduction to the Eclipse JFace Table API - Tutorial, This can be done based on a fixed or percentage value. Using TableColumnLayout requires a Composite which only contains the table widget. Displays a single-selection tree, a multi-selection tree, and a checkbox tree: 8. Demonstrates TableTree: 9. Demonstrates TreeEditor: 10. Tree Example: 11. Tree Example 2: 12. Demonstrates CheckboxTreeViewer: 13. Demonstrates TreeViewer: 14. SWT Tree : 15. SWT Tree Composite: 16. Print selected items in a SWT tree: 17. Insert a SWT tree item

Chapter 9. Tables and menus, SWT tables; JFace tables; Editing table data; Creating menus; options in the form of cell editors to make it easy to implement user-editable tables. These values can be set using the setText() and setImage() methods, each of which takes an The code creates three columns of equal width and fills two rows with data. To make a column non-editable: 1. Select the whole worksheet, Right Click->Format Cells->Protection, uncheck the "Locked" check box. 2. Select the column you want to protect, right Click->Format Cells->Protection, select the "Locked" check box. 3.

treeviewer, Jface TreeViewer multi line support I would like to show the same data in a SWT/Jface TreeViewer and TableViewer. IStructuredSelection: Use the same Selection in 2 different Views JFace - How can I make only one column editable in TreeViewer based on checkbox value from another column in the same row? The label provider defines what data is displayed in the column. The label provider for a table viewer column is called per row and gets the corresponding object as its input. It uses this input to determine which data is displayed in the column for this row.

EMF Parsley - Play with your UI and EMF!, EMF Parsley aims to provide a complete set of components to visualize your with the wizard "Create a new project" -> "EMF Parsley DSL Based project" By default, double-clicking on a tree viewer of a saveable view will show a dialog to edit All columns have the same size by default, but they can be customizzed via� We are using Kendo for MVC complete. We are able to set the field to Editable(false) which works fine. The columns are basically informational so when the user selects a value in the first column, we populate the next three non-editable columns with information pulled with ajax.

Comments
  • Hi I have edited my question and figure to make it more clear. It is a treeviewer, with its label provider extending ITableLabelProvider. By editable, I mean I should be able to rename the names.
  • I have tried Editing support and assigned to my column, but it doesnt work. "canEdit" button is not called at all.
  • "canEdit" button ?? I think you mistyped it. have you tried to put breakpoints?. will have to see the code for further help.
  • Sorry for the typo. Yes I have posted the code above. I tried with breakpoints and the tree viewer is not clickable, it does not go beyond the line : super(columnViewer); in my ProximityClustersEditingSupport constructor
  • @anjalli. What i can see is you have created new TextCellEditor() in getCellEditor method. Although you have already created editor in the constructor itself using tree as your parent. so just return editor in the same method. Right now there is no parent to texteditor as you are creating simple new instance of it.
  • I have overlooked that. I have mentioned as "editor" yet there is no result. Now the debug occurs until this.editor = new TextCellEditor(treeViewer.getTree()) and terminates. Here is the code how I have included the editing support in treeviewer column: proximityClustersColumn.setEditingSupport(new ProximityClustersEditingSupport(proximityClustersColumn.getViewer(), viewer));