I'm writing an Eclipse plugin for a screen definition editor. The preview page will have multiple tables of different rows/columns definitions, the contents of each cell is effectively a control definition (i.e. Label, TextBox, etc). Some basic requirements of the preview are:
User selection on any cell publishes the control properties to another view.
The cell styling is applied depending upon the control type.
Currently using JFace TableViewers but have the following issues:
1. Only one TableViewer can be registered as a selection provider via the getSite().setSelectionProvider(). How to listen for selection changes on all my tables?
2. TableViewer does not appear to allow for cell styling.
3. Cell selection programatically handling with a TableCursor, but the cell in a previous table is still highlighted when I select another cell in another table.
Are there more suitable layouts to use than TableViewer for my purposes?
Regarding point #2, cell styling, TableViewers do allow for customization of the display of cell data. Take a look here for some ideas on how to get started with that.
You can use this approach for supporting selection in multiple tables with some modification (add listener to each of your table viewers so if one of them is selected it automatically becomes the delegate).
Related
I have a Vaadin 14 Flow application that presents a grid of tasks that can be added to and deleted from as well as editing a selected task. Currently I have it set up so that if the user clicks a row (single select), it opens an editor so they can edit the task.
What I'd like to do is have a checkbox on each row that can be used as a multi-row selector to allow deleting multiple rows.
Would it be easier to just have the table be multiple selection enabled and just delete whatever row(s) are selected? I assume multi-selection allows the usual shift-click to select a contiguous range and control-click to select rows at random.
If I switch to multi-select, how will this affect the ability to simply click a row and have it open an editor for that row? If multiple rows are selected, what is likely to happen?
Update:
I'd never used multi-select until now. I didn't realize it provides checkboxes out of the box (no pun intended).
I had never used multi-select before and didn't realize that using that technique automatically adds a checkbox at the front of the row. Problem solved.
In Vaadin 8, I have a Grid with columns and rows populated from jsondata using setDataProvider. Now, I have an edit button, upon clicking it user should be able to edit (a few) columns in the Grid.
In Vaadin 8, there are number of ways to incorporate editing in Grid.
There is a builtin feature of row editor, which can be used also in unbuffered mode. This is not equivalent of having the whole column editable, but mimics it pretty well, while you can use Binder for setting fields, validation, etc. There exists also an add-on that helps keyboard navigation with un-buffered editor.
Alternatively you can use the Grid Renderers Collection add-on, that provides set of editable renderers with edit events etc.. This is literaly what you are looking for, column oriented editing. This is useful approach when only few columns are editable.
https://vaadin.com/directory/component/grid-renderers-collection-for-vaadin7
If you use renderers extensively, there will be more widgets for the browser to render, and that will UI possibly slower than using e.g. row editor in un-buffered mode. This depends heavily on your application and use case. I recommend to study multiple approaches and select the one that fits you the best.
Third alternative is to use ComponentColumn feature, see chapter Component Renderer in Vaadin documentation. This is somewhat easier than implementing custom renderers, but adds some further overhead.
I need to customise the selection behaviour of the cells inside a JTable descendant. I have a custom cell editor using a JTextField descendant as the editorComponent; there's a focus listener registered on it which manages the desired selection behaviour.
I need different behaviour when tabbing around the table than when another window or application comes to the front and then goes away again.
This is currently not possible, because the cell editor's editorComponent seems to have no off-the-shelf way of knowing (or telling it) that it's the editor for a table cell, so it doesn't know that it's "inside" the table, so my focusGained() and focusLost() think focus is moving between different windows even if I'm just tabbing around in the table.
SwingUtilities.windowForComponent() returns null for the editorComponent.
Before I roll my own solution, is there an accepted way of dealing with this issue? I can't be the first person to need to do this...
I've build an application in Java with the help of JFace/SWT. I am using mainly the TableViewer of JFace and sometime the SWT table behind with myTableViewer.getTable().
My table has a header (filled with the column names) and the first row is rendered with CCombos in CellEditors (drop down menus for filters).
Now I want to fix this first row ("filter-row") in the table, so it is always shown, independently if I am scrolling down or not..
Do you know any opportunity to do this (instead of splitting one table in two tables, as I found it in the internet)?
The SWT Table does not support fixed rows or columns.
If the combos were inteded to hold a limited number of choices you may use context menus on the column headers instead.
There are also alternative Table-like implementations in varying degrees of maturity that you may consider:
Nebula Grid
XViewer
NatTable
If non of the above fits your requirements you will have to either use a distinct table that holds the combo widgets or implement a custom 'header' control.
I have a Swing based application containing a JTable. Now I would like to allow each row to be updated or deleted, using a unique row ID. So I want to add an update and delete button to each row, which have the capability to support an ActionListener. However, I have no idea how to do this using NetBeans.
To display a button in a column you need to create:
a custom renderer to display the JButton
a custom editor to respond to the mouse click
Read the section from the Swing tutorial on How to Use Tables. The section on:
Using Custom Renders will explain the basics of using a renderer
Using Other Editors will explain the basics of using an editor
Working example are provided in the tutorial that you can download.
You can check out Table Button Column for one approach.
The code uses a single class to implement the custom renderer and editor that you will need for the column to display your text as a button.