Java Code Examples for javafx.scene.control.Tab

The following examples show how to use javafx.scene.control.Tab. These examples are extracted from open source projects. 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 Project: bootstrapfx   Source File: DemoTabPane.java    License: 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 2
/**
 * 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 3
Source Project: constellation   Source File: DataAccessPane.java    License: 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 4
Source Project: JFX-Browser   Source File: SettingController.java    License: 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 5
Source Project: constellation   Source File: DataAccessSearchProvider.java    License: 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 6
Source Project: CPUSim   Source File: HighlightManager.java    License: 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 7
Source Project: bisq   Source File: MarketView.java    License: 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 8
Source Project: milkman   Source File: ImportControl.java    License: 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 9
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 10
Source Project: milkman   Source File: ResponseComponent.java    License: 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 11
Source Project: milkman   Source File: OptionsDialog.java    License: 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 12
Source Project: phoenicis   Source File: MainWindow.java    License: 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 13
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 14
Source Project: OEE-Designer   Source File: DashboardController.java    License: 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 15
Source Project: marathonv5   Source File: TabSample.java    License: 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 16
Source Project: kafka-message-tool   Source File: DefaultActionHandlerFactory.java    License: 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 17
Source Project: constellation   Source File: ConfigurationPane.java    License: Apache License 2.0 5 votes vote down vote up
public void createNewRun(final Map<String, Attribute> vertexAttributes, final Map<String, Attribute> transactionAttributes, final Set<Integer> keys, final String[] columns, final List<String[]> data) {
    final Tab tab = createTab();
    RunPane runPane = (RunPane) tab.getContent();
    runPane.requestLayout();

    Platform.runLater(() -> {
        RunPane runPane1 = (RunPane) tab.getContent();
        runPane1.setDisplayedAttributes(vertexAttributes, transactionAttributes, keys);
        runPane1.setSampleData(columns, createTableRows(data));
    });
}
 
Example 18
@Override
public void start(Stage stage) throws Exception {
   
    TabPane tabPane = new TabPane();
    Tab tab1 = new Tab();
    tab1.setText("Demos");
    tab1.setClosable(false);
    
    SplitPane sp = new SplitPane();
    final StackPane sp1 = new StackPane();
    sp1.getChildren().add(createTreeView());
    final BorderPane sp2 = new BorderPane();
    sp2.setCenter(createChartPane());
 
    sp.getItems().addAll(sp1, sp2);
    sp.setDividerPositions(0.3f, 0.6f);
    tab1.setContent(sp);
    tabPane.getTabs().add(tab1);        
 
    Tab tab2 = new Tab();
    tab2.setText("About");
    tab2.setClosable(false);
    
    WebView browser = new WebView();
    WebEngine webEngine = browser.getEngine();
    webEngine.load(getClass().getResource("/org/jfree/chart3d/fx/demo/about.html").toString());
    tab2.setContent(browser);
    tabPane.getTabs().add(tab2);        

    Scene scene = new Scene(tabPane, 1024, 768);
    stage.setScene(scene);
    stage.setTitle("Orson Charts JavaFX Demo");
    stage.show();
}
 
Example 19
Source Project: constellation   Source File: ConfigurationPane.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns a combined collection of all attributes that have been allocated
 * to a column in any run.
 *
 * @return a combined collection of all attributes that have been allocated
 * to a column in any run.
 */
public Collection<Attribute> getAllocatedAttributes() {
    List<Attribute> allocatedAttributes = new ArrayList<>();
    for (Tab tab : tabPane.getTabs()) {
        RunPane runPane = (RunPane) tab.getContent();
        allocatedAttributes.addAll(runPane.getAllocatedAttributes());
    }

    return allocatedAttributes;
}
 
