use of org.eclipse.che.ide.api.editor.EditorWithAutoSave in project che by eclipse.
the class SaveAllAction method updateProjectAction.
/** {@inheritDoc} */
@Override
public void updateProjectAction(ActionEvent e) {
boolean hasDirtyEditor = false;
for (EditorPartPresenter editor : editorAgent.getOpenedEditors()) {
if (editor instanceof EditorWithAutoSave) {
if (((EditorWithAutoSave) editor).isAutoSaveEnabled()) {
continue;
}
}
if (editor.isDirty()) {
hasDirtyEditor = true;
break;
}
}
e.getPresentation().setEnabledAndVisible(hasDirtyEditor);
}
use of org.eclipse.che.ide.api.editor.EditorWithAutoSave 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.EditorWithAutoSave in project che by eclipse.
the class JavaRefactoringRename method activateLinkedModeIntoEditor.
private void activateLinkedModeIntoEditor(final RenameRefactoringSession session, final Document document) {
mode = linkedEditor.getLinkedMode();
LinkedModel model = linkedEditor.createLinkedModel();
LinkedModeModel linkedModeModel = session.getLinkedModeModel();
List<LinkedModelGroup> groups = new ArrayList<>();
for (LinkedPositionGroup positionGroup : linkedModeModel.getGroups()) {
LinkedModelGroup group = linkedEditor.createLinkedGroup();
LinkedData data = positionGroup.getData();
if (data != null) {
LinkedModelData modelData = linkedEditor.createLinkedModelData();
modelData.setType("link");
modelData.setValues(data.getValues());
group.setData(modelData);
}
List<Position> positions = new ArrayList<>();
for (Region region : positionGroup.getPositions()) {
positions.add(new Position(region.getOffset(), region.getLength()));
}
group.setPositions(positions);
groups.add(group);
}
model.setGroups(groups);
disableAutoSave();
mode.enterLinkedMode(model);
mode.addListener(new LinkedMode.LinkedModeListener() {
@Override
public void onLinkedModeExited(boolean successful, int start, int end) {
boolean isSuccessful = false;
try {
if (successful) {
isSuccessful = true;
newName = document.getContentRange(start, end - start);
performRename(session);
}
} finally {
mode.removeListener(this);
isActiveLinkedEditor = false;
if (!isSuccessful && linkedEditor instanceof EditorWithAutoSave) {
((EditorWithAutoSave) linkedEditor).enableAutoSave();
}
}
}
});
}
Aggregations