Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to enable/disable a TextCellEditor
    primarykey
    data
    text
    <p>I am making an application which contains 2 views. The first one contains a tree viewer which displays the folders from my system and the second one contains a table viewer which displays the content of a directory selected in the first view. Long story short: a file explorer.</p> <pre class="lang-java prettyprint-override"><code> //initialization of the table viewer tableViewer = new TableViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); tableViewer.setContentProvider(new FileTableContentProvider()); tableViewer.setLabelProvider(new FileTableLabelProvider()); //from within the implementation of any view or editor /* * getSite() - Returns the site for this workbench part (a workbench part can be a view (IViewPart) or an editor (IEditorPart)) * this view is a selection provider; the view sends the event to all the views registered to the selection service */ getSite().setSelectionProvider(tableViewer); //the table column "Name" is added to the table viewer TableColumn columnName = new TableColumn(tableViewer.getTable(), SWT.LEFT); columnName.setText("Name"); columnName.setResizable(true); columnName.setWidth(200); //the table column "Date modified" is added to the table viewer TableColumn columnDateModified = new TableColumn(tableViewer.getTable(), SWT.LEFT); columnDateModified.setText("Date modified"); columnDateModified.setResizable(true); columnDateModified.setWidth(200); //the table column "Type" is added to the table viewer TableColumn columnType = new TableColumn(tableViewer.getTable(), SWT.LEFT); columnType.setText("Type"); columnType.setResizable(true); columnType.setWidth(200); //make the header of the table visible tableViewer.getTable().setHeaderVisible(true); /* * getSite().getPage() - gets the active workbench page. */ getSite().getPage().addSelectionListener("com.awebofcode.fileexplorer.view.filetree",(ISelectionListener)this); /* * add a doubleClickListener for: * 1) if the object selected is a file, then the file will be opened with the associated program * 2) if the object selected is a directory, then enter the folder and update the tree viewer */ tableViewer.addDoubleClickListener(new IDoubleClickListener(){ @Override public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); File itemSelected = (File) selection.getFirstElement(); //if the selected item is a file a double click will launch the associated program if (itemSelected.isFile() &amp;&amp; itemSelected.exists()){ Program.launch(itemSelected.getAbsolutePath()); }else if (itemSelected.isDirectory()){ /* * Update the tree viewer; * PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(FileTreeView.ID) --&gt; returns the view with the specified ID * setSelection() will send an event and the setSelectionChanged will run */ ((FileTreeView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(FileTreeView.ID)).getTreeViewer().setSelection(selection); } } }); //create the cell editor CellEditor[] editors = new CellEditor[1]; editors[0] = new TextCellEditor(tableViewer.getTable()); tableViewer.setColumnProperties(new String[]{"Name", "Date modified", "Type"}); //assign the cell editors to the table viewer tableViewer.setCellEditors(editors); //set the cell modifier to the table viewer tableViewer.setCellModifier(new NameCellModifier(tableViewer)); </code></pre> <p>I created an action that will rename the selected file or folder from the second view.</p> <p>When I click on the name of the file I don't want to enter in the editing mode.I want to stay in the selection mode and only after I click <em>File -> Rename</em> (action rename) the editing mode has to be enabled.</p> <p>The problem is that I cannot find how to enable/disable the <code>TextCellEditor</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload