Search in sources :

Example 41 with GridPane

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());
            }
        }
    });
}
Also used : MomentAddTypeController(controller.controller.MomentAddTypeController) TypeController(controller.controller.TypeController) MomentRemoveTypeController(controller.controller.MomentRemoveTypeController) TypeTreeView(controller.typeTreeView.TypeTreeView) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) MouseEvent(javafx.scene.input.MouseEvent) ClipboardContent(javafx.scene.input.ClipboardContent) DescriptionInterview(model.DescriptionInterview) Image(javafx.scene.image.Image) StackPane(javafx.scene.layout.StackPane) ScrollPane(javafx.scene.control.ScrollPane) Pane(javafx.scene.layout.Pane) SplitPane(javafx.scene.control.SplitPane) FlowPane(javafx.scene.layout.FlowPane) BorderPane(javafx.scene.layout.BorderPane) GridPane(javafx.scene.layout.GridPane) InterviewTreeView(controller.interviewTreeView.InterviewTreeView) InterviewTreeView(controller.interviewTreeView.InterviewTreeView) TreeView(javafx.scene.control.TreeView) TypeTreeView(controller.typeTreeView.TypeTreeView) Dragboard(javafx.scene.input.Dragboard)

Example 42 with GridPane

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();
}
Also used : GridPane(javafx.scene.layout.GridPane) StringWriter(java.io.StringWriter) TextArea(javafx.scene.control.TextArea) Label(javafx.scene.control.Label) Alert(javafx.scene.control.Alert) PrintWriter(java.io.PrintWriter)

Example 43 with GridPane

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);
    }
}
Also used : HBox(javafx.scene.layout.HBox) GridPane(javafx.scene.layout.GridPane)

Example 44 with GridPane

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();
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) ActionEvent(javafx.event.ActionEvent) BackgroundImage(javafx.scene.layout.BackgroundImage) Image(javafx.scene.image.Image) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) BackgroundImage(javafx.scene.layout.BackgroundImage) Button(javafx.scene.control.Button) ImageView(javafx.scene.image.ImageView) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane)

Example 45 with GridPane

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);
                    }
                });
            }
        }
    }
}
Also used : Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) Arrays(java.util.Arrays) Initializable(javafx.fxml.Initializable) AlertUtils(org.kanonizo.gui.AlertUtils) TestSuite(org.kanonizo.framework.objects.TestSuite) URL(java.net.URL) Control(javafx.scene.control.Control) StackPane(javafx.scene.layout.StackPane) VBox(javafx.scene.layout.VBox) Application(javafx.application.Application) Task(javafx.concurrent.Task) AlertType(javafx.scene.control.Alert.AlertType) ComboBox(javafx.scene.control.ComboBox) ContextMenu(javafx.scene.control.ContextMenu) Method(java.lang.reflect.Method) ScriptException(javax.script.ScriptException) Rectangle2D(javafx.geometry.Rectangle2D) TextField(javafx.scene.control.TextField) SearchAlgorithm(org.kanonizo.algorithms.SearchAlgorithm) MenuItem(javafx.scene.control.MenuItem) Set(java.util.Set) ConditionalParameter(org.kanonizo.annotations.ConditionalParameter) Screen(javafx.stage.Screen) OptionProvider(org.kanonizo.annotations.OptionProvider) Collectors(java.util.stream.Collectors) TreeView(javafx.scene.control.TreeView) InvocationTargetException(java.lang.reflect.InvocationTargetException) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) List(java.util.List) Util(org.kanonizo.util.Util) Logger(org.apache.logging.log4j.Logger) PropertyChangeListener(java.beans.PropertyChangeListener) Modifier(java.lang.reflect.Modifier) Optional(java.util.Optional) Display(org.kanonizo.display.Display) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) Scene(javafx.scene.Scene) MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) MouseEvent(javafx.scene.input.MouseEvent) Framework(org.kanonizo.Framework) ReadableConverter(org.kanonizo.display.fx.converters.ReadableConverter) Parameter(com.scythe.instrumenter.InstrumentationProperties.Parameter) HashSet(java.util.HashSet) ResourceBundle(java.util.ResourceBundle) FXMLLoader(javafx.fxml.FXMLLoader) Prerequisite(org.kanonizo.annotations.Prerequisite) Tooltip(javafx.scene.control.Tooltip) GridPane(javafx.scene.layout.GridPane) DirectoryChooser(javafx.stage.DirectoryChooser) KanonizoFxApplication(org.kanonizo.gui.KanonizoFxApplication) ProgressIndicator(javafx.scene.control.ProgressIndicator) Label(javafx.scene.control.Label) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) ScriptEngineManager(javax.script.ScriptEngineManager) StringConverter(javafx.util.StringConverter) Field(java.lang.reflect.Field) File(java.io.File) GuiUtils(org.kanonizo.gui.GuiUtils) FileChooser(javafx.stage.FileChooser) Condition(java.util.concurrent.locks.Condition) ActionEvent(javafx.event.ActionEvent) ScriptEngine(javax.script.ScriptEngine) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) LogManager(org.apache.logging.log4j.LogManager) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) ScriptEngineManager(javax.script.ScriptEngineManager) ScriptEngine(javax.script.ScriptEngine) TextField(javafx.scene.control.TextField) Field(java.lang.reflect.Field) ScriptException(javax.script.ScriptException) Control(javafx.scene.control.Control) ConditionalParameter(org.kanonizo.annotations.ConditionalParameter) ConditionalParameter(org.kanonizo.annotations.ConditionalParameter) Parameter(com.scythe.instrumenter.InstrumentationProperties.Parameter)

Aggregations

GridPane (javafx.scene.layout.GridPane)170 Label (javafx.scene.control.Label)93 Insets (javafx.geometry.Insets)67 Button (javafx.scene.control.Button)49 VBox (javafx.scene.layout.VBox)47 TextField (javafx.scene.control.TextField)42 Scene (javafx.scene.Scene)36 Text (javafx.scene.text.Text)32 HBox (javafx.scene.layout.HBox)31 Node (javafx.scene.Node)26 ButtonType (javafx.scene.control.ButtonType)25 Dialog (javafx.scene.control.Dialog)23 ColumnConstraints (javafx.scene.layout.ColumnConstraints)23 Stage (javafx.stage.Stage)18 List (java.util.List)17 CheckBox (javafx.scene.control.CheckBox)17 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)17 ImageView (javafx.scene.image.ImageView)14 ColumnConstraintsWithPercentage (org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage)14 IOException (java.io.IOException)13