How to force RCP to reload the table content - java

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...

Related

Oracle-adf selectOneChoice reset on treeTable scrolling

I'm facing problem with a selectOneChoice inside a TreeTable in clickToEdit mode.
When scrolling down and returning up, the value of the combo of the focused row is cleaned.
To replicate the issue, just navigate to the ADF demo :
clickToEditTreeTable
Expand all
Select the first row
Change the value of the Col2 to HeadPhone
With the focus still on first row, scroll down until the Fetching Data message appear
Scroll up back to the first row
The value of the Col2 is changed to Mouse
How can i avoid this ?
In my application i have noticed that the value change listener is fired the first time when changing the value, and a second time while scrolling the treeTable,setting it to null
This problem occurs ONLY with a treeTable in editingMode clickToEdit.
The standard table works fine.
My jdev is 11.1.2.1.0.
Thx in advance.
Since you are able to reproduce this issue in ADF demo itself its either an ADF bug or limitation.
I think thats a kind of a bug. You can try to file service request on it.
It seems that since you don't commit your changes (because you still stays on this row). On another fetch your changes ain't being saved and on refetch you getting old values.
As for workaround for this issue:
If your tree ain't too large, you can set iterator RangeSize to -1 to fetch all rows at once to avoid more rows fetching. However if you have a lot of rows, you'll have a perfomance issues.
You can try to set autosubmit property on this field to true, so it will save your data (and hopefully load) on comback (even if it don't, you can do it in your bean). May be you will also need to put there clientListener to submit data, when your control loses focus.
Don't use clickToEdit for this control or call it a feature (no submit - no changes) :)
Since i can't wait a fix, i have found a workaround to the problem.
The value is setted to null ( or false for the checkboxes ), when the element is renderized the second time on scrolling back, because the setter property of the bean and ( if present ) the value change of the selectOneChoice are invoked.
So i have setted a clientListener on the valueChange event that unlike the valueChangeListener is fired correctly, and a fake property as value.

How to make a table refresh in an Eclipse plugin?

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.

Creating JTable inside node of JTree

I know that this question is being asked before but I did not get proper solution.
I read about outline but that was just opposite of what I want i.e. JTable inside JTree
I want to display data in a JTable but it is stored as different groups,so these groups
are node of JTree when I expend one group(node) the JTable of that group is shown.
I went through this article in oracle :Creating TreeTables in Swing:part 1
This was pretty old and not working on my version of java(I don't know why !),so I went
through the next part of TreeTable :Creating TreeTables in Swing: Part 2
The whole code was comparatively new, as it was using "javax.swing" in place of
"com.sun.java.swing" but the problem I faced here was one file named as
"FileSystemModel2.java" was missing it is modified from previous version so I can't work
with old one.There are some method added to new "FileSystemModel.java".How do I inform
them about this missing file or if you have different approach please let me know.
What I want to achieve is shown in picture below :
This image was from "LastPass" and I want to make my own password manager as my project
So please help me with this I am so close but yet I can't move further.
The SwingX project contains a ready-made TreeTable
http://swingx.java.net/
The downloads are a bit hard to find, so here is the link:
http://java.net/downloads/swingx/releases/1.6.2/
A short article about using that component can be found here:
http://sandarenu.blogspot.com/2008/02/treetable-in-java-using-swingx.html

JTable with jgoodies sorting trouble

I've got a blocking problem with the sorting functionality of a JTable; this made stall the development of the spare time open source project for 4 months now. Hope to be pointed into the right direction here.
Context: I'm working on extending the functionality of the ps3mediaserver to add a media library with pms-mlx. The UI of the media server has been done using swing.
Problem: When clicking on a column header in the JTable, a seemingly random column gets sorted instead of the one having been clicked.
Current implementation: Here's the description of the different components and classes being used for the implementation:
ETable: As alternate row colours aren't supported by default in the JTable, I've switched to the ETable extending the JTable. Source comes from here
FileDisplayTable: This is the class creating the table. In the init() method, the sorting is being enabled with 'table.setAutoCreateRowSorter(true);'
FileDisplayTableCellRenderer: Exists to always align cell content on the left
FileDisplayTableColumnModel: Does some mapping between internal types and column names
FileDisplayTableAdapter: This class implements com.jgoodies.binding.adapter.AbstractTableAdapter to map the objects with the table columns.
Possible solutions:
Preferably, I'd like to keep the current implementation and figure out how to correct the sorting, but I doubt someone can help me out with that!? Additionally their are some bits of code I had to add because of strange behaviours; they're commented in the code
The alternate option would be to change the JTable for another control altogether. I've made some research but didn't find the solution I was hoping for. The constraints are that
it must be embeddable in a swing UI
preferably it should support data bindings
support alternate row colours
row sorting
At some point it will be possible to open an editing dialogue, where the content of the row has to be retrieved, can be edited and when saved the row has to be updated.
Before reworking the entire thing I'd like to be sure the component will be able to handle all I want to do with it.
I'm more used to create GUIs using .NET in Visual Studio. It's quite different and a lot more difficult to do the same with swing. Please show me I'm wrong :)
[edit] If someone is willing to reproduce the problem, either get the source or the binaries, launch the application, navigate to the media library tab. In the Genral section import some videos by adding some video files. Go to the library section, click on apply to refresh the list and try to sort the table.
It may be useful to know that JTable columns can be dragged by the user. As a result, the view (JTable or a subclass) and model (an implementation of TableModel) may have different column numbers. Similarly, a RowSorter may affect the order or number of rows in the view as compared to the model. The related conversion methods are mentioned in How to Use Tables: Sorting and Filtering. In particular: "When using a sorter, always remember to translate cell coordinates."
Addendum: As an alternative, consider org.netbeans.swing.etable.ETable or it's subclass org.netbeans.swing.outline.Outline, depicted here.

Best way to implement refusing a value change by the user in Swing?

I have a JCheckBox that should not be checked by the user when a certain other field is empty.
So now I want to have an error popup and then reset the checkbox (I've considered disabling the checkbox, but the connection to the other field is non-obvious, and a tooltip text IMO not visible enough).
What's the correct way to do that in Swing? Through a PropertyVetoException? Where do I throw it and where do I catch it? My first (probably ugly) idea would be to add a ChangeListener that itself shows the popup and resets the value.
Edit: The question is about Nikki (screenshot below), an app I am developing which geotags images and exports them to Google Earth's KMZ format. The checkbox is used to select the images to include in the export. But this requires the images to be gotagged first (which in turn requires either a timestamp, or manual assignment). I don't think this requirement can be made obvious through the UI layout.
(source: brazzy.de)
I would simply disable the check box and add a message explaining why the option is not available. A nice way to show the message is to display a mini exclamation mark next to the check box and put the message in a tooltip.
Poping up an exception often feels wrong because users don't read error messages. For most users an error message popup means that the application did something wrong, in your case it's the normal behavior.
Edit if you insist on letting the check box enabled, another way to show the user that some info is missing would be to flash the missing data. Eg. if latitude and longitude are missing and the user clicks on export, set a red background onto these fields for a just a second. This will clearly show the user what's missing.
In this screen, don't you want to put the mouse over the red circle to understand what's going on?
validation http://www.vogella.de/articles/EclipseDataBinding/images/validation10.gif
I don't think the Export JCheckBox should be disabled at all. Instead, the Export JButton itself should examine the current export list and display any anomalous entries in a way that allows navigation to a chosen photograph. If all entries are correct, Export would proceed as usual.
Addendum: It think you are right to keep the interface as non-modal as possible. My model for this would be unsaved files when exiting an editor or uncommitted changes when closing a project in an IDE.
If that's a status line at the bottom of the window, you might indicate the number of photographs currently selected for export, adding a count if any still need geocoding.
The field should simply be allowed to disable the checkbox. If the coupling is unintuitive then the GUI layout may have to be reconsidered.
EDIT: I ran it from your page, and I believe the issue here is that you actually have a third and fourth step in addition to select folder, select images. The third step is validate image, and fourth is select images for export. I think your problem is that this is not clearly conveyed in the current layout, and that reflects in your question.
I would suggest that you create a separate column containing the checkbox for each image, and that THAT checkbox is disabled until the image passes validation (step 3). Perhaps with an explanatory text in the column about why the image hasn't passed yet.

Categories