javafx.scene.control.Labeled Java Examples
The following examples show how to use
javafx.scene.control.Labeled.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SingleSelectionPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 6 votes |
@Test public void invalidatedDescriptorDoesntTriggerAnything() throws Exception { typePathAndValidate(); typePathAndValidate("/this/doesnt/exists"); WaitForAsyncUtils.waitForAsyncFx(2000, () -> { victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED); victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.LOADING); victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.LOADED); }); Labeled details = lookup(".-pdfsam-selection-details").queryLabeled(); assertTrue(isEmpty(details.getText())); Labeled encStatus = lookup(".encryption-status").queryLabeled(); assertTrue(isEmpty(encStatus.getText())); var field = lookup(".validable-container-field").queryAs(ValidableTextField.class); field.getContextMenu().getItems().parallelStream().filter(i -> !(i instanceof SeparatorMenuItem)) .filter(i -> !i.getText().equals(DefaultI18nContext.getInstance().i18n("Remove"))) .forEach(i -> assertTrue(i.isDisable())); }
Example #2
Source File: ControlStyle.java From MyBox with Apache License 2.0 | 6 votes |
public static void setStyle(Node node, String id, boolean mustStyle) { if (node == null || id == null) { return; } ControlStyle style = getControlStyle(node); setTips(node, style); if (node.getStyleClass().contains("main-button")) { return; } setColorStyle(node, style, AppVariables.ControlColor); // if (mustStyle || AppVariables.ControlColor != ColorStyle.Default) { // setColorStyle(node, style, AppVariables.ControlColor); // } if (AppVariables.controlDisplayText && node instanceof Labeled) { setTextStyle(node, style, AppVariables.ControlColor); } }
Example #3
Source File: ControlStyle.java From MyBox with Apache License 2.0 | 6 votes |
public static void setIcon(Node node, String icon) { try { if (node == null || icon == null || icon.isEmpty()) { return; } ImageView v = new ImageView(icon); if (node instanceof Labeled) { v.setFitWidth(AppVariables.iconSize); v.setFitHeight(AppVariables.iconSize); ((Labeled) node).setGraphic(v); } else if (node instanceof ImageView) { ImageView nodev = (ImageView) node; nodev.setImage(v.getImage()); nodev.setFitWidth(AppVariables.iconSize); nodev.setFitHeight(AppVariables.iconSize); } } catch (Exception e) { logger.debug(node.getId() + " " + e.toString()); } }
Example #4
Source File: TooltipUtil.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
public static void showTooltipIfTruncated(SkinBase skinBase, Labeled labeled) { for (Object node : skinBase.getChildren()) { if (node instanceof Text) { String displayedText = ((Text) node).getText(); String untruncatedText = labeled.getText(); if (displayedText.equals(untruncatedText)) { if (labeled.getTooltip() != null) { labeled.setTooltip(null); } } else if (untruncatedText != null && !untruncatedText.trim().isEmpty()) { final Tooltip tooltip = new Tooltip(untruncatedText); // Force tooltip to use color, as it takes in some cases the color of the parent label // and can't be overridden by class or id tooltip.setStyle("-fx-text-fill: -bs-rd-tooltip-truncated;"); labeled.setTooltip(tooltip); } } } }
Example #5
Source File: FooterTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void onProgressIndeterminate() { NotifiableTaskMetadata taskMetadata = mock(NotifiableTaskMetadata.class); PercentageOfWorkDoneChangedEvent event = new PercentageOfWorkDoneChangedEvent( PercentageOfWorkDoneChangedEvent.UNDETERMINED, taskMetadata); victim.onProgress(event); assertFalse(victim.lookup(".footer-failed-button").isVisible()); assertFalse(victim.lookup(".footer-open-button").isVisible()); assertEquals(DefaultI18nContext.getInstance().i18n("Running"), ((Labeled) victim.lookup(".status-label")).getText()); assertTrue(((ProgressBar) victim.lookup(".pdfsam-footer-bar")).isIndeterminate()); }
Example #6
Source File: FooterTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void onTaskCompleted() { TaskExecutionCompletedEvent event = mock(TaskExecutionCompletedEvent.class); victim.onTaskCompleted(event); assertFalse(victim.lookup(".footer-failed-button").isVisible()); assertTrue(victim.lookup(".footer-open-button").isVisible()); assertEquals(DefaultI18nContext.getInstance().i18n("Completed"), ((Labeled) victim.lookup(".status-label")).getText()); assertEquals(1, ((ProgressBar) victim.lookup(".pdfsam-footer-bar")).getProgress(), 0.01); }
Example #7
Source File: FooterTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void onTaskFailed() { TaskExecutionFailedEvent event = mock(TaskExecutionFailedEvent.class); victim.onTaskFailed(event); assertTrue(victim.lookup(".footer-failed-button").isVisible()); assertFalse(victim.lookup(".footer-open-button").isVisible()); assertEquals(DefaultI18nContext.getInstance().i18n("Failed"), ((Labeled) victim.lookup(".status-label")).getText()); assertEquals(0, ((ProgressBar) victim.lookup(".pdfsam-footer-bar")).getProgress(), 0.01); }
Example #8
Source File: ModulesDashboardPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void priorityOrder() { ModulesDashboardPane victim = new ModulesDashboardPane(Arrays.asList(new LowPriorityTestModule(), new HighPriorityTestModule(), new DefaultPriorityTestModule())); Node title = victim.getChildren().stream().findFirst() .orElseThrow(() -> new NullPointerException("Unable to find the expected node")) .lookup(".dashboard-modules-tile-title"); assertEquals("HighPriorityTestModule", ((Labeled) title).getText()); }
Example #9
Source File: KeywordsTabTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void onLoad() { KeywordsTab victim = new KeywordsTab(); Labeled keywords = (Labeled) ((ScrollPane) victim.getContent()).getContent().lookup(".info-property-value"); assertNotNull(keywords); ChangeListener<? super String> listener = mock(ChangeListener.class); keywords.textProperty().addListener(listener); PdfDocumentDescriptor descriptor = PdfDocumentDescriptor.newDescriptorNoPassword(mock(File.class)); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.requestShow(new ShowPdfDescriptorRequest(descriptor))); descriptor.putInformation(PdfMetadataFields.KEYWORDS, "test"); descriptor.moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED); descriptor.moveStatusTo(PdfDescriptorLoadingStatus.LOADING); descriptor.moveStatusTo(PdfDescriptorLoadingStatus.LOADED); verify(listener, timeout(2000).times(1)).changed(any(ObservableValue.class), anyString(), eq("test")); }
Example #10
Source File: KeywordsTabTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void showRequest() { KeywordsTab victim = new KeywordsTab(); Labeled keywords = (Labeled) ((ScrollPane) victim.getContent()).getContent().lookup(".info-property-value"); assertNotNull(keywords); ChangeListener<? super String> listener = mock(ChangeListener.class); keywords.textProperty().addListener(listener); PdfDocumentDescriptor descriptor = PdfDocumentDescriptor.newDescriptorNoPassword(mock(File.class)); descriptor.putInformation(PdfMetadataFields.KEYWORDS, "test"); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.requestShow(new ShowPdfDescriptorRequest(descriptor))); verify(listener, timeout(2000).times(1)).changed(any(ObservableValue.class), anyString(), eq("test")); }
Example #11
Source File: SummaryTabTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
private List<ChangeListener<? super String>> initListener(Set<Node> properties) { List<ChangeListener<? super String>> listeners = new ArrayList<>(); properties.stream().filter(n -> n instanceof Labeled).map(n -> (Labeled) n).forEach(l -> { ChangeListener<? super String> listener = mock(ChangeListener.class); listeners.add(listener); l.textProperty().addListener(listener); }); return listeners; }
Example #12
Source File: FooterTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void onProgress() { NotifiableTaskMetadata taskMetadata = mock(NotifiableTaskMetadata.class); PercentageOfWorkDoneChangedEvent event = new PercentageOfWorkDoneChangedEvent(new BigDecimal(50), taskMetadata); victim.onProgress(event); assertFalse(victim.lookup(".footer-failed-button").isVisible()); assertFalse(victim.lookup(".footer-open-button").isVisible()); assertEquals(DefaultI18nContext.getInstance().i18n("Running {0}%", "50"), ((Labeled) victim.lookup(".status-label")).getText()); assertEquals(0.5, ((ProgressBar) victim.lookup(".pdfsam-footer-bar")).getProgress(), 0.01); }
Example #13
Source File: ShipTablePane.java From logbook-kai with MIT License | 5 votes |
private void handle(ActionEvent e) { Object src = e.getSource(); if (src instanceof Labeled) { Labeled label = (Labeled) src; ShipTablePane.this.labelValue.getSelectionModel().select(label.getText()); ShipTablePane.this.labelFilter.setSelected(true); } }
Example #14
Source File: Panel.java From bootstrapfx with MIT License | 5 votes |
public String getText() { Node node = headingProperty().get(); if (node instanceof Labeled) { return ((Labeled) node).getText(); } return null; }
Example #15
Source File: FooterTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void onTaskExecutionRequest() throws TaskOutputVisitException { AbstractParameters params = mock(AbstractParameters.class); TaskExecutionRequestEvent event = new TaskExecutionRequestEvent(MODULE_ID, params); TaskOutput output = mock(FileTaskOutput.class); when(params.getOutput()).thenReturn(output); eventStudio().broadcast(event); assertFalse(victim.lookup(".footer-failed-button").isVisible()); assertFalse(victim.lookup(".footer-open-button").isVisible()); assertTrue(victim.lookup(".status-label").isVisible()); assertEquals(DefaultI18nContext.getInstance().i18n("Requested"), ((Labeled) victim.lookup(".status-label")).getText()); assertEquals(0, ((ProgressBar) victim.lookup(".pdfsam-footer-bar")).getProgress(), 0.01); verify(output).accept(any()); }
Example #16
Source File: TimedUpdaterUtil.java From Lipi with MIT License | 5 votes |
public static void temporaryLabeledUpdate(int mseconds, Labeled labeled, String newText) { String oldText = labeled.getText(); labeled.setText(newText); callAfter(mseconds, new CallbackVisitor() { @Override public void call() { labeled.setText(oldText); } }); }
Example #17
Source File: SingleSelectionPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void emptyDetailsOnSwithToInvalid() throws Exception { moveToLoadedWithDecryption(victim); typePathAndValidate("/this/doesnt/exists"); Labeled details = lookup(".-pdfsam-selection-details").queryLabeled(); assertTrue(isEmpty(details.getText())); }
Example #18
Source File: GlowText.java From AnimateFX with Apache License 2.0 | 5 votes |
public GlowText(Labeled node, Paint colorA, Paint colorB) { super(node); this.originalPaint = getNode().textFillProperty().get(); this.colorA = colorA; this.colorB = colorB; getTimeline().getKeyFrames().addAll( new KeyFrame(Duration.millis(0), new KeyValue(getNode().textFillProperty(), colorA)), new KeyFrame(Duration.millis(500), new KeyValue(getNode().textFillProperty(), colorB)), new KeyFrame(Duration.millis(1000), new KeyValue(getNode().textFillProperty(), colorA)) ); }
Example #19
Source File: ControlStyle.java From MyBox with Apache License 2.0 | 5 votes |
public static void setTextStyle(Node node, ControlStyle controlStyle, ColorStyle colorStyle) { try { if (node == null || controlStyle == null || !(node instanceof Labeled)) { return; } Labeled label = ((Labeled) node); // switch (colorStyle) { // case Red: // label.setTextFill(Color.RED); // break; // case Pink: // label.setTextFill(Color.PINK); // break; // case Blue: // label.setTextFill(Color.BLUE); // break; // case Orange: // label.setTextFill(Color.ORANGE); // break; // default: // label.setTextFill(Color.BLUE); // break; // } String name = controlStyle.getName(); if (name != null && !name.isEmpty()) { label.setText(name); } else { label.setText(controlStyle.getComments()); } } catch (Exception e) { logger.debug(node.getId() + " " + e.toString()); } }
Example #20
Source File: SingleSelectionPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void emptyStatusIndicatorOnSwithToInvalid() throws Exception { moveToLoadedWithDecryption(victim); typePathAndValidate("/this/doesnt/exists"); Labeled encStatus = lookup(".encryption-status").queryLabeled(); assertTrue(isEmpty(encStatus.getText())); }
Example #21
Source File: Utils.java From Cryogen with GNU General Public License v2.0 | 5 votes |
public static void fitFont(ObservableList<Node> children, Pane pane) { for (Node obj : recurse(children)) { if (obj instanceof Labeled && !obj.getStyleClass().contains("noresize")){ Labeled element = (Labeled) obj; double s = element.getFont().getSize(); DoubleBinding fontSize = pane.widthProperty().multiply(0.75).add(pane.heightProperty()).divide(1200).multiply(s); obj.styleProperty().bind(Bindings.concat("-fx-font-size: ").concat(fontSize.asString()).concat(";")); } else { //:I } } }
Example #22
Source File: AboutDialogController.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
@FXML private void openInBrowser(final ActionEvent actionEvent) { Labeled source = (Button) actionEvent.getSource(); openUrlInBrowser(source.getText()); }
Example #23
Source File: LoadingStatusIndicatorUpdater.java From pdfsam with GNU Affero General Public License v3.0 | 4 votes |
public LoadingStatusIndicatorUpdater(Labeled indicator) { requireNotNullArg(indicator, "Cannot set loading status on a null indicator"); this.indicator = indicator; }
Example #24
Source File: NodeParentageCrumbBar.java From pmd-designer with BSD 2-Clause "Simplified" License | 4 votes |
/** * If the node is already displayed on the crumbbar, only sets the focus on it. Otherwise, sets * the node to be the deepest one of the crumb bar. Noop if node is null. */ @Override public void setFocusNode(final Node newSelection, DataHolder options) { if (newSelection == null) { setSelectedCrumb(null); return; } if (Objects.equals(newSelection, currentSelection)) { return; } currentSelection = newSelection; boolean found = false; // We're trying to estimate the ratio of px/crumb, // to make an educated guess about how many crumbs we can fit // in case we need to call setDeepestNode int totalNumChar = 0; int totalNumCrumbs = 0; // the sum of children width is the actual width with overflow // the width of this control is the max acceptable width *without* overflow double totalChildrenWidth = 0; // constant padding around the graphic of a BreadCrumbButton // (difference between width of a BreadCrumbButton and that of its graphic) double constantPadding = Double.NaN; int i = 0; // right to left for (javafx.scene.Node button : asReversed(getChildren())) { Node n = (Node) ((TreeItem<?>) button.getUserData()).getValue(); // when recovering from a selection it's impossible that the node be found, // updating the style would cause visible twitching if (!options.hasData(SELECTION_RECOVERY)) { // set the focus on the one being selected, remove on the others // calling requestFocus would switch the focus from eg the treeview to the crumb bar (unusable) button.pseudoClassStateChanged(PseudoClass.getPseudoClass("focused"), newSelection.equals(n)); } // update counters totalNumChar += ((Labeled) button).getText().length(); double childWidth = ((Region) button).getWidth(); totalChildrenWidth += childWidth; totalNumCrumbs++; if (Double.isNaN(constantPadding)) { Region graphic = (Region) ((Labeled) button).getGraphic(); if (graphic != null) { constantPadding = childWidth - graphic.getWidth(); } } if (newSelection.equals(n)) { found = true; selectedIdx = getChildren().size() - i; } i++; } if (!found && !options.hasData(SELECTION_RECOVERY) || options.hasData(SELECTION_RECOVERY) && selectedIdx != 0) { // Then we reset the deepest node. setDeepestNode(newSelection, getWidthEstimator(totalNumChar, totalChildrenWidth, totalNumCrumbs, constantPadding)); // set the deepest as focused getChildren().get(getChildren().size() - 1) .pseudoClassStateChanged(PseudoClass.getPseudoClass("focused"), true); selectedIdx = 0; } else if (options.hasData(SELECTION_RECOVERY)) { Node cur = newSelection; // right to left, update underlying nodes without changing display // this relies on the fact that selection recovery only selects nodes with exactly the same path for (javafx.scene.Node child : asReversed(getChildren())) { if (cur == null) { break; } @SuppressWarnings("unchecked") TreeItem<Node> userData = (TreeItem<Node>) child.getUserData(); userData.setValue(cur); cur = cur.getParent(); } } }
Example #25
Source File: AboutDialogController.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
@FXML private void openInBrowser(final ActionEvent actionEvent) { Labeled source = (Button) actionEvent.getSource(); openUrlInBrowser(source.getText()); }
Example #26
Source File: TimedUpdaterUtil.java From Lipi with MIT License | 4 votes |
public static void temporaryLabeledUpdate(Labeled labeled, String newText) { temporaryLabeledUpdate(DEFAULT_WAIT, labeled, newText); }
Example #27
Source File: GlowText.java From AnimateFX with Apache License 2.0 | 4 votes |
@Override public Labeled getNode() { return (Labeled) super.getNode(); }
Example #28
Source File: LabeledDetailPaneInfo.java From scenic-view with GNU General Public License v3.0 | 4 votes |
@Override protected void updateDetail(final String propertyName) { final boolean all = propertyName.equals("*") ? true : false; final Labeled labeled = (Labeled) getTarget(); if (all || propertyName.equals("text")) { textDetail.setValue(labeled != null ? "\"" + labeled.getText() + "\"" : "-"); textDetail.setIsDefault(labeled == null || labeled.getText() == null); textDetail.setSimpleProperty(labeled != null ? labeled.textProperty() : null); if (!all) textDetail.updated(); if (!all) return; } if (all || propertyName.equals("font")) { fontDetail.setValue(labeled != null ? labeled.getFont().getName() : "-"); fontDetail.setIsDefault(labeled == null); if (!all) fontDetail.updated(); if (!all) return; } if (all || propertyName.equals("graphic")) { final Node graphic = labeled != null ? labeled.getGraphic() : null; graphicDetail.setValue(graphic != null ? graphic.getClass().getSimpleName() : "-"); graphicDetail.setIsDefault(graphic == null); if (!all) graphicDetail.updated(); if (!all) return; } if (all || propertyName.equals("graphicTextGap")) { graphicTextGapDetail.setValue(labeled != null ? f.format(labeled.getGraphicTextGap()) : "-"); graphicTextGapDetail.setIsDefault(labeled == null || labeled.getGraphic() == null); graphicTextGapDetail.setSimpleProperty(labeled != null ? labeled.graphicTextGapProperty() : null); if (!all) graphicTextGapDetail.updated(); if (!all) return; } if (all || propertyName.equals("alignment")) { alignmentDetail.setValue(labeled != null ? labeled.getAlignment().toString() : "-"); alignmentDetail.setIsDefault(labeled == null); alignmentDetail.setEnumProperty(labeled != null ? labeled.alignmentProperty() : null, Pos.class); if (!all) alignmentDetail.updated(); if (!all) return; } if (all || propertyName.equals("textAlignment")) { textAlignmentDetail.setValue(labeled != null ? labeled.getTextAlignment().toString() : "-"); textAlignmentDetail.setIsDefault(labeled == null); textAlignmentDetail.setEnumProperty(labeled != null ? labeled.textAlignmentProperty() : null, TextAlignment.class); if (!all) textAlignmentDetail.updated(); if (!all) return; } if (all || propertyName.equals("textOverrun")) { textOverrunDetail.setValue(labeled != null ? labeled.getTextOverrun().toString() : "-"); textOverrunDetail.setIsDefault(labeled == null); textOverrunDetail.setEnumProperty(labeled != null ? labeled.textOverrunProperty() : null, OverrunStyle.class); if (!all) textOverrunDetail.updated(); if (!all) return; } if (all || propertyName.equals("contentDisplay")) { contentDisplayDetail.setValue(labeled != null ? labeled.getContentDisplay().toString() : "-"); contentDisplayDetail.setIsDefault(labeled == null); contentDisplayDetail.setEnumProperty(labeled != null ? labeled.contentDisplayProperty() : null, ContentDisplay.class); if (!all) contentDisplayDetail.updated(); if (!all) return; } if (all || propertyName.equals("underline")) { underlineDetail.setValue(labeled != null ? Boolean.toString(labeled.isUnderline()) : "-"); underlineDetail.setIsDefault(labeled == null || !labeled.isUnderline()); underlineDetail.setSimpleProperty(labeled != null ? labeled.underlineProperty() : null); if (!all) underlineDetail.updated(); if (!all) return; } if (all || propertyName.equals("wrapText")) { wrapTextDetail.setValue(labeled != null ? Boolean.toString(labeled.isWrapText()) : "-"); wrapTextDetail.setIsDefault(labeled == null || !labeled.isWrapText()); wrapTextDetail.setSimpleProperty(labeled != null ? labeled.wrapTextProperty() : null); if (!all) wrapTextDetail.updated(); if (!all) return; } if (all) sendAllDetails(); }
Example #29
Source File: LabeledDetailPaneInfo.java From scenic-view with GNU General Public License v3.0 | 4 votes |
@Override public boolean targetMatches(final Object candidate) { return candidate instanceof Labeled; }
Example #30
Source File: LabeledDetailPaneInfo.java From scenic-view with GNU General Public License v3.0 | 4 votes |
@Override Class<? extends Node> getTargetClass() { return Labeled.class; }