/**
* 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);
}
}
EditorAreaComponent.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:jmonkeybuilder
作者:
评论列表
文章目录