当前位置: 首页>>代码示例>>Java>>正文


Java Tab.setOnCloseRequest方法代码示例

本文整理汇总了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;
}
 
开发者ID:XDean,项目名称:CSS-Editor-FX,代码行数:24,代码来源:MainFrameController.java

示例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;
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:23,代码来源:SpecificationsPaneController.java

示例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;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:28,代码来源:TabDockingContainer.java

示例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);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:46,代码来源:EditorAreaComponent.java


注:本文中的javafx.scene.control.Tab.setOnCloseRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。