本文整理匯總了Java中javafx.scene.control.ButtonType.YES屬性的典型用法代碼示例。如果您正苦於以下問題:Java ButtonType.YES屬性的具體用法?Java ButtonType.YES怎麽用?Java ButtonType.YES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javafx.scene.control.ButtonType
的用法示例。
在下文中一共展示了ButtonType.YES屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: closeEditor
private boolean closeEditor(IEditor e) {
if (e == null) {
return true;
}
if (e.isDirty()) {
Optional<ButtonType> result = FXUIUtils.showConfirmDialog(DisplayWindow.this,
"File \"" + e.getName() + "\" Modified. Do you want to save the changes ",
"File \"" + e.getName() + "\" Modified", AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO,
ButtonType.CANCEL);
ButtonType shouldSaveFile = result.get();
if (shouldSaveFile == ButtonType.CANCEL) {
return false;
}
if (shouldSaveFile == ButtonType.YES) {
File file = save(e);
if (file == null) {
return false;
}
EditorDockable dockable = (EditorDockable) e.getData("dockable");
dockable.updateKey();
}
}
return true;
}
示例2: canAppend
public boolean canAppend(File file) {
EditorDockable dockable = findEditorDockable(file);
if (dockable == null) {
return true;
}
if (!dockable.getEditor().isDirty()) {
return true;
}
Optional<ButtonType> result = FXUIUtils.showConfirmDialog(DisplayWindow.this,
"File " + file.getName() + " being edited. Do you want to save the file?", "Save Module", AlertType.CONFIRMATION,
ButtonType.YES, ButtonType.NO);
ButtonType option = result.get();
if (option == ButtonType.YES) {
save(dockable.getEditor());
return true;
}
return false;
}
示例3: delete
@Override public Optional<ButtonType> delete(Optional<ButtonType> option) {
if (!option.isPresent() || option.get() != FXUIUtils.YES_ALL) {
option = FXUIUtils.showConfirmDialog(null, "Do you want to delete `" + group.getName() + "`?", "Confirm",
AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO, FXUIUtils.YES_ALL, ButtonType.CANCEL);
}
if (option.isPresent() && (option.get() == ButtonType.YES || option.get() == FXUIUtils.YES_ALL)) {
try {
Group.delete(type, group);
Event.fireEvent(this, new ResourceModificationEvent(ResourceModificationEvent.DELETE, this));
getParent().getChildren().remove(this);
} catch (Exception e) {
e.printStackTrace();
String message = String.format("Unable to delete: %s: %s%n", group.getName(), e);
FXUIUtils.showMessageDialog(null, message, "Unable to delete", AlertType.ERROR);
}
}
return option;
}
示例4: delete
@Override public Optional<ButtonType> delete(Optional<ButtonType> option) {
if (!option.isPresent() || option.get() != FXUIUtils.YES_ALL) {
option = FXUIUtils.showConfirmDialog(null, "Do you want to delete the entry `" + entry.getName() + "`?", "Confirm",
AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO, FXUIUtils.YES_ALL, ButtonType.CANCEL);
}
if (option.isPresent() && (option.get() == ButtonType.YES || option.get() == FXUIUtils.YES_ALL)) {
GroupResource parent = (GroupResource) getParent();
parent.deleteEntry(this);
try {
Group.updateFile(parent.getSuite());
Event.fireEvent(parent, new ResourceModificationEvent(ResourceModificationEvent.UPDATE, parent));
} catch (IOException e) {
e.printStackTrace();
return option;
}
}
return option;
}
示例5: delete
@Override public Optional<ButtonType> delete(Optional<ButtonType> option) {
if (!option.isPresent() || option.get() != FXUIUtils.YES_ALL) {
option = FXUIUtils.showConfirmDialog(null, "Do you want to delete `" + path + "`?", "Confirm", AlertType.CONFIRMATION,
ButtonType.YES, ButtonType.NO, FXUIUtils.YES_ALL, ButtonType.CANCEL);
}
if (option.isPresent() && (option.get() == ButtonType.YES || option.get() == FXUIUtils.YES_ALL)) {
if (Files.exists(path)) {
try {
Files.delete(path);
Event.fireEvent(this, new ResourceModificationEvent(ResourceModificationEvent.DELETE, this));
getParent().getChildren().remove(this);
} catch (IOException e) {
String message = String.format("Unable to delete: %s: %s%n", path, e);
FXUIUtils.showMessageDialog(null, message, "Unable to delete", AlertType.ERROR);
}
}
}
return option;
}
示例6: delete
@Override public Optional<ButtonType> delete(Optional<ButtonType> option) {
if (!option.isPresent() || option.get() != FXUIUtils.YES_ALL) {
option = FXUIUtils.showConfirmDialog(null, "Do you want to delete the folder `" + path + "` and all its children?",
"Confirm", AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO, FXUIUtils.YES_ALL, ButtonType.CANCEL);
}
if (option.isPresent() && (option.get() == ButtonType.YES || option.get() == FXUIUtils.YES_ALL)) {
if (Files.exists(path)) {
try {
File file = path.toFile();
File[] listFiles = file.listFiles();
option = Copy.delete(path, option);
if (listFiles.length > 0)
for (File f : listFiles) {
Event.fireEvent(this,
new ResourceModificationEvent(ResourceModificationEvent.DELETE, new FileResource(f)));
}
Event.fireEvent(this, new ResourceModificationEvent(ResourceModificationEvent.DELETE, this));
getParent().getChildren().remove(this);
} catch (IOException e) {
String message = String.format("Unable to delete: %s: %s%n", path, e);
FXUIUtils.showMessageDialog(null, message, "Unable to delete", AlertType.ERROR);
}
}
}
return option;
}
示例7: newFile
@FXML
public void newFile() {
Alert closeConfirmation = new Alert(
Alert.AlertType.CONFIRMATION,
"Create a new station?",
ButtonType.YES,
ButtonType.NO
);
closeConfirmation.setHeaderText("New station");
closeConfirmation.initModality(Modality.APPLICATION_MODAL);
closeConfirmation.initOwner(root.getScene().getWindow());
Optional<ButtonType> closeResponse = closeConfirmation.showAndWait();
if (ButtonType.YES.equals(closeResponse.get())) {
station = new Station();
updateEditors();
updateTitle();
}
}
示例8: onClickRestore
/**
* Restores all settings to default. Some settings like {@link Property#DEVELOPMENT} and
* {@link Property#SHOW_CHANGELOG} won't be reset, since the user can't change those anyways.
*/
@SuppressWarnings("static-method") // Can't be static because of FXML injection
@FXML
private void onClickRestore() {
final Alert alert = new Alert(AlertType.CONFIRMATION, Client.lang.getString("sureYouWantToRestoreSettings"), ButtonType.YES, ButtonType.NO);
alert.setTitle(Client.lang.getString("restoreSettingsToDefault"));
Client.insertAlertOwner(alert);
final Optional<ButtonType> result = alert.showAndWait();
result.ifPresent(button -> {
if (button == ButtonType.YES) {
restoreApplicationSettings();
LegacySettingsController.restoreLegacySettings();
// Reapply theme, since it might have been changed
Client.getInstance().applyTheme();
// Assure the view that the displays the correct data.
Client.getInstance().reloadViewIfLoaded(View.SETTINGS);
}
});
}
示例9: show
/**
* Shows the alert
* @return true if the user clicks "Yes", false if otherwise
*/
public boolean show(){
alert.initStyle(style);
alert.setHeaderText("Exit");
setGraphicToError(alert);
Optional<ButtonType> result = alert.showAndWait();
return result.isPresent() && result.get() == ButtonType.YES;
}
示例10: binaryChoiceAlert
/**
* Creates a YES/NO alert (buttons included).
* @param header The alert header message
* @param message The alert body message
* @return An alert dialog with the Yes and No buttons.
*/
public static Alert binaryChoiceAlert(String header, String message) {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Confirm action");
alert.setHeaderText(header);
alert.setContentText(message);
ButtonType[] buttons = new ButtonType[] {
ButtonType.YES,
ButtonType.NO
};
alert.getButtonTypes().setAll(buttons);
return alert;
}
示例11: openDirectory
public static void openDirectory(String headerText, File dir) {
Optional<ButtonType> result = Dialogue.showOption(headerText, ButtonType.YES, ButtonType.NO).showAndWait();
if (result.isPresent()) {
if (result.get() == ButtonType.YES) {
try {
Desktop.getDesktop().open(dir);
} catch (Exception ex) {
Dialogue.showException("Error while trying to view image on desktop.", ex);
}
}
}
}
示例12: deleteSelectedFavourites
private void deleteSelectedFavourites() {
final Alert alert = new Alert(AlertType.CONFIRMATION, Client.lang.getString("sureYouWantToDeleteFavourites"), ButtonType.YES, ButtonType.NO);
Client.insertAlertOwner(alert);
alert.setTitle(Client.lang.getString("deleteFavourites"));
final Optional<ButtonType> result = alert.showAndWait();
result.ifPresent(buttonType -> {
if (buttonType == ButtonType.YES) {
final List<SampServer> serverList = getSelectionModel().getSelectedItems();
serverList.forEach(FavouritesController::removeServerFromFavourites);
servers.removeAll(serverList);
}
});
}
示例13: newGantt
@FXML
public void newGantt() {
if(!gantt.isSaved()) {
ButtonType bt = FXDialog.binaryChoiceAlert("The current project has not been saved. Proceed?").showAndWait().get();
if(bt == ButtonType.YES) {
emptyGantt();
}
}
}
示例14: handleCloseRequest
@Override
protected void handleCloseRequest(WindowEvent event) {
if(!gantt.isSaved()) { // TODO add cancel button
ButtonType bt = FXDialog.binaryChoiceAlert("There are unsaved changes in this project. Save and close?").showAndWait().get();
if(bt == ButtonType.YES) {
saveGantt();
} else {
event.consume();
return;
}
}
storageManager.rememberLastViewed(currentFile);
}
示例15: shutdown
private void shutdown(Stage mainWindow) {
// you could also use your logout window / whatever here instead
Alert alert = new Alert(Alert.AlertType.NONE, "Exit Kanphnia2?", ButtonType.YES, ButtonType.NO);
alert.setTitle("Confirm Exit");
if (alert.showAndWait().orElse(ButtonType.NO) == ButtonType.YES) {
// you may need to close other windows or replace this with Platform.exit();
mainWindow.close();
}
}