use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class LibEntryPresenter method go.
@Override
public void go(final AcceptsOneWidget container) {
final Resource resource = appContext.getResource();
Preconditions.checkState(resource != null);
final Optional<Project> project = resource.getRelatedProject();
isPlainJava = JAVAC.equals(project.get().getType());
setReadOnlyMod();
container.setWidget(view);
if (!categories.isEmpty()) {
view.renderLibraries();
return;
}
classpathContainer.getClasspathEntries(project.get().getPath()).then(new Operation<List<ClasspathEntryDto>>() {
@Override
public void apply(List<ClasspathEntryDto> arg) throws OperationException {
categories.clear();
for (ClasspathEntryDto entry : arg) {
if (CONTAINER == entry.getEntryKind() || LIBRARY == entry.getEntryKind()) {
categories.put(entry.getPath(), entry);
}
}
view.setData(categories);
view.renderLibraries();
}
});
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class CutJavaSourceAction method update.
@Override
public void update(ActionEvent event) {
event.getPresentation().setVisible(true);
final Resource[] resources = appContext.getResources();
if (resources == null || resources.length > 1) {
event.getPresentation().setEnabled(false);
return;
}
final Resource resource = resources[0];
final Optional<Project> project = resource.getRelatedProject();
final Optional<Resource> srcFolder = resource.getParentWithMarker(SourceFolderMarker.ID);
if (resource.getResourceType() == FILE) {
event.getPresentation().setEnabled(!isEditorPartActive && isJavaProject(project.get()) && srcFolder.isPresent() && isJavaFile((File) resource));
} else if (resource instanceof Container) {
event.getPresentation().setEnabled(!isEditorPartActive && isJavaProject(project.get()) && srcFolder.isPresent());
}
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class MoveAction method updateInPerspective.
/** {@inheritDoc} */
@Override
public void updateInPerspective(ActionEvent event) {
event.getPresentation().setVisible(true);
final Resource[] resources = appContext.getResources();
if (resources == null || resources.length != 1) {
event.getPresentation().setEnabled(false);
return;
}
final Resource resource = resources[0];
final Optional<Project> project = resource.getRelatedProject();
if (!project.isPresent()) {
event.getPresentation().setEnabled(false);
return;
}
final Optional<Resource> srcFolder = resource.getParentWithMarker(SourceFolderMarker.ID);
if (resource.getResourceType() == FILE) {
event.getPresentation().setEnabled(JavaUtil.isJavaProject(project.get()) && srcFolder.isPresent() && isJavaFile((File) resource));
} else if (resource instanceof Container) {
event.getPresentation().setEnabled(JavaUtil.isJavaProject(project.get()) && srcFolder.isPresent());
}
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class MoveAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent actionEvent) {
final Resource[] resources = appContext.getResources();
if (resources == null || resources.length > 1) {
return;
}
final Resource resource = resources[0];
final Optional<Project> project = resource.getRelatedProject();
if (!JavaUtil.isJavaProject(project.get())) {
return;
}
final Optional<Resource> srcFolder = resource.getParentWithMarker(SourceFolderMarker.ID);
if (!srcFolder.isPresent() || resource.getLocation().equals(srcFolder.get().getLocation())) {
return;
}
RefactoredItemType renamedItemType = null;
if (resource.getResourceType() == FILE && isJavaFile((File) resource)) {
renamedItemType = COMPILATION_UNIT;
} else if (resource instanceof Container) {
renamedItemType = PACKAGE;
}
if (renamedItemType == null) {
return;
}
movePresenter.show(RefactorInfo.of(REFACTOR_MENU, renamedItemType, resources));
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class MoveViewImpl method show.
/** {@inheritDoc} */
@Override
public void show(RefactorInfo refactorInfo) {
MoveType moveType = refactorInfo.getMoveType();
RefactoredItemType refactoredItemType = refactorInfo.getRefactoredItemType();
treePanelToHide.setVisible(REFACTOR_MENU.equals(moveType));
patternsPanelToHide.setVisible(COMPILATION_UNIT.equals(refactoredItemType));
Resource[] selectedItems = refactorInfo.getResources();
int selectionSize = selectedItems.length;
boolean isMultiSelection = selectionSize > 1;
classNameUR.setText(isMultiSelection ? locale.multiSelectionReferences(selectionSize) : selectedItems[0].getName());
className.setText(isMultiSelection ? locale.multiSelectionDestination(selectionSize) : selectedItems[0].getName());
show();
}
Aggregations