Example usage for javafx.scene Node getStyleClass

List of usage examples for javafx.scene Node getStyleClass

Introduction

In this page you can find the example usage for javafx.scene Node getStyleClass.

Prototype

@Override
    public final ObservableList<String> getStyleClass() 

Source Link

Usage

From source file:mesclasses.java.util.MyFXAssert.java

public static void assertFieldInError(Node node) {
    verifyThat(node, NodeMatchers.isNotNull());
    MyAssert.assertContains(node.getStyleClass(), BasicController.ERROR_CLASS);
}

From source file:mesclasses.java.util.MyFXAssert.java

public static void assertFieldOK(Node node) {
    verifyThat(node, NodeMatchers.isNotNull());
    MyAssert.assertNotContains(node.getStyleClass(), BasicController.ERROR_CLASS);
}

From source file:mesclasses.java.util.MyFXAssert.java

public static void assertCss(Node node, String cssClass) {
    verifyThat(node, NodeMatchers.isNotNull());
    MyAssert.assertContains(node.getStyleClass(), cssClass);
}

From source file:com.eviware.loadui.ui.fx.util.NodeUtils.java

private static void updateStyleClasses(final Node nodeToStyle, final String styleClass, Boolean newValue) {
    if (newValue)
        nodeToStyle.getStyleClass().add(styleClass);
    else//from w w w  .j av  a 2  s  .  co  m
        nodeToStyle.getStyleClass().remove(styleClass);
}

From source file:com.panemu.tiwulfx.table.TableControl.java

/**
 * Add JavaFX Node to table's toolbar//from   w w  w.jav  a  2  s.co m
 * @param node 
 */
public void addNode(Node node) {
    if (node instanceof Button) {
        node.getStyleClass().add("flat-button");
    }
    boolean hasPagination = toolbar.getItems().contains(paginationBox);
    if (hasPagination) {
        toolbar.getItems().remove(spacer);
        toolbar.getItems().remove(paginationBox);
    }
    toolbar.getItems().add(node);
    if (hasPagination) {
        toolbar.getItems().add(spacer);
        toolbar.getItems().add(paginationBox);
    }
}

From source file:ubicrypt.ui.ctrl.HomeController.java

@PostConstruct
public void init() {
    gProgress = new GeneralProgress(inProgress, inProgressMessage);
    treeView.setCellFactory(treeView1 -> new TreeCellFactory(treeView1, fileUntracker, appEvents, gProgress));
    addProvider.setOnMouseClicked(event -> ctx.browse("selectProvider"));
    addFile.setOnMouseClicked(event -> {
        if (!localConfig.getProviders().stream().findAny().isPresent()) {
            ctx.browse("selectProvider");
            return;
        }//from w w w. j a  v  a  2  s.  c  o m
        fileAdder.accept(emptyPath);
    });
    settings.setOnMouseClicked(event -> ctx.browse("settings"));
    filesRoot = new TreeItem<>(new RootFilesItem(event -> fileAdder.accept(emptyPath)));
    TreeItem<ITreeItem> root = new TreeItem<>();
    treeView.setRoot(root);

    root.getChildren().add(filesRoot);
    treeView.setShowRoot(false);
    localConfig.getLocalFiles().stream().filter(Utils.ignoredFiles)
            .forEach(localFile -> addFiles(localFile.getPath().iterator(), basePath, filesRoot, localFile));

    //providers
    providersRoot = new TreeItem<>(new RootProvidersItem());
    root.getChildren().add(providersRoot);
    localConfig.getProviders().stream().forEach(providerAdder);

    //provider status events
    providerEvent.subscribe(pevent -> {
        switch (pevent.getEvent()) {
        case added:
            log.info("new provider added:{}", pevent.getHook().getProvider());
            final Optional<TreeItem<ITreeItem>> optItem = providersRoot.getChildren().stream()
                    .filter(item -> ((ProviderItem) item.getValue()).getProvider()
                            .equals(pevent.getHook().getProvider()))
                    .findFirst();
            if (!optItem.isPresent()) {
                providerAdder.accept(pevent.getHook().getProvider());
            }
            pevent.getHook().getStatusEvents().subscribe(event -> {
                Function<String, String> classLabel;
                log.info("provider status {}:{}", event, pevent.getHook().getProvider());
                switch (event) {
                case error:
                    classLabel = code -> format("tree-provider-%s-error", code);
                    break;
                default:
                    //TODO:labels for other statuses
                    classLabel = code -> format("tree-provider-%s", code);
                }
                optItem.ifPresent(item -> {
                    final ProviderItem providerItem = (ProviderItem) item.getValue();
                    final Node graphics = providerItem.getGraphics();
                    graphics.getStyleClass().clear();
                    providerDescriptors.stream()
                            .filter(pd -> pd.getType().equals(providerItem.getProvider().getClass()))
                            .map(ProviderDescriptor::getCode).findFirst()
                            .ifPresent(code -> graphics.getStyleClass().add(classLabel.apply(code)));
                });
            });
            break;
        case removed:
            //TODO: remove provider
            break;
        default:
            log.warn("unmanaged event:{}", pevent.getEvent());
        }
    });

    //remote file events
    fileEvents.filter(fileEvent -> fileEvent.getLocation() == FileEvent.Location.remote)
            .subscribe(fileEvent -> {
                log.debug("file remote event:{}", fileEvent);
                //update file icon
                final UbiFile<UbiFile> file = fileEvent.getFile();
                Observable.create(fileInSync.call(file)).subscribe(res -> {
                    searchFile(filesRoot, file).ifPresent(treeView -> {
                        final Node graphics = treeView.getValue().getGraphics();
                        graphics.getStyleClass().clear();
                        graphics.getStyleClass().add(format("tree-file-saved-%s", res));
                    });
                });
            });
    //local file events
    fileEvents.filter(fileEvent -> fileEvent.getLocation() == FileEvent.Location.local
            && fileEvent.getType() == FileEvent.Type.created).subscribe(fileEvent -> {
                log.debug("file local event:{}", fileEvent);
                localConfig.getLocalFiles().stream().filter(fileEvent.getFile()::equals).findFirst().ifPresent(
                        fe -> addFiles(fileEvent.getFile().getPath().iterator(), basePath, filesRoot, fe));
                searchFile(filesRoot, fileEvent.getFile()).ifPresent(treeView -> {
                    final Node graphics = treeView.getValue().getGraphics();
                    graphics.getStyleClass().clear();
                    graphics.getStyleClass().add(format("tree-file-saved-%s", true));
                });
            });

    //file progress monitor
    progressEvents.subscribe(progress -> {
        Platform.runLater(() -> {
            if (progress.isCompleted()) {
                log.debug("progress completed");
                if (!filesInProgress.remove(progress)) {
                    log.warn("progress not tracked. progress file:{}, element:{}",
                            progress.getProvenience().getFile());
                }
                Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(2), ae -> {
                    progressFile.setText("");
                    progressProvider.setText("");
                    progressBar.setProgress(0D);
                }));
                timeline.play();
            } else {
                filesInProgress.add(progress);
            }
            if (filesInProgress.isEmpty()) {
                //                    footer.setVisible(false);
                return;
            }
            footer.setVisible(true);
            filesInProgress.stream().findFirst().ifPresent(pr -> {
                progressFile.setText(StringUtils
                        .abbreviate(pr.getProvenience().getFile().getPath().getFileName().toString(), 30));
                progressProvider.setText(StringUtils.abbreviate(pr.getTarget().toString(), 30));
                progressBar.setProgress((double) progress.getChunk() / pr.getProvenience().getFile().getSize());
            });
        });
    });

    //sync-done events
    appEvents.subscribe(ClassMatcher.newMatcher().on(SyncBeginEvent.class, event -> {
        log.info("sync begin received");
        Platform.runLater(() -> {
            gProgress.startProgress("Synchronizing providers");
            addFile.setDisable(true);
            addProvider.setDisable(true);
        });
    }).on(SynchDoneEvent.class, event -> {
        log.debug("sync done");
        refreshItems(filesRoot);
        Platform.runLater(() -> {
            gProgress.stopProgress();
            addFile.setDisable(false);
            addProvider.setDisable(false);
        });
    }));
}

