List of usage examples for javafx.scene.control ChoiceDialog ChoiceDialog
public ChoiceDialog(T defaultChoice, Collection<T> choices)
From source file:com.rcs.shoe.shop.fx.controller.ui.Controller.java
protected String showChoiseDialog(String title, String header, String content, List<String> choices, String selected) {/*from ww w .j av a 2 s. c om*/ ChoiceDialog<String> dialog = new ChoiceDialog<>(selected, choices); dialog.setTitle(title); dialog.setHeaderText(header); dialog.setContentText(content); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { return result.get(); } return null; }
From source file:acmi.l2.clientmod.xdat.Controller.java
private MenuItem createAddMenu(String name, TreeView<Object> elements, TreeItem<Object> selected) { ListHolder listHolder = (ListHolder) selected.getValue(); MenuItem add = new MenuItem(name); add.setOnAction(event -> {//from ww w . j av a2 s . c o m Stream<ClassHolder> st = SubclassManager.getInstance().getClassWithAllSubclasses(listHolder.type) .stream().map(ClassHolder::new); List<ClassHolder> list = st.collect(Collectors.toList()); Optional<ClassHolder> choice; if (list.size() == 1) { choice = Optional.of(list.get(0)); } else { ChoiceDialog<ClassHolder> cd = new ChoiceDialog<>(list.get(0), list); cd.setTitle("Select class"); cd.setHeaderText(null); choice = cd.showAndWait(); } choice.ifPresent(toCreate -> { try { IOEntity obj = toCreate.clazz.newInstance(); listHolder.list.add(obj); TreeItem<Object> treeItem = createTreeItem(obj); selected.getChildren().add(treeItem); elements.getSelectionModel().select(treeItem); elements.scrollTo(elements.getSelectionModel().getSelectedIndex()); editor.getHistory().valueCreated(treeItemToScriptString(selected), toCreate.clazz); } catch (ReflectiveOperationException e) { log.log(Level.WARNING, String.format("Couldn't instantiate %s", toCreate.clazz.getName()), e); Dialogs.show(Alert.AlertType.ERROR, "ReflectiveOperationException", null, "Couldn't instantiate " + toCreate.clazz); } }); }); return add; }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void loadProfile() { if (logger.isDebugEnabled()) { logger.debug("[LOAD PROFILE]"); }/* w ww . jav a 2s . co m*/ // // Clear output from last operation // Preconditions.checkArgument(!lblStatus.textProperty().isBound()); lblStatus.setText(""); txtConsole.setText(""); piSignProgress.setProgress(0.0d); piSignProgress.setVisible(false); clearValidationErrors(); // // Get profiles from loaded Configuration object // List<Profile> profiles = configurationDS.getProfiles(); if (CollectionUtils.isEmpty(profiles)) { if (logger.isDebugEnabled()) { logger.debug("[LOAD PROFILE] no profiles"); } String msg = "Select File > Save Profile to save the active profile."; Alert alert = new Alert(Alert.AlertType.INFORMATION, msg); alert.setHeaderText("No profiles saved"); alert.showAndWait(); return; } // // Distill list of profile names from List of Profile objects // List<String> profileNames = profiles.stream().sorted(comparing(Profile::getProfileName)) .map(Profile::getProfileName).collect(toList()); // // Select default item which is active item if available otherwise first item // String defaultProfileName = profileNames.get(0); // // Prompt user for selection - default is first item // if (StringUtils.isNotEmpty(activeConfiguration.activeProfileProperty().getValue())) { defaultProfileName = activeConfiguration.activeProfileProperty().getValue(); } if (logger.isDebugEnabled()) { logger.debug("[LOAD PROFILE] default profileName={}", defaultProfileName); } Dialog<String> dialog = new ChoiceDialog<>(defaultProfileName, profileNames); dialog.setTitle("Profile"); dialog.setHeaderText("Select profile "); Optional<String> result = dialog.showAndWait(); if (!result.isPresent()) { return; // cancel } if (logger.isDebugEnabled()) { logger.debug("[LOAD PROFILE] selected={}", result.get()); } doLoadProfile(result.get()); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param i//www . j a v a 2 s . co m * @param longitude * @param latitude */ private static void afficheHSDiapo(int i, double longitude, double latitude) { double largeur = ivImagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + ivImagePanoramique.getLayoutX(); double Y = (90.0d - latitude) * largeur / 360.0d; Circle circPoint = new Circle(X, Y, 5); circPoint.setFill(Color.TURQUOISE); circPoint.setStroke(Color.ORANGE); circPoint.setId("dia" + i); circPoint.setCursor(Cursor.DEFAULT); panePanoramique.getChildren().add(circPoint); Tooltip tltpHSImage = new Tooltip("Diaporama #" + (i + 1)); tltpHSImage.setStyle(getStrTooltipStyle()); Tooltip.install(circPoint, tltpHSImage); circPoint.setOnDragDetected((mouseEvent1) -> { circPoint.setFill(Color.ORANGE); circPoint.setStroke(Color.TURQUOISE); bDragDrop = true; mouseEvent1.consume(); }); circPoint.setOnMouseDragged((mouseEvent1) -> { double XX = mouseEvent1.getX() - ivImagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > ivImagePanoramique.getFitWidth()) { XX = ivImagePanoramique.getFitWidth(); } circPoint.setCenterX(XX + ivImagePanoramique.getLayoutX()); double YY = mouseEvent1.getY(); if (YY < 0) { YY = 0; } if (YY > ivImagePanoramique.getFitHeight()) { YY = ivImagePanoramique.getFitHeight(); } circPoint.setCenterY(YY); afficheLoupe(XX, YY); mouseEvent1.consume(); }); circPoint.setOnMouseReleased((mouseEvent1) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); int iNumeroPoint = Integer.parseInt(strPoint); double X1 = mouseEvent1.getSceneX(); double Y1 = mouseEvent1.getSceneY(); double mouseX = X1 - ivImagePanoramique.getLayoutX(); if (mouseX < 0) { mouseX = 0; } if (mouseX > ivImagePanoramique.getFitWidth()) { mouseX = ivImagePanoramique.getFitWidth(); } double mouseY = Y1 - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); if (mouseY < 0) { mouseY = 0; } if (mouseY > ivImagePanoramique.getFitHeight()) { mouseY = ivImagePanoramique.getFitHeight(); } double longit, lat; double larg = ivImagePanoramique.getFitWidth(); String strLong, strLat; longit = 360.0f * mouseX / larg - 180; lat = 90.0d - 2.0f * mouseY / larg * 180.0f; getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNumeroPoint).setLatitude(lat); getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNumeroPoint).setLongitude(longit); circPoint.setFill(Color.TURQUOISE); circPoint.setStroke(Color.ORANGE); mouseEvent1.consume(); }); circPoint.setOnMouseClicked((mouseEvent1) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); int iNum = Integer.parseInt(strPoint); Node nodePointDiapo; nodePointDiapo = (Node) panePanoramique.lookup("#dia" + strPoint); if (mouseEvent1.isControlDown()) { valideHS(); setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); panePanoramique.getChildren().remove(nodePointDiapo); for (int io = iNum + 1; io < getiNumDiapo(); io++) { nodePointDiapo = (Node) panePanoramique.lookup("#dia" + Integer.toString(io)); nodePointDiapo.setId("dia" + Integer.toString(io - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); setiNumDiapo(getiNumDiapo() - 1); getPanoramiquesProjet()[getiPanoActuel()].removeHotspotdiapo(iNum); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); mouseEvent1.consume(); } else { if (!bDragDrop) { List<String> choixDiapo1 = new ArrayList<>(); for (int ii = 0; ii < getiNombreDiapo(); ii++) { choixDiapo1.add(diaporamas[ii].getStrNomDiaporama()); } ChoiceDialog<String> dialog1 = new ChoiceDialog<>( diaporamas[getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNum) .getiNumDiapo()].getStrNomDiaporama(), choixDiapo1); dialog1.setTitle(rbLocalisation.getString("main.choixDiapo")); dialog1.setHeaderText(null); dialog1.setContentText(rbLocalisation.getString("main.diapos")); // Traditional way to get the response value. Optional<String> result1 = dialog1.showAndWait(); if (result1.isPresent()) { boolean bTrouve = false; int iTrouve = -1; for (int ii = 0; ii < getiNombreDiapo(); ii++) { if (diaporamas[ii].getStrNomDiaporama().equals(result1.get())) { bTrouve = true; iTrouve = ii; } } if (bTrouve) { retireAffichageHotSpots(); getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNum).setiNumDiapo(iTrouve); valideHS(); ajouteAffichageHotspots(); } } } else { bDragDrop = false; } mouseEvent1.consume(); } }); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param X/*from w w w .jav a 2 s. com*/ * @param Y */ private static void panoAjouteDiaporama(double X, double Y) { if (X > 0 && X < ivImagePanoramique.getFitWidth()) { valideHS(); setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); double mouseX = X; double mouseY = Y - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); double longitude, latitude; double largeur = ivImagePanoramique.getFitWidth(); longitude = 360.0f * mouseX / largeur - 180; latitude = 90.0d - 2.0f * mouseY / largeur * 180.0f; Circle circPoint = new Circle(mouseX + ivImagePanoramique.getLayoutX(), mouseY, 5); circPoint.setFill(Color.TURQUOISE); circPoint.setStroke(Color.ORANGE); circPoint.setId("dia" + getiNumDiapo()); circPoint.setCursor(Cursor.DEFAULT); panePanoramique.getChildren().add(circPoint); Tooltip tltpImage = new Tooltip("Diaporama n " + (getiNumDiapo() + 1)); tltpImage.setStyle(getStrTooltipStyle()); Tooltip.install(circPoint, tltpImage); HotspotDiaporama HS = new HotspotDiaporama(); HS.setLongitude(longitude); HS.setLatitude(latitude); List<String> choixDiapo = new ArrayList<>(); for (int i = 0; i < getiNombreDiapo(); i++) { choixDiapo.add(diaporamas[i].getStrNomDiaporama()); } ChoiceDialog<String> dialog = new ChoiceDialog<>(diaporamas[0].getStrNomDiaporama(), choixDiapo); dialog.setTitle(rbLocalisation.getString("main.choixDiapo")); dialog.setHeaderText(null); dialog.setContentText(rbLocalisation.getString("main.diapos")); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(result.get())) { bTrouve = true; iTrouve = i; } } if (bTrouve) { HS.setiNumDiapo(iTrouve); retireAffichageHotSpots(); getPanoramiquesProjet()[getiPanoActuel()].addHotspotDiapo(HS); setiNumDiapo(getiNumDiapo() + 1); valideHS(); dejaCharge = false; Pane affHS1 = paneAffichageHS(strListePano(), getiPanoActuel()); affHS1.setId("labels"); vbVisuHotspots.getChildren().add(affHS1); spPanneauOutils.setVvalue(spPanneauOutils.getVvalue() + 145); } } circPoint.setOnDragDetected((mouseEvent1) -> { circPoint.setFill(Color.ORANGE); circPoint.setStroke(Color.TURQUOISE); bDragDrop = true; mouseEvent1.consume(); }); circPoint.setOnMouseDragged((mouseEvent1) -> { double XX = mouseEvent1.getX() - ivImagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > ivImagePanoramique.getFitWidth()) { XX = ivImagePanoramique.getFitWidth(); } circPoint.setCenterX(XX + ivImagePanoramique.getLayoutX()); double YY = mouseEvent1.getY(); if (YY < 0) { YY = 0; } if (YY > ivImagePanoramique.getFitHeight()) { YY = ivImagePanoramique.getFitHeight(); } circPoint.setCenterY(YY); afficheLoupe(XX, YY); mouseEvent1.consume(); }); circPoint.setOnMouseReleased((mouseEvent1) -> { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); int iNumeroPoint = Integer.parseInt(strPoint); double X1 = mouseEvent1.getSceneX(); double Y1 = mouseEvent1.getSceneY(); double mouseX1 = X1 - ivImagePanoramique.getLayoutX(); if (mouseX1 < 0) { mouseX1 = 0; } if (mouseX1 > ivImagePanoramique.getFitWidth()) { mouseX1 = ivImagePanoramique.getFitWidth(); } double mouseY1 = Y1 - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); if (mouseY1 < 0) { mouseY1 = 0; } if (mouseY1 > ivImagePanoramique.getFitHeight()) { mouseY1 = ivImagePanoramique.getFitHeight(); } double longit, lat; double larg = ivImagePanoramique.getFitWidth(); longit = 360.0f * mouseX1 / larg - 180; lat = 90.0d - 2.0f * mouseY1 / larg * 180.0f; getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNumeroPoint).setLatitude(lat); getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNumeroPoint).setLongitude(longit); circPoint.setFill(Color.TURQUOISE); circPoint.setStroke(Color.ORANGE); mouseEvent1.consume(); }); circPoint.setOnMouseClicked((mouseEvent1) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); int iNum = Integer.parseInt(strPoint); if (mouseEvent1.isControlDown()) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); Node nodeImage; nodeImage = (Node) panePanoramique.lookup("#dia" + strPoint); panePanoramique.getChildren().remove(nodeImage); for (int io = iNum + 1; io < getiNumDiapo(); io++) { nodeImage = (Node) panePanoramique.lookup("#dia" + Integer.toString(io)); nodeImage.setId("dia" + Integer.toString(io - 1)); Tooltip tltpImage1 = new Tooltip("Diaporama n " + io); tltpImage1.setStyle(getStrTooltipStyle()); Tooltip.install(nodeImage, tltpImage1); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); setiNumDiapo(getiNumDiapo() - 1); getPanoramiquesProjet()[getiPanoActuel()].removeHotspotdiapo(iNum); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); } else { if (!bDragDrop) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); List<String> choixDiapo1 = new ArrayList<>(); for (int i = 0; i < getiNombreDiapo(); i++) { choixDiapo1.add(diaporamas[i].getStrNomDiaporama()); } ChoiceDialog<String> dialog1 = new ChoiceDialog<>( diaporamas[getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNum) .getiNumDiapo()].getStrNomDiaporama(), choixDiapo1); dialog1.setTitle(rbLocalisation.getString("main.choixDiapo")); dialog1.setHeaderText(null); dialog1.setContentText(rbLocalisation.getString("main.diapos")); Optional<String> result1 = dialog1.showAndWait(); if (result1.isPresent()) { boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(result1.get())) { bTrouve = true; iTrouve = i; } } if (bTrouve) { retireAffichageHotSpots(); getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNum) .setiNumDiapo(iTrouve); valideHS(); ajouteAffichageHotspots(); } } } else { bDragDrop = false; } mouseEvent1.consume(); } valideHS(); mouseEvent1.consume(); }); } }
From source file:tachyon.view.ProjectProperties.java
public ProjectProperties(JavaProject project, Window w) { this.project = project; stage = new Stage(); stage.initOwner(w);// ww w.j a v a2s . co m stage.initModality(Modality.APPLICATION_MODAL); stage.setWidth(600); stage.setTitle("Project Properties - " + project.getProjectName()); stage.getIcons().add(tachyon.Tachyon.icon); stage.setResizable(false); HBox mai, libs, one, two, thr, fou; ListView<String> compileList, runtimeList; Button compileAdd, compileRemove, preview, selectIm, runtimeAdd, runtimeRemove; TextField iconField; stage.setScene(new Scene(new VBox(5, pane = new TabPane( new Tab("Library Settings", box1 = new VBox(15, libs = new HBox(10, new Label("External Libraries"), libsView = new ListView<>(), new VBox(5, addJar = new Button("Add Jar"), removeJar = new Button("Remove Jar"))))), new Tab("Program Settings", new ScrollPane(box2 = new VBox(15, one = new HBox(10, new Label("Main-Class"), mainClass = new TextField(project.getMainClassName()), select = new Button("Select")), two = new HBox(10, new Label("Compile-Time Arguments"), compileList = new ListView<>(), new VBox(5, compileAdd = new Button("Add Argument"), compileRemove = new Button("Remove Argument")))))), new Tab("Deployment Settings", box3 = new VBox(15, thr = new HBox(10, new Label("Icon File"), iconField = new TextField(project.getFileIconPath()), preview = new Button("Preview Image"), selectIm = new Button("Select Icon")), fou = new HBox(10, new Label("Runtime Arguments"), runtimeList = new ListView<>(), new VBox(5, runtimeAdd = new Button("Add Argument"), runtimeRemove = new Button("Remove Argument")))))), new VBox(15, mai = new HBox(10, cancel = new Button("Cancel"), confirm = new Button("Confirm")))))); if (applyCss.get()) { stage.getScene().getStylesheets().add(css); } for (Tab b : pane.getTabs()) { b.setClosable(false); } mainClass.setPromptText("Main-Class"); box1.setPadding(new Insets(5, 10, 5, 10)); mai.setAlignment(Pos.CENTER_RIGHT); mai.setPadding(box1.getPadding()); libs.setAlignment(Pos.CENTER); one.setAlignment(Pos.CENTER); two.setAlignment(Pos.CENTER); thr.setAlignment(Pos.CENTER); fou.setAlignment(Pos.CENTER); box1.setAlignment(Pos.CENTER); box2.setPadding(box1.getPadding()); box2.setAlignment(Pos.CENTER); box3.setPadding(box1.getPadding()); box3.setAlignment(Pos.CENTER); mainClass.setEditable(false); mainClass.setPrefWidth(200); for (JavaLibrary lib : project.getAllLibs()) { libsView.getItems().add(lib.getBinaryAbsolutePath()); } for (String sa : project.getCompileTimeArguments().keySet()) { compileList.getItems().add(sa + ":" + project.getCompileTimeArguments().get(sa)); } for (String sa : project.getRuntimeArguments()) { runtimeList.getItems().add(sa); } compileAdd.setOnAction((e) -> { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Compiler Argument"); dialog.initOwner(stage); dialog.setHeaderText("Entry the argument"); ButtonType loginButtonType = new ButtonType("Done", ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField username = new TextField(); username.setPromptText("Key"); TextField password = new TextField(); password.setPromptText("Value"); grid.add(new Label("Key:"), 0, 0); grid.add(username, 1, 0); grid.add(new Label("Value:"), 0, 1); grid.add(password, 1, 1); Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType); loginButton.setDisable(true); username.textProperty().addListener((observable, oldValue, newValue) -> { loginButton.setDisable(newValue.trim().isEmpty()); }); dialog.getDialogPane().setContent(grid); Platform.runLater(() -> username.requestFocus()); dialog.setResultConverter(dialogButton -> { if (dialogButton == loginButtonType) { return new Pair<>(username.getText(), password.getText()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); if (result.isPresent()) { compileList.getItems().add(result.get().getKey() + ":" + result.get().getValue()); } }); compileRemove.setOnAction((e) -> { if (compileList.getSelectionModel().getSelectedItem() != null) { compileList.getItems().remove(compileList.getSelectionModel().getSelectedItem()); } }); runtimeAdd.setOnAction((e) -> { TextInputDialog dia = new TextInputDialog(); dia.setTitle("Add Runtime Argument"); dia.setHeaderText("Enter an argument"); dia.initOwner(stage); Optional<String> res = dia.showAndWait(); if (res.isPresent()) { runtimeList.getItems().add(res.get()); } }); runtimeRemove.setOnAction((e) -> { if (runtimeList.getSelectionModel().getSelectedItem() != null) { runtimeList.getItems().remove(runtimeList.getSelectionModel().getSelectedItem()); } }); preview.setOnAction((e) -> { if (!iconField.getText().isEmpty()) { if (iconField.getText().endsWith(".ico")) { List<BufferedImage> read = new ArrayList<>(); try { read.addAll(ICODecoder.read(new File(iconField.getText()))); } catch (IOException ex) { } if (read.size() >= 1) { Image im = SwingFXUtils.toFXImage(read.get(0), null); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } else if (iconField.getText().endsWith(".icns")) { try { BufferedImage ima = Imaging.getBufferedImage(new File(iconField.getText())); if (ima != null) { Image im = SwingFXUtils.toFXImage(ima, null); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } catch (ImageReadException | IOException ex) { } } else { Image im = new Image(new File(iconField.getText()).toURI().toString()); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } }); selectIm.setOnAction((e) -> { FileChooser fc = new FileChooser(); fc.setTitle("Icon File"); String OS = System.getProperty("os.name").toLowerCase(); fc.getExtensionFilters().add(new ExtensionFilter("Icon File", OS.contains("win") ? getWindowsImageExtensions() : getMacImageExtensions())); fc.setSelectedExtensionFilter(fc.getExtensionFilters().get(0)); File lf = fc.showOpenDialog(stage); if (lf != null) { iconField.setText(lf.getAbsolutePath()); } }); addJar.setOnAction((e) -> { FileChooser f = new FileChooser(); f.setTitle("External Libraries"); f.setSelectedExtensionFilter(new ExtensionFilter("Jar Files", "*.jar")); List<File> showOpenMultipleDialog = f.showOpenMultipleDialog(stage); if (showOpenMultipleDialog != null) { for (File fi : showOpenMultipleDialog) { if (!libsView.getItems().contains(fi.getAbsolutePath())) { libsView.getItems().add(fi.getAbsolutePath()); } } } }); removeJar.setOnAction((e) -> { String selected = libsView.getSelectionModel().getSelectedItem(); if (selected != null) { libsView.getItems().remove(selected); } }); select.setOnAction((e) -> { List<String> all = getAll(); ChoiceDialog<String> di = new ChoiceDialog<>(project.getMainClassName(), all); di.setTitle("Select Main Class"); di.initOwner(stage); di.setHeaderText("Select A Main Class"); Optional<String> show = di.showAndWait(); if (show.isPresent()) { mainClass.setText(show.get()); } }); cancel.setOnAction((e) -> { stage.close(); }); confirm.setOnAction((e) -> { project.setMainClassName(mainClass.getText()); project.setFileIconPath(iconField.getText()); project.setRuntimeArguments(runtimeList.getItems()); HashMap<String, String> al = new HashMap<>(); for (String s : compileList.getItems()) { String[] spl = s.split(":"); al.put(spl[0], spl[1]); } project.setCompileTimeArguments(al); project.setAllLibs(libsView.getItems()); stage.close(); }); }
From source file:utilitybasedfx.MainGUIController.java
@FXML public void eventFileOpen(ActionEvent event) { boolean success = false; boolean projectsFound = false; File files[] = new File(Prefs.getSavePath()).listFiles(); if (files != null) { ArrayList<String> choices = new ArrayList<String>(); for (File f : files) { if (f != null && f.isDirectory()) { choices.add(f.getName()); }// ww w . j a va 2 s. c om } if (!choices.isEmpty()) { ChoiceDialog<String> dialog = new ChoiceDialog<String>(choices.get(0), choices); dialog.setTitle("Open Project"); dialog.setHeaderText("Please choose a project you would like to load"); dialog.setContentText("Project:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { success = true; setActiveProject(result.get()); } projectsFound = true; } } if (!success) { shouldRefreshFileTree = true; } if (!projectsFound) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("No projects found"); alert.setHeaderText("There are no projects found in the following folder"); alert.setContentText(new File(Prefs.getSavePath()).getAbsolutePath()); alert.showAndWait(); } }