提交 2d07f086 编写于 作者: B Benjamin Pasero

no more EditorInput#status

上级 6d1d5d42
......@@ -34,12 +34,8 @@ export class EditorPickerEntry extends QuickOpenEntryGroup {
this.stacks = editorService.getStacksModel();
}
public getPrefix(): string {
if (this.editor.isDirty()) {
return '\u25cf '; // dirty decoration
}
return void 0;
public getIcon(): string {
return this.editor.isDirty() ? 'dirty' : '';
}
public getLabel(): string {
......
......@@ -169,21 +169,21 @@
}
.monaco-workbench .close-editor-action,
.monaco-workbench .close-editor-decorated-action:hover {
.monaco-workbench .close-editor-dirty-action:hover {
background: url('close.svg') center center no-repeat;
}
.vs-dark .monaco-workbench .close-editor-action,
.vs-dark .monaco-workbench .close-editor-decorated-action:hover {
background: url('close-dark.svg') center center no-repeat;
.vs-dark .monaco-workbench .close-editor-dirty-action:hover {
background: url('close-inverse.svg') center center no-repeat;
}
.monaco-workbench .close-editor-decorated-action {
background: url('close-decorated.svg') center center no-repeat;
.monaco-workbench .close-editor-dirty-action {
background: url('close-dirty.svg') center center no-repeat;
}
.vs-dark .monaco-workbench .close-editor-decorated-action {
background: url('close-decorated-inverse.svg') center center no-repeat;
.vs-dark .monaco-workbench .close-editor-dirty-action {
background: url('close-dirty-inverse.svg') center center no-repeat;
}
.monaco-workbench .split-editor-action {
......@@ -213,7 +213,7 @@
/* High Contrast Theming */
.hc-black .monaco-workbench .close-editor-action,
.hc-black .monaco-workbench .close-editor-decorated-action,
.hc-black .monaco-workbench .close-editor-dirty-action,
.hc-black .monaco-workbench .show-group-editors-action,
.hc-black .monaco-workbench .show-group-editors-overflowing-action,
.hc-black .monaco-workbench .split-editor-action {
......@@ -242,7 +242,7 @@
width: 16px;
}
.hc-black .monaco-workbench .close-editor-decorated-action:before {
.hc-black .monaco-workbench .close-editor-dirty-action:before {
content: url('close-decorated-inverse.svg');
position: absolute;
top: 12px;
......@@ -252,7 +252,7 @@
}
.hc-black .monaco-workbench .close-editor-action:before {
content: url('close-dark.svg');
content: url('close-inverse.svg');
position: absolute;
top: 12px;
left: 8px;
......
......@@ -1185,8 +1185,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
// Update the input title actions in each position according to the new status
POSITIONS.forEach((position) => {
if (this.visibleEditors[position] && isInputRelated(this.visibleEditors[position].input, input)) {
const status = input.getStatus();
this.closeEditorActions[position].class = (status && status.decoration) ? 'close-editor-decorated-action' : 'close-editor-action';
this.closeEditorActions[position].class = input.isDirty() ? 'close-editor-dirty-action' : 'close-editor-action';
}
});
}
......@@ -1334,8 +1333,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
this.editorActionsToolbar[position].setActions(primaryActions, secondaryActions)();
// Update title actions accordingly
const status = input.getStatus();
this.closeEditorActions[position].class = (status && status.decoration) ? 'close-editor-decorated-action' : 'close-editor-action';
this.closeEditorActions[position].class = input.isDirty() ? 'close-editor-dirty-action' : 'close-editor-action';
}
public setLoading(position: Position, input: EditorInput): void {
......
......@@ -14,32 +14,6 @@ import {IEditorInput, IEditorModel, IEditorOptions, IResourceInput} from 'vs/pla
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
/**
* A simple bag for input related status that can be shown in the UI
*/
export interface IInputStatus {
/**
* An identifier of the state that can be used e.g. as CSS class when displaying the input.
*/
state?: string;
/**
* A label to display describing the current input status.
*/
displayText?: string;
/**
* A longer description giving more detail about the current input status.
*/
description?: string;
/**
* Preferably a short label to append to the input name to indicate the input status.
*/
decoration?: string;
}
export enum ConfirmResult {
SAVE,
DONT_SAVE,
......@@ -55,7 +29,7 @@ export abstract class EditorInput extends EventEmitter implements IEditorInput {
constructor() {
super();
this.disposed = false;
}
......@@ -82,14 +56,6 @@ export abstract class EditorInput extends EventEmitter implements IEditorInput {
return null;
}
/**
* Returns status information about this input that can be shown to the user. Examples include showing the status
* of the input when hovering over the name of the input.
*/
public getStatus(): IInputStatus {
return null;
}
/**
* Returns the preferred editor for this input. A list of candidate editors is passed in that whee registered
* for the input. This allows subclasses to decide late which editor to use for the input on a case by case basis.
......
......@@ -11,7 +11,7 @@ import URI from 'vs/base/common/uri';
import {getPathLabel, IWorkspaceProvider} from 'vs/base/common/labels';
import {isBinaryMime} from 'vs/base/common/mime';
import {EventType} from 'vs/base/common/events';
import {EditorModel, IFileEditorInput, EditorInput, IInputStatus, BaseDiffEditorInput} from 'vs/workbench/common/editor';
import {EditorModel, IFileEditorInput, EditorInput, BaseDiffEditorInput} from 'vs/workbench/common/editor';
import {BaseTextEditorModel} from 'vs/workbench/common/editor/textEditorModel';
import {DiffEditorModel} from 'vs/workbench/common/editor/diffEditorModel';
import {TextDiffEditorModel} from 'vs/workbench/common/editor/textDiffEditorModel';
......@@ -74,26 +74,6 @@ export class DiffEditorInput extends BaseDiffEditorInput {
return this.description;
}
public getStatus(): IInputStatus {
if (this.modifiedInput) {
let modifiedStatus = this.modifiedInput.getStatus();
if (modifiedStatus) {
return modifiedStatus;
}
}
if (this.originalInput) {
let originalStatus = this.originalInput.getStatus();
if (originalStatus) {
return originalStatus;
}
}
return super.getStatus();
}
public setOriginalInput(input: EditorInput): void {
this.originalInput = input;
}
......
......@@ -9,7 +9,7 @@ import URI from 'vs/base/common/uri';
import {isUnspecific, guessMimeTypes, MIME_TEXT, suggestFilename} from 'vs/base/common/mime';
import labels = require('vs/base/common/labels');
import paths = require('vs/base/common/paths');
import {UntitledEditorInput as AbstractUntitledEditorInput, EditorModel, EncodingMode, IInputStatus, ConfirmResult} from 'vs/workbench/common/editor';
import {UntitledEditorInput as AbstractUntitledEditorInput, EditorModel, EncodingMode, ConfirmResult} from 'vs/workbench/common/editor';
import {UntitledEditorModel} from 'vs/workbench/common/editor/untitledEditorModel';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle';
......@@ -68,15 +68,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
return this.cachedModel && this.cachedModel.isDirty();
}
public getStatus(): IInputStatus {
let isDirty = this.isDirty();
if (isDirty) {
return { state: 'dirty', decoration: '\u25cf' };
}
return null;
}
public confirmSave(): ConfirmResult {
return this.textFileService.confirmSave([this.resource]);
}
......
......@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import nls = require('vs/nls');
import {TPromise} from 'vs/base/common/winjs.base';
import {Registry} from 'vs/platform/platform';
import types = require('vs/base/common/types');
......@@ -14,13 +13,13 @@ import labels = require('vs/base/common/labels');
import URI from 'vs/base/common/uri';
import strings = require('vs/base/common/strings');
import assert = require('vs/base/common/assert');
import {EditorModel, IInputStatus, EncodingMode, ConfirmResult} from 'vs/workbench/common/editor';
import {EditorModel, EncodingMode, ConfirmResult} from 'vs/workbench/common/editor';
import {IEditorRegistry, Extensions, EditorDescriptor} from 'vs/workbench/browser/parts/editor/baseEditor';
import {BinaryEditorModel} from 'vs/workbench/common/editor/binaryEditorModel';
import {IFileOperationResult, FileOperationResult} from 'vs/platform/files/common/files';
import {FileEditorDescriptor} from 'vs/workbench/parts/files/browser/files';
import {ITextFileService, BINARY_FILE_EDITOR_ID, FILE_EDITOR_INPUT_ID, FileEditorInput as CommonFileEditorInput, AutoSaveMode} from 'vs/workbench/parts/files/common/files';
import {CACHE, TextFileEditorModel, State} from 'vs/workbench/parts/files/common/editors/textFileEditorModel';
import {ITextFileService, BINARY_FILE_EDITOR_ID, FILE_EDITOR_INPUT_ID, FileEditorInput as CommonFileEditorInput} from 'vs/workbench/parts/files/common/files';
import {CACHE, TextFileEditorModel} from 'vs/workbench/parts/files/common/editors/textFileEditorModel';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
......@@ -35,18 +34,6 @@ export class FileEditorInput extends CommonFileEditorInput {
// Keep promises that load a file editor model to avoid loading the same model twice
private static FILE_EDITOR_MODEL_LOADERS: { [resource: string]: TPromise<EditorModel>; } = Object.create(null);
// These nls things are looked up way too often to not cache them..
private static nlsSavedDisplay = nls.localize('savedDisplay', "Saved");
private static nlsSavedMeta = nls.localize('savedMeta', "All changes saved");
private static nlsDirtyDisplay = nls.localize('dirtyDisplay', "Dirty");
private static nlsDirtyMeta = nls.localize('dirtyMeta', "Changes have been made to the file...");
private static nlsPendingSaveDisplay = nls.localize('savingDisplay', "Saving...");
private static nlsPendingSaveMeta = nls.localize('pendingSaveMeeta', "Changes are currently being saved...");
private static nlsErrorDisplay = nls.localize('saveErorDisplay', "Save error");
private static nlsErrorMeta = nls.localize('saveErrorMeta', "Sorry, we are having trouble saving your changes");
private static nlsConflictDisplay = nls.localize('saveConflictDisplay', "Conflict");
private static nlsConflictMeta = nls.localize('saveConflictMeta', "Changes cannot be saved because they conflict with the version on disk");
private resource: URI;
private mime: string;
private preferredEncoding: string;
......@@ -148,33 +135,6 @@ export class FileEditorInput extends CommonFileEditorInput {
return this.verboseDescription;
}
public getStatus(): IInputStatus {
let textModel = CACHE.get(this.resource);
if (textModel) {
let state = textModel.getState();
switch (state) {
case State.SAVED: {
return { state: 'saved', displayText: FileEditorInput.nlsSavedDisplay, description: FileEditorInput.nlsSavedMeta };
}
case State.DIRTY: {
return { state: 'dirty', decoration: (this.textFileService.getAutoSaveMode() !== AutoSaveMode.AFTER_SHORT_DELAY) ? '\u25cf' : '', displayText: FileEditorInput.nlsDirtyDisplay, description: FileEditorInput.nlsDirtyMeta };
}
case State.PENDING_SAVE:
return { state: 'saving', decoration: (this.textFileService.getAutoSaveMode() !== AutoSaveMode.AFTER_SHORT_DELAY) ? '\u25cf' : '', displayText: FileEditorInput.nlsPendingSaveDisplay, description: FileEditorInput.nlsPendingSaveMeta };
case State.ERROR:
return { state: 'error', decoration: '\u25cf', displayText: FileEditorInput.nlsErrorDisplay, description: FileEditorInput.nlsErrorMeta };
case State.CONFLICT:
return { state: 'conflict', decoration: '\u25cf', displayText: FileEditorInput.nlsConflictDisplay, description: FileEditorInput.nlsConflictMeta };
}
}
return null;
}
public isDirty(): boolean {
return this.textFileService.isDirty(this.resource);
}
......
......@@ -166,9 +166,8 @@ export abstract class BaseHistoryService {
let prefix = input && input.getName();
if (prefix && input) {
let status = (<EditorInput>input).getStatus();
if (status && status.decoration && !platform.isMacintosh /* Mac has its own decoration in window */) {
prefix = nls.localize('prefixDecoration', "{0} {1}", status.decoration, prefix);
if ((<EditorInput>input).isDirty() && !platform.isMacintosh /* Mac has its own decoration in window */) {
prefix = nls.localize('prefixDecoration', "\u25cf {0}", prefix);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册