@SuppressWarnings("unchecked") public void paid(ActionEvent e) { try { StudentJdc jdc = classList.getSelectionModel().getSelectedItem(); Bill bill = new Bill(); bill.setPaid(stringToInt.apply(pay.getText())); bill.setStudentJdc(jdc); Transaction tran = new Transaction(); tran.setIncome(bill.getPaid()); tran.setComment(jdc.toString() + " -> " + jdc.getStudent().getName()); bill.setTransaction(tran); BillBroker.getInstance().persist(bill, Bill.class); // referesh student ApplicationContext.put(CommonList.Student, StudentBroker.getInstance().getAll()); // select student studentList.getItems().clear(); studentList.getItems().addAll((List<Student>) ApplicationContext.get(CommonList.Student)); needToPay.getItems().clear(); needToPay.getItems().addAll(StudentBroker.getInstance().getAllToPaid()); studentList.getSelectionModel().select(jdc.getStudent()); // select class classList.getSelectionModel().select(jdc); } catch (JdcException je) { if (je.isAlert()) showError("Error", je.getMessage()); } }
public void btnRemoveAssistantOrProfessor_Pressed() { if (!listAssistantsOrProfessors.getSelectionModel().isEmpty()) { ObservableList<String> updatedElements = listAssistantsOrProfessors.getItems(); String valueSelected = listAssistantsOrProfessors.getSelectionModel().getSelectedItem(); String rut = valueSelected.split("-")[1]; for (Professor professor : Manager.INSTANCE.professors) { if (rut.equals(professor.getRut())) { if (((Lecture) Manager.INSTANCE.currentEditignICourse) .getProfessors() .contains(professor)) { ((Lecture) Manager.INSTANCE.currentEditignICourse).removeProfessor(professor); updatedElements.remove(valueSelected); listAssistantsOrProfessors.setItems(updatedElements); break; } else { ViewUtilities.showAlert("El profesor no se encuentra registrado en la clase"); break; } } } } else { ViewUtilities.showAlert("Primero debes seleccionar un profesor para quitar"); } }
@Override public void initialize(URL url, ResourceBundle rb) { listView .getSelectionModel() .selectedItemProperty() .addListener( (ObservableValue<? extends String> ov, String oldValue, String newValue) -> { j = listView.getSelectionModel().getSelectedIndex(); if (!fileList.isEmpty()) { statusDisplay.toBack(); file = new File(fileList.get(j).getPath()); String MEDIA_URL = file.toURI().toString(); Media media = new Media(MEDIA_URL); albumCover.setImage(DEFAULT_ALBUM_COVER); media .getMetadata() .addListener( (Change<? extends String, ? extends Object> ch) -> { if (ch.wasAdded()) { handleMetadata(ch.getKey(), ch.getValueAdded()); } }); if (MEDIA_URL.endsWith(".mp3") || MEDIA_URL.endsWith(".MP3")) { playAudio(media); } if (MEDIA_URL.endsWith(".mp4") || MEDIA_URL.endsWith(".MP4")) { playVideo(media); } onPlay(); } }); }
/** * @param event event of button * @throws GroupNotValidException not valid * @throws IDNotValidException not valid * @throws StringNotValidException not valid */ public final void onBtnGroupClick(final ActionEvent event) throws GroupNotValidException, IDNotValidException, StringNotValidException { try { Object item = disabled.getSelectionModel().getSelectedItem(); Button button = (Button) event.getSource(); // add a group if (button.getText().equals("<<")) { if (item.toString().equals("Arbeit")) { INACTIVEDATA.remove(item); ACTIVEDATA.add(item); c.addToGroup(Main.getWorkGroup()); } if (item.toString().equals("Familie")) { INACTIVEDATA.remove(item); ACTIVEDATA.add(item); c.addToGroup(Main.getFamilyGroup()); } if (item.toString().equals("Freunde")) { INACTIVEDATA.remove(item); ACTIVEDATA.add(item); c.addToGroup(Main.getFriendsGroup()); } } // remove a group item = enabled.getSelectionModel().getSelectedItem(); if (button.getText().equals(">>")) { if (item.toString().equals("Arbeit")) { ACTIVEDATA.remove(item); INACTIVEDATA.add(item); c.removeFromGroup(Main.getWorkGroup()); } if (item.toString().equals("Familie")) { ACTIVEDATA.remove(item); INACTIVEDATA.add(item); c.removeFromGroup(Main.getFamilyGroup()); } if (item.toString().equals("Freunde")) { ACTIVEDATA.remove(item); INACTIVEDATA.add(item); c.removeFromGroup(Main.getFriendsGroup()); } } } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Keine gültige Gruppe erkannt."); alert.setHeaderText(""); alert.setContentText("Es wurde keine gültige Gruppe erkannt. Klicke auf gültige Gruppe."); alert.showAndWait(); logger.log(Level.SEVERE, "Error: " + e.getMessage()); } }
private final void addEventHandlers() { movieTitleListView .getSelectionModel() .selectedItemProperty() .addListener((a, b, c) -> movieTitleListViewItemSelected()); duplicateListView .getSelectionModel() .selectedItemProperty() .addListener((a, b, c) -> duplicateListViewItemSelected()); }
@FXML private void Previous(MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY) { statusDisplay.toBack(); if (j == 0) { listView.getSelectionModel().selectLast(); } else { listView.getSelectionModel().selectPrevious(); } } }
@FXML private void Foward(MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY) { statusDisplay.toBack(); if (j == fileList.size() - 1) { listView.getSelectionModel().selectFirst(); } else { listView.getSelectionModel().selectNext(); } } }
@FXML private void handleRoomSelect() { if (!chatrooms.isEmpty() && chatRoomList.getSelectionModel().getSelectedItem().toString() != null) { roomName.setText( "Chatroom: " + chatRoomList.getSelectionModel().getSelectedItem().toString()); connectionManager.joinRoom( model.getClientUser().getUsername(), chatRoomList.getSelectionModel().getSelectedItem().toString()); roomsPane.setExpanded(false); usersPane.setExpanded(true); } }
/** * Updates the GUI sections labels on the left side of the GUI with the currently selected Item */ private void updateOverview() { // check if anything is selected if (!listView.getSelectionModel().isEmpty()) { ItemBox itemBox = listView.getSelectionModel().getSelectedItem(); nameLabel.setText(itemBox.getName()); amountLabel.setText(String.valueOf(itemBox.getAmount()) + "x"); gtinLabel.setText(itemBox.getGtin()); categoriesLabel.setText(itemBox.getCategoriesText("long")); attributesLabel.setText(itemBox.getAttributes()); log.info("Overview set to " + itemBox.getName()); } }
public void createAppointmentsView(User user, AppointmentViewController parentController) { VBox vbox = new VBox(); vbox.setPadding(new Insets(25)); vbox.setSpacing(8); HBox hbox = new HBox(); hbox.setSpacing(10); Text title = new Text("Appoinments"); title.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20)); hbox.getChildren().add(title); Button mainMenuBtn = new Button("Main Menu"); mainMenuBtn.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { parentController.goBack(); } }); hbox.getChildren().add(mainMenuBtn); vbox.getChildren().add(hbox); // Show schedule appointment if patient or HSP staff if (user.getUsertype() == UserType.PATIENT || user.getUsertype() == UserType.HSPSTAFF) { vbox.getChildren().add(addScheduleAppoinment(null, parentController)); } Text subTitle = new Text("Manage/View Appoinments"); title.setFont(Font.font("Tahoma", FontWeight.NORMAL, 15)); vbox.getChildren().add(subTitle); listView = new ListView<String>(); listView.setItems(parentController.getAppoinmentList()); listView .getSelectionModel() .selectedItemProperty() .addListener( (ObservableValue<? extends String> observable, String oldValue, String newValue) -> { System.out.println(newValue); int index = listView.getSelectionModel().getSelectedIndex(); parentController.didSelectItem(index); }); vbox.getChildren().add(listView); createScene(vbox); }
@FXML protected void handleRemoveFromCart(ActionEvent event) { MenuItem selectedItem = orderList.getSelectionModel().getSelectedItem(); if (null != selectedItem) { orderItems.remove(selectedItem); } }
public void initialize() { bookList.setItems(store.books()); bookList.setCellFactory( param -> new ListCell<Book>() { @Override protected void updateItem(Book item, boolean empty) { super.updateItem(item, empty); final String newTitle = Optional.ofNullable(item).map(Book::getTitle).orElse(""); setText(newTitle); } }); bookList .getSelectionModel() .selectedItemProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue != null) { publishAction(new SelectAction(newValue)); } }); }
/** * ListViewでスレッドを選択する。 * * @param messageThread */ public void setSelection(MessageThread messageThread) { for (MessageThread messageThread1 : messageThreadListView.getItems()) { if (messageThread1.getFilename().equals(messageThread.getFilename())) { messageThreadListView.getSelectionModel().select(messageThread1); } } }
@Override protected void deactivate() { paymentAccountsListView .getSelectionModel() .selectedItemProperty() .removeListener(paymentAccountChangeListener); }
@FXML private void initialize() { getChildren().add(list); list.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); list.getSelectionModel() .selectedItemProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue != null) presenter.setBlueprint(newValue); }); list.setCellFactory( e -> { ListCell<Blueprint> cell = new ListCell<Blueprint>() { @Override protected void updateItem(Blueprint item, boolean empty) { super.updateItem(item, empty); if (item != null) { setText(item.getName()); } else { setText(null); setGraphic(null); } } }; return cell; }); }
private void selectDestFolder() { ListItem item = destDirectoryListView.getSelectionModel().getSelectedItem(); Alert confirm = new Alert(AlertType.CONFIRMATION); confirm.setTitle("ファイル移動"); confirm.setHeaderText(item.folder.getDestPath() + " に移動します。"); confirm.setOnCloseRequest( e -> { if (confirm.getResult() == ButtonType.OK) { try { item.folder.moveInto(this.targetFiles); Alert complete = new Alert(AlertType.INFORMATION); complete.setTitle("移動完了"); complete.setHeaderText(this.targetFiles.size() + " 件のファイルを移動しました。"); complete.setContentText("移動先:" + item.folder.getDestPath()); complete.show(); this.clear(); } catch (UncheckedIOException ex) { Alert error = new Alert(AlertType.ERROR); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); TextArea textArea = new TextArea(sw.toString()); error.getDialogPane().setExpandableContent(textArea); error.setContentText("ファイル保存中にエラーが発生しました。"); error.show(); } } }); confirm.show(); }
public void start(Stage stage) { stage.setTitle("ListView demo"); FlowPane rootNode = new FlowPane(10, 10); rootNode.setAlignment(Pos.CENTER); Scene scene = new Scene(rootNode, 200, 120); stage.setScene(scene); responseLabel = new Label("Select Transport Type"); ObservableList<String> transportTypes = FXCollections.observableArrayList("Train", "Car", "Airplane"); ListView<String> transportListView = new ListView(transportTypes); transportListView.setPrefSize(80, 80); MultipleSelectionModel<String> listViewSelectionModel = transportListView.getSelectionModel(); listViewSelectionModel .selectedItemProperty() .addListener( new ChangeListener<String>() { public void changed( ObservableValue<? extends String> changed, String oldValue, String newValue) { responseLabel.setText("Transport selected is " + newValue); } }); rootNode.getChildren().addAll(transportListView, responseLabel); stage.show(); }
@FXML private void Play(MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY) { if (j == 0) { listView.getSelectionModel().select(j); listView.getFocusModel().focus(j); } if (mp != null) { MediaPlayer.Status status = mp.getStatus(); if (status == MediaPlayer.Status.UNKNOWN || status == MediaPlayer.Status.HALTED) { return; } if (status == MediaPlayer.Status.PAUSED || status == MediaPlayer.Status.READY || status == MediaPlayer.Status.STOPPED) { if (atEndOfMedia) { atEndOfMedia = false; } onPlay(); mp.play(); statusDisplay.toBack(); play = true; } else { mp.pause(); statusDisplay.toFront(); play = false; } } } }
// Handler for MenuItem[fx:id="assignOfficialMenuItem"] onAction public void assignOfficial(ActionEvent event) { // TODO add assertions to be sure that no null value are passed to the // controller officialsController.assignOfficialTo( officialsFilteredTableView.getSelectionModel().getSelectedItem(), assigmentsListView.getSelectionModel().getSelectedItem()); }
// Add new account form private void addNewAccount() { paymentAccountsListView.getSelectionModel().clearSelection(); removeAccountRows(); addAccountButton.setDisable(true); accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, "Create new account", Layout.GROUP_DISTANCE); if (paymentMethodForm != null) { FormBuilder.removeRowsFromGridPane(root, 3, paymentMethodForm.getGridRow() + 1); GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1); } gridRow = 2; paymentMethodForm = getPaymentMethodForm(PaymentMethod.BLOCK_CHAINS); if (paymentMethodForm != null) { paymentMethodForm.addFormForAddAccount(); gridRow = paymentMethodForm.getGridRow(); Tuple2<Button, Button> tuple2 = add2ButtonsAfterGroup(root, ++gridRow, "Save new account", "Cancel"); saveNewAccountButton = tuple2.first; saveNewAccountButton.setOnAction( event -> onSaveNewAccount(paymentMethodForm.getPaymentAccount())); saveNewAccountButton.disableProperty().bind(paymentMethodForm.allInputsValidProperty().not()); Button cancelButton = tuple2.second; cancelButton.setOnAction(event -> onCancelNewAccount()); GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1); } }
private void signOutInDB() { checkAllFieldsHandled(); ObservableList<Topics135> selectedTopics = topicsListView.getSelectionModel().getSelectedItems(); ArrayList<Topics135> arrayOfTopics = new ArrayList<>(); if (selectedTopics != null) { for (Topics135 t : selectedTopics) { arrayOfTopics.add(t); } } if (arrayOfTopics.isEmpty()) { arrayOfTopics = null; } // If not in 135, then Level of Learning will be null. Do not insert level of learning in to DB. int levelOfLearningValue = -1; if (levelOfLearning.getValue() != null) { levelOfLearningValue = levelOfLearning.getValue(); } sod = new SignOutData( student.getEmplId(), arrayOfTopics, levelOfLearningValue, theTutor.getValue()); Main.getMdb().signOut(sod); successfulSignOut = true; close(); }
@Inject public PersonListPart(BorderPane parent, final MApplication application) { ListView<Person> view = new ListView<Person>(); view.setCellFactory( new Callback<ListView<Person>, ListCell<Person>>() { public ListCell<Person> call(ListView<Person> arg0) { return new PersonCell(); } }); view.setId("detail-list"); view.getItems().addAll(createList()); view.getSelectionModel() .selectedItemProperty() .addListener( new ChangeListener<Person>() { public void changed( ObservableValue<? extends Person> arg0, Person arg1, Person arg2) { // System.err.println("new value: " + arg2); // System.err.println(application.getContext().hashCode()); application.getContext().set(Person.class, arg2); } }); parent.setCenter(view); }
@FXML private void lvListenerGetEmployeeInfo(MouseEvent event) { try { tabPayCheck.setDisable(true); clearTextFields(); String[] a = lvEmployees.getSelectionModel().getSelectedItem().split("-"); tfInfoId.setText(a[1].trim()); final int ID = Integer.parseInt(tfInfoId.getText()); tfInfoName.setText(Environment.getEmployeeStrInfo(ID, "name")); tfInfoPos.setText(Environment.getEmployeeStrInfo(ID, "position")); tfInfoStreet.setText(Environment.getEmployeeStrInfo(ID, "street")); tfInfoCSZ.setText(Environment.getCityStateZip(ID)); tfInfoPayRate.setText( String.format("%.2f", Double.parseDouble(Environment.getEmployeeStrInfo(ID, "payRate")))); } catch (Exception e) { Alert alert; alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Error Message"); alert.setHeaderText("Whoops you did not select an Employee."); alert.setContentText("Try again."); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { // ... user chose OK } else { // ... user chose CANCEL or closed the dialog } } }
@FXML protected void formationClickedOn(MouseEvent E) { formComposition = FXCollections.observableArrayList( formationList.getSelectionModel().getSelectedItem().getComposition()); currentFormationComposition.setItems(formComposition); }
/** * Sets up the GUI, ensuring that everything is loaded nicely. * * @param location * @param resources */ public void initialize(URL location, ResourceBundle resources) { filter = new Filter(); Set<String> books = new HashSet<>(); for (Book book : Book.values()) { books.add(book.toString()); } filter.setBooks(books); results.setItems(listItems); String index = "java_ebook_search/index"; String home = "/java_ebook_search/view/index.html"; try { search = new Search(index); commonTerms = TextFields.bindAutoCompletion(query, search.getAutocomplete()); commonTerms.setVisibleRowCount(10); sc = new SpellCheck(); webEngine = webView.getEngine(); webEngine.load(getClass().getResource(home).toString()); results .getSelectionModel() .selectedItemProperty() .addListener((observable, oldValue, newValue) -> loadResult(newValue)); } catch (NullPointerException e) { System.out.println("It's happened again, ignore it"); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
public MainScreenView(final MainScreenController controller) { // Setup Job List: listView_jobs.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); // Setup output area: textArea_output.setEditable(false); textArea_output.setFocusTraversable(false); // Set Component Tooltips: button_createJob.setTooltip(new Tooltip("Open the Job creation dialog to create a new Job.")); button_deleteSelectedJobs.setTooltip( new Tooltip("Removes all Jobs that are currently selected on the list.")); button_deleteAllJobs.setTooltip(new Tooltip("Clears the list of all Jobs.")); button_clearOutput.setTooltip(new Tooltip("Clears the output screen.")); button_editSettings.setTooltip(new Tooltip("Open the settings menu.")); button_encode.setTooltip(new Tooltip("Encodes the selected handler(s).")); button_decode.setTooltip( new Tooltip( "Decodes the selected handler(s).\n\n" + "No checking is done to see if the files have ever been encoded,\n" + "so it's up to you to ensure you're decoding the correct files.")); // Set Component EventHandlers: button_createJob.setOnAction(controller); button_encode.setOnAction(controller); button_decode.setOnAction(controller); button_deleteSelectedJobs.setOnAction(controller); button_deleteAllJobs.setOnAction(controller); button_clearOutput.setOnAction(controller); button_editSettings.setOnAction(controller); // Setup the Layout: final HBox panel_left_top = new HBox(10); panel_left_top.setAlignment(Pos.CENTER); panel_left_top .getChildren() .addAll(button_createJob, button_deleteSelectedJobs, button_deleteAllJobs); final HBox panel_left_bottom = new HBox(10); panel_left_bottom.setAlignment(Pos.CENTER); panel_left_bottom.getChildren().addAll(button_encode, button_decode); final VBox panel_left = new VBox(4); HBox.setHgrow(panel_left, Priority.ALWAYS); VBox.setVgrow(listView_jobs, Priority.ALWAYS); panel_left.getChildren().addAll(panel_left_top, listView_jobs, panel_left_bottom); final BorderPane panel_right_bottom = new BorderPane(); panel_right_bottom.setLeft(button_clearOutput); panel_right_bottom.setRight(button_editSettings); final VBox panel_right = new VBox(4); HBox.setHgrow(panel_right, Priority.ALWAYS); VBox.setVgrow(textArea_output, Priority.ALWAYS); panel_right.getChildren().addAll(textArea_output, panel_right_bottom); this.setSpacing(4); this.getChildren().addAll(panel_left, panel_right); }
/** * The main driving force here is to experiment with AnchoredSelectionModel we'll live with the * regression here, since it will be solved correctly in core. */ @Test public void testRT15793() { ListView<String> view = createEmptyView(); int notified = 0; // view.itemsProperty().addListener(o -> {LOG.info("notified");}); // view.itemsProperty().addListener((o, old, value) -> {LOG.info("notified");}); ObservableList<String> emptyList = FXCollections.observableArrayList(); // listView is instantiated with an empty list, so following assumption // is incorrect // assertEquals(null, view.getItems()); view.setItems(emptyList); emptyList.add("something"); view.getSelectionModel().select(0); assertEquals(0, view.getSelectionModel().getSelectedIndex()); emptyList.remove(0); assertEquals(-1, view.getSelectionModel().getSelectedIndex()); }
@FXML private void handleChoosenPerson() { Dokument dokument = lista.getSelectionModel().getSelectedItem(); if (dokument != null) { getDokumentyController().setFields(dokument); } }
@Override protected void activate() { paymentAccountsListView.setItems(model.getPaymentAccounts()); paymentAccountsListView .getSelectionModel() .selectedItemProperty() .addListener(paymentAccountChangeListener); }
private void display() { initModality(Modality.APPLICATION_MODAL); setTitle("Student Review"); setMinWidth(250); setMinHeight(300); signOutButton = new Button("SignOut"); signOutButton.setOnAction(event -> signOutInDB()); buttonHBox = new HBox(signOutButton); buttonHBox.setAlignment(Pos.CENTER_RIGHT); studentInfo = new RegistrationStudentInfoEntryBox(); // Disabling all fields setValue(studentInfo.getEmplIdTextField(), String.valueOf(student.getEmplId())); setValue(studentInfo.getFirstNameTextField(), student.getFirstName()); setValue(studentInfo.getLastNameTextField(), student.getLastName()); studentInfo.getYearChoiceBox().setValue(student.getYear()); studentInfo.getYearChoiceBox().setDisable(true); theTutor = new ChoiceBox<>(); theTutor.getItems().addAll(Tutor.values()); theTutorLabel = new Label("Tutor "); theTutorLayout = new HBox(); theTutorLayout.getChildren().addAll(theTutorLabel, theTutor); is135 = new CheckBox("Discussed 135 Topics? "); is135.setOnAction(event -> handleListView()); // Hidden until is135 is checked levelOfLearning = new ChoiceBox<>(); levelOfLearning.getItems().addAll(1, 2, 3, 4); levelOfLearningLabel = new Label("Level Of Learning "); levelOfLearningLayout = new HBox(); levelOfLearningLayout.getChildren().addAll(levelOfLearningLabel, levelOfLearning); levelOfLearningLayout.setVisible(false); levelOfLearningLayout.setManaged(false); // Hidden until is135 is checked topicsListView = new ListView<>(); topicsListView.getItems().addAll(Topics135.values()); topicsListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); topicsListView.setVisible(false); topicsListView.setManaged(false); vertical135Layout = new VBox(10); vertical135Layout.getChildren().addAll(is135, levelOfLearningLayout, topicsListView); mainVBox = new VBox(20); mainVBox.getChildren().addAll(studentInfo, theTutorLayout, vertical135Layout, buttonHBox); mainVBox.setMargin(vertical135Layout, new Insets(0, 20, 0, 20)); mainVBox.setMargin(buttonHBox, new Insets(20)); mainVBox.setAlignment(Pos.TOP_CENTER); scene = new Scene(mainVBox); setScene(scene); showAndWait(); }