Example usage for javafx.scene.control Tab setContent

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

Introduction

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

Prototype

public final void setContent(Node value) 

Source Link

Document

The content to show within the main TabPane area.

Usage

From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java

private void addFixtureTab(final Fixture fixture, boolean isDefault) {
    try {//  w  ww  .j a  v a2  s .co m
        FXMLLoader loader = new FXMLLoader(getClass().getResource("Fixture.fxml"));
        Parent fixtureTab = (Parent) loader.load();

        FixtureController controller = loader.getController();
        controller.setFixture(fixture);
        controller.setIsDefault(isDefault);

        Tab newTab = new Tab(fixture.getName());
        newTab.setContent(fixtureTab);
        newTab.closableProperty().setValue(!isDefault);
        newTab.setOnCloseRequest(event -> {
            boolean isOkClicked = showConfirmationDialog(
                    UIMessages.getMessage("UI_CLOSE_TAB_LABEL", fixture.getName()));
            if (!isOkClicked) {
                event.consume();
            } else {
                fixtures.getFixtures().remove(fixture);
            }
        });
        fixtureTabPane.getTabs().add(newTab);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:acmi.l2.clientmod.xdat.Controller.java

@Override
public void initialize(URL location, ResourceBundle resources) {
    interfaceResources = resources;//from   w w  w  . j  av  a 2s .c o  m

    Node scriptingTab = loadScriptTabContent();

    initialDirectory.addListener((observable, oldVal, newVal) -> {
        if (newVal != null)
            XdatEditor.getPrefs().put("initialDirectory", newVal.getPath());
    });
    editor.xdatClassProperty().addListener((ob, ov, nv) -> {
        log.log(Level.INFO, String.format("XDAT class selected: %s", nv.getName()));

        tabs.getTabs().clear();

        for (Iterator<InvalidationListener> it = xdatListeners.iterator(); it.hasNext();) {
            editor.xdatObjectProperty().removeListener(it.next());
            it.remove();
        }

        editor.setXdatObject(null);

        if (scriptingTab != null) {
            Tab tab = new Tab("script console");
            tab.setContent(scriptingTab);
            tabs.getTabs().add(tab);
        }

        Arrays.stream(nv.getDeclaredFields()).filter(field -> List.class.isAssignableFrom(field.getType()))
                .forEach(field -> {
                    field.setAccessible(true);
                    tabs.getTabs().add(createTab(field));
                });
    });
    progressBar.visibleProperty().bind(editor.workingProperty());
    open.disableProperty().bind(Bindings.isNull(editor.xdatClassProperty()));
    BooleanBinding nullXdatObject = Bindings.isNull(editor.xdatObjectProperty());
    tabs.disableProperty().bind(nullXdatObject);
    save.disableProperty().bind(nullXdatObject);
    saveAs.disableProperty().bind(nullXdatObject);

    xdatFile.addListener((observable, oldValue, newValue) -> {
        if (newValue == null)
            return;

        Collection<File> files = FileUtils.listFiles(newValue.getParentFile(),
                new WildcardFileFilter("SysString-*.dat"), null);
        if (!files.isEmpty()) {
            File file = files.iterator().next();
            log.info("sysstring file: " + file);
            try (InputStream is = L2Crypt.decrypt(new FileInputStream(file), file.getName())) {
                SysstringPropertyEditor.strings.clear();
                int count = IOUtil.readInt(is);
                for (int i = 0; i < count; i++) {
                    SysstringPropertyEditor.strings.put(IOUtil.readInt(is), IOUtil.readString(is));
                }
            } catch (Exception ignore) {
            }
        }

        File file = new File(newValue.getParentFile(), "L2.ini");
        try {
            TexturePropertyEditor.environment = new Environment(file);
            TexturePropertyEditor.environment.getPaths().forEach(s -> log.info("environment path: " + s));
        } catch (Exception ignore) {
        }
    });
}

From source file:io.github.moosbusch.permagon.configuration.builder.spi.AbstractPermagonBuilder.java

protected void buildTab(Tab pane) {
    if (containsKey(NODE_CONTENT_PROPERTY)) {
        Object obj = Objects.requireNonNull(get(NODE_CONTENT_PROPERTY));

        if (obj instanceof ObservableMap) {
            ObservableMap propertiesMap = (ObservableMap) obj;
            Object childrenObj = Objects.requireNonNull(propertiesMap.get(NODE_CONTENT_PROPERTY));

            if (childrenObj instanceof Node) {
                pane.setContent((Node) childrenObj);
            }//  www  . j  a v  a  2 s  .  c om
        }
    }
}

From source file:de.dkfz.roddy.client.fxuiclient.RoddyUIController.java

public void addTab(Pane component, String title, TabType tabType, boolean closable) {
    Tab t = new Tab(title);
    t.setStyle("TabHeader" + tabType.name());
    t.setClosable(true);//from  www.  j ava2  s . c  om
    t.setContent(component);
    if (tabType == TabType.Dataset)
        t.setGraphic(new ImageView(iconDatasetSpecific));
    appTabs.getTabs().add(t);
}

From source file:de.micromata.mgc.javafx.launcher.gui.AbstractConfigDialog.java

private Tab createTab(LocalSettingsConfigModel configModel,
        Pair<Pane, ? extends AbstractConfigTabController<?>> wc) {
    AbstractConfigTabController<?> contrl = wc.getSecond();
    contrl.setConfigDialog(this);

    Pane tabPane = wc.getFirst();/*from w  ww.  j av  a2s.c o  m*/

    contrl.setTabPane(tabPane);
    Tab tabB = new Tab();

    AnchorPane tabContentPane = new AnchorPane();
    tabContentPane.setMaxHeight(Integer.MAX_VALUE);
    //    tabContentPane.setPrefHeight(500);
    FeedbackPanel feedback = new FeedbackPanel();

    feedback.setPrefHeight(100);
    feedback.setMinHeight(100);
    FXEvents.get().addEventHandler(this, feedback, FeedbackPanelEvents.CLEAR, event -> {
        feedback.clearMessages();
    });
    contrl.setFeedback(feedback);
    tabContentPane.getChildren().add(tabPane);
    tabContentPane.getChildren().add(feedback);
    AnchorPane.setTopAnchor(tabPane, 2.0);
    AnchorPane.setRightAnchor(tabPane, 0.0);
    AnchorPane.setLeftAnchor(tabPane, 0.0);
    AnchorPane.setBottomAnchor(tabPane, 70.0);
    AnchorPane.setBottomAnchor(feedback, 0.0);

    tabB.setContent(tabContentPane);
    AnchorPane.setTopAnchor(tabContentPane, 0.0);
    AnchorPane.setRightAnchor(tabContentPane, 0.0);
    AnchorPane.setLeftAnchor(tabContentPane, 0.0);
    AnchorPane.setBottomAnchor(tabContentPane, 0.0);

    Node scrollPane = tabPane.getChildren().get(0);
    AnchorPane.setTopAnchor(scrollPane, 0.0);
    AnchorPane.setRightAnchor(scrollPane, 0.0);
    AnchorPane.setLeftAnchor(scrollPane, 0.0);
    AnchorPane.setBottomAnchor(scrollPane, 0.0);

    configurationTabs.getTabs().add(tabB);
    tabController.add(contrl);
    contrl.setTab(tabB);
    ((ModelController) contrl).setModel(configModel);
    contrl.initializeWithModel();
    contrl.addToolTips();
    tabB.setText(contrl.getTabTitle());
    contrl.registerValMessageReceivers();

    return tabB;
}

From source file:acmi.l2.clientmod.xdat.Controller.java

private Tab createTab(Field listField) {
    Tab tab = new Tab(listField.getName());

    SplitPane pane = new SplitPane();

    TextField filter = TextFields.createClearableTextField();
    VBox.setMargin(filter, new Insets(2));
    TreeView<Object> elements = createTreeView(listField, filter.textProperty());
    VBox.setVgrow(elements, Priority.ALWAYS);
    PropertySheet properties = createPropertySheet(elements);

    pane.getItems().addAll(new VBox(filter, elements), properties);
    pane.setDividerPositions(0.3);//  ww  w .  j  a v  a2 s. c  o m

    tab.setContent(wrap(pane));

    return tab;
}

From source file:ipat_fx.FXMLDocumentController.java

public TabPane getByProfile(HashMap<String, ArrayList<GridPane>> map, int noOfProfiles) {

    TabPane tabpane = new TabPane();
    Tab tabForProfile;
    FlowPane paneForProfile;//  ww w  .  j a  v a2s.com

    for (int i = 0; i < noOfProfiles; i++) {
        tabForProfile = new Tab();
        paneForProfile = new FlowPane();
        tabForProfile.setId("li_Profile_" + i);
        tabForProfile.setText("Profile " + i);
        int j = 0;
        for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext(); j++) {
            String nameOfArtefact = iterator.next();
            ArrayList<GridPane> cells = map.get(nameOfArtefact);
            paneForProfile.getChildren().add(cells.get(i));
        }
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setContent(paneForProfile);
        tabForProfile.setContent(scrollPane);
        tabpane.getTabs().add(tabForProfile);
    }
    return tabpane;
}

From source file:ipat_fx.FXMLDocumentController.java

public TabPane getByImage(HashMap<String, ArrayList<GridPane>> map) {

    TabPane tabpane = new TabPane();
    Tab tabForImage;
    FlowPane paneForImage;//from   w w w  .  ja  v  a  2s  .co m

    Iterator<String> iterator = map.keySet().iterator();
    while (iterator.hasNext()) {
        tabForImage = new Tab();
        paneForImage = new FlowPane();
        String nameOfArtefact = iterator.next();
        tabForImage.setId("li_" + nameOfArtefact);
        tabForImage.setText(nameOfArtefact);
        ArrayList<GridPane> cells = map.get(nameOfArtefact);
        for (GridPane cell1 : cells) {
            GridPane cell = cell1;
            //paneForImage.add(cell, 0, i);
            paneForImage.getChildren().add(cell);
        }
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setContent(paneForImage);
        tabForImage.setContent(scrollPane);
        tabpane.getTabs().add(tabForImage);
    }
    return tabpane;
}

From source file:org.beryx.viewreka.fxapp.Viewreka.java

public void refreshViews() {
    if (project == null)
        return;/*www.  j a  v  a 2 s . c  om*/

    project.getProjectSettingsManager().saveSettings();

    viewsTabPane.getTabs().clear();

    ProjectSettings projectSettings = project.getProjectSettingsManager().getSettings();
    String currentViewName = projectSettings.getCurrentView();

    Tab selectedTab = null;
    for (FxView view : project.getViews()) {
        String viewName = view.getName();
        final Tab tab = new Tab(viewName);
        viewsTabPane.getTabs().add(tab);
        if (viewName.equals(currentViewName)) {
            selectedTab = tab;
        }

        final ViewPane<?> viewPane = ViewPane.fromModel(view, projectSettings);
        tab.setContent(viewPane);

        viewPane.autosize();

        tab.setOnSelectionChanged(new EventHandler<Event>() {
            @Override
            public void handle(Event event) {
                viewPane.autosize();
                Tab selTab = viewsTabPane.getSelectionModel().getSelectedItem();
                if (selTab != null) {
                    String selectedView = selTab.getText();
                    projectSettings.setCurrentView(selectedView);
                }
            }
        });
    }

    if (selectedTab != null) {
        viewsTabPane.getSelectionModel().select(selectedTab);
    }
    layout();
}

From source file:gov.va.isaac.gui.preferences.PreferencesViewController.java

public void aboutToShow() {
    // Using allValid_ to prevent rerunning content of aboutToShow()
    if (allValid_ == null) {
        // These listeners are for debug and testing only. They may be removed at any time.
        UserProfileBindings userProfileBindings = AppContext.getService(UserProfileBindings.class);
        for (Property<?> property : userProfileBindings.getAll()) {
            property.addListener(new ChangeListener<Object>() {
                @Override//from  w w  w. j  av a  2 s.co  m
                public void changed(ObservableValue<? extends Object> observable, Object oldValue,
                        Object newValue) {
                    logger.debug("{} property changed from {} to {}", property.getName(), oldValue, newValue);
                }
            });
        }

        // load fields before initializing allValid_
        // in case plugin.validationFailureMessageProperty() initialized by getNode()
        tabPane_.getTabs().clear();
        List<PreferencesPluginViewI> sortableList = new ArrayList<>();
        Comparator<PreferencesPluginViewI> comparator = new Comparator<PreferencesPluginViewI>() {
            @Override
            public int compare(PreferencesPluginViewI o1, PreferencesPluginViewI o2) {
                if (o1.getTabOrder() == o2.getTabOrder()) {
                    return o1.getName().compareTo(o2.getName());
                } else {
                    return o1.getTabOrder() - o2.getTabOrder();
                }
            }
        };
        for (PreferencesPluginViewI plugin : plugins_) {
            sortableList.add(plugin);
        }
        Collections.sort(sortableList, comparator);
        for (PreferencesPluginViewI plugin : sortableList) {
            logger.debug("Adding PreferencesPluginView tab \"{}\"", plugin.getName());
            Label tabLabel = new Label(plugin.getName());

            tabLabel.setMaxHeight(Double.MAX_VALUE);
            tabLabel.setMaxWidth(Double.MAX_VALUE);
            Tab pluginTab = new Tab();
            pluginTab.setGraphic(tabLabel);
            Region content = plugin.getContent();
            content.setMaxWidth(Double.MAX_VALUE);
            content.setMaxHeight(Double.MAX_VALUE);
            content.setPadding(new Insets(5.0));

            Label errorMessageLabel = new Label();
            errorMessageLabel.textProperty().bind(plugin.validationFailureMessageProperty());
            errorMessageLabel.setAlignment(Pos.BOTTOM_CENTER);
            TextErrorColorHelper.setTextErrorColor(errorMessageLabel);

            VBox vBox = new VBox();
            vBox.getChildren().addAll(errorMessageLabel, content);
            vBox.setMaxWidth(Double.MAX_VALUE);
            vBox.setAlignment(Pos.TOP_CENTER);

            plugin.validationFailureMessageProperty().addListener(new ChangeListener<String>() {
                @Override
                public void changed(ObservableValue<? extends String> observable, String oldValue,
                        String newValue) {
                    if (newValue != null && !StringUtils.isEmpty(newValue)) {
                        TextErrorColorHelper.setTextErrorColor(tabLabel);
                    } else {
                        TextErrorColorHelper.clearTextErrorColor(tabLabel);
                    }
                }
            });
            //Initialize, if stored value is wrong
            if (StringUtils.isNotEmpty(plugin.validationFailureMessageProperty().getValue())) {
                TextErrorColorHelper.setTextErrorColor(tabLabel);
            }
            pluginTab.setContent(vBox);
            tabPane_.getTabs().add(pluginTab);
        }

        allValid_ = new ValidBooleanBinding() {
            {
                ArrayList<ReadOnlyStringProperty> pluginValidationFailureMessages = new ArrayList<>();
                for (PreferencesPluginViewI plugin : plugins_) {
                    pluginValidationFailureMessages.add(plugin.validationFailureMessageProperty());
                }
                bind(pluginValidationFailureMessages
                        .toArray(new ReadOnlyStringProperty[pluginValidationFailureMessages.size()]));
                setComputeOnInvalidate(true);
            }

            @Override
            protected boolean computeValue() {
                for (PreferencesPluginViewI plugin : plugins_) {
                    if (plugin.validationFailureMessageProperty().get() != null
                            && plugin.validationFailureMessageProperty().get().length() > 0) {
                        this.setInvalidReason(plugin.validationFailureMessageProperty().get());

                        logger.debug("Setting PreferencesView allValid_ to false because \"{}\"",
                                this.getReasonWhyInvalid().get());
                        return false;
                    }
                }

                logger.debug("Setting PreferencesView allValid_ to true");

                this.clearInvalidReason();
                return true;
            }
        };

        okButton_.disableProperty().bind(allValid_.not());
        // set focus on default
        // Platform.runLater(...);
    }

    // Reload persisted values every time view opened
    for (PreferencesPluginViewI plugin : plugins_) {
        plugin.getContent();
    }
}