List of usage examples for javafx.collections ObservableList add
boolean add(E e);
From source file:staff.Waiter.MenuController.java
@FXML private void onClickgetListButton(ActionEvent e) throws SQLException, IOException { getMenuButton.setDisable(true);//from w w w . j a v a 2 s . com String itemInfo = ""; Statement st = conn.createStatement(); ObservableList<Menu> totallist = menutable.getItems(); ObservableList<Menu> orderlist = FXCollections.observableArrayList(); float tprice = 0; int ttime = 0; String itemDetails = "";//"ITEM NAME PRICE QUANTITY TOTAL\n\n"; for (Menu i : totallist) { if (Integer.parseInt(i.getMquantity()) > 0) { orderlist.add(i); System.out.println("Id:" + i.getMid() + " Item : " + i.getMname() + " Price " + i.getMprice() + " Quantity: " + i.getMquantity()); tprice += (i.getMprice() * Integer.parseInt(i.getMquantity())); String query = "select ttime from menu where d_id='" + i.getMid() + "'"; ResultSet rs = st.executeQuery(query); rs.next(); ttime += (rs.getInt("ttime") * Integer.parseInt(i.getMquantity())); System.out.println("Total time:" + ttime); //itemDetails+=""+i.getMname()+" Rs."+i.getMprice()+" "+i.getMquantity()+" "+(i.getMprice() * Integer.parseInt(i.getMquantity()))+"\n\n"; itemDetails += "Item :" + i.getMname() + " Price :" + i.getMprice() + " Qty :" + i.getMquantity() + " Total :" + (i.getMprice() * Integer.parseInt(i.getMquantity())) + "\n\n"; s[idx++] = i.getMname() + "" + i.getMquantity(); itemInfo += i.getMname() + "" + i.getMquantity() + "-"; } } itemDetails += "TOTAL COST : " + tprice + "\n\n"; int couponGiven = 0; //Checking the validity of coupon if it exists if (!couponTextField.getText().equals("")) { int coupon = Integer.parseInt(couponTextField.getText()); couponGiven = coupon; String q = "select * from coupon where coupon_id='" + coupon + "' "; ResultSet rs1 = st.executeQuery(q); if (rs1.next()) { Alert a = new Alert(Alert.AlertType.CONFIRMATION); a.setTitle("Confirmation"); a.setHeaderText(null); a.setContentText("Great!!Customer has a valid coupon"); a.showAndWait(); float discount = rs1.getFloat("discount_percent"); tprice -= (tprice * discount) / 100; itemDetails += "You have been given a discount of " + discount + "%\n\nFinal Cost : Rs." + tprice + "\n\n"; } else { Alert a = new Alert(Alert.AlertType.ERROR); a.setTitle("Error"); a.setHeaderText(null); a.setContentText("The coupon is not a valid one!!!!"); a.showAndWait(); } } System.out.println("total price:" + tprice); totalPrice.setText("Total bill" + tprice); //Making an entry in `order` table //serialization ByteArrayOutputStream out = new ByteArrayOutputStream(); new ObjectOutputStream(out).writeObject(s); String list = new String(Hex.encodeHex(out.toByteArray())); System.out.println("IN BYTE FORM:" + list); //for unique order_id int counter = 0; //fetching the c_id of the last customer String query = "select * from order_info"; ResultSet rs = st.executeQuery(query); System.out.println("Counter:" + counter); while (rs.next()) { counter = rs.getInt("order_id"); } counter++; System.out.println("Counter:" + counter); String status = "pending"; //PLACING ORDER String q = "insert into order_info (list,table_id,time,status,cost,waiter_id,bill_paid,c_id,coupon_id) values('" + itemInfo + "'," + tableId + "," + ttime + ",'" + status + "'," + tprice + ",'" + wid + "',0," + c_id + "," + couponGiven + ")"; System.out.println("here:" + q); st.executeUpdate(q); //UPDATING TABLE_INFO q = "update table_info set order_taken=1 where t_id=" + tableId + " "; st.executeUpdate(q); //UPDATING `book_and_order q = "insert into book_and_order values(" + tableId + "," + counter + "," + c_id + ")"; st.executeUpdate(q); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 400, 250, Color.WHITE); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);/*from w w w. j a v a2 s. co m*/ gridpane.setVgap(10); ColumnConstraints column1 = new ColumnConstraints(150, 150, Double.MAX_VALUE); ColumnConstraints column2 = new ColumnConstraints(50); ColumnConstraints column3 = new ColumnConstraints(150, 150, Double.MAX_VALUE); column1.setHgrow(Priority.ALWAYS); column3.setHgrow(Priority.ALWAYS); gridpane.getColumnConstraints().addAll(column1, column2, column3); Label candidatesLbl = new Label("Candidates"); GridPane.setHalignment(candidatesLbl, HPos.CENTER); gridpane.add(candidatesLbl, 0, 0); Label selectedLbl = new Label("selected"); gridpane.add(selectedLbl, 2, 0); GridPane.setHalignment(selectedLbl, HPos.CENTER); // Candidates final ObservableList<String> candidates = FXCollections.observableArrayList("Z", "A", "B", "C", "D"); final ListView<String> candidatesListView = new ListView<>(candidates); gridpane.add(candidatesListView, 0, 1); final ObservableList<String> selected = FXCollections.observableArrayList(); final ListView<String> heroListView = new ListView<>(selected); gridpane.add(heroListView, 2, 1); Button sendRightButton = new Button(" > "); sendRightButton.setOnAction((ActionEvent event) -> { String potential = candidatesListView.getSelectionModel().getSelectedItem(); if (potential != null) { candidatesListView.getSelectionModel().clearSelection(); candidates.remove(potential); selected.add(potential); } }); Button sendLeftButton = new Button(" < "); sendLeftButton.setOnAction((ActionEvent event) -> { String s = heroListView.getSelectionModel().getSelectedItem(); if (s != null) { heroListView.getSelectionModel().clearSelection(); selected.remove(s); candidates.add(s); } }); VBox vbox = new VBox(5); vbox.getChildren().addAll(sendRightButton, sendLeftButton); gridpane.add(vbox, 1, 1); root.setCenter(gridpane); GridPane.setVgrow(root, Priority.ALWAYS); primaryStage.setScene(scene); primaryStage.show(); }
From source file:edu.mit.lib.handbag.Controller.java
private void setMetadataList(Workflow wf) { ObservableList<PropertySheet.Item> items = metadataPropertySheet.getItems(); items.clear();//from w ww. ja v a 2s . c o m boolean anyNeeded = false; for (MetadataSpec spec : wf.getMetadata()) { if (!spec.isOptional() && spec.needsValue()) { anyNeeded = true; } items.add(new MetadataItem(spec)); } cleanMetadata = true; completeMetadata = !anyNeeded; }
From source file:com.exalttech.trex.ui.views.importPcap.ImportedPacketTableView.java
/** * Add index to duplicate list/*from w w w. java 2s . c om*/ * @param duplicateIndexesList * @param tableData */ private void addDuplicateIndex(ObservableList<Integer> duplicateIndexesList, ImportPcapTableData tableData) { if (!duplicateIndexesList.contains(tableData.getIndex())) { duplicateIndexesList.add(tableData.getIndex()); } }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 400, 250, Color.WHITE); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);/* w w w . j a v a 2 s . c o m*/ gridpane.setVgap(10); ColumnConstraints column1 = new ColumnConstraints(150, 150, Double.MAX_VALUE); ColumnConstraints column2 = new ColumnConstraints(50); ColumnConstraints column3 = new ColumnConstraints(150, 150, Double.MAX_VALUE); column1.setHgrow(Priority.ALWAYS); column3.setHgrow(Priority.ALWAYS); gridpane.getColumnConstraints().addAll(column1, column2, column3); // Candidates label Label candidatesLbl = new Label("Candidates"); GridPane.setHalignment(candidatesLbl, HPos.CENTER); gridpane.add(candidatesLbl, 0, 0); // Heroes label Label heroesLbl = new Label("Letters"); gridpane.add(heroesLbl, 2, 0); GridPane.setHalignment(heroesLbl, HPos.CENTER); final ObservableList<String> candidates = FXCollections.observableArrayList("A", "B", "C", "D"); final ListView<String> candidatesListView = new ListView<>(candidates); gridpane.add(candidatesListView, 0, 1); final ObservableList<String> heroes = FXCollections.observableArrayList(); final ListView<String> heroListView = new ListView<>(heroes); gridpane.add(heroListView, 2, 1); Button sendRightButton = new Button(" > "); sendRightButton.setOnAction((ActionEvent event) -> { String potential = candidatesListView.getSelectionModel().getSelectedItem(); if (potential != null) { candidatesListView.getSelectionModel().clearSelection(); candidates.remove(potential); heroes.add(potential); } }); Button sendLeftButton = new Button(" < "); sendLeftButton.setOnAction((ActionEvent event) -> { String notHero = heroListView.getSelectionModel().getSelectedItem(); if (notHero != null) { heroListView.getSelectionModel().clearSelection(); heroes.remove(notHero); candidates.add(notHero); } }); // place the buttons VBox vbox = new VBox(5); vbox.setAlignment(Pos.CENTER); vbox.getChildren().addAll(sendRightButton, sendLeftButton); GridPane.setHalignment(vbox, HPos.CENTER); gridpane.add(vbox, 1, 1); // place the grid root.setCenter(gridpane); GridPane.setVgrow(root, Priority.ALWAYS); primaryStage.setScene(scene); primaryStage.show(); }
From source file:staff.Waiter.MenuController.java
@FXML private void onClickgetMenuButton(ActionEvent e) { ObservableList<Menu> list = FXCollections.observableArrayList(); try {//from w w w. j a va 2 s . c o m Statement st = conn.createStatement(); String query = "select * from menu"; ResultSet rs = st.executeQuery(query); int f = 0; while (rs.next()) { f++; Menu a = new Menu(rs.getInt("d_id"), rs.getString("d_name"), rs.getFloat("price"), "0"); list.add(a); } if (f != 0) menutable.getItems().addAll(list); } catch (SQLException ex) { Logger.getLogger(CurrentOrderController.class.getName()).log(Level.SEVERE, null, ex); } getListButton.setDisable(false); couponTextField.setEditable(true); }
From source file:org.nmrfx.processor.gui.RefManager.java
void setupItems(int dim) { ChartProcessor chartProcessor = processorController.chartProcessor; NMRData nmrData = getNMRData();/*from ww w. j a v a 2s . c o m*/ ObservableList<PropertySheet.Item> newItems = FXCollections.observableArrayList(); String dimName = "" + (dim + 1); if (dim == 0) { newItems.add(new TextOperationItem(stringListener, chartProcessor.getDatasetName(), dimName, "dataset", "Enter the name of the dataset")); ArrayList<String> extensionChoices = new ArrayList<>(); extensionChoices.add(".nv"); extensionChoices.add(".ucsf"); newItems.add(new ChoiceOperationItem(stringListener, chartProcessor.getExtension(), extensionChoices, dimName, "extension", "Filename extension (determines dataset type)")); if (nmrData != null) { ArrayList<String> choices = new ArrayList<>(); if (nmrData.getNDim() > 1) { ArrayList<Integer> dimList = new ArrayList<>(); for (int i = 1; i <= (nmrData.getNDim() - 1); i++) { dimList.add(i); } PermutationIterator permIter = new PermutationIterator(dimList); StringBuilder sBuilder = new StringBuilder(); while (permIter.hasNext()) { ArrayList<Integer> permDims = (ArrayList<Integer>) permIter.next(); sBuilder.setLength(0); if (nmrData.getVendor().equals("bruker")) { sBuilder.append(nmrData.getNDim()); } for (Integer iVal : permDims) { sBuilder.append(iVal); } choices.add(sBuilder.toString()); } newItems.add(new EditableChoiceOperationItem(stringListener, chartProcessor.getAcqOrder(), choices, dimName, "acqOrder", "Enter the acquisiton order of the dataset")); } } else { newItems.add(new TextOperationItem(stringListener, chartProcessor.getAcqOrder(), dimName, "acqOrder", "Enter the acquisiton order of the dataset")); } if ((nmrData != null) && nmrData.getVendor().equals("bruker")) { newItems.add(new BooleanOperationItem(boolListener, chartProcessor.getFixDSP(), dimName, "fixdsp", "Fix DSP buildup before FT")); } } //newItems.add(new IntRangeOperationItem(intListener, 3, 0, 5, "op", "opname", "opDesc")); for (String propName : propNames) { if (propName.equals("skip")) { if (dim > 0) { String value = getPropValue(dim, propName, false); boolean boolValue = false; if (value.equals("1")) { boolValue = true; } newItems.add(new BooleanOperationItem(boolListener, boolValue, dimName, propName, "Skip this dimension?")); } } else if (propName.equals("ref")) { String value = getPropValue(dim, propName, false); String defaultValue = getPropValue(dim, propName, true); if (nmrData != null) { if (dim == 0) { defaultValue = nmrData.getRef(0) + ""; } } String comment = " (default is " + defaultValue + ")"; newItems.add(new MenuTextOperationItem(stringListener, value, dimName, propName, "Select the " + propName + comment)); } else if (propName.contains("size")) { String value = getPropValue(dim, propName, false); int iValue = 0; try { iValue = Integer.parseInt(value); } catch (NumberFormatException nFe) { } String defaultValue = getPropValue(dim, propName, true); String comment = " (default is " + defaultValue + ")"; newItems.add(new IntOperationItem(intListener, iValue, 0, 1000000, dimName, propName, "Enter the " + propName + comment)); } else if (propName.equals("acqarray")) { int arraySize = 0; if (nmrData != null) { arraySize = nmrData.getArraySize(dim); } String comment = " (default is " + 0 + ")"; newItems.add(new IntOperationItem(intListener, arraySize, 0, 1000000, dimName, propName, "Enter the " + propName + comment)); } else { String value = getPropValue(dim, propName, false); String defaultValue = getPropValue(dim, propName, true); String comment = " (default is " + defaultValue + ")"; newItems.add(new TextOperationItem(stringListener, value, dimName, propName, "Enter the " + propName + comment)); } } refSheet.getItems().setAll(newItems); }
From source file:com.ggvaidya.scinames.summary.HigherStabilityView.java
public void init() { Project project = projectView.getProject(); // Setup stage. stage.setTitle("Higher taxonomy stability between " + project.getDatasets().size() + " datasets"); // Setup table. controller.getTableEditableProperty().set(false); //controller.setTableColumnResizeProperty(TableView.CONSTRAINED_RESIZE_POLICY); ObservableList<TableColumn> cols = controller.getTableColumnsProperty(); cols.clear();//from www. java 2 s . co m // Precalculating. // Generate list of all dataset columns to search on datasetColumns = project.getDatasets().stream().flatMap(ds -> ds.getColumns().stream()) .collect(Collectors.toSet()); // Set up columns. cols.add(createTableColumnFromPrecalc(precalc, "HigherTaxon")); // One column per dataset for (Dataset ds : project.getDatasets()) { String dsBaseName = ds.getName(); String dsName = dsBaseName; int index = 1; while (datasetNames.containsKey(dsName)) { dsName = dsBaseName + "_" + index; index += 1; } datasetNames.put(dsName, ds); datasetNamesInOrder.add(dsName); cols.add(createTableColumnFromPrecalc(precalc, dsName + "_with_synonymy")); cols.add(createTableColumnFromPrecalc(precalc, dsName + "_without_synonymy")); } // Set table items to an observable list. controller.getTableItemsProperty().set(higherTaxaList); // Set up callbacks so we modify that observable list whenever the user changes the header text. controller.getHeaderTextEditableProperty().set(true); controller.getHeaderTextProperty().set("Enter higher taxonomy column name here, or set blank for genus"); controller.getHeaderTextProperty().addListener(a -> { generateHigherTaxonomyList(controller.getHeaderTextProperty().get()); }); // Start with "" (which means genus) generateHigherTaxonomyList(""); }
From source file:com.ggvaidya.scinames.ui.DatasetDiffController.java
private void addUniqueMaps(ObservableList<DatasetColumn> byUniques) { byUniques.add(DATASET_COLUMN_ALL); byUniques.add(DATASET_COLUMN_NAME_ONLY); byUniques.add(DATASET_COLUMN_BINOMIAL_NAME_CLUSTER); byUniques.add(DATASET_COLUMN_NAME_SPECIFIC_EPITHET); }
From source file:com.ggvaidya.scinames.complexquery.ComplexQueryViewController.java
private void updatePrerecordedQueries() { ObservableList<String> items = prerecordedQueries.getItems(); items.clear();//from www . j a v a 2s . com items.add("Choose one of the pre-recorded queries, or enter your own below:"); prerecordedQueries.getSelectionModel().clearAndSelect(0); }