Search in sources :

Example 6 with FileProblems

use of com.liferay.ide.project.core.upgrade.FileProblems in project liferay-ide by liferay.

the class MigrationUtil method getCurrentProblemsFromTreeNode.

@SuppressWarnings("rawtypes")
public static List<Problem> getCurrentProblemsFromTreeNode(ISelection selection) {
    List<Problem> notIgnoreProblems = new ArrayList<>();
    if (selection instanceof IStructuredSelection) {
        final IStructuredSelection ss = (IStructuredSelection) selection;
        Iterator iterator = ss.iterator();
        while (iterator.hasNext()) {
            Object element = iterator.next();
            if (element instanceof FileProblems) {
                FileProblems fp = (FileProblems) element;
                for (Problem problem : fp.getProblems()) {
                    if (problem.getStatus() != Problem.STATUS_IGNORE) {
                        notIgnoreProblems.add(problem);
                    }
                }
            } else if (element instanceof MigrationProblems) {
                MigrationProblems migrationProblems = (MigrationProblems) element;
                for (FileProblems fProblems : migrationProblems.getProblems()) {
                    for (Problem problem : fProblems.getProblems()) {
                        if (problem.getStatus() != Problem.STATUS_IGNORE) {
                            notIgnoreProblems.add(problem);
                        }
                    }
                }
            } else if (element instanceof MigrationProblemsContainer) {
                MigrationProblemsContainer migrationProblemsContainer = (MigrationProblemsContainer) element;
                for (MigrationProblems migrationProblems : migrationProblemsContainer.getProblemsArray()) {
                    for (FileProblems fProblems : migrationProblems.getProblems()) {
                        for (Problem problem : fProblems.getProblems()) {
                            if (problem.getStatus() != Problem.STATUS_IGNORE) {
                                notIgnoreProblems.add(problem);
                            }
                        }
                    }
                }
            }
        }
        // remove duplicate problem
        HashSet<Problem> hashSet = new HashSet<>(notIgnoreProblems);
        notIgnoreProblems.clear();
        notIgnoreProblems.addAll(hashSet);
        return notIgnoreProblems;
    }
    return notIgnoreProblems;
}
Also used : FileProblems(com.liferay.ide.project.core.upgrade.FileProblems) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Problem(com.liferay.blade.api.Problem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MigrationProblems(com.liferay.ide.project.core.upgrade.MigrationProblems) MigrationProblemsContainer(com.liferay.ide.project.core.upgrade.MigrationProblemsContainer) HashSet(java.util.HashSet)

Example 7 with FileProblems

use of com.liferay.ide.project.core.upgrade.FileProblems in project liferay-ide by liferay.

the class MigrationUtil method getProblemsFromTreeNode.

@SuppressWarnings("rawtypes")
public static List<Problem> getProblemsFromTreeNode(ISelection selection) {
    List<Problem> allProblems = new ArrayList<>();
    if (selection instanceof IStructuredSelection) {
        final IStructuredSelection ss = (IStructuredSelection) selection;
        Iterator iterator = ss.iterator();
        while (iterator.hasNext()) {
            Object element = iterator.next();
            if (element instanceof FileProblems) {
                FileProblems fp = (FileProblems) element;
                allProblems.addAll(fp.getProblems());
            } else if (element instanceof MigrationProblems) {
                MigrationProblems migrationProblems = (MigrationProblems) element;
                for (FileProblems fProblems : migrationProblems.getProblems()) {
                    allProblems.addAll(fProblems.getProblems());
                }
            } else if (element instanceof MigrationProblemsContainer) {
                MigrationProblemsContainer migrationProblemsContainer = (MigrationProblemsContainer) element;
                for (MigrationProblems migrationProblems : migrationProblemsContainer.getProblemsArray()) {
                    for (FileProblems fProblems : migrationProblems.getProblems()) {
                        allProblems.addAll(fProblems.getProblems());
                    }
                }
            }
        }
        // remove duplicate problem
        HashSet<Problem> hashSet = new HashSet<>(allProblems);
        allProblems.clear();
        allProblems.addAll(hashSet);
        return allProblems;
    }
    return allProblems;
}
Also used : FileProblems(com.liferay.ide.project.core.upgrade.FileProblems) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Problem(com.liferay.blade.api.Problem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MigrationProblems(com.liferay.ide.project.core.upgrade.MigrationProblems) MigrationProblemsContainer(com.liferay.ide.project.core.upgrade.MigrationProblemsContainer) HashSet(java.util.HashSet)

Example 8 with FileProblems

use of com.liferay.ide.project.core.upgrade.FileProblems in project liferay-ide by liferay.

the class IgnoreAlwaysAction method run.

@Override
public void run() {
    final Problem problem = MigrationUtil.getProblemFromSelection(getSelection());
    _storeIgnoredProblem(problem);
    new WorkspaceJob("Ignore all problems of this type") {

        public IStatus runInWorkspace(IProgressMonitor monitor) {
            IStatus retval = Status.OK_STATUS;
            try {
                FindBreakingChangesPage page = UpgradeView.getPage(Page.findbreackingchangesPageId, FindBreakingChangesPage.class);
                TreeViewer treeViewer = page.getTreeViewer();
                MigrationContentProvider contentProvider = (MigrationContentProvider) treeViewer.getContentProvider();
                final MigrationProblemsContainer mpContainer = (MigrationProblemsContainer) contentProvider.getProblems().get(0);
                final MigrationProblems[] projectProblem = mpContainer.getProblemsArray();
                for (MigrationProblems pProblem : projectProblem) {
                    FileProblems[] fProblems = pProblem.getProblems();
                    for (FileProblems fp : fProblems) {
                        List<Problem> problems = fp.getProblems();
                        Iterator<Problem> iterator = problems.iterator();
                        while (iterator.hasNext()) {
                            Problem p = iterator.next();
                            if (p.getTicket().equals(problem.getTicket())) {
                                new IgnoreAction().run(p, _provider);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                retval = ProjectUI.createErrorStatus("Unable to get file from problem");
            }
            return retval;
        }
    }.schedule();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) TreeViewer(org.eclipse.jface.viewers.TreeViewer) FindBreakingChangesPage(com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) MigrationProblems(com.liferay.ide.project.core.upgrade.MigrationProblems) MigrationProblemsContainer(com.liferay.ide.project.core.upgrade.MigrationProblemsContainer) IOException(java.io.IOException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) FileProblems(com.liferay.ide.project.core.upgrade.FileProblems) Iterator(java.util.Iterator) Problem(com.liferay.blade.api.Problem) List(java.util.List)

Example 9 with FileProblems

use of com.liferay.ide.project.core.upgrade.FileProblems in project liferay-ide by liferay.

the class MigrationDecorator method decorate.

@Override
public void decorate(Object element, IDecoration decoration) {
    final List<Problem> problems = new ArrayList<>();
    final List<Problem> resolvedProblems = new ArrayList<>();
    final List<Problem> ignoreProblems = new ArrayList<>();
    if (element instanceof FileProblems) {
        final FileProblems fileProblems = (FileProblems) element;
        problems.addAll(fileProblems.getProblems());
        resolvedProblems.addAll(fileProblems.getProblems(Problem.STATUS_RESOLVED));
        ignoreProblems.addAll(fileProblems.getProblems(Problem.STATUS_IGNORE));
    } else if (element instanceof UpgradeProblems) {
        final UpgradeProblems upgradeProblems = (UpgradeProblems) element;
        for (FileProblems fileProblems : upgradeProblems.getProblems()) {
            problems.addAll(fileProblems.getProblems());
            resolvedProblems.addAll(fileProblems.getProblems(Problem.STATUS_RESOLVED));
            ignoreProblems.addAll(fileProblems.getProblems(Problem.STATUS_IGNORE));
        }
    } else if (element instanceof ProblemsContainer) {
        ProblemsContainer problemsContainer = (ProblemsContainer) element;
        for (UpgradeProblems upgradeProblems : problemsContainer.getProblemsArray()) {
            for (FileProblems fileProblems : upgradeProblems.getProblems()) {
                problems.addAll(fileProblems.getProblems());
                resolvedProblems.addAll(fileProblems.getProblems(Problem.STATUS_RESOLVED));
                ignoreProblems.addAll(fileProblems.getProblems(Problem.STATUS_IGNORE));
            }
        }
    }
    if (ListUtil.isNotEmpty(problems)) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        sb.append(problems.size()).append(" total");
        if (ListUtil.isNotEmpty(resolvedProblems)) {
            sb.append(", ");
            sb.append(resolvedProblems.size());
            sb.append(" resolved");
        }
        if (ListUtil.isNotEmpty(ignoreProblems)) {
            sb.append(", ");
            sb.append(ignoreProblems.size());
            sb.append(" ignored");
        }
        sb.append("]");
        decoration.addSuffix(sb.toString());
    }
}
Also used : FileProblems(com.liferay.ide.project.core.upgrade.FileProblems) UpgradeProblems(com.liferay.ide.project.core.upgrade.UpgradeProblems) ArrayList(java.util.ArrayList) Problem(com.liferay.blade.api.Problem) ProblemsContainer(com.liferay.ide.project.core.upgrade.ProblemsContainer)

Example 10 with FileProblems

use of com.liferay.ide.project.core.upgrade.FileProblems in project liferay-ide by liferay.

the class UpgradeAssistantSettingsUtilTests method readExistingMigrationProblemsContainer.

@Test
public void readExistingMigrationProblemsContainer() throws Exception {
    MigrationProblemsContainer migrationProblemsContainer = UpgradeAssistantSettingsUtil.getObjectFromStore(MigrationProblemsContainer.class);
    assertNotNull(migrationProblemsContainer);
    MigrationProblems[] migrationProblems = migrationProblemsContainer.getProblemsArray();
    assertEquals(2, migrationProblems.length);
    FileProblems[] fileProblems = migrationProblems[0].getProblems();
    assertNotNull(fileProblems);
    assertEquals(18, fileProblems.length);
    List<Problem> problems = fileProblems[0].getProblems();
    assertNotNull(problems);
    assertEquals(9, problems.size());
}
Also used : FileProblems(com.liferay.ide.project.core.upgrade.FileProblems) Problem(com.liferay.blade.api.Problem) MigrationProblems(com.liferay.ide.project.core.upgrade.MigrationProblems) MigrationProblemsContainer(com.liferay.ide.project.core.upgrade.MigrationProblemsContainer) Test(org.junit.Test)

Aggregations

FileProblems (com.liferay.ide.project.core.upgrade.FileProblems)10 Problem (com.liferay.blade.api.Problem)9 MigrationProblems (com.liferay.ide.project.core.upgrade.MigrationProblems)7 MigrationProblemsContainer (com.liferay.ide.project.core.upgrade.MigrationProblemsContainer)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 UpgradeProblems (com.liferay.ide.project.core.upgrade.UpgradeProblems)3 File (java.io.File)3 IOException (java.io.IOException)3 List (java.util.List)3 IFile (org.eclipse.core.resources.IFile)3 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IStatus (org.eclipse.core.runtime.IStatus)3 ProblemsContainer (com.liferay.ide.project.core.upgrade.ProblemsContainer)2 FindBreakingChangesPage (com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage)2 CoreException (org.eclipse.core.runtime.CoreException)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 BundleContext (org.osgi.framework.BundleContext)2