Example 20
Source Project: marathonv5   Source File: TabDockingContainer.java    License: Apache License 2.0 5 votes vote down vote up
private void populateMenuItems(ContextMenu contextMenu, Tab tab) {
    int tabCount = getTabs().size();
    int tabIndex = getTabs().indexOf(tab);
    ObservableList<MenuItem> items = contextMenu.getItems();
    items.clear();
    MenuItem closeMenuItem = new MenuItem("Close");
    closeMenuItem.setOnAction((e) -> requestClose(tab));
    items.add(closeMenuItem);
    if (tabCount > 1) {
        MenuItem closeRestMenuItem = new MenuItem("Close Others");
        closeRestMenuItem.setOnAction((e) -> closeOtherTabs(tab));
        items.add(closeRestMenuItem);
    }
    if (tabCount > 1 && tabIndex != 0) {
        MenuItem closeLeftTabsMenuItem = new MenuItem("Close Tabs to the Left");
        closeLeftTabsMenuItem.setOnAction((e) -> closeTabsToLeft(tab));
        items.add(closeLeftTabsMenuItem);
    }
    if (tabCount > 1 && tabIndex != tabCount - 1) {
        MenuItem closeRigthTabsMenuItem = new MenuItem("Close Tabs to the Right");
        closeRigthTabsMenuItem.setOnAction((e) -> closeTabsToRight(tab));
        items.add(closeRigthTabsMenuItem);
    }
    if (tabCount > 1) {
        MenuItem closeAllMenuItem = new MenuItem("Close All");
        closeAllMenuItem.setOnAction((e) -> closeAllTabs());
        items.addAll(new SeparatorMenuItem(), closeAllMenuItem);
    }
}
 
Example 21
Source Project: MyBox   Source File: MarkdownEditerController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initializeNext() {
    try {
        initPage(null);
        initFileTab();
        initConversionOptions();
        initCharsetTab();
        initLocateTab();
        initReplaceTab();
        initInputPane();

        initMainArea();
        initHtmlTab();
        initTextTab();

        tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Tab>() {
            @Override
            public void changed(ObservableValue<? extends Tab> observable,
                    Tab oldValue, Tab newValue) {
                if (markdownTab.equals(oldValue)) {
                    markdown2all();
                }
            }
        });

    } catch (Exception e) {
        logger.error(e.toString());
    }

}
 
Example 22
Source Project: phoebus   Source File: WidgetInfoDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private Tab createProperties(final Widget widget)
 {
     // Use text field to allow copying the name (for use in scripts)
     // and value, but not the localized description and category
     // which are just for information
     final TableColumn<WidgetProperty<?>, String> cat = new TableColumn<>(Messages.WidgetInfoDialog_Category);
     cat.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getCategory().getDescription()));

     final TableColumn<WidgetProperty<?>, String> descr = new TableColumn<>(Messages.WidgetInfoDialog_Property);
     descr.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getDescription()));

     final TableColumn<WidgetProperty<?>, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
     name.setCellFactory(col -> new ReadOnlyTextCell<>());
     name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getName()));

     final TableColumn<WidgetProperty<?>, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
     value.setCellFactory(col -> new ReadOnlyTextCell<>());
     value.setCellValueFactory(param -> new ReadOnlyStringWrapper(Objects.toString(param.getValue().getValue())));

     final TableView<WidgetProperty<?>> table =
         new TableView<>(FXCollections.observableArrayList(widget.getProperties()));
     table.getColumns().add(cat);
     table.getColumns().add(descr);
     table.getColumns().add(name);
     table.getColumns().add(value);
     table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

     return new Tab(Messages.WidgetInfoDialog_TabProperties, table);
}
 
Example 23
Source Project: MyBox   Source File: WebBrowserController.java    License: Apache License 2.0 5 votes vote down vote up
@FXML
protected void forwardAction() {
    Tab tab = tabPane.getSelectionModel().getSelectedItem();
    WebBrowserBoxController controller = tabControllers.get(tab);
    if (controller == null) {
        return;
    }
    controller.forwardAction();
}
 
Example 24
Source Project: MyBox   Source File: WebBrowserController.java    License: Apache License 2.0 5 votes vote down vote up
@FXML
protected void refreshAction() {
    Tab tab = tabPane.getSelectionModel().getSelectedItem();
    WebBrowserBoxController controller = tabControllers.get(tab);
    if (controller == null) {
        return;
    }
    controller.refreshAction();
}
 
Example 25
Source Project: JFX-Browser   Source File: MainController.java    License: MIT License 5 votes vote down vote up
public TabPane getTabPaneView(TabPane tabpane, Tab addNewTab) {
	tabpane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Tab>() {
		@Override

		public void changed(ObservableValue<? extends Tab> ov, Tab t, Tab newSelectedTab) {

			// Closeing tab if first index tab close and size will be the 2
			// https://docs.oracle.com/javase/8/javafx/api/index.html?javafx/scene/package-summary.html

			if (tabPane.getTabs().size() == 1) {
				Platform.exit();
			}

			// The current tab title is set the stage title
			//MainClass.getStage().setTitle(tabPane.getSelectionModel().getSelectedItem().getText());
			
			//The above line was just setting the name of window but according to the requirement we
			// just set the fixed name of browser Jfx Browser 

			if (newSelectedTab == addNewTab) {
				
				// ---------------New tab is created --------------------
				
				Platform.runLater(new Runnable() {
					@Override
					public void run() {
						
						creatNewTab(tabpane, addNewTab);

					}
				});
			}
		}
	});

	return tabpane;

}
 
