Java 类javafx.scene.control.Control 实例源码

项目:marathonv5    文件:SearchBoxSample.java   
public SearchBox() {
    setId("SearchBox");
    getStyleClass().add("search-box");
    setMinHeight(24);
    setPrefSize(200, 24);
    setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
    textBox = new TextField();
    textBox.setPromptText("Search");
    clearButton = new Button();
    clearButton.setVisible(false);
    getChildren().addAll(textBox, clearButton);
    clearButton.setOnAction(new EventHandler<ActionEvent>() {                
        @Override public void handle(ActionEvent actionEvent) {
            textBox.setText("");
            textBox.requestFocus();
        }
    });
    textBox.textProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            clearButton.setVisible(textBox.getText().length() != 0);
        }
    });
}
项目:marathonv5    文件:SearchBoxSample.java   
public SearchBox() {
    setId("SearchBox");
    getStyleClass().add("search-box");
    setMinHeight(24);
    setPrefSize(200, 24);
    setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
    textBox = new TextField();
    textBox.setPromptText("Search");
    clearButton = new Button();
    clearButton.setVisible(false);
    getChildren().addAll(textBox, clearButton);
    clearButton.setOnAction(new EventHandler<ActionEvent>() {                
        @Override public void handle(ActionEvent actionEvent) {
            textBox.setText("");
            textBox.requestFocus();
        }
    });
    textBox.textProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            clearButton.setVisible(textBox.getText().length() != 0);
        }
    });
}
项目:uPMT    文件:AddMomentCommand.java   
@Override
public void execute() {
    momentExpPane.showMoment();
    main.getCurrentDescription().addMomentExp(momentExpPane.getMoment());

    if(momentExpPane.getCol() == main.getCurrentDescription().getNumberCols()-1){
        MomentExpVBox mb = new MomentExpVBox(main, true);
        MainViewTransformations.addMomentExpBorderPaneListener(mb, main);
        ColumnConstraints c = new ColumnConstraints();
        c.setMinWidth(180);
        c.setPrefWidth(Control.USE_COMPUTED_SIZE);
        c.setMaxWidth(Control.USE_COMPUTED_SIZE);
        // add a new col and the borderPane
        main.getGrid().getColumnConstraints().add(c);
        main.getGrid().add(mb,main.getCurrentDescription().getNumberCols(), 0);
        // increase the number of col by one
        main.getCurrentDescription().setNumberCols(main.getCurrentDescription().getNumberCols()+1);
    }
    main.needToSave();
}
项目:Gargoyle    文件:CommonsContextMenu.java   
/**
 * 컨텍스트 메뉴 추가.
 *
 * @Date 2015. 10. 14.
 * @param tableView
 * @param mode
 *            Menus 클래스 참고
 * @return
 * @User KYJ
 */
