public void loadData(boolean forceReload) { ICFSecuritySchemaObj schemaObj = (ICFSecuritySchemaObj) javafxSchema.getSchema(); if ((containingCluster == null) || forceReload) { CFSecurityAuthorization auth = schemaObj.getAuthorization(); long containingClusterId = auth.getSecClusterId(); containingCluster = schemaObj.getClusterTableObj().readClusterByIdIdx(containingClusterId); } if ((listOfSysCluster == null) || forceReload) { observableListOfSysCluster = null; listOfSysCluster = schemaObj .getSysClusterTableObj() .readSysClusterByClusterIdx(containingCluster.getRequiredId(), javafxIsInitializing); if (listOfSysCluster != null) { observableListOfSysCluster = FXCollections.observableArrayList(listOfSysCluster); observableListOfSysCluster.sort(compareSysClusterByQualName); } else { observableListOfSysCluster = FXCollections.observableArrayList(); } dataTable.setItems(observableListOfSysCluster); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } }
@Test public void testItemsPermutate() { int[] indices = new int[] {1, 3, 5}; indicesList.addIndices(indices); report.clear(); ListChangeReport itemsReport = new ListChangeReport(items); // permutation on items // [0->8, 1->7, 2->6, 3->5, 4->4, 5->3, 6->2, 7->1, 8->0] items.sort(null); // itemsReport.prettyPrint(); int[] permutated = new int[] {3, 5, 7}; // LOG.info("sortedItems" + itemsReport.getLastChange()); // LOG.info("sorted: " + report.getLastChange()); // report.prettyPrint(); assertEquals(1, report.getEventCount()); assertEquals(1, getChangeCount(report.getLastChange(), ChangeType.REPLACED)); Change c = report.getLastChange(); c.reset(); c.next(); assertEquals("added size same", permutated.length, c.getAddedSize()); for (int i = 0; i < permutated.length; i++) { assertEquals("added at " + i, permutated[i], c.getAddedSubList().get(i)); } assertEquals("removed size same", indices.length, c.getRemovedSize()); for (int i = 0; i < indices.length; i++) { assertEquals("removed at" + i, indices[i], c.getRemoved().get(i)); } // LOG.info("" + indicesList); }
@Test public void testItemsPermutateSimulation() { ObservableList<Integer> indices = new TestIndicesList(items, 1, 3, 5); String msg = "indices before/after: " + indices + " / "; ListChangeReport report = new ListChangeReport(indices); ListChangeReport itemsReport = new ListChangeReport(items); items.sort(null); // itemsReport.prettyPrint(); // report.prettyPrint(); // LOG.info(msg + indices); }
@Override public void update(Observable arg0, Object arg1) { ObservableList<String> liste = FXCollections.observableArrayList(); for (Mot m : (ArrayList<Mot>) arg1) { liste.add(m.getLibelle()); } liste.sort(null); listViewResultats.setItems(liste); }
public void setJavaFXDataCollection(Collection<ICFDbTestNumberTypeObj> value) { final String S_ProcName = "setJavaFXDataCollection"; javafxDataCollection = value; observableListOfNumberType = null; if (javafxDataCollection != null) { observableListOfNumberType = FXCollections.observableArrayList(javafxDataCollection); observableListOfNumberType.sort(compareNumberTypeByQualName); } else { observableListOfNumberType = FXCollections.observableArrayList(); } if (dataTable != null) { dataTable.setItems(observableListOfNumberType); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } }
public void loadData(boolean forceReload) { ICFAsteriskSchemaObj schemaObj = (ICFAsteriskSchemaObj) javafxSchema.getSchema(); if ((listOfSipConf == null) || forceReload) { observableListOfSipConf = null; listOfSipConf = schemaObj.getSipConfTableObj().readAllSipConf(javafxIsInitializing); if (listOfSipConf != null) { observableListOfSipConf = FXCollections.observableArrayList(listOfSipConf); observableListOfSipConf.sort(compareSipConfByQualName); } else { observableListOfSipConf = FXCollections.observableArrayList(); } dataTable.setItems(observableListOfSipConf); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } }
public void setJavaFXDataCollection(Collection<ICFAccFeeObj> value) { final String S_ProcName = "setJavaFXDataCollection"; javafxDataCollection = value; observableListOfFee = FXCollections.observableArrayList(); if (javafxDataCollection != null) { Iterator<ICFAccFeeObj> iter = javafxDataCollection.iterator(); while (iter.hasNext()) { observableListOfFee.add(iter.next()); } observableListOfFee.sort(compareFeeByQualName); } if (dataTable != null) { dataTable.setItems(observableListOfFee); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } }
/** * Executes the search * * @return ObservableList<SearchResult> containing the results of the search */ public ObservableList<SearchResult> execute() { ObservableList<SearchResult> results = FXCollections.observableArrayList(); // Loop through all the Searchable objects in the "database" for (Searchable searchable : SearchableItems.getInstance().getSearchables()) { // Check for matches against every string the object allows to be searchable List<SearchableField> searchableFields = searchable.getSearchableStrings(); for (SearchableField searchableField : searchableFields) { // Perform comparison if (searchableField .getFieldValue() .toLowerCase() .matches(".*" + getQueryLowerCase().trim() + ".*")) { results.add(new SearchResult(searchable, getQueryLowerCase().trim())); } break; // Cheats way of only caring about the first element in the array (if there is one) since we // only care about the first searchable string (short name) for this basic search // implementation } } // Sort the results SortStrategy<SearchResult, String, String> sortStrategy = new AnchoredSortStrategy<>(); sortStrategy.setData(getQueryLowerCase().trim()); sortStrategy.setComparableGetter(SearchResult::getResultText); // Sort results alphabetically results.sort( (e1, e2) -> sortStrategy .getComparableGetter() .apply(e1) .compareTo(sortStrategy.getComparableGetter().apply(e2))); // Sort results using sort strategy ArrayList<SearchResult> sorted = new ArrayList<>(sortStrategy.sorted(results)); results.setAll(sorted); return results; }
private void onListChanged() { Log.traceCall(); list.clear(); list.addAll( tradeManager .getTrades() .stream() .map(PendingTradesListItem::new) .collect(Collectors.toList())); // we sort by date, earliest first list.sort((o1, o2) -> o2.getTrade().getDate().compareTo(o1.getTrade().getDate())); // TODO improve selectedItem handling // selectedItem does not get set to null if we dont have the view visible // So if the item gets removed form the list, and a new item is added we need to check if the // old // selectedItem is in the new list, if not we know it is an invalid one if (list.size() == 1) onSelectTrade(list.get(0)); else if (list.size() > 1 && (selectedItem == null || !list.contains(selectedItem))) onSelectTrade(list.get(0)); else if (list.size() == 0) onSelectTrade(null); }