I have developed an Eclipse plugin, when I clicked the button a table appears on the view. However, this table does not refresh itself, when I click it again or when I a run operations on the table (such as deletion).
While I was implementing my table, I used TableColumn to create my columns and "TableItem" for the rows and values. Therefore, the "TableViewer"s refresh or remove functions does not work.
My table is able to appear, when I click the button and I call this function in the handler, such as;
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView("ViewID");
However, still I am not able refresh it. Any help would be nice.
Thanks!
Basically, you need to call viewer.update() whenever you want to refresh or update the table. SWT tables and JFace viewers does not have a way to monitor the data model.
Alternatively, you can use Eclipse Data Binding to bind the model and the controls/viewers together. Have a look at this entry level tutorial to get you started.
Related
I have this huge RCP enterprise CRM system I'm working on. Last year it was updated to RCP 4.5. Sadly I'm very bad with RCP because I never had to do with the frontend of it... So my question might seem a little bit strange.
Anyways, my problem is:
I have one table window where all the rows all filled up correctly with data. One column has a function, where I can double click on and one other window will open, where I can edit/remove/add data to it. The IDs of the added values are then showing in the main window's table column. (this is working correctly)
The problem: If I open this editor window, edit something (add new values or remove one or more), then click save and close this edit window (it's actually a new tab...) and then going back to this window after the editing, it will show me the state BEFORE the editing... (new values are not in the list, removed one are still on the list) The values are correctly stored or deleted in the DB, only the UI seems to stuck with the old state. I have to restart the GUI if I want to see the correct (and the actual) state.
My question: how can I force RCP to forget the old state for this tab/window and load the data everytime from DB? I tried many things in the saving method of this window (refresh, dispose of), but nothing seems to work...
Are you using a TableViewer or so?. using the tableViewer.setInput(...) again with new data + layout() may solve the problem, buit as #greg-449 said, we need for information on what kind of taale you are using to display your data and how you tell that table where is this data...
I have a TableViewer in my application that has the following features:
It gets data from a web service, and upon selecting a row, buttons get enabled and you can make operations (all these operations are calling the webservice, so the table stays in sync with the database).
When I add a new line, I submit an "add" command to the web service, and refresh the table. Now I have a new line, and I know which line is the new one.
Now I want to select the new line by default, and I tried many commands like tableViewer.getTable().select(index); and as it is now:
public void selectAdded(int id) {
tableViewer.getTable().setSelection(id);
}
This picture shows what is the problem:
The upper one shows as it works now with this code. The row below shows how it looks when I click a row. The problem is, the buttons don't get enabled, and I have two read-only text fields that remains blank instead of showing the information I need. But when I click, everything works normally.
What should I do to achive that selectAdded(int id) acts like a click? The solution should be multi-platform (Mac/Windows), but at least on Mac.
Don't use the Table selection methods which using TableViewer. Instead use
ISelection selection = new StructuredSelection(model object);
tableViewer.setSelection(selection);
'model object' is the model object for the row you want to select (as returned by your content provider).
I'm developing a JAVA swing application, developed using hibernate and mysql as a database.
I'm trying to bind data from a JList to appear on a JTable, when one of items in the list is clicked. For example i have different user types in my application, Supervisor, Manager, Administrator and others.
Each of the user type has users register under them. I want the application to show certain users when a certain item is clicked on the JList. Like when I click on the supervisor item then all registered supervisors must appear on the JTable. Don't know if I'm making sense, but you all allowed to reply and I will try to make you understand better. Thanks.
Like when I click on the supervisor item then all registered supervisors must appear on the JTable.
One way is to populate the table with all the data and then filter the table when you select an item from the JList. Read the section from the Swing tutorial on Sorting and Filtering.
Otherwise you would need to dynamically query you database every time a JList item is selected.
In either case you will need to add a ListSelectionListener to your JList to invoke your processing. Read the section from the Swing tutorial on How to Use Lists for an example.
i am developing a plugin that calculates the class metrics of the selected java file.
so, m using IWorkbenchWindowAction delegate to add the plugin button and menu option.
by selecting the java file, and clicking on the plugin button,
i obtain the pathname of the selected file, and now
i need to calculate the metrics over it.
suppose i have already calculated the metrics.
now, i want to display them in tabular form.
what needs to be done ???
how can i display a table , and display it as soon as the plugin button is pressed (after calculating the metrics, ofcourse).. ??
You must probably create your own view, with table (Viewer) inside it. Updating viewer strategy can be different. For instance, you can make your view listen to some events, which are generated after the metrics are calculated. Or, if you want to have a separate button for updating the view, then you should attach proper action/command handler with necessary logic. Does this answer your question, or I am missing something?
I have too many columns in a table to display them all at once, and would like to let the user change which columns are visible. How can I do this?
note: It is easy to make the application select columns at runtime. What I am asking is what UI element(s) to add to allow the user to hide/unhide columns at runtime.
If you can import some external libraries, you could have a look to
http://swinglabs.org/docs/components/JXTable/tutorial.jsp which supports such runtime modifications.
Table Column Manager allows the user to right click on the table header to control which columns are visible.
There isn't a standard way, however what you could do is something like this:
Use a custom table header render component to install additional actions/UI on the column headers (e.g. through a context menu of checkboxes)
Add a custom model which you can re-configure to display different items depending on what the user selected through additional actions on the column headers
Do the event wiring/plumbing.
Alternatively: find a custom component that does this. There probably is something out there already: projects like the component library from JIDE would be a good place to look.
Use TableModel.addColumn(TableColumn) and TableModel.removeColumn(TableColumn) methods to show/hide columns on-the-fly.
You can attach that calls to any other GUI components (for example, make a JPanel or a JTable with a few checkboxes).
Either display a popup menu with the possible columns when user right-clicks the header or implement a small (and light) popup dialog with a checkbox list for selecting the visible columns. The dialog can be opened by right-clicking, by clicking a toolbar button or from a toolbar menu.