public static void addMenus(Control node, int mode) {
    ContextMenu contextMenu = new ContextMenu();

    if (Menus.isAdd(mode)) {
        contextMenu.getItems().add(addMenuEvent(node));
    }

    if (Menus.isDelete(mode)) {
        contextMenu.getItems().add(deleteMenuEvent(node));
    }

    if (Menus.isUp(mode)) {
        contextMenu.getItems().add(upMenuEvent(node));
    }

    if (Menus.isDown(mode)) {
        contextMenu.getItems().add(downMenuEvent(node));
    }

    node.setContextMenu(contextMenu);
}
项目:openjfx-8u-dev-tests    文件:TextFieldApp.java   
@Override
protected TestNode setup() {
    super.setup();

    Integer[] counts = new Integer[] {0, 5, 10, 20};
    setupInteger(Pages.PrefColumnCount.name(), counts);

    String[] texts = new String[] {"", "new text"};
    setupString(Pages.PromptText.name(), texts);

    TestNode nodes[] = new TestNode[Pos.values().length];
    for (int i = 0; i < Pos.values().length; i++) {
        nodes[i] = new StandardObjectSetterNode(Pages.Alignment.name(), Pos.values()[i]) {
            @Override
            protected Object create() {
                Control node = (Control)super.create();
                node.setMinSize(SLOT_WIDTH - 10, SLOT_HEIGHT - 10);
                return node;
            }
        };
    }
    pageSetup(Pages.Alignment.name(), nodes, Pos.values());

    return rootTestNode;
}
项目:openjfx-8u-dev-tests    文件:TreeViewCommonFunctionality.java   
protected static void clickOnFirstCell(final Wrap<? extends Control> testedControl) {
    String item = new GetAction<String>() {
        @Override
        public void run(Object... os) throws Exception {
            TreeItem root;
            Control control = testedControl.getControl();
            if (control instanceof TreeView) {
                root = ((TreeView) control).getRoot();
            } else {
                root = ((TreeTableView) control).getRoot();
            }
            setResult(root.getValue().toString());
        }
    }.dispatch(Root.ROOT.getEnvironment(), testedControl);
    Wrap<Text> cellWrap = getCellWrap(testedControl, item);
    cellWrap.as(Showable.class).shower().show();
    cellWrap.mouse().click(1, cellWrap.getClickPoint(), Mouse.MouseButtons.BUTTON1);
}
项目:openjfx-8u-dev-tests    文件:TreeViewCommonFunctionality.java   
protected static Wrap<Text> getCellWrap(final Wrap<? extends Control> testedControl, final Integer index) {
    final String content = new GetAction<String>() {
        @Override
        public void run(Object... os) throws Exception {
            Control control = testedControl.getControl();
            TreeItem item;
            if (control instanceof TreeView) {
                item = ((TreeView) control).getTreeItem(index);
            } else {
                item = ((TreeTableView) control).getTreeItem(index);
            }
            setResult(item.getValue().toString());
        }
    }.dispatch(Root.ROOT.getEnvironment());

    scrollTo(testedControl, 0, index);

    return getCellWrap(testedControl, content);
}
项目:openjfx-8u-dev-tests    文件:TreeViewCommonFunctionality.java   
protected static Wrap<Text> getCellWrap(final Wrap<? extends Control> testedControl, final String item) {
    final Lookup lookup = testedControl.as(Parent.class, Object.class).lookup(
            new LookupCriteria<Object>() {
                @Override
                public boolean check(Object cell_item) {
                    return cell_item.toString().equals(item);
                }
            });
    testedControl.waitState(new State<Boolean>() {
        public Boolean reached() {
            if (lookup.size() >= 0) {
                return true;
            } else {
                return null;
            }
        }
    });
    return lookup.wrap();
}
项目:openjfx-8u-dev-tests    文件:TreeViewCommonFunctionality.java   
protected static HashSet<Point> getSelected(final Wrap<? extends Control> testedControl) {

        return new GetAction<HashSet<Point>>() {
            @Override
            public void run(Object... parameters) throws Exception {
                HashSet<Point> selected = new HashSet<Point>();
                final Control control = testedControl.getControl();
                MultipleSelectionModel model;
                if (control instanceof TreeView) {
                    model = ((TreeView) control).getSelectionModel();
                } else {
                    model = ((TreeTableView) control).getSelectionModel();
                }
                for (Object obj : model.getSelectedIndices()) {
                    Integer pos = (Integer) obj;
                    selected.add(new Point(-1, pos));
                }
                setResult(selected);
            }
        }.dispatch(Root.ROOT.getEnvironment());
    }
