javafx.scene.control.Tab Java Examples

The following examples show how to use javafx.scene.control.Tab. 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: ResponseComponent.java    From milkman with MIT License 6 votes vote down vote up
public void display(RequestContainer request, AsyncResponseControl respCtrl) {
	var response = respCtrl.getResponse();
	
	clear();
	hideSpinner();

	addStatusInformation(response.getStatusInformations());
	
	setupAsyncControl(respCtrl);
	
	plugins.loadRequestAspectPlugins().stream()
		.flatMap(p -> p.getResponseTabs().stream())
		.forEach(tabController -> {
			plugins.wireUp(tabController);
			if (tabController.canHandleAspect(request, response)) {
				Tab aspectTab = tabController.getRoot(request, response);
				aspectTab.setClosable(false);
				tabs.getTabs().add(aspectTab);
			}
		});
	
	tabs.getSelectionModel().select(oldSelection);
}
 
Example #2
Source File: HighlightManager.java    From CPUSim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Checks the address of the given RAM and if it has a non-null
 * SourceLine, then bring the text window to front and highlight the
 * row.
 * Displays an error message if the text file doesn't exist or if
 * the desired line of the file does not exist.
 *
 * @param ram          the RAM with the SourceLines to be highlighted
 * @param breakAddress the address of the break point in ram
 */
private void highlightBreakInText(RAM ram, int breakAddress) {
    SourceLine sourceLine = ram.getSourceLine(breakAddress);
    if (sourceLine != null) {
        File file = new File(sourceLine.getFileName());
        if (!file.canRead()) {
            return;
        }
        Tab newTabForFile = desktop.getTabForFile(file);
        InlineStyleTextArea text = (InlineStyleTextArea) newTabForFile.getContent();
        int line = sourceLine.getLine();
        int start = getLineStartOffset(text.getText(), line);
        int end = getLineEndOffset(text.getText(), line);
        text.selectRange(start, end);

        // now change the background of the label in left column to orange
        LineNumAndBreakpointFactory lFactory =
                (LineNumAndBreakpointFactory) text.getParagraphGraphicFactory();
        lFactory.setCurrentBreakPointLineNumber(line);
    }
}
 
Example #3
Source File: ImportControl.java    From milkman with MIT License 6 votes vote down vote up
public ImportControl(boolean allowFile) {
	fileChooser = new FileChooser();
	rawContent = new TextArea();
	selectedFile = new TextField();
	
	Button openFileSelectionBtn = new Button("Select...");
	openFileSelectionBtn.setOnAction(e -> {
		File f = fileChooser.showOpenDialog(FxmlUtil.getPrimaryStage());
		if (f != null && f.exists() && f.isFile()) {
			selectedFile.setText(f.getPath());
		}
	});
	
	HBox.setHgrow(selectedFile, Priority.ALWAYS);
	HBox selectionCtrl = new HBox(selectedFile, openFileSelectionBtn);
	selectionCtrl.setPadding(new Insets(10));
	if (allowFile){
		getTabs().add(new Tab("File", selectionCtrl));
	}
	getTabs().add(new Tab("Raw", rawContent));
	VBox.setVgrow(this, Priority.ALWAYS);
}
 
Example #4
Source File: DefaultActionHandlerFactory.java    From kafka-message-tool with MIT License 6 votes vote down vote up
@Override
public TemplateGuiActionsHandler<KafkaListenerConfig> createListenerConfigListViewActionHandler(AnchorPane rightContentPane,
                                                                                                TabPane masterTabPane,
                                                                                                Tab tab,
                                                                                                ListView<KafkaListenerConfig> listView,
                                                                                                ListView<KafkaTopicConfig> topicConfigListView,
                                                                                                ControllerProvider repository) {
    return new ListenerConfigGuiActionsHandler(new TabPaneSelectionInformer(masterTabPane, tab),
                                               new ListViewActionsHandler<>(interactor, listView),
                                               modelDataProxy,
                                               repository,
                                               rightContentPane,
                                               topicConfigListView,
                                               applicationPorts.getListeners(),
                                               new ToFileSaver(interactor));
}
 
