use of javafx.css.PseudoClass in project Gargoyle by callakrsos.
the class SkinPreviewViewComposite method previewTabInit.
@FxPostInitialize
public void previewTabInit() {
Task<Void> task = new Task<Void>() {
@Override
protected Void call() throws Exception {
Thread.sleep(5000L);
Platform.runLater(() -> {
//메뉴바 배경.
{
Background background = mbSample.getBackground();
Color fill = (Color) background.getFills().get(0).getFill();
colorMbSample.setValue(fill);
//메뉴바 텍스트
{
Label lookup = (Label) mbSample.lookup(".label");
Color textFill = (Color) lookup.getTextFill();
colorMbLabelSample.setValue(textFill);
}
}
//Hbox 배경.
{
Background background = hboxSample.getBackground();
Color fill = (Color) background.getFills().get(0).getFill();
colorHboxSample.setValue(fill);
}
{
//선택디지않는 탭 색상 처리.
Set<Node> lookupAll = tabpaneSample.lookupAll(".tab:top");
lookupAll.forEach(lookup -> {
Optional<PseudoClass> findFirst = lookup.getPseudoClassStates().stream().filter(v -> {
return "selected".equals(v.getPseudoClassName());
}).findFirst();
if (findFirst.isPresent()) {
Label selectedTabLabel = (Label) lookup.lookup(".tab-label");
Color textFill = (Color) selectedTabLabel.getTextFill();
colorSelectedTabText.setValue(textFill);
} else {
Label selectedTabLabel = (Label) lookup.lookup(".tab-label");
Color textFill = (Color) selectedTabLabel.getTextFill();
colorUnSelectedTabText.setValue(textFill);
}
});
{
lookupAll.stream().findFirst().ifPresent(n -> {
Pane p = (Pane) n;
Background background = p.getBackground();
Color fill = (Color) background.getFills().get(0).getFill();
colorTabSample1Selected.setValue(fill);
});
}
}
});
return null;
}
};
Window window = this.getScene().getWindow();
if (window != null) {
FxUtil.showLoading(window, task);
} else
FxUtil.showLoading(task);
}
use of javafx.css.PseudoClass in project POL-POM-5 by PhoenicisOrg.
the class CreateShortcutPanel method populate.
/**
* populates the panel
*/
public void populate() {
final PseudoClass errorClass = PseudoClass.getPseudoClass("error");
final VBox vBox = new VBox();
GridPane gridPane = new GridPane();
gridPane.getStyleClass().add("grid");
gridPane.getColumnConstraints().addAll(new ColumnConstraintsWithPercentage(30), new ColumnConstraintsWithPercentage(70));
// name
Label nameLabel = new Label(tr("Name:"));
nameLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
GridPane.setValignment(nameLabel, VPos.TOP);
gridPane.add(nameLabel, 0, 0);
TextField name = new TextField();
gridPane.add(name, 1, 0);
Tooltip nameErrorTooltip = new Tooltip(tr("Please specify a name!"));
// category
Label categoryLabel = new Label(tr("Category:"));
categoryLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
GridPane.setValignment(categoryLabel, VPos.TOP);
gridPane.add(categoryLabel, 0, 1);
TextField category = new TextField();
gridPane.add(category, 1, 1);
Tooltip categoryErrorTooltip = new Tooltip(tr("Please specify a category!"));
// description
Label descriptionLabel = new Label(tr("Description:"));
descriptionLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
GridPane.setValignment(descriptionLabel, VPos.TOP);
gridPane.add(descriptionLabel, 0, 2);
TextArea description = new TextArea();
gridPane.add(description, 1, 2);
// miniature
Label miniatureLabel = new Label(tr("Miniature:"));
miniatureLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
GridPane.setValignment(miniatureLabel, VPos.TOP);
gridPane.add(miniatureLabel, 0, 3);
TextField miniature = new TextField();
Button openMiniatureBrowser = new Button(tr("Choose"));
openMiniatureBrowser.setOnAction(event -> {
FileChooser chooser = new FileChooser();
chooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(tr("Images"), "*.miniature, *.png"));
File newMiniature = chooser.showOpenDialog(null);
miniature.setText(newMiniature.toString());
});
HBox miniatureHbox = new HBox(miniature, openMiniatureBrowser);
HBox.setHgrow(miniature, Priority.ALWAYS);
gridPane.add(miniatureHbox, 1, 3);
Tooltip miniatureErrorTooltip = new Tooltip(tr("Please specify a valid miniature!"));
// executable
Label executableLabel = new Label(tr("Executable:"));
executableLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
GridPane.setValignment(executableLabel, VPos.TOP);
gridPane.add(executableLabel, 0, 4);
TextField executable = new TextField();
Button openExecutableBrowser = new Button(tr("Choose"));
openExecutableBrowser.setOnAction(event -> {
FileChooser chooser = new FileChooser();
File newMiniature = chooser.showOpenDialog(null);
executable.setText(newMiniature.toString());
});
HBox executableHbox = new HBox(executable, openExecutableBrowser);
HBox.setHgrow(executable, Priority.ALWAYS);
gridPane.add(executableHbox, 1, 4);
Tooltip executableErrorTooltip = new Tooltip(tr("Please specify a valid executable!"));
Region spacer = new Region();
spacer.getStyleClass().add("detailsButtonSpacer");
Button createButton = new Button(tr("Create"));
createButton.setOnMouseClicked(event -> {
boolean error = false;
if (StringUtils.isEmpty(name.getText())) {
name.pseudoClassStateChanged(errorClass, true);
name.setTooltip(nameErrorTooltip);
error = true;
}
if (StringUtils.isEmpty(category.getText())) {
category.pseudoClassStateChanged(errorClass, true);
category.setTooltip(categoryErrorTooltip);
error = true;
}
URI miniatureUri = null;
// but if a miniature is given, it must exist
if (StringUtils.isNotEmpty(miniature.getText())) {
File miniatureFile = new File(miniature.getText());
if (miniatureFile.exists()) {
miniatureUri = miniatureFile.toURI();
} else {
miniature.pseudoClassStateChanged(errorClass, true);
miniature.setTooltip(miniatureErrorTooltip);
error = true;
}
}
File executableFile = new File(executable.getText());
if (!executableFile.exists()) {
executable.pseudoClassStateChanged(errorClass, true);
executable.setTooltip(executableErrorTooltip);
error = true;
}
if (!error) {
ShortcutCreationDTO newShortcut = new ShortcutCreationDTO.Builder().withName(name.getText()).withCategory(category.getText()).withDescription(description.getText()).withMiniature(miniatureUri).withExecutable(executableFile).build();
this.onCreateShortcut.accept(newShortcut);
}
});
vBox.getChildren().addAll(gridPane, spacer, createButton);
this.setCenter(vBox);
}
use of javafx.css.PseudoClass in project phoenicis by PhoenicisOrg.
the class CreateShortcutPanel method populate.
/**
* populates the panel
*/
public void populate() {
final PseudoClass errorClass = PseudoClass.getPseudoClass("error");
final VBox vBox = new VBox();
GridPane gridPane = new GridPane();
gridPane.getStyleClass().add("grid");
gridPane.getColumnConstraints().addAll(new ColumnConstraintsWithPercentage(30), new ColumnConstraintsWithPercentage(70));
// name
Label nameLabel = new Label(tr("Name:"));
nameLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
GridPane.setValignment(nameLabel, VPos.TOP);
gridPane.add(nameLabel, 0, 0);
TextField name = new TextField();
gridPane.add(name, 1, 0);
Tooltip nameErrorTooltip = new Tooltip(tr("Please specify a name!"));
// category
Label categoryLabel = new Label(tr("Category:"));
categoryLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
GridPane.setValignment(categoryLabel, VPos.TOP);
gridPane.add(categoryLabel, 0, 1);
TextField category = new TextField();
gridPane.add(category, 1, 1);
Tooltip categoryErrorTooltip = new Tooltip(tr("Please specify a category!"));
// description
Label descriptionLabel = new Label(tr("Description:"));
descriptionLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
GridPane.setValignment(descriptionLabel, VPos.TOP);
gridPane.add(descriptionLabel, 0, 2);
TextArea description = new TextArea();
gridPane.add(description, 1, 2);
// miniature
Label miniatureLabel = new Label(tr("Miniature:"));
miniatureLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
GridPane.setValignment(miniatureLabel, VPos.TOP);
gridPane.add(miniatureLabel, 0, 3);
TextField miniature = new TextField();
Button openMiniatureBrowser = new Button(tr("Choose"));
openMiniatureBrowser.setOnAction(event -> {
FileChooser chooser = new FileChooser();
chooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(tr("Images"), "*.miniature, *.png"));
File newMiniature = chooser.showOpenDialog(null);
miniature.setText(newMiniature.toString());
});
HBox miniatureHbox = new HBox(miniature, openMiniatureBrowser);
HBox.setHgrow(miniature, Priority.ALWAYS);
gridPane.add(miniatureHbox, 1, 3);
Tooltip miniatureErrorTooltip = new Tooltip(tr("Please specify a valid miniature!"));
// executable
Label executableLabel = new Label(tr("Executable:"));
executableLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
GridPane.setValignment(executableLabel, VPos.TOP);
gridPane.add(executableLabel, 0, 4);
TextField executable = new TextField();
Button openExecutableBrowser = new Button(tr("Choose"));
openExecutableBrowser.setOnAction(event -> {
FileChooser chooser = new FileChooser();
File newMiniature = chooser.showOpenDialog(null);
executable.setText(newMiniature.toString());
});
HBox executableHbox = new HBox(executable, openExecutableBrowser);
HBox.setHgrow(executable, Priority.ALWAYS);
gridPane.add(executableHbox, 1, 4);
Tooltip executableErrorTooltip = new Tooltip(tr("Please specify a valid executable!"));
Region spacer = new Region();
spacer.getStyleClass().add("detailsButtonSpacer");
Button createButton = new Button(tr("Create"));
createButton.setOnMouseClicked(event -> {
boolean error = false;
if (StringUtils.isEmpty(name.getText())) {
name.pseudoClassStateChanged(errorClass, true);
name.setTooltip(nameErrorTooltip);
error = true;
}
if (StringUtils.isEmpty(category.getText())) {
category.pseudoClassStateChanged(errorClass, true);
category.setTooltip(categoryErrorTooltip);
error = true;
}
URI miniatureUri = null;
// but if a miniature is given, it must exist
if (StringUtils.isNotEmpty(miniature.getText())) {
File miniatureFile = new File(miniature.getText());
if (miniatureFile.exists()) {
miniatureUri = miniatureFile.toURI();
} else {
miniature.pseudoClassStateChanged(errorClass, true);
miniature.setTooltip(miniatureErrorTooltip);
error = true;
}
}
File executableFile = new File(executable.getText());
if (!executableFile.exists()) {
executable.pseudoClassStateChanged(errorClass, true);
executable.setTooltip(executableErrorTooltip);
error = true;
}
if (!error) {
ShortcutCreationDTO newShortcut = new ShortcutCreationDTO.Builder().withName(name.getText()).withCategory(category.getText()).withDescription(description.getText()).withMiniature(miniatureUri).withExecutable(executableFile).build();
this.onCreateShortcut.accept(newShortcut);
}
});
vBox.getChildren().addAll(gridPane, spacer, createButton);
this.setCenter(vBox);
}
use of javafx.css.PseudoClass in project JavaFXLibrary by eficode.
the class ConvenienceKeywords method findAllWithPseudoClass.
@RobotKeyword("Returns *all* nodes matching query AND given pseudo-class state. \r\n" + "``query`` is a query locator, see `3.1 Using queries`.\n\n" + "``pseudo`` is a String value specifying pseudo class value.\n\n" + "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and " + "keyword returns null in case lookup returns nothing.\n\n" + "\nExample:\n" + "| ${my node}= | Find All With Pseudo Class | .check-box-tree-cell .check-box | selected | \n")
@ArgumentNames({ "query", "pseudo", "failIfNotFound=" })
public List<Object> findAllWithPseudoClass(String query, String pseudo, boolean failIfNotFound) {
robotLog("INFO", "Trying to find all nodes with query: \"" + query + "\" that has pseudoclass state as: \"" + pseudo + "\", failIfNotFound= \"" + Boolean.toString(failIfNotFound) + "\"");
try {
Set<Node> nodes = robot.lookup(query).queryAll();
Set<Node> matches = nodes.stream().filter(n -> n.getPseudoClassStates().stream().map(PseudoClass::getPseudoClassName).anyMatch(pseudo::contains)).collect(Collectors.toSet());
return mapObjects(matches);
} catch (JavaFXLibraryNonFatalException e) {
if (failIfNotFound)
throw e;
return Collections.emptyList();
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Find all with pseudo class operation failed for query: \"" + query + "\" and pseudo: \"" + pseudo + "\"", e);
}
}
use of javafx.css.PseudoClass in project jabref by JabRef.
the class GroupTreeController method initialize.
@FXML
public void initialize() {
viewModel = new GroupTreeViewModel(stateManager, dialogService, taskExecutor);
// Set-up groups tree
groupTree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
// Set-up bindings
Consumer<ObservableList<GroupNodeViewModel>> updateSelectedGroups = (newSelectedGroups) -> newSelectedGroups.forEach(this::selectNode);
Consumer<List<TreeItem<GroupNodeViewModel>>> updateViewModel = (newSelectedGroups) -> {
if (newSelectedGroups == null) {
viewModel.selectedGroupsProperty().clear();
} else {
viewModel.selectedGroupsProperty().setAll(newSelectedGroups.stream().map(TreeItem::getValue).collect(Collectors.toList()));
}
};
BindingsHelper.bindContentBidirectional(groupTree.getSelectionModel().getSelectedItems(), viewModel.selectedGroupsProperty(), updateSelectedGroups, updateViewModel);
viewModel.filterTextProperty().bind(searchField.textProperty());
groupTree.rootProperty().bind(EasyBind.map(viewModel.rootGroupProperty(), group -> new RecursiveTreeItem<>(group, GroupNodeViewModel::getChildren, GroupNodeViewModel::expandedProperty, viewModel.filterPredicateProperty())));
// Icon and group name
mainColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
mainColumn.setCellFactory(new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>().withText(GroupNodeViewModel::getDisplayName).withIcon(GroupNodeViewModel::getIconCode, GroupNodeViewModel::getColor).withTooltip(GroupNodeViewModel::getDescription));
// Number of hits
PseudoClass anySelected = PseudoClass.getPseudoClass("any-selected");
PseudoClass allSelected = PseudoClass.getPseudoClass("all-selected");
numberColumn.setCellFactory(new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>().withGraphic(group -> {
final StackPane node = new StackPane();
node.getStyleClass().setAll("hits");
if (!group.isRoot()) {
BindingsHelper.includePseudoClassWhen(node, anySelected, group.anySelectedEntriesMatchedProperty());
BindingsHelper.includePseudoClassWhen(node, allSelected, group.allSelectedEntriesMatchedProperty());
}
Text text = new Text();
text.textProperty().bind(group.getHits().asString());
text.getStyleClass().setAll("text");
node.getChildren().add(text);
node.setMaxWidth(Control.USE_PREF_SIZE);
return node;
}));
// Arrow indicating expanded status
disclosureNodeColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
disclosureNodeColumn.setCellFactory(new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>().withGraphic(viewModel -> {
final StackPane disclosureNode = new StackPane();
disclosureNode.visibleProperty().bind(viewModel.hasChildrenProperty());
disclosureNode.getStyleClass().setAll("tree-disclosure-node");
final StackPane disclosureNodeArrow = new StackPane();
disclosureNodeArrow.getStyleClass().setAll("arrow");
disclosureNode.getChildren().add(disclosureNodeArrow);
return disclosureNode;
}).withOnMouseClickedEvent(group -> event -> group.toggleExpansion()));
// Set pseudo-classes to indicate if row is root or sub-item ( > 1 deep)
PseudoClass rootPseudoClass = PseudoClass.getPseudoClass("root");
PseudoClass subElementPseudoClass = PseudoClass.getPseudoClass("sub");
// Pseudo-classes for drag and drop
PseudoClass dragOverBottom = PseudoClass.getPseudoClass("dragOver-bottom");
PseudoClass dragOverCenter = PseudoClass.getPseudoClass("dragOver-center");
PseudoClass dragOverTop = PseudoClass.getPseudoClass("dragOver-top");
groupTree.setRowFactory(treeTable -> {
TreeTableRow<GroupNodeViewModel> row = new TreeTableRow<>();
row.treeItemProperty().addListener((ov, oldTreeItem, newTreeItem) -> {
boolean isRoot = newTreeItem == treeTable.getRoot();
row.pseudoClassStateChanged(rootPseudoClass, isRoot);
boolean isFirstLevel = (newTreeItem != null) && (newTreeItem.getParent() == treeTable.getRoot());
row.pseudoClassStateChanged(subElementPseudoClass, !isRoot && !isFirstLevel);
});
row.setDisclosureNode(null);
row.disclosureNodeProperty().addListener((observable, oldValue, newValue) -> row.setDisclosureNode(null));
row.contextMenuProperty().bind(EasyBind.monadic(row.itemProperty()).map(this::createContextMenuForGroup).orElse((ContextMenu) null));
row.setOnDragDetected(event -> {
TreeItem<GroupNodeViewModel> selectedItem = treeTable.getSelectionModel().getSelectedItem();
if ((selectedItem != null) && (selectedItem.getValue() != null)) {
Dragboard dragboard = treeTable.startDragAndDrop(TransferMode.MOVE);
dragboard.setDragView(row.snapshot(null, null));
ClipboardContent content = new ClipboardContent();
content.put(DragAndDropDataFormats.GROUP, selectedItem.getValue().getPath());
dragboard.setContent(content);
event.consume();
}
});
row.setOnDragOver(event -> {
Dragboard dragboard = event.getDragboard();
if ((event.getGestureSource() != row) && row.getItem().acceptableDrop(dragboard)) {
event.acceptTransferModes(TransferMode.MOVE, TransferMode.LINK);
removePseudoClasses(row, dragOverBottom, dragOverCenter, dragOverTop);
switch(getDroppingMouseLocation(row, event)) {
case BOTTOM:
row.pseudoClassStateChanged(dragOverBottom, true);
break;
case CENTER:
row.pseudoClassStateChanged(dragOverCenter, true);
break;
case TOP:
row.pseudoClassStateChanged(dragOverTop, true);
break;
}
}
event.consume();
});
row.setOnDragExited(event -> {
removePseudoClasses(row, dragOverBottom, dragOverCenter, dragOverTop);
});
row.setOnDragDropped(event -> {
Dragboard dragboard = event.getDragboard();
boolean success = false;
if (dragboard.hasContent(DragAndDropDataFormats.GROUP)) {
String pathToSource = (String) dragboard.getContent(DragAndDropDataFormats.GROUP);
Optional<GroupNodeViewModel> source = viewModel.rootGroupProperty().get().getChildByPath(pathToSource);
if (source.isPresent()) {
source.get().draggedOn(row.getItem(), getDroppingMouseLocation(row, event));
success = true;
}
}
if (dragboard.hasContent(DragAndDropDataFormats.ENTRIES)) {
TransferableEntrySelection entrySelection = (TransferableEntrySelection) dragboard.getContent(DragAndDropDataFormats.ENTRIES);
row.getItem().addEntriesToGroup(entrySelection.getSelection());
success = true;
}
event.setDropCompleted(success);
event.consume();
});
return row;
});
// Filter text field
setupClearButtonField(searchField);
}
Aggregations