I have a TabPane with 10 tabs (each with its controller). In one of them I have a table 'categories' where the user can add / edit / delete categories.
The other tabs have the same table 'categories', smaller, in read-only mode, where the user can only select categories.
Then, when the table 'categories' is modified in the categories tab, what I want is for all other tables categories of the other tabs are updated.
What I thought is (not implemented yet), on the top panel to put a listener that detects tab changes and, when the user leaves the categories tab, check if changes have been made.
If so, call all the controllers involved to update their own tables of categories.
The question I have is, if there is a less cumbersome way to do this. Something like sending a message 'table has been changed' and all the 'listeners' tabs of the message update their tables. Similar to a locally JMS, not client-server. Is there something like this messaging service that can be employed within the same application or the solution that I raised above is the most consistent? I think the question is more Java than JavaFX.
Thanks a lot.
The easiest way would be to hold the categories in an ObservableList at some top level (say in your Application sub class) and have all the tables share a reference to that list (table.setItems(yourList)). Whenever a change is made in the categories tab, the other tabs will automatically reflect the change.
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 configurations pane in my JavaFX 8 application that is spread across a number of tabs within tabs. Currently I am forced to split tabs for a longer configuration process.
I know that I'll have two .fxml files for the two tabs, but I should be able to use the same controller for both. Currently, however, if I make changes to one tab, the other tab doesn't see the changes. I'm guessing it creates a separate instance of the controller. Is it possible for the two .fxml tabs to use the same instance of the controller so that the information can be shared across the two tabs?
Example for more clarification:
Tab1 contains textfield input for email, Firstname, etc.
Tab2 uses email information and generates usernames and allows user to modify other settings using the generated values.
To reuse a controller between multiple FXML loads, you can use fxmlLoader.setController() or fxmlLoader.setControllerFactory().
I don't really recommend a reused controller approach, so I won't post detailed code for it here. Rather, I recommend passing parameters.
I have to build a page within a java application containing 4 tables (we've chose to use javaFX to use, therefore we're using TableView tables)
There is a problem though. Using multiple tables on 1 pane doesnt seem succesfull. Here you can see the result: http://i.imgur.com/lmPB6Ih.png?1 (I cannot post images yet..)
As you can see it only shows 1 player (a goalkeeper) instead of all the desired players. Whenever i disable all tables but one it shows the desired information.
You can find my code via this link: http://pastebin.com/5AAchCKh
You can't reuse the TableColumn objects.
This fails:
tableTeamField.getColumns().addAll(name,position,age,worth,shooting,...);
tableSelectionField.getColumns().addAll(name,position,age,worth,shooting,...);
When the data is applied to the tables, only the data from the last table is shown in all of them. Basically, you are applying to the sane column different values: only the last one will be visible.
So you need to create different TableColumns for each TableView. This will work:
tableTeamField.getColumns().addAll(name1,position1,age1,worth1,shooting1,...);
tableSelectionField.getColumns().addAll(name2,position2,age2,worth2,shooting2,...);
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.
In my application, I have URN-identified data coming in from the server. I'm in the process of abstracting as far as possible so there is very little to no logical code in my views, and I'm using a generic presenter that wraps those views. All widgets have URNs, making it super easy to map incoming data to a specific widget (until now, a 1 to 1 relationship). This has worked well for pretty much every widget, and now I've reached a point where I'm tripped up.
Assume I have (just for simplicity's sake) two RadioButton elements on a view. These buttons belong to a "group" (just by setting their name values to the same thing), but obviously they're 2 distinct elements. I can't map my URN-identified data to a single widget as in every other case because, in this case, it is two widgets.
Here's an example of what I mean:
Utility Company is a ListBox, so just one widget there. I map each item in the list to a specific Enum value.
Utility Rate is a TextBox, so again just one widget to map.
For Energy Usage, they can select to use either an average for the year or input 12 monthly values. I'm stuck here. I can't map to just one of the RadioButton elements, because then I'd need some extra logic in the view to handle the behavior appropriately.
Am I stuck mapping to just one widget and sticking (unwanted) logic in my view to determine what the state of all of the elements should be based on the value that came in for the one widget that is mapped?
How should I handle this case?
Edit (Solution):
Following the concepts of jusio's answer, I came up with a workable solution. Because I didn't want to go sticking special case handling through my logic to take care of a non-widget, I created a RadioButtonSet faux widget (public class RadioButtonSet <T extends Enum<?> & HasDisplayText> extends Widget implements HasValueChangeHandlers<T>, HasValue<T>), into which I manually pass the radios I intend to group. Having done that, I can get or set its value and have it fire appropriate events when the user changes the selection. Then mapping the collection of radios is no different than doing so for a listbox. Thanks jusio.
I believe in your case you shouldn't treat radio buttons as two separate widgets, basically in your case you can treat the radio button group as combo box, because behavior is almost the same (the only problem is that you have additional master detail). So basically what you will have to do is to wrap real BO objects into some kind of RadioButtonGroupModel, and give it to view, view can take this model and generate radio buttons (with some editors or whatever else). I remember running into this problem when i was extending databinding FW for JFace, and this was the best way I could find to solve this problem.
If I understood correctly the problem, there are 2 possible solutions:
Give each RadioButton a unique URN (ex: oldURN_1 , oldURN_2)
When you send data for a URN, disable the other one
Keep the same Name for each RadioButton but add a number variable in the data the server sends indicating which radioButton it is supposed to use (ex: 0 for Average and 1 for Monthly)