Example #5
Source File: TabSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TabSample() {
    BorderPane borderPane = new BorderPane();
    final TabPane tabPane = new TabPane();
    tabPane.setPrefSize(400, 400);
    tabPane.setSide(Side.TOP);
    tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
    final Tab tab1 = new Tab();
    tab1.setText("Tab 1");
    final Tab tab2 = new Tab();
    tab2.setText("Tab 2");
    final Tab tab3 = new Tab();
    tab3.setText("Tab 3");
    final Tab tab4 = new Tab();
    tab4.setText("Tab 4");
    tabPane.getTabs().addAll(tab1, tab2, tab3, tab4);
    borderPane.setCenter(tabPane);
    getChildren().add(borderPane);
}
 
Example #6
Source File: DashboardController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private void refreshCharts(Tab newValue) throws Exception {
	String id = newValue.getId();

	if (id.equals(tbTimeLosses.getId())) {
		onSelectTimeLosses();
	} else if (id.equals(tbFirstLevelPareto.getId())) {
		onSelectFirstLevelPareto();
	} else if (id.equals(tbYieldPareto.getId())) {
		onSelectStartupAndYieldPareto();
	} else if (id.equals(tbRejectsPareto.getId())) {
		onSelectRejectsPareto();
	} else if (id.equals(tbReducedSpeedPareto.getId())) {
		onSelectReducedSpeedPareto();
	} else if (id.equals(tbMinorStoppagesPareto.getId())) {
		onSelectMinorStoppagesPareto();
	} else if (id.equals(tbUnplannedDowntimePareto.getId())) {
		onSelectUnplannedDowntimePareto();
	} else if (id.equals(tbSetupPareto.getId())) {
		onSelectSetupPareto();
	} else if (id.equals(tbPlannedDowntimePareto.getId())) {
		onSelectPlannedDowntimePareto();
	} else if (id.equals(tbEvents.getId())) {
		onSelectHistory();
	}
}
 
Example #7
Source File: DataAccessSearchProvider.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    final String message;
    final DataAccessPane dapane = DataAccessUtilities.getDataAccessPane();
    if (dapane != null) {
        final Tab tab = dapane.getCurrentTab();
        if (tab != null) {
            final QueryPhasePane queryPhasePane = DataAccessPane.getQueryPhasePane(tab);
            Platform.runLater(() -> {
                queryPhasePane.expandPlugin(pluginName);
            });

            return;
        } else {
            message = "Please create a step in the Data Access view.";
        }
    } else {
        message = "Please open the Data Access view and create a step.";
    }

    NotificationDisplayer.getDefault().notify("Data Access view",
            UserInterfaceIconProvider.WARNING.buildIcon(16, ConstellationColor.DARK_ORANGE.getJavaColor()),
            message,
            null
    );
}
 
Example #8
Source File: MarketView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void loadView(Class<? extends View> viewClass) {
    final Tab tab;
    View view = viewLoader.load(viewClass);

    if (view instanceof OfferBookChartView) tab = offerBookTab;
    else if (view instanceof TradesChartsView) tab = tradesTab;
    else if (view instanceof SpreadView) tab = spreadTab;
    else throw new IllegalArgumentException("Navigation to " + viewClass + " is not supported");

    if (tab.getContent() != null && tab.getContent() instanceof ScrollPane) {
        ((ScrollPane) tab.getContent()).setContent(view.getRoot());
    } else {
        tab.setContent(view.getRoot());
    }
    root.getSelectionModel().select(tab);
}
 
Example #9
Source File: SettingController.java    From JFX-Browser with MIT License 6 votes vote down vote up
public Tab getSettingView(Tab settingTab, BorderPane borderpane) {

		/*
		 * Add two buttons in gridpane that will be put in
		 * drawer->drawerstack(container) -> left side of border to come ount
		 * whenever user click the setting button
		 */

		// ---------------------------------Right----DrawerStack--------------------------------

		// Setting the left side of Borderpane drawerstack container
		try {
			// ScrollPane scrollPane = new ScrollPane();
			System.out.println("Setting fxml is ready to set");
			borderpane.setCenter(FXMLLoader.load(getClass().getResource(Main.FXMLS+"Setting.fxml")));
		} catch (Exception e1) {
			System.out.println("Exception: Setting fxml is not set");
			System.out.println("File is not find for setting! " + " \n " + e1);

		}

		// borderpane.setCenter(root);
		settingTab.setContent(borderpane);

		return settingTab;
	}
 