项目:openjfx-8u-dev-tests    文件:ApplicationInteractionFunctions.java   
protected Collection<TableColumnBase> getTopLevelColumns() {
    return new GetAction<Collection<TableColumnBase>>() {

        @Override
        public void run(Object... parameters) throws Exception {
            Collection<TableColumnBase> cols;
            Control control = testedControl.getControl();

            if (isTableTests) {
                cols = ((TableView) control).getColumns();
            } else {
                cols = ((TreeTableView) control).getColumns();
            }
            setResult(cols);
        }
    }.dispatch(testedControl.getEnvironment());
}
项目:openjfx-8u-dev-tests    文件:TestBaseCommon.java   
private static AbstractScroll getScroll(final Wrap<? extends Control> testedControl, final boolean vertical) {
    Lookup<ScrollBar> lookup = testedControl.as(Parent.class, Node.class).lookup(ScrollBar.class,
            new LookupCriteria<ScrollBar>() {
                @Override
                public boolean check(ScrollBar control) {
                    return control.isVisible() && (control.getOrientation() == Orientation.VERTICAL) == vertical;
                }
            });
    int count = lookup.size();
    if (count == 0) {
        return null;
    } else if (count == 1) {
        return lookup.as(AbstractScroll.class);
    } else {
        return null;
    }
}
项目:openjfx-8u-dev-tests    文件:TestBaseCommon.java   
protected static Range getVisibleRange(final Wrap<? extends Control> testedControl) {
    int[] visibleIndices;

    if (testedControl.getControl() instanceof TableView) {
        visibleIndices = org.jemmy.fx.control.TableUtils.shown(
                testedControl.getEnvironment(),
                testedControl,
                new org.jemmy.fx.control.TableUtils.TableViewIndexInfoProvider((TableViewWrap) testedControl), TableCell.class);
    } else {
        visibleIndices = org.jemmy.fx.control.TableUtils.shown(
                testedControl.getEnvironment(),
                testedControl,
                new org.jemmy.fx.control.TableUtils.TreeTableViewIndexInfoProvider((TreeTableViewWrap) testedControl), TreeTableCell.class);
    }

    return new Range(visibleIndices[1], visibleIndices[3]);
}
项目:openjfx-8u-dev-tests    文件:TreeTableCellsTest.java   
@Test(timeout = 30000)
public void progressBarCellFactoryTest() {
    doFactoryChange(CellType.ProgressBar);
    final Lookup lookup = testedControl.as(Parent.class, Node.class).lookup(new LookupCriteria() {
        public boolean check(Object cntrl) {
            if (cntrl instanceof ProgressBar) {
                //Some cells are created for caching purposes, ignore them.
                if (!((Control) cntrl).getParent().getParent().getParent().isVisible()
                        || !((Control) cntrl).getParent().getParent().isVisible()
                        || !((Control) cntrl).getParent().isVisible()) {
                    return false;
                }
                return true;
            }
            return false;
        }
    });
    Wrap<? extends ProgressBar> progressBar = lookup.wrap();
    assertEquals("Initial value is incorrect", getProgressBarValue(progressBar), 0.5, 0.0001);
    changeProgressValues(0.75);
    assertEquals("Initial value is incorrect", getProgressBarValue(progressBar), 0.75, 0.0001);
    assertEquals("Amount of progress bars", lookup.size(), DATA_ITEMS_SIZE);
}
项目:openjfx-8u-dev-tests    文件:SceneOnOtherThreadTest.java   
@Test(timeout = 2000)
public void testSceneCreationOnNonFxThread() throws InterruptedException {
    Stage stage = SimpleApp.getStage();
    int centerX = (int)(stage.getX() + stage.getWidth() / 2);
    int centerY = (int)(stage.getY() + stage.getHeight() / 2);
    Control area = new TextField("");
    area.setStyle("-fx-background-color: #ff0000;");
    area.setMinWidth(stage.getWidth());
    area.setMinHeight(stage.getHeight());
    Scene newScene = new Scene(area);
    Platform.runLater(() -> {
        stage.setScene(newScene);
    });
    Utils.waitFor(() -> stage.getScene() == newScene);
    Robot glassRobot  = GlassInputFactory.getRobot();
    Utils.waitFor(() -> {
        AtomicInteger color = new AtomicInteger();
        Platform.runLater(() -> {
            color.set(glassRobot.getPixelColor(centerX, centerY));
        });
        while (color.get() == 0) {}
        Color c = new Color(color.get(), true);
        return Color.RED.equals(c);
    });
}
项目:openjfx-8u-dev-tests    文件:TestBaseBase.java   
protected void clickTextButton(String name) {
    /**
     * new ControlDock because there is no ButtonDock Yet.
     */
    final ControlWrap<? extends Control> label =
            new ControlDock(scene.as(Parent.class, Node.class), name).wrap();
    label.mouse().move();
    Utils.deferAction(new Runnable() {
        public void run() {
            EventHandler<? super MouseEvent> hndlr = label.getControl().getOnMouseClicked();
            if (null == hndlr) {
                hndlr = label.getControl().getOnMousePressed();
            }
            hndlr.handle(null);
        }
    });
}
项目:cd2t-100    文件:InstructionsController.java   
private Pane createInstructionItem(InstructionDescriptor descriptor) {
  Label opcodeLabel = new Label(descriptor.getOpcode());
  opcodeLabel.setAlignment(Pos.TOP_LEFT);

  Label descriptionLabel = new Label(descriptor.getDescription());
  descriptionLabel.setAlignment(Pos.TOP_LEFT);
  descriptionLabel.setWrapText(true);
  descriptionLabel.setMaxHeight(Double.MAX_VALUE);
  descriptionLabel.setMaxWidth(Double.MAX_VALUE);

  VBox dataBox = new VBox(5.0);

  dataBox.getChildren().addAll(opcodeLabel, descriptionLabel);

  HBox root = new HBox(10.0, dataBox);
  root.setPrefHeight(85);
  root.setPadding(new Insets(10.0));
  root.setHgrow(dataBox, Priority.ALWAYS);
  root.setMinHeight(Control.USE_PREF_SIZE);

  return root;
}
项目:qupath    文件:PanelToolsFX.java   
/**
 * Create a GridPane containing columns that resize similarly to Swing's GridLayout(),
 * where controls have their widths bound to their parent.
 * 
 * @param nodes
 * @return
 */
