Search in sources :

Example 1 with PackageFragmentRoot

use of org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot in project che by eclipse.

the class JavaProjectNode method getChildrenImpl.

@Override
protected Promise<List<Node>> getChildrenImpl() {
    return createFromAsyncRequest(callback -> {
        final List<Node> childrenNodes = new ArrayList<>();
        for (PackageFragmentRoot packageFragmentRoot : project.getPackageFragmentRoots()) {
            final List<PackageFragment> packageFragments = packageFragmentRoot.getPackageFragments();
            final List<Node> nodes = packageFragments.stream().map(packageFragment -> nodeFactory.create(packageFragment, matches, packageFragmentRoot)).collect(Collectors.toList());
            childrenNodes.addAll(nodes);
        }
        callback.onSuccess(childrenNodes);
    });
}
Also used : AsyncPromiseHelper.createFromAsyncRequest(org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.createFromAsyncRequest) JavaProject(org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject) Inject(com.google.inject.Inject) PackageFragmentRoot(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Assisted(com.google.inject.assistedinject.Assisted) Promise(org.eclipse.che.api.promises.client.Promise) NodePresentation(org.eclipse.che.ide.ui.smartTree.presentation.NodePresentation) List(java.util.List) Match(org.eclipse.che.ide.ext.java.shared.dto.search.Match) PackageFragment(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragment) Node(org.eclipse.che.ide.api.data.tree.Node) Map(java.util.Map) NodesResources(org.eclipse.che.ide.project.shared.NodesResources) PackageFragment(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragment) PackageFragmentRoot(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot) Node(org.eclipse.che.ide.api.data.tree.Node) ArrayList(java.util.ArrayList)

Example 2 with PackageFragmentRoot

use of org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot in project che by eclipse.

the class JavaElementToDtoConverter method getPackageFragmentRoots.

private List<PackageFragmentRoot> getPackageFragmentRoots(Object parent, String projectPath) throws JavaModelException {
    List<PackageFragmentRoot> result = new ArrayList<>();
    Set<Object> objects = childrens.get(parent);
    if (objects == null) {
        return result;
    }
    for (Object object : objects) {
        if (object instanceof IPackageFragmentRoot) {
            PackageFragmentRoot root = DtoFactory.newDto(PackageFragmentRoot.class);
            IPackageFragmentRoot fragmentRoot = (IPackageFragmentRoot) object;
            root.setProjectPath(projectPath);
            root.setKind(fragmentRoot.getKind());
            root.setPath(fragmentRoot.getPath().toOSString());
            root.setElementName(fragmentRoot.getElementName());
            root.setHandleIdentifier(fragmentRoot.getHandleIdentifier());
            root.setPackageFragments(getPackageFragments(fragmentRoot, projectPath));
            result.add(root);
        }
    }
    return result;
}
Also used : PackageFragmentRoot(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) ArrayList(java.util.ArrayList) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot)

Example 3 with PackageFragmentRoot

use of org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot in project che by eclipse.

the class JarNavigationTest method testAllProjectsWithoutPackages.

@Test
public void testAllProjectsWithoutPackages() throws Exception {
    List<JavaProject> packages = navigation.getAllProjectsAndPackages(false);
    assertThat(packages).isNotNull().isNotEmpty();
    JavaProject project = packages.get(0);
    assertThat(project.getPackageFragmentRoots()).isNotNull().isNotEmpty();
    PackageFragmentRoot fragmentRoot = project.getPackageFragmentRoots().get(0);
    assertThat(fragmentRoot.getPackageFragments()).isNullOrEmpty();
}
Also used : JavaProject(org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject) PackageFragmentRoot(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) Test(org.junit.Test)

Example 4 with PackageFragmentRoot

use of org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot in project che by eclipse.

the class JarNavigationTest method testAllProjectsAndPackages.

@Test
public void testAllProjectsAndPackages() throws Exception {
    List<JavaProject> packages = navigation.getAllProjectsAndPackages(true);
    assertThat(packages).isNotNull().isNotEmpty();
    JavaProject project = packages.get(0);
    assertThat(packages.get(0).getPackageFragmentRoots()).isNotNull().isNotEmpty();
    assertThat(project.getPackageFragmentRoots()).isNotNull().isNotEmpty();
    PackageFragmentRoot fragmentRoot = project.getPackageFragmentRoots().get(0);
    assertThat(fragmentRoot.getPackageFragments()).isNotEmpty();
}
Also used : JavaProject(org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject) PackageFragmentRoot(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) Test(org.junit.Test)

Example 5 with PackageFragmentRoot

use of org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot in project che by eclipse.

the class MoveViewImpl method setTreeOfDestinations.

/** {@inheritDoc} */
@Override
public void setTreeOfDestinations(List<JavaProject> projects) {
    final SingleSelectionModel<Object> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            Object object = selectionModel.getSelectedObject();
            if (object instanceof JavaProject) {
                JavaProject project = (JavaProject) object;
                delegate.setMoveDestinationPath(project.getPath(), project.getPath());
            }
            if (object instanceof PackageFragmentRoot) {
                PackageFragmentRoot fragmentRoot = (PackageFragmentRoot) object;
                delegate.setMoveDestinationPath(fragmentRoot.getPath(), fragmentRoot.getProjectPath());
            }
            if (object instanceof PackageFragment) {
                PackageFragment fragment = (PackageFragment) object;
                delegate.setMoveDestinationPath(fragment.getPath(), fragment.getProjectPath());
            }
        }
    });
    CellTree tree = new CellTree(new ProjectsAndPackagesModel(projects, selectionModel, resources), null, cellTreeResources);
    tree.setAnimationEnabled(true);
    treePanel.clear();
    treePanel.add(tree);
}
Also used : PackageFragment(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragment) JavaProject(org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject) PackageFragmentRoot(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot) SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) CellTree(com.google.gwt.user.cellview.client.CellTree) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Aggregations

PackageFragmentRoot (org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot)7 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)5 JavaProject (org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject)4 ArrayList (java.util.ArrayList)3 PackageFragment (org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragment)3 Test (org.junit.Test)3 CellTree (com.google.gwt.user.cellview.client.CellTree)1 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)1 SingleSelectionModel (com.google.gwt.view.client.SingleSelectionModel)1 Inject (com.google.inject.Inject)1 Assisted (com.google.inject.assistedinject.Assisted)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 NotNull (javax.validation.constraints.NotNull)1 Promise (org.eclipse.che.api.promises.client.Promise)1 AsyncPromiseHelper.createFromAsyncRequest (org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.createFromAsyncRequest)1 Node (org.eclipse.che.ide.api.data.tree.Node)1 CompilationUnit (org.eclipse.che.ide.ext.java.shared.dto.model.CompilationUnit)1 FindUsagesResponse (org.eclipse.che.ide.ext.java.shared.dto.search.FindUsagesResponse)1