use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class OpenDeclarationFinder method openDeclaration.
public void openDeclaration() {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (activeEditor == null) {
return;
}
if (!(activeEditor instanceof TextEditor)) {
Log.error(getClass(), "Open Declaration support only TextEditor as editor");
return;
}
TextEditor editor = ((TextEditor) activeEditor);
int offset = editor.getCursorOffset();
final VirtualFile file = editor.getEditorInput().getFile();
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
final Optional<Resource> srcFolder = ((Resource) file).getParentWithMarker(SourceFolderMarker.ID);
if (!srcFolder.isPresent()) {
return;
}
final String fqn = JavaUtil.resolveFQN((Container) srcFolder.get(), (Resource) file);
navigationService.findDeclaration(project.get().getLocation(), fqn, offset).then(new Operation<OpenDeclarationDescriptor>() {
@Override
public void apply(OpenDeclarationDescriptor result) throws OperationException {
if (result != null) {
handleDescriptor(project.get().getLocation(), result);
}
}
});
} else if (file instanceof JarFileNode) {
navigationService.findDeclaration(((JarFileNode) file).getProjectLocation(), file.getLocation().toString().replace('/', '.'), offset).then(new Operation<OpenDeclarationDescriptor>() {
@Override
public void apply(OpenDeclarationDescriptor result) throws OperationException {
if (result != null) {
handleDescriptor(((JarFileNode) file).getProject(), result);
}
}
});
}
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class ConvertFolderToProjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent event) {
Resource folder = getSelectedItem();
if (folder == null) {
return;
}
Path location = folder.getLocation();
if (location == null) {
return;
}
MutableProjectConfig mutableProjectConfig = new MutableProjectConfig();
mutableProjectConfig.setPath(location.toString());
mutableProjectConfig.setName(folder.getName());
projectConfigWizard.show(mutableProjectConfig);
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class DownloadProjectAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
final Resource resource = appContext.getResource();
if (resource == null || resource.getResourceType() != PROJECT) {
return;
}
final Project project = (Project) resource;
downloadContainer.setUrl(project.getURL());
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class FullTextSearchAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
final Resource[] resources = appContext.getResources();
final Path searchPath;
if (resources == null || resources.length == 0 || resources.length > 1) {
searchPath = Path.ROOT;
} else {
if (resources[0] instanceof Container) {
searchPath = resources[0].getLocation();
} else {
final Container parent = resources[0].getParent();
searchPath = parent != null ? parent.getLocation() : Path.ROOT;
}
}
presenter.showDialog(searchPath);
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class ProjectConfigurationAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
final Resource[] resources = appContext.getResources();
checkState(resources != null && resources.length == 1);
final Resource resource = resources[0];
checkState(resource instanceof Container);
if (resource.getResourceType() == PROJECT) {
final MutableProjectConfig config = new MutableProjectConfig((Project) resource);
projectWizard.show(config);
}
}
Aggregations