/** * this method will update the source control after evaluating the validation condition */ protected void onEval() { Node control = getSrcControl(); if (hasErrors.get()) { control.pseudoClassStateChanged(PSEUDO_CLASS_ERROR, true); if (control instanceof Control) { Tooltip controlTooltip = ((Control) control).getTooltip(); if (controlTooltip != null && !controlTooltip.getStyleClass().contains("error-tooltip")) { tooltip = ((Control) control).getTooltip(); } errorTooltip.setText(getMessage()); ((Control) control).setTooltip(errorTooltip); } } else { if (control instanceof Control) { Tooltip controlTooltip = ((Control) control).getTooltip(); if ((controlTooltip != null && controlTooltip.getStyleClass().contains("error-tooltip")) || (controlTooltip == null && tooltip != null)) { ((Control) control).setTooltip(tooltip); } tooltip = null; } control.pseudoClassStateChanged(PSEUDO_CLASS_ERROR, false); } }
getClip().layoutYProperty().unbind(); getClip().layoutXProperty() .bind(Bindings.createDoubleBinding(() -> newVal.getLayoutX() + newVal.getWidth() / 2, newVal.widthProperty(), newVal.layoutXProperty())); getClip().layoutYProperty() .bind(Bindings.createDoubleBinding(() -> newVal.getLayoutY() + newVal.getHeight() / 2, newVal.heightProperty(), newVal.layoutYProperty())); newVal.widthProperty().addListener((o1, oldVal1, newVal1) -> updateToggleAnimation()); newVal.heightProperty().addListener((o1, oldVal1, newVal1) -> updateToggleAnimation()); newVal.setOnMouseClicked((click) -> togglePane()); });
control.requestLayout(); }); .setEndValue(1) .setInterpolator(Interpolator.EASE_BOTH) .setAnimateCondition(() -> control.isFocused()).build()), .setEndValue(1) .setInterpolator(Interpolator.EASE_BOTH) .setAnimateCondition(() -> control.isFocused()).build(), JFXKeyValue.builder() .setTarget(animatedPromptTextFill) .setEndValueSupplier(() -> control.getFocusColor()) .setInterpolator(Interpolator.EASE_BOTH) .setAnimateCondition(() -> control.isFocused() && control.isLabelFloat()).build(), JFXKeyValue.builder() .setTargetSupplier(() -> promptTextSupplier.get() == null ? null : promptTextSupplier.get().translateYProperty()) control.focusedProperty().addListener(observable -> { if (control.isFocused()) { focus(); } else { if (!control.isLabelFloat() || (control.isLabelFloat() && !control.isFocused())) { animatedPromptTextFill.set(promptTextFill.get());
public void setControl(Control control) { maxWidthProperty().bind(control.maxWidthProperty()); prefWidthProperty().bind(control.prefWidthProperty()); prefHeightProperty().bind(control.prefHeightProperty()); errorContainer.setMaxWidth(control.getMaxWidth() > -1 ? control.getMaxWidth() : control.getPrefWidth()); errorContainer.prefWidthProperty().bind(control.widthProperty()); errorContainer.prefHeightProperty().bind(control.heightProperty()); getChildren().clear(); getChildren().add(control); getChildren().add(errorContainer); this.controlProperty.set(control); }
@Override public boolean isSettable(Control n) { Skin<?> skin = n.getSkin(); if (skin != null && skin instanceof AquaProgressBarSkin) { return true; } return false; }
this.icon.setManaged(false); if( c.getSkin() != null ) { ((SkinBase<?>)c.getSkin()).getChildren().add(this.icon); c.skinProperty().addListener( ( ob, ol, ne ) -> { if( ol != null ) { ((SkinBase<?>)ol).getChildren().remove(this.icon); } else if( location == Location.TOP_RIGHT ) { this.icon.layoutXProperty().bind(Bindings.createDoubleBinding(() -> { return Double.valueOf(c.getWidth() - this.icon.widthProperty().get() / 2); },this.icon.widthProperty(), c.widthProperty())); this.icon.layoutYProperty().bind(this.icon.heightProperty().divide(-2)); } else if( location == Location.BOTTOM_LEFT ) { this.icon.layoutXProperty().bind(this.icon.widthProperty().divide(-2)); this.icon.layoutYProperty().bind(Bindings.createDoubleBinding(() -> { return Double.valueOf(c.getHeight() - this.icon.heightProperty().get() / 2); }, this.icon.heightProperty(), c.heightProperty())); } else if( location == Location.BOTTOM_RIGHT ) { this.icon.layoutXProperty().bind(Bindings.createDoubleBinding(() -> { return Double.valueOf(c.getWidth() - this.icon.widthProperty().get() / 2); },this.icon.widthProperty(), c.widthProperty())); this.icon.layoutYProperty().bind(Bindings.createDoubleBinding(() -> { return Double.valueOf(c.getHeight() - this.icon.heightProperty().get() / 2); }, this.icon.heightProperty(), c.heightProperty()));
private static void modifyTableMenu(final Control control, final Consumer<ContextMenu> consumer) { if (control.getScene() == null) { control.sceneProperty().addListener(new InvalidationListener() { @Override public void invalidated(Observable o) { control.sceneProperty().removeListener(this); modifyTableMenu(control, consumer); } }); return; } Skin<?> skin = control.getSkin(); if (skin == null) { control.skinProperty().addListener(new InvalidationListener() { @Override public void invalidated(Observable o) { control.skinProperty().removeListener(this); modifyTableMenu(control, consumer); } }); return; } doModify(skin, consumer); }
final Button helpButton = new Button("Help"); helpButton.setOnAction(new EventHandler() { public void handle(Event arg0) { showTooltip(stage, helpButton, "test tool tip", null); } }); public static void showTooltip(Stage owner, Control control, String tooltipText, ImageView tooltipGraphic) { Point2D p = control.localToScene(0.0, 0.0); final Tooltip customTooltip = new Tooltip(); customTooltip.setText(tooltipText); control.setTooltip(customTooltip); customTooltip.setAutoHide(true); customTooltip.show(owner, p.getX() + control.getScene().getX() + control.getScene().getWindow().getX(), p.getY() + control.getScene().getY() + control.getScene().getWindow().getY()); }
ContextMenu contextMenu = control.getContextMenu(); if (contextMenu != null) { findElements(contextMenu, predicate, accumulator); Tooltip tooltip = control.getTooltip(); if (tooltip != null) { findElements(tooltip, predicate, accumulator);
/** * Create an element that will layout the <code>childNode</code> * at the right dialog content border. * @param childNode that should be right aligned. * @return wrapping Pane */ public Pane right(Control childNode) { final int width = IDialog.WRAPPING_WIDTH - 24; Pane g = new Pane(childNode); childNode.widthProperty().addListener((observable, oldValue, newValue) -> { double inset = (width - childNode.getWidth()); g.setLayoutX(inset); }); return g; }
public List<Node> createButtonList() { ArrayList<Node> result = new ArrayList<Node>(); for (final FormCreator form : childFormCreators) { Control createShowFormButton = form.createShowFormButton(); createShowFormButton.setDisable(!form.isEnabled()); createShowFormButton.setTooltip(form.getTooltip()); if (!form.isEnabled()) {/* * workaround disabled button must be wrapped in split pane to show tooltip * https://javafx-jira.kenai.com/browse/RT-28850 */ SplitPane wrapper = new SplitPane(); wrapper.getItems().add(createShowFormButton); createShowFormButton = wrapper; wrapper.setTooltip(form.getTooltip()); } result.add(createShowFormButton); } return result; }
public void addMenu(Control tableView, Runnable copyTableCell, Supplier<String> createCsvFromTable){ MenuItem item = new MenuItem("Copy cell",uniformDesign.createIcon(FontAwesome.Glyph.COPY)); item.setOnAction(event -> { copyTableCell.run(); }); item.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN));//don't work on ContextMenu but keep is for the display text KeyCodeCombination keyCodeCombination = new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN); tableView.addEventFilter(KeyEvent.KEY_RELEASED, event -> { if (keyCodeCombination.match(event)) { copyTableCell.run(); } }); MenuItem export = new MenuItem("Copy table (csv)",uniformDesign.createIcon(FontAwesome.Glyph.TABLE)); export.setOnAction(event -> { exportTableToClipboard(createCsvFromTable.get()); }); MenuItem fileExport = new MenuItem("Save table (csv)",uniformDesign.createIcon(FontAwesome.Glyph.FILE)); fileExport.setOnAction(event -> { exportTableToFile(createCsvFromTable.get(),tableView.getScene().getWindow()); }); ContextMenu menu = new ContextMenu(); menu.getItems().add(item); menu.getItems().add(export); menu.getItems().add(fileExport); tableView.setContextMenu(menu); }
if (control instanceof FxComponent) { final FxComponent component = (FxComponent) control; control.focusedProperty().addListener((observable, oldValue, newValue) -> { if (newValue) { FxUtilities.getInstance().focusGained(component); control.hoverProperty().addListener((observable, oldValue, newValue) -> { if (!control.isFocused()) { if (newValue) { if (component.getError() == null) {
/** * Updates node hierarchy with current values from resource bundles. * * @param node hierarchy root node */ public void updateNodeHierarchy(Node node){ for(String id : propertyMap.keySet()){ Node target = node.lookup("#" + id); if(target != null){ updateProperties(target, id); // special handling for popup controls if(target instanceof Control){ Tooltip tl = ((Control)target).getTooltip(); if(tl != null && propertyMap.containsKey(tl.getId())){ updateProperties(tl, tl.getId()); } } } } }
tooltip = new Tooltip(); tooltip.setText(field.getHint()); control.setTooltip(tooltip);
/** * Sets the error message as tooltip for the matching control. * * @param below * The control needed for positioning the tooltip. * @param reference * The control which gets the tooltip. */ protected void toggleTooltip(Node reference, Control below) { String fieldTooltip = field.getTooltip(); if ((reference.isFocused() || reference.isHover()) && (!fieldTooltip.equals("") || field.getErrorMessages().size() > 0)) { tooltip.setText((!fieldTooltip.equals("") ? fieldTooltip + "\n" : "") + String.join("\n", field.getErrorMessages())); if (tooltip.isShowing()) { return; } Point2D p = below.localToScene(0.0, 0.0); tooltip.show( getScene().getWindow(), p.getX() + getScene().getX() + getScene().getWindow().getX(), p.getY() + getScene().getY() + getScene().getWindow().getY() + below.getHeight() + 5 ); } else { tooltip.hide(); } }
public void invalid() { if (control.isFocused()) { focus(); } }
/** * Returns the window of the specified control. * * @param control control * @return Window */ protected Window getWindow(final Control control) { final Scene scene = control.getScene(); return scene == null ? null : scene.getWindow(); }
@Override public boolean isSettable(Control n) { Skin<?> skin = n.getSkin(); if (skin != null && skin instanceof AquaFocusBorder) { return true; } return false; }
public void setControl(Control control) { maxWidthProperty().bind(control.maxWidthProperty()); prefWidthProperty().bind(control.prefWidthProperty()); prefHeightProperty().bind(control.prefHeightProperty()); errorContainer.setMaxWidth(control.getMaxWidth() > -1 ? control.getMaxWidth() : control.getPrefWidth()); errorContainer.prefWidthProperty().bind(control.widthProperty()); errorContainer.prefHeightProperty().bind(control.heightProperty()); getChildren().clear(); getChildren().add(control); getChildren().add(errorContainer); this.controlProperty.set(control); }