use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class AppContextImpl method onWorkspaceStopped.
@Override
public void onWorkspaceStopped(WorkspaceStoppedEvent event) {
appStateManager.get().persistWorkspaceState(getWorkspaceId()).then(ignored -> {
for (Project project : projects) {
eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED)));
}
projects = NO_PROJECTS;
resourceManager = null;
});
//goto close all editors
final EditorAgent editorAgent = editorAgentProvider.get();
final List<EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors();
for (EditorPartPresenter editor : openedEditors) {
editorAgent.closeEditor(editor);
}
runtime = null;
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class EditorAgentImpl method doSave.
private void doSave(final AsyncCallback callback) {
final EditorPartPresenter partPresenter = dirtyEditors.get(0);
partPresenter.doSave(new AsyncCallback<EditorInput>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(EditorInput result) {
dirtyEditors.remove(partPresenter);
if (dirtyEditors.isEmpty()) {
callback.onSuccess("Success");
} else {
doSave(callback);
}
}
});
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class SaveAction method updateProjectAction.
@Override
public void updateProjectAction(ActionEvent e) {
EditorPartPresenter editor = editorAgent.getActiveEditor();
if (editor != null) {
if (editor instanceof EditorWithAutoSave) {
if (((EditorWithAutoSave) editor).isAutoSaveEnabled()) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
}
e.getPresentation().setVisible(true);
e.getPresentation().setEnabled(editor.isDirty());
} else {
e.getPresentation().setEnabledAndVisible(false);
}
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class SaveAllAction method save.
private void save(final List<EditorPartPresenter> editors) {
if (editors.isEmpty()) {
return;
}
final EditorPartPresenter editorPartPresenter = editors.get(0);
if (editorPartPresenter.isDirty()) {
editorPartPresenter.doSave(new AsyncCallback<EditorInput>() {
@Override
public void onFailure(Throwable caught) {
Log.error(SaveAllAction.class, caught);
//try to save other files
editors.remove(editorPartPresenter);
save(editors);
}
@Override
public void onSuccess(EditorInput result) {
editors.remove(editorPartPresenter);
save(editors);
}
});
} else {
editors.remove(editorPartPresenter);
save(editors);
}
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class SignatureHelpAction method updateInPerspective.
@Override
public void updateInPerspective(@NotNull ActionEvent event) {
final EditorPartPresenter editor = editorAgent.getActiveEditor();
boolean isCanDoOperation = false;
HandlesTextOperations handlesOperations;
if (editor instanceof HandlesTextOperations) {
handlesOperations = (HandlesTextOperations) editor;
isCanDoOperation = handlesOperations.canDoOperation(TextEditorOperations.SIGNATURE_HELP);
}
event.getPresentation().setEnabledAndVisible(isCanDoOperation);
}
Aggregations