use of javafx.scene.input.KeyEvent in project uPMT by coco35700.
the class TypeTreeViewControllerProperty method rename.
@Override
public void rename() {
super.rename();
ChangeListener<Boolean> listener = new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
if (!newPropertyValue) {
if (type.getType().isProperty()) {
String oldName = new String(type.getType().getName());
if (!oldName.equals(textField.getText())) {
boolean hasName = false;
for (Type propriete : type.getParent().getTypes()) {
if (propriete.getName().equals(textField.getText())) {
hasName = true;
break;
}
}
if (!hasName) {
RenamePropertySchemeCommand cmd = new RenamePropertySchemeCommand(type.getRenamePropertyController(), oldName, textField.getText(), main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
} else {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(main._langBundle.getString("invalid_name"));
alert.setHeaderText(null);
alert.setContentText(main._langBundle.getString("properties_name_invalid"));
alert.show();
}
}
}
typePane.setLeft(nomType);
rename.setDisable(false);
textField.focusedProperty().removeListener(this);
}
}
};
textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.ENTER) {
if (type.getType().isProperty()) {
textField.setText(textField.getText());
}
typePane.setLeft(nomType);
rename.setDisable(false);
}
if (event.getCode() == KeyCode.ESCAPE) {
typePane.setLeft(nomType);
rename.setDisable(true);
}
}
});
textField.focusedProperty().addListener(listener);
typePane.setLeft(textField);
Platform.runLater(() -> textField.requestFocus());
Platform.runLater(() -> textField.selectAll());
}
use of javafx.scene.input.KeyEvent in project uPMT by coco35700.
the class InterviewTreeViewController method renameInter.
public void renameInter() {
renameInterview.setDisable(true);
TextField textField = new TextField();
textField.setText(interview.getName());
textField.setMaxWidth(100);
textField.requestFocus();
textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
if (!newPropertyValue) {
nomEntretien.setText(textField.getText());
interview.setName(textField.getText());
interviewPane.setLeft(nomEntretien);
renameInterview.setDisable(false);
}
}
});
textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.ENTER) {
nomEntretien.setText(textField.getText());
interview.setName(textField.getText());
interviewPane.setLeft(nomEntretien);
renameInterview.setDisable(true);
}
if (event.getCode() == KeyCode.ESCAPE) {
interviewPane.setLeft(nomEntretien);
renameInterview.setDisable(true);
}
}
});
interviewPane.setLeft(textField);
Platform.runLater(() -> textField.requestFocus());
Platform.runLater(() -> textField.selectAll());
}
use of javafx.scene.input.KeyEvent in project uPMT by coco35700.
the class TypeTreeViewControllerFolder method rename.
@Override
public void rename() {
super.rename();
ChangeListener<Boolean> listener = new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
if (!newPropertyValue) {
if (type.getType().isFolder()) {
String oldName = new String(type.getType().getName());
if (!oldName.equals(textField.getText())) {
boolean hasName = false;
for (Type folder : type.getParent().getTypes()) {
if (folder.getName().equals(textField.getText())) {
hasName = true;
break;
}
}
if (!hasName) {
RenameFolderSchemeCommand cmd = new RenameFolderSchemeCommand(ref, type.getType().getName(), textField.getText(), main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
} else {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(main._langBundle.getString("invalid_name"));
alert.setHeaderText(null);
alert.setContentText(main._langBundle.getString("folder_name_invalid"));
alert.show();
}
}
}
typePane.setLeft(nomType);
rename.setDisable(false);
textField.focusedProperty().removeListener(this);
}
}
};
textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.ENTER) {
if (type.getType().isProperty()) {
textField.setText(textField.getText());
}
typePane.setLeft(nomType);
rename.setDisable(false);
}
if (event.getCode() == KeyCode.ESCAPE) {
typePane.setLeft(nomType);
rename.setDisable(true);
}
}
});
textField.focusedProperty().addListener(listener);
typePane.setLeft(textField);
Platform.runLater(() -> textField.requestFocus());
Platform.runLater(() -> textField.selectAll());
}
use of javafx.scene.input.KeyEvent in project Board-Instrumentation-Framework by intel.
the class Prompt_InputBox method SetupDialog.
@Override
protected Pane SetupDialog(Stage dialog) {
GridPane root = new GridPane();
root.setHgap(5.0);
root.setVgap(5.0);
root.setPadding(new Insets(5, 5, 2, 5));
Button btn = new Button();
btn.setText("OK");
Label lblMessage = new Label(getMessage());
Label lblSpacer = new Label(" ");
lblMessage.setWrapText(true);
TextField objPrompt = new TextField();
if (null != _PrevVal) {
objPrompt.setText(_PrevVal);
}
root.setAlignment(Pos.CENTER_LEFT);
GridPane.setColumnSpan(lblMessage, 2);
GridPane.setHalignment(btn, HPos.CENTER);
if (getWidth() > 0) {
objPrompt.setPrefWidth(getWidth());
}
if (getHeight() > 0) {
root.setPrefHeight(getHeight());
}
root.add(lblMessage, 0, 0);
root.add(objPrompt, 0, 2);
root.add(btn, 0, 3);
root.add(lblSpacer, 0, 4);
// place on correct screen and center
int xPos = (int) (Configuration.getConfig().getPrimaryScreen().getVisualBounds().getMinX());
int yPos = (int) (Configuration.getConfig().getPrimaryScreen().getVisualBounds().getMinY());
dialog.setX(xPos);
dialog.setY(yPos);
dialog.centerOnScreen();
objPrompt.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
KeyCode kc = ke.getCode();
if (kc.equals(KeyCode.ENTER)) {
SetPromptedValue(objPrompt.getText());
_PrevVal = objPrompt.getText();
dialog.close();
}
}
});
btn.setOnAction((ActionEvent event) -> {
SetPromptedValue(objPrompt.getText());
_PrevVal = objPrompt.getText();
dialog.close();
});
return root;
}
use of javafx.scene.input.KeyEvent in project jabref by JabRef.
the class KeyBindingsDialogViewModelTest method testSetSingleKeyBindingToDefault.
@Test
@Ignore
public void testSetSingleKeyBindingToDefault() {
KeyBindingViewModel viewModel = setKeyBindingViewModel(KeyBinding.ABBREVIATE);
model.selectedKeyBindingProperty().set(viewModel);
KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "C", "C", KeyCode.C, true, true, true, false);
assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent));
model.setNewBindingForCurrent(shortcutKeyEvent);
model.saveKeyBindings();
assertTrue(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent));
viewModel.resetToDefault();
model.saveKeyBindings();
assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent));
}
Aggregations