In texts about a selections (like this https://www.eclipse.org/articles/Article-WorkbenchSelections/article.html) it is usually said to provide selection by commands like this:
getSite().setSelectionProvider(tableviewer);
This is good if a view has only one control, for example, TableViewer.
But what to do if view has several controls?
I can't delegate selection providing to any ONE of them. Probably I should track which one is selected and switch selection provider appropriately?
You can create a selection provider which wraps all of your viewers (or other selection providers) and switches between them automatically. Unfortunately, something like that isn't included in the framework.
Related
I implemented a custom PropertySheet as described in here.
So I have a main view, which implements the selectionprovider and it works to show the properties in my custom PropertySheet view.
My problem is now, that I want to edit the some properties of the selection in the property view and prevent changing the selection in the main view, if there are unsaved changes in the property view.
What is the best way to solve that problem?
If I implement the ISaveablePart in my custom property view, I can mark it as dirty. How can I prevent to change the selection, if my property view is dirty?
Thanks in advance!
As a view is a non-modal (e.g. non-blocking) UI component, there is no real way to prevent selection changes outside the view. For this reason, the expected way of Properties view to work is to save as soon as possible.
The default, TreeViewer based implementation of EMF models uses a CellEditor to change its values; when the value in a CellEditor changes, the changed values are written back to the original model automatically to avoid the data loss scenarios you have mentioned.
In other words, you have to rely on your data source (e.g. the editor that provides the selection) to store the permanent changes, and the changes can be serialized through that source (editor).
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).
Hi am creating an application in which I am using JTable to listing of file or folder names.
My question is:
How can I find and Search a Particular file or folder in JTable like in Windows.
In windows directory listing when we press any key then we can see that file or folder start with that character is selected and if we again press same key then next file/folder is selected with start with that character.
If you can use 3th party code, I would suggest to take a look at the SwingX project. Their JXTable, JXTree, JXList and some other classes provide an implementation of the Searchable interface, which makes creating a search widget a breeze.
And if that is even too difficult, they provide out-of-the-box a JXFindPanel which provides a UI to search a Searchable
If you can (and you're willing to) use third party UI components, the Open Source JIDE Common Layer offers a few nice components: e.g. you might like FolderChooser which has an automatic find-as-you-type functionality.
Here's the link: JIDE Common Layer. If you click the "RUN IT" button you can see a sample via Java Web Start.
I've used many JIDE components (only the open source ones) in my projects and avoided reinventing the wheel many times.
Hope this might help you.
You want an action happen when a key is typed ?
-> add a keyListener to your table
You want to know which row is valid
-> query your datamodel connected to your jtable
You want a selected row to change ?
-> in the keytyped implementation of your listener change the selection
table.getSelectionModel().setSelectionInterval(1,1);
Since I don't know something about how did you implement your code logics, JTable implemented Sorting and Filtering
but you describtions talking about JTreeTable
I would consider writing a custom TableCellRenderer, responsible for highlighting any matching letters in the String being rendered. When someone updates the search text field the simplest approach is going to then be to repaint the entire JTable to show the updated "match state" of the table cells.
I have rather big swing interface (several textboxes, comboboxes, checkboxes, custom popup dialogs etc) and a data model that has to be changed when ui control changes: new text is entered into text box, check box is clicked, etc.
The question is: what is the best practice to organize update+validation of input values.
Unfortunately I can not use binding framework like beansbinding.
Add appropriate listeners to the components, and update the model when the events are fired.
Or design your UI so that everything is saved to the model only when a Save or OK button is clicked. This also helps with validation, because you just need to validate everything at once, when the button is clicked.
Combine the answer of JB Nizet with validation in your components, for example by using JFormattedTextField (or an enhanced version of this). You can use the JFormattedTextField also as editor for JComboBox instances. You can add validation to JSlider instances.
In short, provide immediate feedback to the user when he types in an invalid value. That combined with validation on the model side makes a good application.
This can be compared to a modern website: client-side validation with javascript to give the user immediate feedback + server-side validation for validation which does not go through the UI, or to avoid nasty users bypassing your client-side validation
I am using list-field in a BlackBerry application. In each list-field item, I have a bitmap-field at the left, text at center and again a bitmap-field at the right.
Can I determine whether the fields are focusable inside the list-field rows for keypad versions of BlackBerry Devices for e.g BlackBery Tour?
No in list field no control except whole row is focusable explicitly. If you want to perform any click events you can use touchEvent() but the calculation will be too complex and not so reliable.
If you want to have separate clickable items in one row you must use HorizontalFieldManager each time.
Update: : I have come across this scenario twice, and if I were in place of you I will consider what exactly the feature is about, If you are concerned about UI and there is not any heavy functionality behind focusing you can try touchEvent or navigationClick but using both will be cumbersome. Too much logic, too much thinking, hard to test.
If there is any functionality, you have an option to add them on menu, It will be more convenient way than using horizontal field manager or the above mentioned methods.