use of javafx.scene.layout.GridPane in project uPMT by coco35700.
the class MainViewController method initialize.
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
Image image = ResourceLoader.loadImage("momentIcon.png");
this.ajoutMomentButton.setImage(image);
if (!main.getCurrentProject().getInterviews().isEmpty()) {
main.setCurrentDescription(main.getCurrentProject().getInterviews().getFirst());
}
treeViewSchema.setEditable(true);
treeViewInterview.setEditable(true);
treeViewSchema.setCellFactory((TreeView<TypeController> t) -> new TypeTreeView(main));
treeViewInterview.setCellFactory((TreeView<DescriptionInterview> t) -> new InterviewTreeView(main));
TreeItem<TypeController> Schemaroot;
TreeItem<DescriptionInterview> Interviewroot;
Schemaroot = new TreeItem<TypeController>();
Interviewroot = new TreeItem<DescriptionInterview>();
Schemaroot.getChildren().add(SchemaTransformations.SchemaToTreeView(main.getCurrentProject().getSchema()));
Interviewroot.getChildren().add(SchemaTransformations.EntretienToTreeView(main.getCurrentProject().getInterviews()));
treeViewSchema.setRoot(Schemaroot);
treeViewSchema.setShowRoot(false);
treeViewInterview.setRoot(Interviewroot);
treeViewInterview.setShowRoot(false);
main.setTreeViewSchema(treeViewSchema);
main.setTreeViewInterview(treeViewInterview);
if (main.getCurrentDescription() != null) {
// Give time to end initializing the scheme on the left
Platform.runLater(new Runnable() {
@Override
public void run() {
for (DescriptionInterview d : main.getCurrentProject().getInterviews()) {
GridPane gp = new GridPane();
gp.setMinHeight(200);
gp.setPadding(new Insets(100, 0, 0, 0));
addLinesToGrid(gp);
main.setGrid(gp);
MainViewTransformations.loadGridData(gp, main, d);
interviewsPane.put(d, gp);
}
updateGrid();
}
});
}
ajoutMomentButton.setOnDragDetected(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// TODO Auto-generated method stub
if (main.getCurrentDescription() != null) {
Dragboard db = ajoutMomentButton.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
content.putString("ajoutMoment");
content.putRtf("Moment Vide");
db.setContent(content);
}
}
});
if (main.getCurrentDescription() != null)
setDroppableText(main.getCurrentDescription().getDescripteme().getTexte().trim());
paneDragText = new Pane();
paneDragText.setStyle("-fx-background-color:#f4f4f4;");
paneDragText.setCursor(Cursor.MOVE);
paneDragText.setOpacity(0.2);
// Quand on selectionne du texte, on met un panel devant le text pour pouvoir le dragger
droppableText.addEventFilter(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
if (!droppableText.getSelectedText().equals("") && !droppableText.getSelectedText().equals(" ") && !droppableText.getSelectedText().equals("\n"))
stackForDragDrop.getChildren().add(paneDragText);
}
});
// Quand on clique sur la panel qui s'est mit par dessus le texte, on l'enleve pour � nouveau rendre le texte selectionnable
paneDragText.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
droppableText.deselect();
stackForDragDrop.getChildren().clear();
stackForDragDrop.getChildren().add(droppableText);
}
});
// Quand on drag le panel qui s'est mit par dessus le text
paneDragText.setOnDragDetected(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// TODO Auto-generated method stub
if (main.getCurrentDescription() != null) {
Dragboard db = ajoutMomentButton.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
content.putString("ajoutMoment");
content.put(DataFormat.HTML, droppableText.getSelectedText());
db.setContent(content);
}
}
});
buttonTextInterview.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
if (droppableText.isDisabled()) {
buttonTextInterview.setImage(ResourceLoader.loadImage("closeMenuBlack.png"));
droppableText.setDisable(false);
mainSplitPane.setDividerPosition(1, splitPos);
stackForDragDrop.getChildren().add(droppableText);
topBarContainerTextInterview.setCenter(textInterviewTitle);
paneOfTextArea.setMaxWidth(paneOfTextArea.USE_COMPUTED_SIZE);
} else {
buttonTextInterview.setImage(ResourceLoader.loadImage("openMenuBlack.png"));
droppableText.deselect();
droppableText.setDisable(true);
splitPos = mainSplitPane.getDividers().get(1).getPosition();
mainSplitPane.setDividerPosition(1, 1);
stackForDragDrop.getChildren().clear();
topBarContainerTextInterview.setCenter(null);
paneOfTextArea.setMaxWidth(buttonTextInterview.getFitWidth());
}
}
});
}
use of javafx.scene.layout.GridPane in project StegMeister by GaleForce89.
the class StegMeister method showErrorDialog.
private static void showErrorDialog(Throwable e) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Exception Dialog");
alert.setHeaderText("Something went horribly wrong...");
alert.setContentText("Click the button to view");
alert.setResizable(true);
alert.initOwner(getPrimaryStage());
// Create expandable Exception.
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String exceptionText = sw.toString();
Label label = new Label("The exception stacktrace was:");
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.setMaxHeight(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
// Set expandable Exception into the dialog pane.
alert.getDialogPane().setExpandableContent(expContent);
alert.getDialogPane().setPrefWidth(600);
alert.showAndWait();
}
use of javafx.scene.layout.GridPane in project JavaFXLibrary by eficode.
the class TestWindowManagementController method addEmployeeButtonListener.
public void addEmployeeButtonListener() {
Dialog<Employee> dialog = new Dialog<>();
dialog.setTitle("Add employee information");
dialog.setHeaderText("New employee");
Label nameLabel = new Label("Name: ");
Label phoneLabel = new Label("Phone: ");
TextField nameField = new TextField();
TextField phoneField = new TextField();
nameField.setId("nameField");
phoneField.setId("phoneField");
GridPane grid = new GridPane();
grid.add(nameLabel, 1, 1);
grid.add(nameField, 2, 1);
grid.add(phoneLabel, 1, 2);
grid.add(phoneField, 2, 2);
dialog.getDialogPane().setContent(grid);
ButtonType buttonTypeOk = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().add(buttonTypeOk);
dialog.setResultConverter((b) -> {
if (b == buttonTypeOk)
return new Employee(nameField.getText(), phoneField.getText());
return null;
});
Optional<Employee> result = dialog.showAndWait();
if (result.isPresent()) {
Employee employee = result.get();
Label nameCell = new Label(employee.getName());
Label phoneCell = new Label(employee.getPhoneNumber());
nameCell.getStyleClass().add("employeeDataCell");
phoneCell.getStyleClass().add("employeeDataCell");
HBox dataRow = new HBox(nameCell, phoneCell);
dataRow.getStyleClass().add("employeeDataRow");
employeeDataContainer.getChildren().add(dataRow);
}
}
use of javafx.scene.layout.GridPane in project CST-135 by psradke.
the class FinalSale method start.
@Override
public void start(Stage primaryStage) throws Exception {
// Background image
BackgroundImage backImg = new BackgroundImage(new Image("file:src/DispenserDesign/Background&ButtonImages/FinalSalePage/FinalSaleBackground.png", 810, 720, false, true), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
// PANE CREATION
// Home and Back Buttons Pane
GridPane buttons = new GridPane();
buttons.setHgap(10);
buttons.setVgap(10);
buttons.setPadding(new Insets(0, 10, 0, 10));
// TableView Cart Pane
GridPane cartView = new GridPane();
cartView.setHgap(9);
cartView.setVgap(9);
cartView.setOpacity(0.9);
cartView.setPadding(new Insets(0, 10, 0, 10));
// Delete and Purchase Buttons Pane
GridPane buttons2 = new GridPane();
buttons2.setHgap(10);
buttons2.setVgap(10);
buttons2.setPadding(new Insets(0, 10, 0, 10));
// Main Pane for arrangement
VBox vBox = new VBox();
vBox.setPadding(new Insets(10, 10, 10, 10));
vBox.getChildren().addAll(buttons, cartView, buttons2);
// Background Pane
StackPane root = new StackPane();
root.setMaxSize(800, 610);
root.setMinSize(800, 610);
root.setBackground(new Background(backImg));
root.setPadding(new Insets(0, 10, 0, 10));
root.getChildren().add(vBox);
// BUTTON CREATION
// Home Button
Button home = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/NavigationButtons/HomeButton.png")));
home.setBackground(Background.EMPTY);
home.setMaxSize(5, 10);
home.setMinSize(5, 10);
buttons.add(home, 9, 2);
// home.setOnAction(e -> {
// homePage.setScene(scene);
// });
// Back Button
Button back = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/NavigationButtons/BackButton.png")));
back.setBackground(Background.EMPTY);
back.setMaxSize(5, 10);
back.setMinSize(5, 10);
buttons.add(back, 64, 2);
back.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Back");
}
});
// Purchase Button
Button purchase = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/FinalSalePage/Purchase.png")));
purchase.setBackground(Background.EMPTY);
purchase.setMaxSize(5, 10);
purchase.setMinSize(5, 10);
buttons2.add(purchase, 36, 11);
purchase.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Purcahse");
}
});
// Delete Button
// Button delete = new Button("Delete Product");
// delete.setOnAction(e -> deleteClicked());
// CREATE TABLE FOR DISPLAYING CART
TableView<Product> table;
// Name column
TableColumn<Product, String> nameCol = new TableColumn<>("Name");
nameCol.setMinWidth(150);
nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
// Price column
TableColumn<Product, Double> priceCol = new TableColumn<>("Price");
priceCol.setMinWidth(20);
priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
// Weight column
TableColumn<Product, Double> weightCol = new TableColumn<>("Weight");
weightCol.setMinWidth(50);
weightCol.setCellValueFactory(new PropertyValueFactory<>("weight"));
// Quantity column
TableColumn<Product, Double> quantityCol = new TableColumn<>("Quantity");
quantityCol.setMinWidth(20);
quantityCol.setCellValueFactory(new PropertyValueFactory<>("quantity"));
table = new TableView<>();
table.setItems(getProduct());
table.setBackground(Background.EMPTY);
table.setMaxSize(620, 313);
table.setMinSize(620, 313);
table.getColumns().addAll(nameCol, priceCol, weightCol, quantityCol);
cartView.add(table, 7, 18);
Scene scene = new Scene(root, 800, 710);
primaryStage.setTitle("Checkout");
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
}
use of javafx.scene.layout.GridPane in project kanonizo by kanonizo.
the class KanonizoFrame method addParams.
private void addParams(Object alg, GridPane paramLayout, boolean runPrerequisites) {
List<Field> params = Arrays.asList(alg.getClass().getFields()).stream().filter(f -> f.getAnnotation(Parameter.class) != null).collect(Collectors.toList());
int row = 0;
int col = -1;
for (Field param : params) {
if (col + 2 > ITEMS_PER_ROW * 2) {
col = -1;
row++;
}
Label paramLabel = new Label(Util.humanise(param.getName()) + ":");
paramLabel.setAlignment(Pos.CENTER_LEFT);
paramLabel.setTooltip(new Tooltip(Util.humanise(param.getName())));
Control paramField = getParameterField(param, runPrerequisites);
paramField.setTooltip(new Tooltip(param.getAnnotation(Parameter.class).description()));
paramLayout.add(paramLabel, ++col, row, 1, 1);
paramLayout.add(paramField, ++col, row, 1, 1);
if (param.isAnnotationPresent(ConditionalParameter.class)) {
String condition = param.getAnnotation(ConditionalParameter.class).condition();
String[] listensTo = param.getAnnotation(ConditionalParameter.class).listensTo().split(",");
for (String listen : listensTo) {
Util.addPropertyChangeListener(listen, (e) -> {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("nashorn");
try {
Class<?> container = param.getDeclaringClass();
engine.put("CallerClass", container);
engine.eval("var " + container.getSimpleName() + " = CallerClass.static");
boolean cond = (boolean) engine.eval(condition);
paramField.setDisable(!cond);
paramLabel.setDisable(!cond);
} catch (ScriptException ex) {
logger.error(ex);
}
});
}
}
}
}
Aggregations