/** Mètode que s'inicia automaticament al començament */ public void initialize() { setData(city, units); llista.setItems(data); llista.setCellFactory( new Callback<ListView<String>, ListCell<String>>() { @Override public ListCell<String> call(ListView<String> llista) { return new TempsCell(); } }); inicialitzarDialog(); llista.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { String fname = llista.getSelectionModel().getSelectedItem(); String icon = ""; int p = fname.lastIndexOf('#'); if (p >= 0) { icon = fname.substring(0, p); } String[] temps = fname.split("-"); createDialog(icon, temps[1].replace("\t", "")); dialog.show(); } }); }
/** * It's responsible for refreshing the application's task list when the "Refresh" button is * pressed. * * @throws ClassNotFoundException * @throws SQLException * @throws IOException */ @FXML public void refreshList() throws ClassNotFoundException, SQLException, IOException { super.loadShell(); super.loadLog(); lstView.setItems(FXCollections.observableArrayList(shl.mapToSet())); // lstView.setCellFactory(ComboBoxListCell.forListView(FXCollections.observableArrayList(data))); // lstView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); lstView.setEditable(true); lstView.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { System.out.println("clicked on " + lstView.getSelectionModel().getSelectedItem()); shl.setCurrentTab((Task) lstView.getSelectionModel().getSelectedItem()); whatever(); taskName.setText(shl.getCurrentTab().getName()); description.setText(shl.getCurrentTaskDescription()); name.setText(shl.getCurrentTab().getAssignee()); authorname.setText(shl.getCurrentTab().getAuthor()); comment.setText(shl.getCurrentTab().getComment()); lastEditor.setText(shl.getCurrentTab().getLastEditor().getID()); status.setText(statusCheck()); statusV.setText(statusVCheck()); lastEditDate.setText(shl.getCurrentTab().getLastEditDate()); creationDate.setText(shl.getCurrentTab().getCreationDate()); verificationDate.setText(shl.getCurrentTab().getVerificationDate()); completionDate.setText(shl.getCurrentTab().getCompletionDate()); // authorname.setText(shl.getCurrentTab().getAuthor().getName()); if (shl.getCurrentTab().getFileDemo() != null) { fileLabel.setText(shl.getCurrentTab().getFileDemo().toString()); } else fileLabel.setText("No file uploaded"); if (shl.getCurrentTab().isLOCKED()) { comment.setDisable(true); } else comment.setDisable(false); /*if(shl.getCurrentTab().getStatus()==true && shl.getCurrentTab().getStatusV()==true){ set background color green }*/ } }); }
private void populatePopup(List<String> searchResult) { listView = new ListView<>(); listView.setOnMouseClicked( new EventHandler<MouseEvent>() { public void handle(MouseEvent mouseEvent) { ObservableList<String> itemSelecionado = listView.getSelectionModel().getSelectedItems(); String selected = listView.getSelectionModel().getSelectedItem(); setText(selected); popup.hide(); positionCaret(selected.length()); } }); listView.setOnKeyPressed( new EventHandler<KeyEvent>() { public void handle(KeyEvent keyEvent) { if (keyEvent.getCode().equals(KeyCode.ENTER)) { String selected = listView.getSelectionModel().getSelectedItem(); if (selected == null || selected.isEmpty()) { return; } setText(selected); popup.hide(); positionCaret(selected.length()); } else if (keyEvent.getCode().equals(KeyCode.ESCAPE)) { popup.hide(); setText(""); } } }); listView.getItems().clear(); int count = searchResult.size(); for (int i = 0; i < count; i++) { final String result = searchResult.get(i); listView.getItems().add(result); } if ((count * 26) + 10 < maxHeight) { listView.setMaxHeight((count * 26) + 10); } else { listView.setMaxHeight(maxHeight); } listView.setMaxWidth(getWidth()); popup.getContent().clear(); popup.getContent().add(listView); }
@Override public void apply(ListView<JsonNode> list, Relation relation) { list.setOnMouseClicked( event -> { Route route = back.peek().getRoute(relation); if (route == null) { return; } if (!list.getItems().isEmpty() && event.getButton() == MouseButton.PRIMARY && event.getClickCount() >= 2) { JsonNode item = list.getSelectionModel().getSelectedItem(); if (item == null) { return; } try { push(extract(route, item)); } catch (QueryException e) { log.error("Unable to push page: %s", route.getPath(), e); } } }); }
public entryView(Object object) { getChildren().clear(); getStylesheets().add("css/entryView.css"); giveNode(object); BorderPane mainpane = new BorderPane(); BorderPane centerpane = new BorderPane(); BorderPane bottompane = new BorderPane(); GridPane divgrid = new GridPane(); GridPane maingrid = new GridPane(); Label emptylab = new Label(); Label divlab = new Label(); VBox options = new VBox(); VBox tlist = new VBox(); Button ok = new Button("ok"); Periods periods = new Periods(); TList loadteacher = new TList(); DatePicker date = new DatePicker(); BorderPane datepane = new BorderPane(); BorderPane nextpane = new BorderPane(); Button next = new Button("next"); options.setId("options"); tlist.setId("tlist"); divgrid.setId("divgrid"); bottompane.setId("bottompane"); periods.setId("period"); divlab.setId("divlabel"); datepane.setId("datepane"); nextpane.setId("nextpane"); emptylab.setPrefHeight(100); bottompane.setStyle("-fx-background-color:#ecf0f1;"); StringConverter converter = new StringConverter<LocalDate>() { DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); @Override public String toString(LocalDate date) { if (date != null) { return dateFormatter.format(date); } else { return ""; } } @Override public LocalDate fromString(String string) { if (string != null && !string.isEmpty()) { return LocalDate.parse(string, dateFormatter); } else { return null; } } }; date.setConverter(converter); date.setPromptText("dd-MM-yyyy".toLowerCase()); date.setValue(LocalDate.now()); maingrid = div.loadDiv(); list = (ListView) div.takelist(); periods.period(); list.getSelectionModel().select(0); divlab.setText((String) list.getItems().get(0)); list.setOnMouseClicked( e -> { divlab.setText((String) list.getSelectionModel().getSelectedItem()); periods.getChildren().clear(); periods.period(); }); final Node node = maingrid.getChildren().get(0); Platform.runLater( new Runnable() { @Override public void run() { node.requestFocus(); } }); next.setOnAction( e -> { // list.getSelectionModel().getSelectedIndex()+1 list.getSelectionModel().select(list.getSelectionModel().getSelectedIndex() + 1); divlab.setText((String) list.getSelectionModel().getSelectedItem()); }); nextpane.setRight(next); datepane.setRight(date); options.getChildren().clear(); options.getChildren().add(maingrid); divgrid.setHgap(5); // divgrid.add(emptylab, 0, 1); divgrid.add(datepane, 1, 0); divgrid.add(divlab, 0, 2); divgrid.add(periods, 1, 2); divgrid.add(nextpane, 1, 3); divgrid.setAlignment(Pos.TOP_CENTER); mainpane.setCenter(centerpane); mainpane.setLeft(options); mainpane.setRight(loadteacher); centerpane.setCenter(divgrid); centerpane.setBottom(bottompane); bottompane.setRight(ok); addCloseButton cb = new addCloseButton(); cb.addxb(1); setTop(cb); setCenter(mainpane); }