Java Code Examples for javafx.collections.ObservableList#add()
The following examples show how to use
javafx.collections.ObservableList#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListPropertyExTests.java From gef with Eclipse Public License 2.0 | 6 votes |
@Test public void changeListenerRegistrationAndDeregistration() { ListProperty<Integer> property = propertyProvider.get(); // register listener ChangeExpector<Integer> changeListener = null; changeListener = new ChangeExpector<>(property); property.addListener(changeListener); // add second listener (and remove again) ChangeExpector<Integer> changeListener2 = null; changeListener2 = new ChangeExpector<>(property); property.addListener(changeListener2); property.removeListener(changeListener2); ObservableList<Integer> newValue = FXCollections.observableArrayList(); newValue.add(1); changeListener.addExpectation(property.get(), newValue); property.set(newValue); changeListener.check(); }
Example 2
Source File: OperatorController.java From OEE-Designer with MIT License | 6 votes |
public void populateTopEntityNodes() throws Exception { // fetch the entities List<PlantEntity> entities = PersistenceService.instance().fetchTopPlantEntities(); Collections.sort(entities); // add them to the root entity ObservableList<TreeItem<EntityNode>> children = getRootEntityItem().getChildren(); children.clear(); for (PlantEntity entity : entities) { TreeItem<EntityNode> entityItem = new TreeItem<>(new EntityNode(entity)); children.add(entityItem); setEntityGraphic(entityItem); } // refresh tree view getRootEntityItem().setExpanded(true); tvEntities.getSelectionModel().clearSelection(); tvEntities.refresh(); }
Example 3
Source File: HistoryManagment.java From JFX-Browser with MIT License | 6 votes |
public static ObservableList getDomainNames(ObservableList domainNames) { ResultSet rs = null; try { String str = "select url from history"; perp = SqliteConnection.Connector().prepareStatement(str); rs = perp.executeQuery(); while (rs.next()) // loop for data fetching and pass it to GUI table // view { String link1 = rs.getString(1); // ObservableList<String> domainNamesList = // FXCollections.observableArrayList(); domainNames.add(link1); } rs.close(); perp.close(); SqliteConnection.Connector().close(); } catch (Exception e) { System.out.println("Issues in fullHistoryShow method"); } return domainNames; }
Example 4
Source File: MicroController.java From CPUSim with GNU General Public License v3.0 | 6 votes |
/** * returns a list of updated microinstructions based on the objects * in the list. It replaces the objects in the list with their * associated objects, if any, after updating the fields of those old objects. * It also sorts the micros by name. * * @param list a list of micro instructions * @return a list of updated micro instructions */ public ObservableList createNewMicroList(Microinstruction[] list) { ObservableList newMicros = FXCollections.observableArrayList(); for (int i = 0; i < list.length; i++) { Microinstruction micro = list[i]; Microinstruction oldMicro = (Microinstruction) assocList.get(micro); if (oldMicro != null) { //if the new micro is just an edited clone of an old micro, //then just copy the new data to the old micro micro.copyDataTo(oldMicro); newMicros.add(oldMicro); } else newMicros.add(micro); } return sortVectorByName(newMicros); }
Example 5
Source File: ScanAllController.java From FlyingAgent with Apache License 2.0 | 5 votes |
private void loadDataToNetworkTable(NetworkInformation networkInformation) { ObservableList<NetworkTable> networkTableData = FXCollections.observableArrayList(); /* This data add below just for testing */ for (Network network : networkInformation.getNetworkList()) { networkTableData.add(new NetworkTable(network.getName(), network.getIpAddress(), network.getMacAddress())); } TreeItem treeItem = new RecursiveTreeItem<>(networkTableData, RecursiveTreeObject::getChildren); try { tableNetwork.setRoot(treeItem); } catch (Exception e) { System.err.println("Exception in tree item of network table !"); } }
Example 6
Source File: AlarmTreeView.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Called when an item is added/removed to tell user * that there are changes to the tree structure, * may not make sense to interact with the tree right now. * * <p>Resets on its own after 1 second without changes. */ private void indicateChange() { final ScheduledFuture<?> previous = ongoing_change.getAndSet(UpdateThrottle.TIMER.schedule(clear_change_indicator, 1, TimeUnit.SECONDS)); if (previous == null) { logger.log(Level.INFO, "Alarm tree changes start"); setCursor(Cursor.WAIT); final ObservableList<Node> items = getToolbar().getItems(); items.add(1, changing); } else previous.cancel(false); }
Example 7
Source File: SceneNodeTreeNode.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override @FxThread public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) { if (!(nodeTree instanceof ModelNodeTree)) { return; } final Menu createMenu = createCreationMenu(nodeTree); items.add(createMenu); items.add(new RenameNodeAction(nodeTree, this)); }
Example 8
Source File: DetailPCController.java From FlyingAgent with Apache License 2.0 | 5 votes |
private void loadDataToNetworkTable(NetworkInformation networkInformation) { ObservableList<NetworkTable> networkTableData = FXCollections.observableArrayList(); /* This data add below just for testing */ for (Network network : networkInformation.getNetworkList()) { networkTableData.add(new NetworkTable(network.getName(), network.getIpAddress(), network.getMacAddress())); } TreeItem treeItem = new RecursiveTreeItem<>(networkTableData, RecursiveTreeObject::getChildren); try { tableNetwork.setRoot(treeItem); } catch (Exception e) { System.err.println("Exception in tree item of network table !"); } }
Example 9
Source File: BattleOfDecksConfigView.java From metastone with GNU General Public License v2.0 | 5 votes |
private void setupNumberOfGamesBox() { ObservableList<Integer> numberOfGamesEntries = FXCollections.observableArrayList(); numberOfGamesEntries.add(1); numberOfGamesEntries.add(10); numberOfGamesEntries.add(100); numberOfGamesEntries.add(1000); numberOfGamesBox.setItems(numberOfGamesEntries); numberOfGamesBox.getSelectionModel().select(2); }
Example 10
Source File: Corpus.java From SONDY with GNU General Public License v3.0 | 5 votes |
public ObservableList<Message> getMessages(Event event){ ObservableList<Message> messages = FXCollections.observableArrayList(); String[] interval = event.getTemporalDescription().split(","); int timeSliceA = convertDayToTimeSlice(Double.parseDouble(interval[0])); int timeSliceB = convertDayToTimeSlice(Double.parseDouble(interval[1])); String term = event.getTextualDescription().split(" ")[0]; NumberFormat formatter = new DecimalFormat("00000000"); for(int i = timeSliceA; i <= timeSliceB; i++){ try { File textFile = new File(path+File.separator+preprocessing+File.separator+formatter.format(i)+".text"); File timeFile = new File(path+File.separator+preprocessing+File.separator+formatter.format(i)+".time"); File authorFile = new File(path+File.separator+preprocessing+File.separator+formatter.format(i)+".author"); LineIterator textIter = FileUtils.lineIterator(textFile); LineIterator timeIter = FileUtils.lineIterator(timeFile); LineIterator authorIter = FileUtils.lineIterator(authorFile); while(textIter.hasNext()){ String text = textIter.nextLine(); String author = authorIter.nextLine(); String time = timeIter.nextLine(); if(StringUtils.containsIgnoreCase(text,term)){ messages.add(new Message(author,time,text)); } } } catch (IOException ex) { Logger.getLogger(Corpus.class.getName()).log(Level.SEVERE, null, ex); } } return messages; }
Example 11
Source File: JFXHelper.java From Schillsaver with MIT License | 5 votes |
/** * Creates a combo box with zero or more options. * Null options are ignored. * * @param options * The options to add to the combo box. * * @return * The combo box. */ public static ComboBox<String> createComboBox(final String ... options) { final ObservableList<String> list = FXCollections.observableArrayList(); for (final String option : options) { if (option != null) { list.add(option); } } return new ComboBox<>(list); }
Example 12
Source File: ServiceSearchData.java From Corendon-LostLuggage with MIT License | 5 votes |
/** * This method is for generating the right color search query, based on the user input * * @param search a string that will be searched and converted in the query * @return statement the right query statement (part) for the colors * @throws java.sql.SQLException checking in the db */ private String generateColorStatement(String search) throws SQLException{ //create a temporary query (String) that will be returned String generatedStatement = ""; //create an other temporary string that will be checked in the db //for searching trough all the ralCodes and language's possibilities String colorQuery = "SELECT ralCode FROM color WHERE " + " english LIKE '%replace%' OR " + " dutch LIKE '%replace%' OR " + " ralCode LIKE '%replace%';"; //replace the parts based on the user input colorQuery = colorQuery.replaceAll("replace", search); //get the resultSet of the input ResultSet resultSetColor = DB.executeResultSetQuery(colorQuery); //create a temporary list where the results (ralCode) will be put in ObservableList<String> stringList = FXCollections.observableArrayList(); //loop trough the resultSet while (resultSetColor.next()){ //if there is an result get the ralCode String colorId = resultSetColor.getString("ralCode"); //add this to the string List stringList.add(colorId); } //loop trough evry item in the colorList and add the result to the query for (String colorListItem : stringList) { generatedStatement += " mainColor LIKE '%"+colorListItem+"%' OR " + " secondColor LIKE '%"+colorListItem+"%' OR "; } return generatedStatement; }
Example 13
Source File: DateTimeRangeInputPane.java From constellation with Apache License 2.0 | 5 votes |
/** * Set the highlighting of the TitlePane's title. * <p> * Highlighting is done by adding/removing our own style class. We attempt * to make sure that we don't add it more than once. * * @param highlight True to be highlighted, false to be unhighlighted. */ private void setUsingAbsolute(final boolean highlight) { final ObservableList<String> classes = absPane.getStyleClass(); if (highlight) { if (!classes.contains(HIGHLIGHTED_CLASS)) { classes.add(0, HIGHLIGHTED_CLASS); clearRangeButtons(); } } else { classes.remove(HIGHLIGHTED_CLASS); } }
Example 14
Source File: ServiceSample.java From JavaFX with MIT License | 5 votes |
@Override protected ObservableList<String> call() throws Exception { for (int i = 0; i < 500; i++) { updateProgress(i, 500); Thread.sleep(5); } ObservableList<String> sales = FXCollections.observableArrayList(); sales.add("A1: " + random.nextInt()); sales.add("A2: " + random.nextInt()); return sales; }
Example 15
Source File: PeerInfoWithTagEditor.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void animateHide(Runnable onFinishedHandler) { if (GlobalSettings.getUseAnimations()) { double duration = getDuration(300); Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); gridPane.setRotationAxis(Rotate.X_AXIS); Camera camera = gridPane.getScene().getCamera(); gridPane.getScene().setCamera(new PerspectiveCamera()); Timeline timeline = new Timeline(); ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames(); keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.rotateProperty(), 0, interpolator), new KeyValue(gridPane.opacityProperty(), 1, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.rotateProperty(), -90, interpolator), new KeyValue(gridPane.opacityProperty(), 0, interpolator) )); timeline.setOnFinished(event -> { gridPane.setRotate(0); gridPane.setRotationAxis(Rotate.Z_AXIS); gridPane.getScene().setCamera(camera); onFinishedHandler.run(); }); timeline.play(); } else { onFinishedHandler.run(); } }
Example 16
Source File: DritarjaKryesore.java From Automekanik with GNU General Public License v3.0 | 5 votes |
public void filtroFinancat(TextField puna) { try { String sql; if (!puna.getText().isEmpty()) sql = "select * from Punet where lower(lloji) like lower('%" + puna.getText() + "%') or lower(konsumatori) like lower('%" + puna.getText() + "%'" + ") order by data desc"; else sql = "select * from Punet order by data desc"; Connection conn = DriverManager.getConnection(CON_STR, "test", "test"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql); ObservableList<TabelaPunet> data = FXCollections.observableArrayList(); Format format = new SimpleDateFormat("dd/MM/yyyy"); while (rs.next()) { String d = format.format(rs.getDate("data")); data.add(new TabelaPunet(rs.getInt("id"), rs.getString("lloji").toUpperCase(), d, rs.getFloat("qmimi"), rs.getString("konsumatori").toUpperCase(), rs.getString("pershkrimi"), rs.getString("kryer"), rs.getString("makina").toUpperCase())); } tblPunet.getItems().clear(); tblPunet.setItems(data); stmt.close(); rs.close(); conn.close(); } catch (Exception ex) { ex.printStackTrace(); } }
Example 17
Source File: StyleHelper.java From AsciidocFX with Apache License 2.0 | 4 votes |
public static void addClass(Styleable styleable, String clazz) { ObservableList<String> styleClass = styleable.getStyleClass(); if(!styleClass.contains(clazz)){ styleClass.add(clazz); } }
Example 18
Source File: CurveFittedAreaChartSample.java From marathonv5 with Apache License 2.0 | 4 votes |
private static void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements) { // as we do not have direct access to the data, first recreate the list of all the data points we have final Point2D[] dataPoints = new Point2D[strokeElements.size()]; for (int i = 0; i < strokeElements.size(); i++) { final PathElement element = strokeElements.get(i); if (element instanceof MoveTo) { final MoveTo move = (MoveTo) element; dataPoints[i] = new Point2D(move.getX(), move.getY()); } else if (element instanceof LineTo) { final LineTo line = (LineTo) element; final double x = line.getX(), y = line.getY(); dataPoints[i] = new Point2D(x, y); } } // next we need to know the zero Y value final double zeroY = ((MoveTo) fillElements.get(0)).getY(); // now clear and rebuild elements strokeElements.clear(); fillElements.clear(); Pair<Point2D[], Point2D[]> result = calcCurveControlPoints(dataPoints); Point2D[] firstControlPoints = result.getKey(); Point2D[] secondControlPoints = result.getValue(); // start both paths strokeElements.add(new MoveTo(dataPoints[0].getX(), dataPoints[0].getY())); fillElements.add(new MoveTo(dataPoints[0].getX(), zeroY)); fillElements.add(new LineTo(dataPoints[0].getX(), dataPoints[0].getY())); // add curves for (int i = 1; i < dataPoints.length; i++) { final int ci = i - 1; strokeElements.add(new CubicCurveTo( firstControlPoints[ci].getX(), firstControlPoints[ci].getY(), secondControlPoints[ci].getX(), secondControlPoints[ci].getY(), dataPoints[i].getX(), dataPoints[i].getY())); fillElements.add(new CubicCurveTo( firstControlPoints[ci].getX(), firstControlPoints[ci].getY(), secondControlPoints[ci].getX(), secondControlPoints[ci].getY(), dataPoints[i].getX(), dataPoints[i].getY())); } // end the paths fillElements.add(new LineTo(dataPoints[dataPoints.length - 1].getX(), zeroY)); fillElements.add(new ClosePath()); }
Example 19
Source File: DesktopController.java From CPUSim with GNU General Public License v3.0 | 4 votes |
/** * saves the content of a tab in a new file * * @param tab tab whose content needs to be saved * @return true if the tab was successfully saved to a file */ private boolean saveAs(Tab tab) { FileChooser fileChooser = new FileChooser(); initFileChooser(fileChooser, "Save Text", true); /*fileChooser.getExtensionFilters().add(new ExtensionFilter("Assembly Language File (.a)", "*.a"));*/ File fileToSave = fileChooser.showSaveDialog(stage); final File finalFileToSave; if (fileToSave == null) { finalFileToSave = null; } /*else if (fileToSave.getAbsolutePath().lastIndexOf(".a") != fileToSave.getAbsolutePath().length() - 2) { finalFileToSave = new File(fileToSave.getAbsolutePath() + ".a"); }*/ else { finalFileToSave = new File(fileToSave.getAbsolutePath()); } if (finalFileToSave != null) { InlineStyleTextArea textToSave = (InlineStyleTextArea) tab.getContent(); saveTextFile(finalFileToSave, textToSave.getText()); ((CodePaneTab) tab).setFile(finalFileToSave); tab.getTooltip().setText(finalFileToSave.getAbsolutePath()); //update the reopen menu updateReopenTextFiles(finalFileToSave); // Update popup Menu that appears when you right-click on the tab MenuItem copyPath = new MenuItem("Copy Path Name "); copyPath.setOnAction(e -> { Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); content.putString(finalFileToSave.getAbsolutePath()); clipboard.setContent(content); }); ObservableList<MenuItem> mi = tab.getContextMenu().getItems(); mi.remove(3); mi.add(copyPath); } return finalFileToSave != null; }
Example 20
Source File: BouncingTargets.java From ShootOFF with GNU General Public License v3.0 | 4 votes |
private void addSettingControls() { final GridPane bouncingTargetsPane = new GridPane(); final ColumnConstraints cc = new ColumnConstraints(100); cc.setHalignment(HPos.CENTER); bouncingTargetsPane.getColumnConstraints().addAll(new ColumnConstraints(), cc); final int MAX_TARGETS = 10; final int MAX_VELOCITY = 30; final int SHOOT_DEFAULT_COUNT = 4 - 1; final int DONT_SHOOT_DEFAULT_COUNT = 1 - 1; final int DEFAULT_MAX_VELOCITY = 10; final ObservableList<String> targetCounts = FXCollections.observableArrayList(); for (int i = 1; i <= MAX_TARGETS; i++) targetCounts.add(Integer.toString(i)); final ComboBox<String> shootTargetsComboBox = new ComboBox<>(targetCounts); shootTargetsComboBox.getSelectionModel().select(SHOOT_DEFAULT_COUNT); shootTargetsComboBox.valueProperty().addListener((observable, oldValue, newValue) -> { shootCount = Integer.parseInt(newValue); stopExercise(); startExercise(); }); bouncingTargetsPane.add(new Label("Shoot Targets:"), 0, 0); bouncingTargetsPane.add(shootTargetsComboBox, 1, 0); final ComboBox<String> dontShootTargetsComboBox = new ComboBox<>(targetCounts); dontShootTargetsComboBox.getSelectionModel().select(DONT_SHOOT_DEFAULT_COUNT); dontShootTargetsComboBox.valueProperty().addListener((observable, oldValue, newValue) -> { dontShootCount = Integer.parseInt(newValue); stopExercise(); startExercise(); }); bouncingTargetsPane.add(new Label("Don't Shoot Targets:"), 0, 1); bouncingTargetsPane.add(dontShootTargetsComboBox, 1, 1); final ObservableList<String> maxVelocity = FXCollections.observableArrayList(); for (int i = 1; i <= MAX_VELOCITY; i++) maxVelocity.add(Integer.toString(i)); final ComboBox<String> maxVelocityComboBox = new ComboBox<>(maxVelocity); maxVelocityComboBox.getSelectionModel().select(DEFAULT_MAX_VELOCITY - 1); maxVelocityComboBox.valueProperty().addListener((observable, oldValue, newValue) -> { BouncingTargets.maxVelocity = Integer.parseInt(newValue); stopExercise(); startExercise(); }); bouncingTargetsPane.add(new Label("Max Target Speed:"), 0, 2); bouncingTargetsPane.add(maxVelocityComboBox, 1, 2); final CheckBox removeTargets = new CheckBox(); removeTargets.setOnAction((event) -> removeShootTargets = removeTargets.isSelected()); bouncingTargetsPane.add(new Label("Remove Hit Shoot Targets:"), 0, 3); bouncingTargetsPane.add(removeTargets, 1, 3); super.addExercisePane(bouncingTargetsPane); }