use of java.lang.System.Logger.Level.ERROR in project tcMenu by davetcc.
the class NewProjectController method onCreate.
public void onCreate(ActionEvent actionEvent) {
boolean newOnlyMode = newOnlyRadio.isSelected();
if (newOnlyMode) {
if (!passDirtyCheck())
return;
project.newProject();
} else if (maybeDirectory.isPresent() && !StringHelper.isStringEmptyOrNull(projectNameField.getText())) {
if (!passDirtyCheck())
return;
try {
String projName = projectNameField.getText();
var projectCreator = new CreateProjectCommand();
projectCreator.createNewProject(Paths.get(maybeDirectory.get()), projName, cppMainCheckbox.isSelected(), platformCombo.getSelectionModel().getSelectedItem(), s -> logger.log(INFO, s), namespaceField.getText());
Path emfFileName = Paths.get(maybeDirectory.get(), projName, projName + ".emf");
project.openProject(emfFileName.toString());
} catch (Exception e) {
logger.log(ERROR, "Failure processing create new project", e);
var alert = new Alert(Alert.AlertType.ERROR, "Error during create project", ButtonType.CLOSE);
BaseDialogSupport.getJMetro().setScene(alert.getDialogPane().getScene());
alert.showAndWait();
}
} else {
var alert = new Alert(Alert.AlertType.WARNING, "Please ensure all fields are populated", ButtonType.CLOSE);
BaseDialogSupport.getJMetro().setScene(alert.getDialogPane().getScene());
alert.showAndWait();
// avoid closing.
return;
}
Stage stage = (Stage) createButton.getScene().getWindow();
stage.close();
}
use of java.lang.System.Logger.Level.ERROR in project tcMenu by davetcc.
the class PropertiesAuthenticator method addAuthentication.
/**
* Adds an authentication token to the store, it assumes that all appropriate permission from the user has
* been sought.
* @param user the user to add
* @param uuid the uuid associated with the user
* @return
*/
@Override
public CompletableFuture<Boolean> addAuthentication(String user, UUID uuid) {
if (dialogManager == null)
return CompletableFuture.completedFuture(false);
return CompletableFuture.supplyAsync(() -> {
try {
logger.log(INFO, "Request for authentication with " + user);
var shouldProceed = new AtomicBoolean(false);
var dialogLatch = new CountDownLatch(1);
dialogManager.withTitle("Pair with " + user, true).withMessage("Be sure you know where this connection originated", true).withDelegate(DialogViewer.DialogShowMode.REGULAR, menuButtonType -> {
shouldProceed.set(menuButtonType == MenuButtonType.ACCEPT);
dialogLatch.countDown();
return true;
}).showDialogWithButtons(MenuButtonType.ACCEPT, MenuButtonType.CANCEL);
if (!dialogLatch.await(30, TimeUnit.SECONDS)) {
logger.log(INFO, "Dialog Latch timed out without user operation");
}
if (shouldProceed.get()) {
synchronized (properties) {
Path pathLocation = Path.of(location);
properties.setProperty(user, uuid.toString());
properties.store(Files.newBufferedWriter(pathLocation, CREATE, TRUNCATE_EXISTING), "TcMenu Auth properties");
}
logger.log(INFO, "Wrote auth properties to ", location);
return true;
} else {
logger.log(INFO, "Pairing dialog was not accepted");
return false;
}
} catch (Exception e) {
logger.log(ERROR, "Failed to write auth properties to ", location);
return false;
}
});
}
Aggregations