List of usage examples for javafx.scene.control TextInputDialog TextInputDialog
public TextInputDialog()
From source file:gmailclientfx.core.GmailClient.java
public static void authorizeUser() throws IOException { FLOW = new GoogleAuthorizationCodeFlow.Builder(TRANSPORT, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, SCOPES) //.setApprovalPrompt("select_account") .setAccessType("offline").build(); String url = FLOW.newAuthorizationUrl().setRedirectUri(REDIRECT_URI).build(); String txtURI = url + "&prompt=select_account"; String code = ""; if (Desktop.isDesktopSupported()) { try {//from www . j av a 2 s . co m Desktop.getDesktop().browse(new URI(txtURI)); TextInputDialog dialog = new TextInputDialog(); dialog.setTitle("Verifikacija"); dialog.setHeaderText(null); dialog.setContentText("Unesite verifikacijski kod: "); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { code = result.get(); } } catch (URISyntaxException ex) { Logger.getLogger(GmailClient.class.getName()).log(Level.SEVERE, null, ex); System.out.println("Greska prilikom logiranja!"); } } GoogleTokenResponse tokenResponse = FLOW.newTokenRequest(code).setRedirectUri(REDIRECT_URI).execute(); CREDENTIAL = new GoogleCredential.Builder().setTransport(TRANSPORT).setJsonFactory(JSON_FACTORY) .setClientSecrets(CLIENT_ID, CLIENT_SECRET).addRefreshListener(new CredentialRefreshListener() { @Override public void onTokenResponse(Credential credential, TokenResponse tokenResponse) { // Handle success. } @Override public void onTokenErrorResponse(Credential credential, TokenErrorResponse tokenErrorResponse) { // Handle error. } }).build(); CREDENTIAL.setFromTokenResponse(tokenResponse); GMAIL = new Gmail.Builder(TRANSPORT, JSON_FACTORY, CREDENTIAL).setApplicationName("JavaGmailSend").build(); PROFILE = GMAIL.users().getProfile("me").execute(); EMAIL = PROFILE.getEmailAddress(); USER_ID = PROFILE.getHistoryId(); ACCESS_TOKEN = CREDENTIAL.getAccessToken(); REFRESH_TOKEN = CREDENTIAL.getRefreshToken(); /*Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Verifikacija"); alert.setHeaderText(null); alert.setContentText("Uspjena verifikacija!"); alert.showAndWait();*/ }
From source file:eu.over9000.skadi.ui.MainWindow.java
private void setupToolbar(final Stage stage) { this.add = GlyphsDude.createIconButton(FontAwesomeIcons.PLUS); this.addName = new TextField(); this.addName.setOnAction(event -> this.add.fire()); this.add.setOnAction(event -> { final String name = this.addName.getText().trim(); if (name.isEmpty()) { return; }//from w ww . j a va 2 s. co m final boolean result = this.channelHandler.addChannel(name, this.sb); if (result) { this.addName.clear(); } }); this.imprt = GlyphsDude.createIconButton(FontAwesomeIcons.DOWNLOAD); this.imprt.setOnAction(event -> { final TextInputDialog dialog = new TextInputDialog(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(stage); dialog.setTitle("Import followed channels"); dialog.setHeaderText("Import followed channels from Twitch"); dialog.setGraphic(null); dialog.setContentText("Twitch username:"); dialog.showAndWait().ifPresent(name -> { final ImportFollowedService ifs = new ImportFollowedService(this.channelHandler, name, this.sb); ifs.start(); }); }); this.details = GlyphsDude.createIconButton(FontAwesomeIcons.INFO); this.details.setDisable(true); this.details.setOnAction(event -> { this.detailChannel.set(this.table.getSelectionModel().getSelectedItem()); if (!this.sp.getItems().contains(this.detailPane)) { this.sp.getItems().add(this.detailPane); this.doDetailSlide(true); } }); this.details.setTooltip(new Tooltip("Show channel information")); this.remove = GlyphsDude.createIconButton(FontAwesomeIcons.TRASH); this.remove.setDisable(true); this.remove.setOnAction(event -> { final Channel candidate = this.table.getSelectionModel().getSelectedItem(); final Alert alert = new Alert(AlertType.CONFIRMATION); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(stage); alert.setTitle("Delete channel"); alert.setHeaderText("Delete " + candidate.getName()); alert.setContentText("Do you really want to delete " + candidate.getName() + "?"); final Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { this.channelHandler.getChannels().remove(candidate); this.sb.setText("Removed channel " + candidate.getName()); } }); this.refresh = GlyphsDude.createIconButton(FontAwesomeIcons.REFRESH); this.refresh.setTooltip(new Tooltip("Refresh all channels")); this.refresh.setOnAction(event -> { this.refresh.setDisable(true); final ForcedChannelUpdateService service = new ForcedChannelUpdateService(this.channelHandler, this.sb, this.refresh); service.start(); }); this.settings = GlyphsDude.createIconButton(FontAwesomeIcons.COG); this.settings.setTooltip(new Tooltip("Settings")); this.settings.setOnAction(event -> { final SettingsDialog dialog = new SettingsDialog(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(stage); final Optional<StateContainer> result = dialog.showAndWait(); if (result.isPresent()) { this.persistenceHandler.saveState(result.get()); } }); this.onlineOnly = new ToggleButton("Live", GlyphsDude.createIcon(FontAwesomeIcons.FILTER)); this.onlineOnly.setSelected(this.currentState.isOnlineFilterActive()); this.onlineOnly.setOnAction(event -> { this.currentState.setOnlineFilterActive(this.onlineOnly.isSelected()); this.persistenceHandler.saveState(this.currentState); this.updateFilterPredicate(); }); // TODO re-enable if 8u60 is released this.onlineOnly.setDisable(true); this.filterText = new TextField(); this.filterText.textProperty().addListener((obs, oldV, newV) -> this.updateFilterPredicate()); this.filterText.setTooltip(new Tooltip("Filter channels by name, status and game")); // TODO re-enable if 8u60 is released this.filterText.setDisable(true); this.tb = new ToolBar(); this.tb.getItems().addAll(this.addName, this.add, this.imprt, new Separator(), this.refresh, this.settings, new Separator(), this.onlineOnly, this.filterText, new Separator(), this.details, this.remove); this.chatAndStreamButton = new HandlerControlButton(this.chatHandler, this.streamHandler, this.table, this.tb, this.sb); this.updateFilterPredicate(); }
From source file:net.rptools.tokentool.controller.ManageOverlays_Controller.java
@FXML void addFolderButton_onAction(ActionEvent event) { TextInputDialog dialog = new TextInputDialog(); dialog.setTitle(I18N.getString("ManageOverlays.filechooser.folder.title")); dialog.setContentText(I18N.getString("ManageOverlays.filechooser.folder.content_text")); Optional<String> result = dialog.showAndWait(); result.ifPresent(name -> {/*from w w w.ja v a 2 s.co m*/ if (FileSaveUtil.makeDir(name, currentDirectory)) { displayTreeView(); } ; }); }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void saveProfile() { if (logger.isDebugEnabled()) { logger.debug("[SAVE PROFILE]"); }//from w w w .j a v a2s . c o m if (activeConfiguration.activeProfileProperty().isEmpty().get()) { if (logger.isDebugEnabled()) { logger.debug("[SAVE PROFILE] activeProfileName is empty"); } Dialog<String> dialog = new TextInputDialog(); dialog.setTitle("Profile name"); dialog.setHeaderText("Enter profile name"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { String newProfileName = result.get(); if (configurationDS.profileExists(newProfileName)) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Overwrite existing profile?"); alert.setHeaderText("Profile exists"); Optional<ButtonType> response = alert.showAndWait(); if (!response.isPresent() || response.get() != ButtonType.OK) { return; } } activeConfiguration.activeProfileProperty().set(newProfileName); try { recordRecentProfile(newProfileName); // #18 configurationDS.saveProfile(); // saves active profile Stage s = (Stage) sp.getScene().getWindow(); s.setTitle("ResignatorApp - " + newProfileName); needsSave.set(false); addToProfileBrowser(newProfileName); } catch (IOException exc) { logger.error("error saving profile '" + newProfileName + "'", exc); Alert alert = new Alert(Alert.AlertType.ERROR, exc.getMessage()); alert.setHeaderText("Can't save profile"); alert.showAndWait(); } } else { String msg = "A profile name is required"; Alert alert = new Alert(Alert.AlertType.ERROR, msg); alert.setHeaderText("Can't save profile"); alert.showAndWait(); } } else { // just save if (logger.isDebugEnabled()) { logger.debug("[SAVE PROFILE] there is an active profile"); } try { recordRecentProfile(activeProfile.getProfileName()); // #18 configurationDS.saveProfile(); // saves active profile needsSave.set(false); } catch (IOException exc) { logger.error("error saving profile '" + activeConfiguration.activeProfileProperty().get() + "'", exc); Alert alert = new Alert(Alert.AlertType.ERROR, exc.getMessage()); alert.setHeaderText("Can't save profile"); alert.showAndWait(); } } }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void saveAsProfile() { Dialog<String> dialog = new TextInputDialog(); dialog.setTitle("Profile name"); dialog.setHeaderText("Enter profile name"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { ///*w w w. j a v a2s.c om*/ // Check for uniqueness; prompt for overwrite // final String profileName = result.get(); if (profileNameInUse(profileName)) { if (logger.isDebugEnabled()) { logger.debug("[SAVE AS] profile name in use; prompt for overwrite"); } Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Overwrite existing profile '" + profileName + "'?"); alert.setHeaderText("Profile name in use"); Optional<ButtonType> response = alert.showAndWait(); if (!response.isPresent() || response.get() != ButtonType.OK) { if (logger.isDebugEnabled()) { logger.debug("[SAVE AS] overwrite canceled"); } return; } } if (configurationDS.profileExists(profileName)) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Overwrite existing profile?"); alert.setHeaderText("Profile exists"); Optional<ButtonType> response = alert.showAndWait(); if (!response.isPresent() || response.get() != ButtonType.OK) { return; } } activeConfiguration.activeProfileProperty().set(profileName); // activeProfile object tweaked w. new name try { recordRecentProfile(activeProfile.getProfileName()); // #18 configurationDS.saveProfile(); Stage s = (Stage) sp.getScene().getWindow(); s.setTitle("ResignatorApp - " + profileName); needsSave.set(false); addToProfileBrowser(profileName); } catch (IOException exc) { logger.error("error saving profile '" + profileName + "'", exc); Alert alert = new Alert(Alert.AlertType.ERROR, exc.getMessage()); alert.setHeaderText("Can't save profile"); alert.showAndWait(); } } else { String msg = "A profile name is required"; Alert alert = new Alert(Alert.AlertType.ERROR, msg); alert.setHeaderText("Can't save profile"); alert.showAndWait(); } }
From source file:org.sleuthkit.autopsy.timeline.actions.SaveSnapshotAsReport.java
/** * Constructor/*from w w w . j a v a2 s . co m*/ * * @param controller The controller for this timeline action * @param nodeSupplier The Supplier of the node to snapshot. */ @NbBundle.Messages({ "Timeline.ModuleName=Timeline", "SaveSnapShotAsReport.action.dialogs.title=Timeline", "SaveSnapShotAsReport.action.name.text=Snapshot Report", "SaveSnapShotAsReport.action.longText=Save a screen capture of the current view of the timeline as a report.", "# {0} - report file path", "SaveSnapShotAsReport.ReportSavedAt=Report saved at [{0}]", "SaveSnapShotAsReport.Success=Success", "SaveSnapShotAsReport.FailedToAddReport=Failed to add snaphot to case as a report.", "# {0} - report path", "SaveSnapShotAsReport.ErrorWritingReport=Error writing report to disk at {0}.", "# {0} - generated default report name", "SaveSnapShotAsReport.reportName.prompt=leave empty for default report name: {0}.", "SaveSnapShotAsReport.reportName.header=Enter a report name for the Timeline Snapshot Report.", "SaveSnapShotAsReport.duplicateReportNameError.text=A report with that name already exists." }) public SaveSnapshotAsReport(TimeLineController controller, Supplier<Node> nodeSupplier) { super(Bundle.SaveSnapShotAsReport_action_name_text()); setLongText(Bundle.SaveSnapShotAsReport_action_longText()); setGraphic(new ImageView(SNAP_SHOT)); this.controller = controller; this.currentCase = controller.getAutopsyCase(); setEventHandler(actionEvent -> { //capture generation date and use to make default report name Date generationDate = new Date(); final String defaultReportName = FileUtil.escapeFileName(currentCase.getName() + " " + new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss").format(generationDate)); //NON_NLS BufferedImage snapshot = SwingFXUtils.fromFXImage(nodeSupplier.get().snapshot(null, null), null); //prompt user to pick report name TextInputDialog textInputDialog = new TextInputDialog(); PromptDialogManager.setDialogIcons(textInputDialog); textInputDialog.setTitle(Bundle.SaveSnapShotAsReport_action_dialogs_title()); textInputDialog.getEditor() .setPromptText(Bundle.SaveSnapShotAsReport_reportName_prompt(defaultReportName)); textInputDialog.setHeaderText(Bundle.SaveSnapShotAsReport_reportName_header()); //keep prompt even if text field has focus, until user starts typing. textInputDialog.getEditor() .setStyle("-fx-prompt-text-fill: derive(-fx-control-inner-background, -30%);");//NON_NLS /* * Create a ValidationSupport to validate that a report with the * entered name doesn't exist on disk already. Disable ok button if * report name is not validated. */ ValidationSupport validationSupport = new ValidationSupport(); validationSupport.registerValidator(textInputDialog.getEditor(), false, new Validator<String>() { @Override public ValidationResult apply(Control textField, String enteredReportName) { String reportName = StringUtils.defaultIfBlank(enteredReportName, defaultReportName); boolean exists = Files.exists(Paths.get(currentCase.getReportDirectory(), reportName)); return ValidationResult.fromErrorIf(textField, Bundle.SaveSnapShotAsReport_duplicateReportNameError_text(), exists); } }); textInputDialog.getDialogPane().lookupButton(ButtonType.OK).disableProperty() .bind(validationSupport.invalidProperty()); //show dialog and handle result textInputDialog.showAndWait().ifPresent(enteredReportName -> { //reportName defaults to case name + timestamp if left blank String reportName = StringUtils.defaultIfBlank(enteredReportName, defaultReportName); Path reportFolderPath = Paths.get(currentCase.getReportDirectory(), reportName, "Timeline Snapshot"); //NON_NLS Path reportMainFilePath; try { //generate and write report reportMainFilePath = new SnapShotReportWriter(currentCase, reportFolderPath, reportName, controller.getEventsModel().getZoomParamaters(), generationDate, snapshot) .writeReport(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Error writing report to disk at " + reportFolderPath, ex); //NON_NLS new Alert(Alert.AlertType.ERROR, Bundle.SaveSnapShotAsReport_ErrorWritingReport(reportFolderPath)).show(); return; } try { //add main file as report to case Case.getCurrentCase().addReport(reportMainFilePath.toString(), Bundle.Timeline_ModuleName(), reportName); } catch (TskCoreException ex) { LOGGER.log(Level.WARNING, "Failed to add " + reportMainFilePath.toString() + " to case as a report", ex); //NON_NLS new Alert(Alert.AlertType.ERROR, Bundle.SaveSnapShotAsReport_FailedToAddReport()).show(); return; } //notify user of report location final Alert alert = new Alert(Alert.AlertType.INFORMATION, null, OPEN, OK); alert.setTitle(Bundle.SaveSnapShotAsReport_action_dialogs_title()); alert.setHeaderText(Bundle.SaveSnapShotAsReport_Success()); //make action to open report, and hyperlinklable to invoke action final OpenReportAction openReportAction = new OpenReportAction(reportMainFilePath); HyperlinkLabel hyperlinkLabel = new HyperlinkLabel( Bundle.SaveSnapShotAsReport_ReportSavedAt(reportMainFilePath.toString())); hyperlinkLabel.setOnAction(openReportAction); alert.getDialogPane().setContent(hyperlinkLabel); alert.showAndWait().filter(OPEN::equals).ifPresent(buttonType -> openReportAction.handle(null)); }); }); }
From source file:spdxedit.PackageEditor.java
public void handleBtnCopyrightClick(MouseEvent event) { String oldCopyright = currentFile.getCopyrightText(); TextInputDialog dialog = new TextInputDialog(); dialog.setTitle("Copyright"); dialog.setHeaderText("Enter the copyright text"); ((Stage) dialog.getDialogPane().getScene().getWindow()).getIcons() .addAll(UiUtils.ICON_IMAGE_VIEW.getImage()); Optional<String> newCopyrightText = dialog.showAndWait(); if (newCopyrightText.isPresent()) { currentFile.setCopyrightText(newCopyrightText.get()); }/*from ww w . java 2 s . c o m*/ }
From source file:tachyon.view.ProjectProperties.java
public ProjectProperties(JavaProject project, Window w) { this.project = project; stage = new Stage(); stage.initOwner(w);/*from www .j av a 2s. 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:ui.main.MainViewController.java
private void addConversationListener() { conversations.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override/*from w w w .j a v a2 s . c om*/ public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (newValue == null) { chatterName.setText(""); return; } contacts.getSelectionModel().clearSelection(); chatList.getChildren().clear(); chatterName.setText(((HostedRoom) newValue).getName()); chatterPresence.setText("Group Chat"); chatterAvatar.setImage(new Image("resources/guest.png", 100, 100, true, true)); Iterator<GroupChatManager> i = loggedMucs.iterator(); while (i.hasNext()) { GroupChatManager gcm = i.next(); if (gcm.getRoom().equals(((HostedRoom) newValue).getJid())) { currentmuc = gcm.getMuc(); //getConversationHistory(); reloadConversationMessages(gcm.getMsgList()); return; } } try { currentmuc = chatManager.joinRoom(((HostedRoom) newValue).getJid()); loggedMucs.add(new GroupChatManager(currentmuc, getConversationHistory())); } catch (NonAuthorizedException e) { TextInputDialog dialog = new TextInputDialog(); dialog.setTitle("Closed Conference Login"); dialog.setHeaderText("Password Required!"); dialog.setContentText("Password :"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { try { currentmuc = chatManager.joinPrivateRoom(((HostedRoom) newValue).getJid(), result.get()); loggedMucs.add(new GroupChatManager(currentmuc, getConversationHistory())); } catch (NonAuthorizedException ex) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Invalid Password!"); alert.setHeaderText("Conversation cannot be displayed!"); alert.setContentText( "The password for the conversation is incorrect. Please try again!"); alert.showAndWait(); return; } } } ChatsManager.setSelectedConversation(newValue.toString()); isSingleChat = false; hideExtraComButtons(); addConversationMessageListener(); } }); }