本文整理汇总了Java中javafx.scene.control.Tab.setOnCloseRequest方法的典型用法代码示例。如果您正苦于以下问题:Java Tab.setOnCloseRequest方法的具体用法?Java Tab.setOnCloseRequest怎么用?Java Tab.setOnCloseRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Tab
的用法示例。
在下文中一共展示了Tab.setOnCloseRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openFile
import javafx.scene.control.Tab; //导入方法依赖的package包/类
private TabEntity openFile(File file) {
if (file != null) {
int index = getFileIndex(file);
if (index != -1) {
tabPane.getSelectionModel().select(index);
return tabList.get(index);
}
}
TabEntity tabEntity = new TabEntity();
tabEntity.file.set(file);
tabEntity.loadFile();
Tab tab = tabEntity.tab;
tab.setOnCloseRequest(e -> andFinal(() -> close(), () -> e.consume()));
tab.setContent(tabEntity.codeArea);
tab.textProperty().bind(tabEntity.name);
tabList.add(tabEntity);
tabPane.getSelectionModel().select(tab);
return tabEntity;
}
示例2: addTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
private SpecificationController addTab(HybridSpecification hybridSpecification, int index) {
final SpecificationController controller =
new SpecificationController(typeContext, ioVariables, hybridSpecification, this.state,
Bindings.isEmpty(scenario.getCode().syntaxErrorsProperty()).not(), globalConfig);
Tab tab = new Tab();
tab.setOnCloseRequest(e -> onTabCloseRequest(e, tab));
if (hybridSpecification.isEditable()) {
tab.setContextMenu(createTabContextMenu());
}
tab.textProperty().bind(hybridSpecification.nameProperty());
tab.setContent(controller.getView());
if (hybridSpecification.isEditable()) {
tab.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.EDIT));
} else {
tab.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LOCK));
}
view.getTabs().add(index, tab);
controllers.put(tab, controller);
view.getTabPane().getSelectionModel().select(tab);
scenario.setActiveSpec(hybridSpecification);
return controller;
}
示例3: newTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
private Tab newTab(Dockable dockable) {
DockKey dockKey = dockable.getDockKey();
Tab tab = new Tab(dockKey.getName(), dockable.getComponent());
if (dockKey.getPolicy() == TabPolicy.NotClosable) {
tab.setClosable(false);
}
if (dockKey.isCloseOptionsNeeded()) {
MenuItem closeMenuItem = new MenuItem("Close");
closeMenuItem.setOnAction((e) -> requestClose(tab));
ContextMenu contextMenu = new ContextMenu(closeMenuItem);
contextMenu.showingProperty().addListener((obs, wasShowing, isNowShowing) -> {
if (isNowShowing) {
populateMenuItems(contextMenu, tab);
}
});
tab.setContextMenu(contextMenu);
}
dockKey.nameProperty().addListener((event, o, n) -> tab.setText(n));
tab.setOnClosed((event) -> {
remove(dockable);
});
tab.setGraphic(dockKey.getIcon());
tab.setOnCloseRequest((event) -> {
desktop.fireDockableStateWillChangeEvent(dockable, State.DOCKED, State.CLOSED, event);
});
return tab;
}
示例4: addEditor
import javafx.scene.control.Tab; //导入方法依赖的package包/类
/**
* Add and open the new file editor.
*
* @param editor the editor
* @param needShow the need show
*/
@FXThread
private void addEditor(@NotNull final FileEditor editor, final boolean needShow) {
final Path editFile = editor.getEditFile();
final Tab 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));
final ObservableMap<Object, Object> properties = tab.getProperties();
properties.put(KEY_EDITOR, editor);
editor.dirtyProperty().addListener((observable, oldValue, newValue) -> {
tab.setText(newValue == Boolean.TRUE ? "*" + editor.getFileName() : editor.getFileName());
});
final ObservableList<Tab> tabs = getTabs();
tabs.add(tab);
if (needShow) {
final SingleSelectionModel<Tab> selectionModel = getSelectionModel();
selectionModel.select(tab);
}
DictionaryUtils.runInWriteLock(getOpenedEditors(), editFile, tab, ObjectDictionary::put);
EditorUtil.decrementLoading();
if (isIgnoreOpenedFiles()) {
return;
}
final Workspace workspace = WORKSPACE_MANAGER.getCurrentWorkspace();
if (workspace != null) {
workspace.addOpenedFile(editFile, editor);
}
}