editor with write capability
This commit is contained in:
parent
a0e19fd143
commit
2f8f374abc
@ -123,7 +123,6 @@ public final class EditorWorkspace extends Workspace {
|
||||
notifyStateChanged();
|
||||
renderSession();
|
||||
});
|
||||
tabStrip.setTabCloseAction(this::requestCloseFile);
|
||||
|
||||
root.setCenter(buildLayout());
|
||||
statusBar.showPlaceholder(presentationRegistry.resolve("text"));
|
||||
@ -450,51 +449,6 @@ public final class EditorWorkspace extends Workspace {
|
||||
renderSession();
|
||||
}
|
||||
|
||||
private void requestCloseFile(final Path path) {
|
||||
final var fileBuffer = openFileSession.file(path).orElse(null);
|
||||
if (fileBuffer == null) {
|
||||
return;
|
||||
}
|
||||
if (fileBuffer.dirty() && !confirmDirtyFileClose(fileBuffer)) {
|
||||
return;
|
||||
}
|
||||
openFileSession.close(path);
|
||||
notifyStateChanged();
|
||||
renderSession();
|
||||
}
|
||||
|
||||
private boolean confirmDirtyFileClose(final EditorOpenFileBuffer fileBuffer) {
|
||||
final var alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||
if (root.getScene() != null) {
|
||||
alert.initOwner(root.getScene().getWindow());
|
||||
}
|
||||
final var saveButtonType = new ButtonType(
|
||||
p.studio.Container.i18n().text(I18n.CODE_EDITOR_CLOSE_DIRTY_SAVE),
|
||||
ButtonBar.ButtonData.YES);
|
||||
final var discardButtonType = new ButtonType(
|
||||
p.studio.Container.i18n().text(I18n.CODE_EDITOR_CLOSE_DIRTY_DISCARD),
|
||||
ButtonBar.ButtonData.NO);
|
||||
final var cancelButtonType = new ButtonType(
|
||||
p.studio.Container.i18n().text(I18n.CODE_EDITOR_CLOSE_DIRTY_CANCEL),
|
||||
ButtonBar.ButtonData.CANCEL_CLOSE);
|
||||
alert.setTitle(p.studio.Container.i18n().text(I18n.CODE_EDITOR_CLOSE_DIRTY_TITLE));
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText(p.studio.Container.i18n().format(
|
||||
I18n.CODE_EDITOR_CLOSE_DIRTY_MESSAGE,
|
||||
fileBuffer.tabLabel()));
|
||||
alert.getButtonTypes().setAll(saveButtonType, discardButtonType, cancelButtonType);
|
||||
final var result = alert.showAndWait().orElse(cancelButtonType);
|
||||
if (result == saveButtonType) {
|
||||
vfsProjectDocument.saveDocument(fileBuffer.path());
|
||||
return true;
|
||||
}
|
||||
if (result == discardButtonType) {
|
||||
vfsProjectDocument.discardDocument(fileBuffer.path());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleWorkspaceShortcuts(final KeyEvent event) {
|
||||
if (SAVE_ALL_SHORTCUT.match(event)) {
|
||||
if (!saveAllButton.isDisabled()) {
|
||||
|
||||
@ -598,29 +598,6 @@
|
||||
-fx-text-fill: #d6dde6;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-container {
|
||||
-fx-spacing: 8;
|
||||
-fx-alignment: center-left;
|
||||
-fx-padding: 0 8 0 12;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-label {
|
||||
-fx-alignment: center-left;
|
||||
-fx-font-size: 12px;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-close-chip {
|
||||
-fx-alignment: center;
|
||||
-fx-padding: 0;
|
||||
-fx-cursor: hand;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-close-icon {
|
||||
-fx-fill: transparent;
|
||||
-fx-stroke: #d6dde6;
|
||||
-fx-stroke-width: 1.15;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-button-active {
|
||||
-fx-background-color: #16283d;
|
||||
-fx-border-color: #8fc4f2 #516579 #516579 #516579;
|
||||
@ -635,24 +612,12 @@
|
||||
-fx-text-fill: #d9dee5;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-label.editor-workspace-tab-button-read-only {
|
||||
-fx-text-fill: #d9dee5;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-button-read-only:hover {
|
||||
-fx-background-color: #2b323d;
|
||||
-fx-border-color: #5b6878;
|
||||
-fx-text-fill: #eff4fa;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-label.editor-workspace-tab-button-read-only:hover {
|
||||
-fx-text-fill: #eff4fa;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-close-chip.editor-workspace-tab-button-read-only .editor-workspace-tab-close-icon {
|
||||
-fx-stroke: #d9dee5;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-button-read-only.editor-workspace-tab-button-active {
|
||||
-fx-background-color: #16283d;
|
||||
-fx-border-color: #8fc4f2 #516579 #516579 #516579;
|
||||
@ -661,11 +626,6 @@
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-label.editor-workspace-tab-button-read-only.editor-workspace-tab-button-active {
|
||||
-fx-text-fill: #ffffff;
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-button-read-only.editor-workspace-tab-button-active:hover {
|
||||
-fx-background-color: #1c3148;
|
||||
-fx-border-color: #a7d7ff #5c738b #5c738b #5c738b;
|
||||
@ -677,24 +637,12 @@
|
||||
-fx-text-fill: #e8f6eb;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-label.editor-workspace-tab-button-editable {
|
||||
-fx-text-fill: #e8f6eb;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-button-editable:hover {
|
||||
-fx-background-color: #29412f;
|
||||
-fx-border-color: #6f957a;
|
||||
-fx-text-fill: #f4fff5;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-label.editor-workspace-tab-button-editable:hover {
|
||||
-fx-text-fill: #f4fff5;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-close-chip.editor-workspace-tab-button-editable .editor-workspace-tab-close-icon {
|
||||
-fx-stroke: #e8f6eb;
|
||||
}
|
||||
|
||||
.editor-workspace-tab-button-editable.editor-workspace-tab-button-active {
|
||||
-fx-background-color: #1d3a2a;
|
||||
-fx-border-color: #8ad3a2 #587464 #587464 #587464;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user