Search in sources :

Example 31 with Resource

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();
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Resource(org.eclipse.che.ide.api.resources.Resource) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) List(java.util.List) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 32 with Resource

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());
    }
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) JavaUtil.isJavaProject(org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject) Container(org.eclipse.che.ide.api.resources.Container) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 33 with Resource

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());
    }
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Container(org.eclipse.che.ide.api.resources.Container) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 34 with Resource

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));
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Container(org.eclipse.che.ide.api.resources.Container) Resource(org.eclipse.che.ide.api.resources.Resource) File(org.eclipse.che.ide.api.resources.File) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile)

Example 35 with Resource

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();
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) MoveType(org.eclipse.che.ide.ext.java.client.refactoring.move.MoveType) RefactoredItemType(org.eclipse.che.ide.ext.java.client.refactoring.move.RefactoredItemType)

Aggregations

Resource (org.eclipse.che.ide.api.resources.Resource)146 Project (org.eclipse.che.ide.api.resources.Project)73 OperationException (org.eclipse.che.api.promises.client.OperationException)48 Operation (org.eclipse.che.api.promises.client.Operation)46 PromiseError (org.eclipse.che.api.promises.client.PromiseError)40 Container (org.eclipse.che.ide.api.resources.Container)32 Path (org.eclipse.che.ide.resource.Path)30 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)22 Optional (com.google.common.base.Optional)15 File (org.eclipse.che.ide.api.resources.File)14 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)14 List (java.util.List)13 Promise (org.eclipse.che.api.promises.client.Promise)13 FunctionException (org.eclipse.che.api.promises.client.FunctionException)12 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)12 ArrayList (java.util.ArrayList)11 Function (org.eclipse.che.api.promises.client.Function)9 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)9 JavaUtil.isJavaProject (org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject)9 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)8