public static GridPane createColumnGridControls(final Node... nodes) {
    GridPane pane = new GridPane();
    int n = nodes.length;
    double maxMinWidth = 0;
    for (int i = 0; i < n; i++) {
        ColumnConstraints col = new ColumnConstraints();
        col.setPercentWidth(100.0/n);           
        pane.getColumnConstraints().add(col);
        Node node = nodes[i];
        pane.add(node, i, 0);
        if (node instanceof Control) {
            maxMinWidth = Math.max(maxMinWidth, ((Control)node).getPrefWidth());
            ((Control)node).prefWidthProperty().bind(pane.widthProperty().divide(n));
        }
    }
    RowConstraints row = new RowConstraints();
    row.setPercentHeight(100);
    pane.getRowConstraints().add(row);
    pane.setMinWidth(maxMinWidth * n);
    pane.setPrefWidth(maxMinWidth * n);
    return pane;
}
项目:qupath    文件:PanelToolsFX.java   
/**
     * Create a GridPane containing columns that resize similarly to Swing's GridLayout(),
     * while also resizing contained objects to have the corresponding widths.
     * 
     * @param nodes
     * @return
     */
    public static GridPane createRowGridControls(final Node... nodes) {
        GridPane pane = new GridPane();
        int n = nodes.length;
        for (int i = 0; i < n; i++) {
            RowConstraints row = new RowConstraints();
            row.setPercentHeight(100.0/n);          
            pane.getRowConstraints().add(row);
            Node node = nodes[i];
            pane.add(node, 0, i);
            if (node instanceof Control) {
//              ((Control)node).setMinSize(((Control) node).getPrefWidth(), ((Control) node).getPrefHeight());
                ((Control)node).prefWidthProperty().bind(pane.widthProperty());
            }
        }
        ColumnConstraints col = new ColumnConstraints();
        col.setPercentWidth(100);
        pane.getColumnConstraints().add(col);
        return pane;
    }
项目:qupath    文件:PathAnnotationPanel.java   
/**
 * Binds the width properties to the GridPane width.
 * 
 * @param controls
 * @return
 */
