Search in sources :

Example 6 with JavaProject

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

the class MovePresenter method showProjectsAndPackages.

private void showProjectsAndPackages() {
    Promise<List<JavaProject>> projectsPromise = navigationService.getProjectsAndPackages(true);
    projectsPromise.then(new Operation<List<JavaProject>>() {

        @Override
        public void apply(List<JavaProject> projects) throws OperationException {
            List<JavaProject> currentProject = new ArrayList<>();
            for (JavaProject project : projects) {
                currentProject.add(project);
            }
            view.setTreeOfDestinations(currentProject);
            view.show(refactorInfo);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(locale.showPackagesError(), error.getMessage(), Status.FAIL, FLOAT_MODE);
        }
    });
}
Also used : JavaProject(org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject) PromiseError(org.eclipse.che.api.promises.client.PromiseError) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 7 with JavaProject

use of org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject 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)

Example 8 with JavaProject

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

the class JavaElementToDtoConverter method getProjects.

public List<JavaProject> getProjects() throws JavaModelException {
    Set<Object> objects = childrens.get(result);
    List<JavaProject> result = new ArrayList<>();
    if (objects == null) {
        return result;
    }
    for (Object object : objects) {
        JavaProject javaProject = DtoFactory.newDto(JavaProject.class);
        IJavaProject project = (IJavaProject) object;
        javaProject.setName(project.getElementName());
        String path = project.getPath().toOSString();
        javaProject.setPath(path);
        javaProject.setPackageFragmentRoots(getPackageFragmentRoots(object, path));
        result.add(javaProject);
    }
    return result;
}
Also used : JavaProject(org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject) IJavaProject(org.eclipse.jdt.core.IJavaProject) IJavaProject(org.eclipse.jdt.core.IJavaProject) ArrayList(java.util.ArrayList)

Aggregations

JavaProject (org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject)8 ArrayList (java.util.ArrayList)5 PackageFragmentRoot (org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 Test (org.junit.Test)3 List (java.util.List)2 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)2 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 HashMap (java.util.HashMap)1 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 Region (org.eclipse.che.ide.ext.java.shared.dto.Region)1 PackageFragment (org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragment)1 FindUsagesResponse (org.eclipse.che.ide.ext.java.shared.dto.search.FindUsagesResponse)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 IJavaElement (org.eclipse.jdt.core.IJavaElement)1 IMember (org.eclipse.jdt.core.IMember)1