Example 26
Source Project: constellation   Source File: ParameterIOUtilities.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Save the data access state to the graph.
 * <p>
 * Currently only global parameters are saved.
 *
 * @param tabs The TabPane
 * @param graph The active graph to save the state to
 */
public static void saveDataAccessState(final TabPane tabs, final Graph graph) {
    if (graph != null) {
        // buildId the data access state object
        final DataAccessState dataAccessState = new DataAccessState();
        for (final Tab step : tabs.getTabs()) {
            dataAccessState.newTab();
            final QueryPhasePane pluginPane = (QueryPhasePane) ((ScrollPane) step.getContent()).getContent();
            for (final Map.Entry<String, PluginParameter<?>> param : pluginPane.getGlobalParametersPane().getParams().getParameters().entrySet()) {
                final String id = param.getKey();
                final PluginParameter<?> pp = param.getValue();
                final String value = pp.getStringValue();
                if (value != null) {
                    dataAccessState.add(id, value);
                }
            }
        }

        // save the state onto the graph
        WritableGraph wg = null;
        try {
            wg = graph.getWritableGraph("Update Data Access State", true);
            final int dataAccessStateAttribute = DataAccessConcept.MetaAttribute.DATAACCESS_STATE.ensure(wg);
            wg.setObjectValue(dataAccessStateAttribute, 0, dataAccessState);
        } catch (InterruptedException ex) {
            Exceptions.printStackTrace(ex);
            Thread.currentThread().interrupt();
        } finally {
            if (wg != null) {
                wg.commit();
            }
        }
    }
}
 
Example 27
Source Project: FxDock   Source File: FxDockTabPane.java    License: Apache License 2.0 5 votes vote down vote up
public Node getTab(int ix)
{
	if(ix >= 0)
	{
		ObservableList<Tab> ps = getTabs();
		if(ix < ps.size())
		{
			return ps.get(ix).getContent();
		}
	}
	return null;
}
 
Example 28
Source Project: mars-sim   Source File: TabController.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void configureTab(Tab tab, String title, String iconPath, AnchorPane containerPane, URL resourceURL, EventHandler<Event> onSelectionChangedEvent) {
    double imageWidth = 40.0;

    ImageView imageView = new ImageView(new Image(iconPath));
    imageView.setFitHeight(imageWidth);
    imageView.setFitWidth(imageWidth);

    Label label = new Label(title);
    label.setMaxWidth(tabWidth - 20);
    label.setPadding(new Insets(5, 0, 0, 0));
    label.setStyle("-fx-text-fill: black; -fx-font-size: 10pt; -fx-font-weight: bold;");
    label.setTextAlignment(TextAlignment.CENTER);

    BorderPane tabPane = new BorderPane();
    tabPane.setRotate(90.0);
    tabPane.setMaxWidth(tabWidth);
    tabPane.setCenter(imageView);
    tabPane.setBottom(label);

    tab.setText("");
    tab.setGraphic(tabPane);

    tab.setOnSelectionChanged(onSelectionChangedEvent);

    if (containerPane != null && resourceURL != null) {
        try {
            Parent contentView = FXMLLoader.load(resourceURL);
            containerPane.getChildren().add(contentView);
            AnchorPane.setTopAnchor(contentView, 0.0);
            AnchorPane.setBottomAnchor(contentView, 0.0);
            AnchorPane.setRightAnchor(contentView, 0.0);
            AnchorPane.setLeftAnchor(contentView, 0.0);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
Example 29
Source Project: jace   Source File: IdeController.java    License: 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);
            }
        }
    });
}
 
Example 30
Source Project: Jupiter   Source File: Editor.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Callback when a file is changed.
 *
 * @param file changed file
 */
private void onFileChange(File file) {
  // code for processing change event
  updateTree();
  for (Tab openTab : editorTabPane.getTabs()) {
    EditorTab tab = (EditorTab) openTab;
    if (!tab.untitled() && FS.equals(file, tab.getFile())) {
      Platform.runLater(() -> tab.externalModify());
      return;
    }
  }
}