public static GridPane createColumnGridControls(final Control... controls) {
    GridPane pane = new GridPane();
    int n = controls.length;
    for (int i = 0; i < n; i++) {
        ColumnConstraints col = new ColumnConstraints();
        col.setPercentWidth(100.0/n);           
        pane.getColumnConstraints().add(col);
        Control control = controls[i];
        pane.add(control, i, 0);
        control.prefWidthProperty().bind(pane.widthProperty().divide(n));
    }
    RowConstraints row = new RowConstraints();
    row.setPercentHeight(100);
    pane.getRowConstraints().add(row);
    return pane;
}
项目:aptasuite    文件:BarController.java   
public void drawBar() {

//        Bounds b = svg.boundsInLocalProperty().getValue();
//        System.out.println("Befor Resize" + b.getHeight() + "    " + b.getWidth() );
//        
//        b = svg.boundsInLocalProperty().getValue();
//        System.out.println("After Resize" + b.getHeight() + "    " + b.getWidth() );

        svg.minHeight(5);
        svg.prefHeight(Control.USE_COMPUTED_SIZE);
        svg.maxHeight(Control.USE_COMPUTED_SIZE);

        svg.minWidth(5);
        svg.prefWidth(Control.USE_COMPUTED_SIZE);
        svg.maxWidth(Control.USE_COMPUTED_SIZE);        

        rootStackPane.getChildren().add(svg);

        rootAnchorPane.widthProperty().addListener( stageSizeListener );
        rootAnchorPane.heightProperty().addListener( stageSizeListener );

//        rootStackPane.setBackground( new Background( new BackgroundFill( (Color.color(Math.random(), Math.random(), Math.random()) ), CornerRadii.EMPTY, Insets.EMPTY )));

    }
项目:JavaFxNodeToSvg    文件:NodeToSvgConverter.java   
/**
 * Converts a Control to SVG code (without SVG header and end tags)
 *
 * @param control
 * @return
 */
private String getSvgCodeForControl(Control control) {

    boolean isLabel = control instanceof Label;
    if (isLabel) {
        //handle Node=>Parent=>Region=>Control=>Label
        Label label = (Label) control;
        LabelToSvgConverter labelConverter = new LabelToSvgConverter();
        labelConverter.setIndentation(indentation);
        String svgString = labelConverter.extendCode("", label);
        indentation = labelConverter.getIndentation();
        return svgString;
    }

    String message = "Controls of type '" + control.getClass().getName() + "' are not yet implemented.";
    throw new IllegalArgumentException(message);
}
项目:StreamSis    文件:CuteGraphicValidationDecoration.java   
/**
 * Adds listener to {@link ValidationSupport} to play animations more correctly.
 * 
 * Internally it nullifies {@link #lastMessageMap} value, if it notices that
 * the corresponding control doesn't have validation problems anymore.
 *
 * @param validationSupport the validation support
 */
