use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class EditorAgentImpl method getState.
@Override
public JsonObject getState() {
JsonObject state = Json.createObject();
EditorMultiPartStackState stacks = null;
try {
stacks = editorMultiPartStack.getState();
} catch (IllegalStateException ignore) {
}
if (stacks != null) {
state.put("FILES", storeEditors(stacks));
}
EditorPartPresenter activeEditor = getActiveEditor();
if (activeEditor != null) {
state.put("ACTIVE_EDITOR", activeEditor.getEditorInput().getFile().getLocation().toString());
}
return state;
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class EditorCurrentFilePathMacro method expand.
/** {@inheritDoc} */
@Override
public Promise<String> expand() {
final EditorPartPresenter editor = getActiveEditor();
if (editor == null) {
return promises.resolve("");
}
final Path absolutePath = appContext.getProjectsRoot().append(editor.getEditorInput().getFile().getLocation());
return promises.resolve(absolutePath.toString());
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class EditorCurrentProjectNameMacro method expand.
/** {@inheritDoc} */
@Override
public Promise<String> expand() {
final EditorPartPresenter editor = getActiveEditor();
if (editor == null) {
return promises.resolve("");
}
final VirtualFile file = editor.getEditorInput().getFile();
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
if (!project.isPresent()) {
return promises.resolve("");
}
return promises.resolve(project.get().getName());
}
return promises.resolve("");
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class EditorCurrentProjectTypeMacro method expand.
/** {@inheritDoc} */
@Override
public Promise<String> expand() {
final EditorPartPresenter editor = getActiveEditor();
if (editor == null) {
return promises.resolve("");
}
final VirtualFile file = editor.getEditorInput().getFile();
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
if (!project.isPresent()) {
return promises.resolve("");
}
return promises.resolve(project.get().getType());
}
return promises.resolve("");
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class AppContextImpl method getRootProject.
@Override
public Project getRootProject() {
if (projects == null) {
return null;
}
if (currentResource == null || currentResources == null) {
EditorAgent editorAgent = editorAgentProvider.get();
if (editorAgent == null) {
return null;
}
final EditorPartPresenter editor = editorAgent.getActiveEditor();
if (editor == null) {
return null;
}
final VirtualFile file = editor.getEditorInput().getFile();
if (file instanceof SyntheticNode) {
final Path projectPath = ((SyntheticNode) file).getProject();
for (Project project : projects) {
if (project.getLocation().equals(projectPath)) {
return project;
}
}
}
}
if (currentResource == null) {
return null;
}
Project root = null;
for (Project project : projects) {
if (project.getLocation().isPrefixOf(currentResource.getLocation())) {
root = project;
}
}
if (root == null) {
return null;
}
for (int i = 1; i < currentResources.length; i++) {
if (!root.getLocation().isPrefixOf(currentResources[i].getLocation())) {
return null;
}
}
return root;
}
Aggregations