From source file:ubicrypt.ui.files.FilesController.java

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
    fxml = substringBefore(substringAfterLast(url.getFile(), "/"), ".fxml");
    treeView.setCellFactory(treeView1 -> new TreeCellFactory(treeView1, fileUntracker, null, osUtil, basePath));
    localConfig.getLocalFiles().stream().filter(Utils.trackedFile)
            .forEach(localFile -> addFiles(localFile.getPath().iterator(), basePath, root, localFile));

    //remote file events
    fileEvents.filter(fileEvent -> fileEvent.getLocation() == FileEvent.Location.remote)
            .subscribe(fileEvent -> {
                log.debug("file remote event:{}", fileEvent);
                //update file icon
                final UbiFile<UbiFile> file = fileEvent.getFile();
                Observable.create(fileInSync.call(file)).subscribe(res -> {
                    searchFile(root, file).ifPresent(treeView -> {
                        log.debug("found file item:{}", treeView);
                        final Node graphics = treeView.getValue().getGraphics();
                        graphics.getStyleClass().clear();
                        graphics.getStyleClass().add(format("tree-file-saved-%s", res));
                    });/*from  ww  w .  ja v  a 2 s  . com*/
                });
            });
    //local file events
    fileEvents.filter(fileEvent -> fileEvent.getLocation() == FileEvent.Location.local).subscribe(fileEvent -> {
        log.debug("file local event:{}", fileEvent);
        Optional<TreeItem<ITreeItem>> optfile = searchFile(root, fileEvent.getFile());
        if (!optfile.isPresent()) {
            optfile = localConfig.getLocalFiles().stream().filter(fileEvent.getFile()::equals).findFirst()
                    .map(fe -> addFiles(fileEvent.getFile().getPath().iterator(), basePath, root, fe));
        }
        if (!optfile.isPresent()) {
            log.debug("file not present:{}", fileEvent.getFile().getPath());
            return;
        }
        TreeItem<ITreeItem> vfile = optfile.get();
        final Node graphics = vfile.getValue().getGraphics();
        graphics.getStyleClass().clear();
        switch (fileEvent.getType()) {
        case created:
        case synched:
            graphics.getStyleClass().add("tree-file-saved-true");
            break;
        case unsynched:
            graphics.getStyleClass().add("tree-file-saving");
            break;
        case error:
            graphics.getStyleClass().add("tree-file-saved-true");
            break;
        case removed:
        case deleted:
            removeItem(vfile);
            break;
        default:
            graphics.getStyleClass().add(format("tree-file-saved-%s", true));
        }
    });

    //sync-done events
    appEvents.subscribe(ClassMatcher.newMatcher().on(SyncBeginEvent.class, event -> {
        log.info("sync begin received");
    }).on(SynchDoneEvent.class, event -> {
        log.debug("synchronization done");
    }));
}