private void listenToValidationSupport(ValidationSupport validationSupport) {
    // This listener nullifies lastMessageMap value, if it notices that the corresponding
    // control don't have validation error anymore.
    validationSupport.validationResultProperty().addListener((o, oldValue, newValue) -> {
        Collection<ValidationMessage> validationMessages = newValue.getMessages();
        HashSet<Control> currentControlsWithValidationProblems = new HashSet<Control>();
        for (ValidationMessage message : validationMessages) {
            currentControlsWithValidationProblems.add(message.getTarget());
        }
        for (Control c : lastMessageMap.keySet()) {
            // Let's check if control became valid.
            if (!currentControlsWithValidationProblems.contains(c)) {
                // Clean up messages for control, because it's now valid.
                lastMessageMap.put(c, null);
            }
        }
    });
}
项目:Elegit    文件:CommitInfoController.java   
public void initialize() {
    commitInfoNameCopyButton.setMinSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
    commitInfoGoToButton.setMinSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);

    Text clipboardIcon = GlyphsDude.createIcon(FontAwesomeIcon.CLIPBOARD);
    this.commitInfoNameCopyButton.setGraphic(clipboardIcon);

    Text goToIcon = GlyphsDude.createIcon(FontAwesomeIcon.ARROW_CIRCLE_LEFT);
    this.commitInfoGoToButton.setGraphic(goToIcon);

    this.commitInfoGoToButton.setTooltip(new Tooltip(
            "Go to selected commit"
    ));

    this.commitInfoNameCopyButton.setTooltip(new Tooltip(
            "Copy commit ID"
    ));
}
项目:marathonv5    文件:TextValidatorSample.java   
public ValidatorPane() {
    content.addListener(new ChangeListener<Control>() {
        public void changed(ObservableValue<? extends Control> ov, Control oldValue, Control newValue) {
            if (oldValue != null) getChildren().remove(oldValue);
            if (newValue != null) getChildren().add(0, newValue);
        }
    });
}
项目:marathonv5    文件:TextValidatorSample.java   
@Override
protected void layoutChildren() {
    Control c = content.get();
    if (c != null) {
        c.resizeRelocate(0, 0, getWidth(), getHeight());
    }
}
项目:marathonv5    文件:SearchBoxSample.java   
public SearchBoxSample() {
    String searchBoxCss = SearchBoxSample.class.getResource("SearchBox.css").toExternalForm();
    VBox vbox = VBoxBuilder.create().build();
    vbox.getStylesheets().add(searchBoxCss);
    vbox.setPrefWidth(200);
    vbox.setMaxWidth(Control.USE_PREF_SIZE);
    vbox.getChildren().add(new SearchBox());
    getChildren().add(vbox);
}
项目:marathonv5    文件:TextValidatorSample.java   
public ValidatorPane() {
    content.addListener(new ChangeListener<Control>() {
        public void changed(ObservableValue<? extends Control> ov, Control oldValue, Control newValue) {
            if (oldValue != null) getChildren().remove(oldValue);
            if (newValue != null) getChildren().add(0, newValue);
        }
    });
}
项目:marathonv5    文件:TextValidatorSample.java   
@Override
protected void layoutChildren() {
    Control c = content.get();
    if (c != null) {
        c.resizeRelocate(0, 0, getWidth(), getHeight());
    }
}
项目:marathonv5    文件:SearchBoxSample.java   
public SearchBoxSample() {
    String searchBoxCss = SearchBoxSample.class.getResource("SearchBox.css").toExternalForm();
    VBox vbox = VBoxBuilder.create().build();
    vbox.getStylesheets().add(searchBoxCss);
    vbox.setPrefWidth(200);
    vbox.setMaxWidth(Control.USE_PREF_SIZE);
    vbox.getChildren().add(new SearchBox());
    getChildren().add(vbox);
}
项目:easyMvvmFx    文件:ValidationVisualizerBase.java   
@Override
public void initVisualization(final ValidationStatus result, final Control control, boolean required) {
    if (required) {
        applyRequiredVisualization(control, required);
    }

    applyVisualization(control, result.getHighestMessage(), required);

    result.getMessages().addListener((ListChangeListener<ValidationMessage>) c -> {
        while (c.next()) {
            Platform.runLater(() -> applyVisualization(control, result.getHighestMessage(), required));
        }
    });
}
项目:MineIDE    文件:DraggableTab.java   
private Rectangle2D getAbsoluteRect(final Control node)
{
    return new Rectangle2D(
            node.localToScene(node.getLayoutBounds().getMinX(), node.getLayoutBounds().getMinY()).getX()
                    + node.getScene().getWindow().getX(),
            node.localToScene(node.getLayoutBounds().getMinX(), node.getLayoutBounds().getMinY()).getY()
                    + node.getScene().getWindow().getY(),
            node.getWidth(), node.getHeight());
}
项目:uPMT    文件:MainViewTransformations.java   
public static void loadGridData(GridPane grid,Main main, DescriptionEntretien d){
    // Grid initialisation ( reset )
    grid.getColumnConstraints().clear();
    // Grid Creation
    // for each moment of the interview we add a collumn
    for (int j = 0; j < d.getNumberCols(); j++) {
        ColumnConstraints c = new ColumnConstraints();
        c.setMinWidth(180);
        c.setPrefWidth(Control.USE_COMPUTED_SIZE);
        c.setMaxWidth(Control.USE_COMPUTED_SIZE);
        grid.getColumnConstraints().add(c);
    }

    for (int i = 0; i < 1; i++) {
        for (int j = 0; j < d.getNumberCols(); j++) {
            // Creation of the Moment box           
            MomentExpVBox mp = new MomentExpVBox(main);
            addMomentExpBorderPaneListener(mp, main);

            MomentExperience mom;
            boolean hasMoment = false;
            if (main.getCurrentDescription() != null) {
                for (MomentExperience m : d.getMoments()) {
                    if(m.getGridCol() == j){
                        mom = m;
                        mp.setMoment(mom);
                        hasMoment = true;
                    }
                }
            }
            if (hasMoment) {
                mp.showMoment();
                mp.LoadMomentData();
                loadTypes(mp, main);
                loadSousMoment(mp,main);
            }               
            grid.add(mp,j,i);
        }
    }
}
项目:javafx-qiniu-tinypng-client    文件:ValidationVisualizerBase.java   
@Override
public void initVisualization(final ValidationStatus result, final Control control, boolean required) {
    if (required) {
        applyRequiredVisualization(control, required);
    }

    applyVisualization(control, result.getHighestMessage(), required);

    result.getMessages().addListener((ListChangeListener<ValidationMessage>) c -> {
        while (c.next()) {
            Platform.runLater(() -> applyVisualization(control, result.getHighestMessage(), required));
        }
    });
}
项目:Planchester    文件:BasePage.java   
protected void validate(List<? extends Control> fields) {
    for (Control field : fields) {
        if(field instanceof TextField) {
            validate(((TextField) field).getText(), field);
        } else if(field instanceof BigDecimalField) {
            validate(((BigDecimalField) field).getText(), field);
        }
    }
}
项目:Planchester    文件:BasePage.java   
protected void validate(String value, Control control) {
    if(value == null || value.isEmpty()) {
        control.setStyle("-fx-border-color: red");
    } else {
        control.setStyle("-fx-border-color: green");
    }
}
项目:waterrower-workout    文件:IntegerValidator.java   
@Override
public ValidationResult apply(Control control, String value) {
    if (value.isEmpty() && emptyAllowed)
        return null;
    try {
        int number = valueOf(value);
        return fromErrorIf(control, message, (number < minValue) || (number > maxValue));
    } catch (NumberFormatException e) {
        return fromError(control, message);
    }
}
项目:waterrower-workout    文件:DateValidator.java   
@Override
public ValidationResult apply(Control control, String value) {
    if (value.isEmpty() && emptyAllowed)
        return null;
    try {
        if (converter.fromString(value) == null)
            return fromError(control, message);
        return null;
    } catch (Exception e) {
        return fromError(control, message);
    }
}
项目:Java-9-Programming-Blueprints    文件:SendMessageDialogController.java   
/**
 * Initializes the controller class.
 *
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    msgText.prefWidthProperty().bind(container.widthProperty().subtract(20));
    msgText.setMaxWidth(Control.USE_PREF_SIZE);
    msgText.setWrapText(true);
}
项目:Gargoyle    文件:ComponentClassifier.java   
void print(List<Node> controls) {

        System.out.println("#### 컨트롤 개수 ####");
        System.out.println(controls.size());

        controls.forEach(n -> {
            if (n instanceof Control) {
                Skin<?> skin = ((Control) n).getSkin();
                System.out.println("skin : " + skin);
                n.getPseudoClassStates();
            }
            System.out.println(n);

        });
    }
项目:Gargoyle    文件:CommonsContextMenu.java   
/**
 * 컨텍스트 메뉴 추가.
 * 
 * @param node
 * @param items
 */
public static void addMenus(Control node, MenuItem... items) {
    ContextMenu contextMenu = new ContextMenu();

    if (items != null) {
        for (MenuItem item : items) {
            contextMenu.getItems().add(item);
        }
    }

    node.setContextMenu(contextMenu);
}