Example usage for javafx.scene.control Tab getContent

List of usage examples for javafx.scene.control Tab getContent

Introduction

In this page you can find the example usage for javafx.scene.control Tab getContent.

Prototype

public final Node getContent() 

Source Link

Document

The content associated with the tab.

Usage

From source file:Main.java

private static Node lookupInternal(Node node, String id) {
    if (id.equals(node.getId())) {
        return node;
    }//from w  ww  . j av  a 2  s.co  m
    if (node instanceof Parent) {
        for (Node child : ((Parent) node).getChildrenUnmodifiable()) {
            Node result = lookupInternal(child, id);
            if (result != null) {
                return result;
            }
        }
        if (node instanceof SplitPane) {
            SplitPane sp = (SplitPane) node;
            Node result = null;
            for (Node child : sp.getItems()) {
                result = lookupInternal(child, id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof ScrollPane) {
            ScrollPane sp = (ScrollPane) node;
            Node result = null;
            if (sp.getContent() != null) {
                result = lookupInternal(sp.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof BorderPane) {
            BorderPane sp = (BorderPane) node;
            Node result = null;
            if (sp.getBottom() != null) {
                result = lookupInternal(sp.getBottom(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getTop() != null) {
                result = lookupInternal(sp.getTop(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getLeft() != null) {
                result = lookupInternal(sp.getLeft(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getRight() != null) {
                result = lookupInternal(sp.getRight(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getCenter() != null) {
                result = lookupInternal(sp.getCenter(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof TitledPane) {
            TitledPane sp = (TitledPane) node;
            Node result = null;
            if (sp.getContent() != null) {
                result = lookupInternal(sp.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof Accordion) {
            Accordion sp = (Accordion) node;
            for (Node child : ((Accordion) node).getPanes()) {
                Node result = lookupInternal(child, id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof TabPane) {
            TabPane bp = (TabPane) node;
            Node result = null;
            for (Tab tab : bp.getTabs()) {
                result = lookupInternal(tab.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
    }
    return null;
}

From source file:Main.java

private static Node lookupInternal(Node node, String id) {
    if (id.equals(node.getId())) {
        return node;
    }/*from w w  w . j  a  v a2 s . c  o  m*/
    if (node instanceof Parent) {
        for (Node child : ((Parent) node).getChildrenUnmodifiable()) {
            Node result = lookupInternal(child, id);
            if (result != null) {
                return result;
            }
        }
        if (node instanceof SplitPane) {
            SplitPane sp = (SplitPane) node;
            Node result = null;
            for (Node child : sp.getItems()) {
                result = lookupInternal(child, id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof ScrollPane) {
            ScrollPane sp = (ScrollPane) node;
            Node result = null;
            if (sp.getContent() != null) {
                result = lookupInternal(sp.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof BorderPane) {
            BorderPane sp = (BorderPane) node;
            Node result = null;
            if (sp.getBottom() != null) {
                result = lookupInternal(sp.getBottom(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getTop() != null) {
                result = lookupInternal(sp.getTop(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getLeft() != null) {
                result = lookupInternal(sp.getLeft(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getRight() != null) {
                result = lookupInternal(sp.getRight(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getCenter() != null) {
                result = lookupInternal(sp.getCenter(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof TitledPane) {
            TitledPane sp = (TitledPane) node;
            Node result = null;
            if (sp.getContent() != null) {
                result = lookupInternal(sp.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof Accordion) {
            for (Node child : ((Accordion) node).getPanes()) {
                Node result = lookupInternal(child, id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof TabPane) {
            TabPane bp = (TabPane) node;
            Node result = null;
            for (Tab tab : bp.getTabs()) {
                result = lookupInternal(tab.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
    }
    return null;
}

From source file:cz.lbenda.dataman.rc.DatamanApp.java

/** Add node to center pane */
private void addRemoveToDetail(@Nonnull String title, @Nonnull Node node, boolean closable) {
    boolean removed = false;
    for (Iterator<Tab> itt = detailTabs.getTabs().iterator(); itt.hasNext();) {
        Tab tab = itt.next();
        if (node.equals(tab.getContent())) {
            itt.remove();/*w  ww. j a v a  2  s .c  o  m*/
            removed = true;
        }
    }
    if (!removed) {
        Tab tab = new Tab(title, node);
        tab.setClosable(closable);
        this.detailTabs.getTabs().add(tab);
        this.detailTabs.getSelectionModel().select(tab);
    }
}

From source file:org.noroomattheinn.visibletesla.App.java

/**
 * Begin watching for user inactivity (keyboard input, mouse movements, etc.)
 * on any of the specified Tabs./*www . ja v  a2s .co  m*/
 * @param tabs  Watch for user activity targeted to any of these tabs.
 */
void watchForUserActivity(List<Tab> tabs) {
    for (Tab t : tabs) {
        Node n = t.getContent();
        n.addEventFilter(KeyEvent.ANY, new EventPassThrough());
        n.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventPassThrough());
        n.addEventFilter(MouseEvent.MOUSE_RELEASED, new EventPassThrough());
    }
    ThreadManager.get().launch(new InactivityThread(60L * 1000L * prefs.idleThresholdInMinutes.get()),
            "Inactivity");
}

From source file:de.pixida.logtest.designer.MainWindow.java

private Editor getEditorOfTab(final Tab currentTab) {
    Validate.notNull(currentTab.getContent());
    final Node currentContent = currentTab.getContent();
    if (currentContent instanceof Editor) {
        return (Editor) currentContent;
    }/* w w w  . ja  v  a  2s.c  o m*/
    return null;
}

From source file:ipat_fx.FXMLDocumentController.java

@FXML
public void nextGeneration() {

    //check if num of profiles is a valid input 
    int numOfProfiles = Integer.parseInt(noOfProfiles.getText());
    if (numOfProfiles > 8) {
        JOptionPane.showMessageDialog(null, "Please make the number of profiles smaller than 8.");
    } else {// w w w. j a v a  2  s .  c om
        HashMap<String, Object> scores = new HashMap<>();
        // TODO get the scores from the user input to then get the next gen

        ObservableList<Tab> tabs = null;

        if (tabFlag.equalsIgnoreCase("byImage")) {
            tabs = byImageTab.getTabs();
        } else if (tabFlag.equalsIgnoreCase("byProfile")) {
            tabs = byProfileTab.getTabs();
        } else {
            System.out.println("Something is wrong with tabFlag in FXML DOC CONT");
        }

        Iterator<Tab> profileTabIterator = tabs.iterator();
        while (profileTabIterator.hasNext()) {
            Tab profileTab = profileTabIterator.next();
            ScrollPane scrollPane = (ScrollPane) profileTab.getContent();
            FlowPane cells = (FlowPane) scrollPane.getContent();
            Iterator<Node> cellIterator = cells.getChildren().iterator();
            while (cellIterator.hasNext()) {
                GridPane cell = (GridPane) cellIterator.next();
                Iterator<Node> nodeIterator = cell.getChildren().iterator();
                while (nodeIterator.hasNext()) {
                    Node cellElement = nodeIterator.next();
                    if (cellElement instanceof Slider) {
                        scores.put(cellElement.getId(), String.valueOf(((Slider) cellElement).getValue()));
                    }
                    if (cellElement instanceof CheckBox) {
                        scores.put(cellElement.getId(), ((CheckBox) cellElement).isSelected());
                    }
                }
            }
        }

        HashMap<String, Object> display = controller.mainloop(scores, numOfProfiles);
        WebView previewView = (WebView) display.get("previewView");
        previewPane.getChildren().add(previewView);
        @SuppressWarnings("unchecked")
        HashMap<String, ArrayList<GridPane>> map = (HashMap<String, ArrayList<GridPane>>) display
                .get("results");

        if (tabFlag.equalsIgnoreCase("byImage")) {
            byImageTab = getByImage(map);
            byImagePane.setCenter(byImageTab);
        } else if (tabFlag.equalsIgnoreCase("byProfile")) {
            byProfileTab = getByProfile(map, numOfProfiles);
            byProfilePane.setCenter(byProfileTab);
        }

        tabPane.getSelectionModel().selectedIndexProperty()
                .addListener((ObservableValue<? extends Number> ov, Number oldValue, Number newValue) -> {
                    if (newValue == Number.class.cast(1)) {
                        byImageTab = getByImage(map);
                        byImagePane.setCenter(byImageTab);
                    } else if (newValue == Number.class.cast(0)) {
                        byProfileTab = getByProfile(map, numOfProfiles);
                        byProfilePane.setCenter(byProfileTab);
                    } else {
                        System.out.println("Error this tab has not been created.");
                    }
                });
    }
}

From source file:com.thomaskuenneth.tkmactuning.TKMacTuning.java

private void addPlugin(TabPane tabPane, String className, String pluginName) {
    try {/*  w  w  w .ja v  a  2  s .  c o  m*/
        Class clazz = Class.forName(className);
        Constructor cons = clazz.getConstructor(TKMacTuning.class, String.class);
        AbstractPlugin plugin = (AbstractPlugin) cons.newInstance(this, pluginName);
        String primaryUICategory = plugin.getPrimaryUICategory();
        Tab tab = (Tab) tabPane.getProperties().get(primaryUICategory);
        if (tab == null) {
            tab = new Tab(primaryUICategory);
            tabPane.getProperties().put(primaryUICategory, tab);
            tabPane.getTabs().add(tab);
            VBox content = new VBox();
            content.setPadding(LayoutConstants.PADDING_1);
            content.setSpacing(LayoutConstants.VERTICAL_CONTROL_GAP);
            tab.setContent(content);
        }
        VBox content = (VBox) tab.getContent();
        Node node = plugin.getNode();
        if (node != null) {
            String secondaryUICategory = plugin.getSecondaryUICategory();
            if (AbstractPlugin.ROOT.equals(secondaryUICategory)) {
                content.getChildren().add(node);
            } else {
                Pane group = (Pane) tabPane.getProperties().get(GROUP + secondaryUICategory);
                if (group == null) {
                    group = new VBox(LayoutConstants.VERTICAL_CONTROL_GAP);
                    tabPane.getProperties().put(GROUP + secondaryUICategory, group);
                    HBox headline = new HBox();
                    headline.setStyle(
                            "-fx-border-insets: 0 0 1 0; -fx-border-color: transparent transparent -fx-text-box-border transparent; -fx-border-width: 1;");
                    headline.getChildren().add(new Label(secondaryUICategory));
                    group.getChildren().add(headline);
                    content.getChildren().add(group);
                }
                group.getChildren().add(node);
            }
        } else {
            LOGGER.log(Level.SEVERE, "could not create control for plugin {0}({1})",
                    new Object[] { className, pluginName });
        }
    } catch (InstantiationException | ClassNotFoundException | NoSuchMethodException | SecurityException
            | InvocationTargetException | IllegalAccessException ex) {
        LOGGER.log(Level.SEVERE, "addPlugin()", ex);
    }
}

From source file:mesclasses.view.JourneeController.java

private void unselectTab(Tab tab) {
    tab.getContent().setManaged(false);
    tab.getContent().setVisible(false);
}

From source file:mesclasses.view.JourneeController.java

private void selectTab(Tab tab, SmartGrid grid) {
    tab.getContent().setManaged(true);
    tab.getContent().setVisible(true);/* w  w  w .  j a  v a2s.c  o  m*/
    double vvalue = 0;
    if (selectedScroll != null) {
        vvalue = selectedScroll.getVvalue();
    }
    selectedGrid = grid;
    selectedScroll = getScrollPane(tab);
    selectedScroll.setVvalue(vvalue);
}

From source file:mesclasses.view.JourneeController.java

private ScrollPane getScrollPane(Tab tab) {
    VBox box = (VBox) tab.getContent();
    for (Node child : box.getChildren()) {
        if (child instanceof ScrollPane) {
            return (ScrollPane) child;
        }/* w  w w.  j  a  va2  s . c  om*/
    }
    return null;
}