Example #10
Source File: FunctionTreeFactory.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
public static void clearContent(ObservableList<Textual> extracts, TabPane editorList, Supplier<Void> doAfter) {

        if (extracts.isEmpty()) {
            doAfter.get();
        }

        for (Textual entry : extracts) {
            Platform.runLater(() -> {
                Tab tab = getTabFromTextual(editorList, entry);
                Event.fireEvent(tab, new Event(Tab.TAB_CLOSE_REQUEST_EVENT));
                if (editorList.getTabs().size() <= 1) {
                    extracts.clear();
                    doAfter.get();
                }
            });
        }
    }
 
Example #11
Source File: DataAccessPane.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * check whether the selected plugins contain any parameters with invalid
 * values
 *
 * @param tab
 * @return
 */
private boolean validateTabEnabledPlugins(Tab tab) {
    for (DataSourceTitledPane pane : getQueryPhasePane(tab).getDataAccessPanes()) {
        if (pane.isQueryEnabled()) {
            final PluginParameters params = pane.getParameters();
            if (params != null) {
                final Map<String, PluginParameter<?>> paramsMap = params.getParameters();
                for (Map.Entry<String, PluginParameter<?>> entry : paramsMap.entrySet()) {
                    final PluginParameter<?> value = entry.getValue();
                    if (value.getError() != null) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
 
Example #12
Source File: OptionsDialog.java    From milkman with MIT License 6 votes vote down vote up
public void showAndWait(List<OptionPageProvider> optionPageProviders) {
	JFXDialogLayout content = new OptionsDialogFxml(this);
	content.setPrefWidth(600);
	for(OptionPageProvider<?> p : optionPageProviders) {
		OptionDialogPane pane = p.getOptionsDialog(new OptionDialogBuilder());
		Tab tab = new Tab("", pane);
		Label label = new Label(pane.getName());
		label.setRotate(90);
		label.setMinWidth(100);
		label.setMaxWidth(100);
		label.setMinHeight(40);
		label.setMaxHeight(40);
		tab.setGraphic(label);
		tabs.getTabs().add(tab);
		
	}

	dialog = FxmlUtil.createDialog(content);
	
	dialog.showAndWait();
}
 
Example #13
Source File: CircuitSim.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Selects the tab of the specified circuit and changes its current state to the specified state.
 *
 * @param circuit The circuit whose tab will be selected
 * @param state   The state to set as the current state. May be null (no change to the current state).
 */
public void switchToCircuit(Circuit circuit, CircuitState state) {
	runFxSync(() -> {
		if(state != null) {
			CircuitManager manager = getCircuitManager(circuit);
			if(manager != null) {
				manager.getCircuitBoard().setCurrentState(state);
			}
		}
		
		Tab tab = getTabForCircuit(circuit);
		if(tab != null) {
			canvasTabPane.getSelectionModel().select(tab);
			needsRepaint = true;
		}
	});
}
 
Example #14
Source File: DemoTabPane.java    From bootstrapfx with MIT License 6 votes vote down vote up
private DemoTab(String title, String sourceFile) throws Exception {
    super(title);
    setClosable(false);

    TabPane content = new TabPane();
    setContent(content);
    content.setSide(Side.BOTTOM);

    Tab widgets = new Tab("Widgets");
    widgets.setClosable(false);
    URL location = getClass().getResource(sourceFile);
    FXMLLoader fxmlLoader = new FXMLLoader(location);
    Node node = fxmlLoader.load();
    widgets.setContent(node);

    Tab source = new Tab("Source");
    source.setClosable(false);
    XMLEditor editor = new XMLEditor();
    editor.setEditable(false);

    String text = IOUtils.toString(getClass().getResourceAsStream(sourceFile));
    editor.setText(text);
    source.setContent(editor);

    content.getTabs().addAll(widgets, source);
}
 
Example #15
Source File: FileEditorTabPane.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 6 votes vote down vote up
boolean closeEditor(FileEditor fileEditor, boolean save) {
	if (fileEditor == null)
		return true;

	Tab tab = fileEditor.getTab();

	if (save) {
		Event event = new Event(tab,tab,Tab.TAB_CLOSE_REQUEST_EVENT);
		Event.fireEvent(tab, event);
		if (event.isConsumed())
			return false;
	}

	runWithoutSavingEditorsState(() -> {
		tabPane.getTabs().remove(tab);
		if (tab.getOnClosed() != null)
			Event.fireEvent(tab, new Event(Tab.CLOSED_EVENT));
	});

	saveEditorsState();

	return true;
}
 
Example #16
Source File: MainWindow.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Tab createContainersTab(ContainersFeaturePanel containers) {
    final Tab containersTab = new Tab(tr("Containers"), containers);

    containersTab.setClosable(false);

    containersTab.setOnSelectionChanged(event -> containers.getContainersManager().fetchContainers(
            containerCategories -> Platform.runLater(() -> {
                containers.getCategories().setAll(containerCategories);
                containers.setInitialized(true);
            }),
            e -> Platform.runLater(() -> {
                final ErrorDialog errorDialog = ErrorDialog.builder()
                        .withMessage(tr("Loading containers failed."))
                        .withException(e)
                        .withOwner(containers.getScene().getWindow())
                        .build();

                errorDialog.showAndWait();
            })));

    return containersTab;
}
 
Example #17
Source File: TerminalTab.java    From TerminalFX with MIT License 5 votes vote down vote up
private void closeOtherTerminals(ActionEvent actionEvent) {
    final ObservableList<Tab> tabs = FXCollections.observableArrayList(this.getTabPane().getTabs());
    for (final Tab tab : tabs) {
        if (tab instanceof TerminalTab) {
            if (tab != this) {
                ((TerminalTab) tab).closeTerminal();
            }
        }
    }
}
 
Example #18
Source File: Validate.java    From CPUSim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check if the address in the Loading tab is valid and in bound.
 * @param address string of the address
 * @param ramLength length of the RAM
 */
public static void addressIsValidAndInBound(String address,
                                            int ramLength,
                                            TabPane tabPane,
                                            Tab loadingTab){
    int startInt = 0;
    // Catch non number entries
    try {
        startInt = Integer.parseInt(address);
    } catch (NumberFormatException nfe) {
        if (tabPane.getSelectionModel().getSelectedItem() != loadingTab) {
            tabPane.getSelectionModel().select(loadingTab);
        throw new ValidationException(
                "The starting address is invalid. Please change to a" +
                        " valid integer.");
        }
    }

    // Catch out of bound entries
    if (0 > startInt || startInt >= ramLength) {
        if (tabPane.getSelectionModel().getSelectedItem() != loadingTab) {
            tabPane.getSelectionModel().select(loadingTab);
            throw new ValidationException(
                "The starting address is out of range. Please change to a" +
                        " valid integer between 0 and " + (ramLength - 1) + ".");
        }
    }
}
 
Example #19
Source File: ScenicViewGui.java    From scenic-view with GNU General Public License v3.0 5 votes vote down vote up
private void updateMenuBar(final Tab oldValue, final Tab newValue) {
    if (oldValue != null && oldValue instanceof ContextMenuContainer) {
        Menu menu = ((ContextMenuContainer) oldValue).getMenu();
        menuBar.getMenus().remove(menu);
    }
    if (newValue != null && newValue instanceof ContextMenuContainer) {
        Menu newMenu = ((ContextMenuContainer) newValue).getMenu();
        if (newMenu != null) {
            menuBar.getMenus().add(menuBar.getMenus().size() - 1, newMenu);
        }
    }
}
 
Example #20
Source File: IdeController.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
private Program createTab(DocumentType type, File document, boolean isBlank) {
    WebView editor = new WebView();
    Program proxy = new Program(type, globalOptions);
    proxy.initEditor(editor, document, isBlank);
    Tab t = new Tab(proxy.getName(), editor);
    tabPane.getTabs().add(t);
    openDocuments.put(t, proxy);
    t.setOnCloseRequest(this::handleCloseTabRequest);
    return proxy;
}
 
Example #21
Source File: GuiFactory.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public Tab getTab(String name, TextArea textArea)
{
  Tab tab = new Tab();
  tab.setText(name);
  tab.setContent(textArea);
  return tab;
}
 
Example #22
Source File: Editor.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
/** Saves all tabs. */
protected void saveAll() {
  for (Tab openTab : editorTabPane.getTabs()) {
    EditorTab tab = (EditorTab) openTab;
    saveTab(tab, false);
  }
}
 
Example #23
Source File: Simulator.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
/** Shows/hides symbol table. */
private void symbolTable() {
  if (Settings.SHOW_ST.get()) {
    if (!hardware.getTabs().contains(symbolTableTab)) {
      hardware.getTabs().add(symbolTableTab);
    }
  } else {
    Tab selected = hardware.getSelectionModel().getSelectedItem();
    hardware.getTabs().remove(symbolTableTab);
    if (selected == symbolTableTab) {
      hardware.getSelectionModel().select(0);
    }
  }
}
 
Example #24
Source File: TabDockingContainer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void debugPrint(String indent) {
    System.out.println(indent + "tab(" + getProperties().get(DockingDesktop.DOCKING_CONTAINER) + ")");
    ObservableList<Tab> tabs = getTabs();
    for (Tab tab : tabs) {
        if (tab.getContent() instanceof IDockingContainer) {
            ((IDockingContainer) tab.getContent()).debugPrint(indent + "  ");
        } else {
            System.out.println(indent + "  " + tab.getText());
        }
    }
}
 
Example #25
Source File: TabDockingContainer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void changed(ObservableValue<? extends Tab> observable, Tab oldValue, Tab newValue) {
    Dockable o = null, n = null;
    for (Dockable d : dockables) {
        if (oldValue != null && oldValue.getContent() == d.getComponent()) {
            o = d;
        }
        if (newValue != null && newValue.getContent() == d.getComponent()) {
            n = d;
        }
    }
    desktop.fireDockableSelectionEvent(o, n);
}
 
Example #26
Source File: CircuitSim.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Tab getTabForCircuit(Circuit circuit) {
	for(Entry<String, Pair<ComponentLauncherInfo, CircuitManager>> entry : circuitManagers.entrySet()) {
		if(entry.getValue().getValue().getCircuit() == circuit) {
			for(Tab tab : canvasTabPane.getTabs()) {
				if(tab.getText().equals(entry.getKey())) {
					return tab;
				}
			}
		}
	}
	
	return null;
}
 
Example #27
Source File: SqlAspectEditor.java    From milkman with MIT License 5 votes vote down vote up
@Override
@SneakyThrows
public Tab getRoot(RequestContainer request) {
	val sqlAspect = request.getAspect(JdbcSqlAspect.class)
			.orElseThrow(() -> new IllegalArgumentException("Jdbc Sql Aspect missing"));
	
	ContentEditor root = new ContentEditor();
	root.setEditable(true);
	root.setContent(sqlAspect::getSql, run(sqlAspect::setSql).andThen(() -> sqlAspect.setDirty(true)));
	root.setContentTypePlugins(Collections.singletonList(new SqlContentType()));
	root.setContentType("application/sql");
	return new Tab("Body", root);
}
 
Example #28
Source File: FxDockTabPane.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public int indexOfTab(Node n)
{
	ObservableList<Tab> ts = getTabs();
	for(int i=ts.size()-1; i>=0; --i)
	{
		Tab t = ts.get(i);
		if(t.getContent() == n)
		{
			return i;
		}
	}
	return -1;
}
 
Example #29
Source File: EditorAreaComponent.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Add and open the new file editor.
 *
 * @param editor   the editor
 * @param needShow the need show
 */
@FxThread
private void addEditor(@NotNull FileEditor editor, boolean needShow) {

    var editFile = editor.getEditFile();

    var tab = new Tab(editor.getFileName());
    tab.setGraphic(new ImageView(ICON_MANAGER.getIcon(editFile, DEFAULT_FILE_ICON_SIZE)));
    tab.setContent(editor.getPage());
    tab.setOnCloseRequest(event -> handleRequestToCloseEditor(editor, tab, event));
    tab.getProperties().put(KEY_EDITOR, editor);

    editor.dirtyProperty().addListener((observable, oldValue, newValue) ->
            tab.setText(newValue == Boolean.TRUE ? "*" + editor.getFileName() : editor.getFileName()));

    getTabs().add(tab);

    if (needShow) {
        getSelectionModel().select(tab);
    }

    DictionaryUtils.runInWriteLock(getOpenedEditors(), editFile, tab, ObjectDictionary::put);
    ArrayUtils.runInWriteLock(getOpeningFiles(), editFile, Array::fastRemove);

    UiUtils.decrementLoading();

    if (isIgnoreOpenedFiles()) {
        return;
    }

    var workspace = WORKSPACE_MANAGER.getCurrentWorkspace();
    if (workspace != null) {
        workspace.addOpenedFile(editFile, editor);
    }
}
 
Example #30
Source File: IdeController.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
@FXML
void onSaveAllClicked(ActionEvent event) {
    openDocuments.forEach((Tab t, Program p) -> {
        if (p.isChanged()) {
            if (p.getFile().isPresent()) {
                p.save(p.getFile().get());
                t.setText(p.getName());
            } else {
                tabPane.getSelectionModel().select(t);
                onSaveAsClicked(event);
            }
        }
    });
}