use of org.eclipse.che.ide.api.parts.EditorPartStack in project che by eclipse.
the class OrionEditorPresenter method updateTabReference.
private void updateTabReference(File file, Path oldPath) {
final PartPresenter activePart = editorMultiPartStackPresenter.getActivePart();
final EditorPartStack activePartStack = editorMultiPartStackPresenter.getPartStackByPart(activePart);
if (activePartStack == null) {
return;
}
final EditorTab editorTab = activePartStack.getTabByPath(oldPath);
if (editorTab != null) {
editorTab.setFile(file);
}
}
use of org.eclipse.che.ide.api.parts.EditorPartStack in project che by eclipse.
the class EditorMultiPartStackPresenter method addEditorPartStack.
private EditorPartStack addEditorPartStack(final PartPresenter part, final EditorPartStack relativePartStack, final Constraints constraints, double size) {
final EditorPartStack editorPartStack = editorPartStackFactory.get();
partStackPresenters.add(editorPartStack);
view.addPartStack(editorPartStack, relativePartStack, constraints, size);
if (part != null) {
editorPartStack.addPart(part);
}
return editorPartStack;
}
use of org.eclipse.che.ide.api.parts.EditorPartStack in project che by eclipse.
the class EditorAgentImpl method doOpen.
private void doOpen(final VirtualFile file, final OpenEditorCallback callback, final Constraints constraints) {
EditorPartStack activePartStack = editorMultiPartStack.getActivePartStack();
if (constraints == null && activePartStack != null) {
PartPresenter partPresenter = activePartStack.getPartByPath(file.getLocation());
if (partPresenter != null) {
workspaceAgent.setActivePart(partPresenter, EDITING);
callback.onEditorActivated((EditorPartPresenter) partPresenter);
return;
}
}
final FileType fileType = fileTypeRegistry.getFileTypeByFile(file);
final EditorProvider editorProvider = editorRegistry.getEditor(fileType);
if (editorProvider instanceof AsyncEditorProvider) {
AsyncEditorProvider provider = (AsyncEditorProvider) editorProvider;
Promise<EditorPartPresenter> promise = provider.createEditor(file);
if (promise != null) {
promise.then(new Operation<EditorPartPresenter>() {
@Override
public void apply(EditorPartPresenter arg) throws OperationException {
initEditor(file, callback, fileType, arg, constraints, editorProvider);
}
});
return;
}
}
final EditorPartPresenter editor = editorProvider.getEditor();
initEditor(file, callback, fileType, editor, constraints, editorProvider);
}
use of org.eclipse.che.ide.api.parts.EditorPartStack in project che by eclipse.
the class EditorAgentImpl method loadState.
@Override
@SuppressWarnings("unchecked")
public void loadState(@NotNull final JsonObject state) {
if (state.hasKey("FILES")) {
JsonObject files = state.getObject("FILES");
EditorPartStack partStack = editorMultiPartStack.createRootPartStack();
final Map<EditorPartPresenter, EditorPartStack> activeEditors = new HashMap<>();
List<Promise<Void>> restore = restore(files, partStack, activeEditors);
Promise<ArrayOf<?>> promise = promiseProvider.all2(restore.toArray(new Promise[restore.size()]));
promise.then(new Operation() {
@Override
public void apply(Object arg) throws OperationException {
String activeFile = "";
if (state.hasKey("ACTIVE_EDITOR")) {
activeFile = state.getString("ACTIVE_EDITOR");
}
EditorPartPresenter activeEditorPart = null;
for (Map.Entry<EditorPartPresenter, EditorPartStack> entry : activeEditors.entrySet()) {
entry.getValue().setActivePart(entry.getKey());
if (activeFile.equals(entry.getKey().getEditorInput().getFile().getLocation().toString())) {
activeEditorPart = entry.getKey();
}
}
workspaceAgent.setActivePart(activeEditorPart);
}
});
}
}
use of org.eclipse.che.ide.api.parts.EditorPartStack in project che by eclipse.
the class EditorAgentImpl method onSelectionChanged.
@Override
public void onSelectionChanged(SelectionChangedEvent event) {
final String isLinkedWithEditor = preferencesManager.getValue(LinkWithEditorAction.LINK_WITH_EDITOR);
if (!parseBoolean(isLinkedWithEditor)) {
return;
}
final Selection<?> selection = event.getSelection();
if (selection instanceof Selection.NoSelectionProvided) {
return;
}
Resource currentResource = null;
if (selection == null || selection.getHeadElement() == null || selection.getAllElements().size() > 1) {
return;
}
final Object headObject = selection.getHeadElement();
if (headObject instanceof HasDataObject) {
Object data = ((HasDataObject) headObject).getData();
if (data instanceof Resource) {
currentResource = (Resource) data;
}
} else if (headObject instanceof Resource) {
currentResource = (Resource) headObject;
}
EditorPartStack activePartStack = editorMultiPartStack.getActivePartStack();
if (currentResource == null || activePartStack == null || activeEditor == null) {
return;
}
final Path locationOfActiveOpenedFile = activeEditor.getEditorInput().getFile().getLocation();
final Path selectedResourceLocation = currentResource.getLocation();
if (!(activePart instanceof ProjectExplorerPresenter) && selectedResourceLocation.equals(locationOfActiveOpenedFile)) {
return;
}
PartPresenter partPresenter = activePartStack.getPartByPath(selectedResourceLocation);
if (partPresenter != null) {
workspaceAgent.setActivePart(partPresenter, EDITING);
}
}
Aggregations