Search in sources :

Example 6 with MigrationProblemsContainer

use of com.liferay.ide.project.core.upgrade.MigrationProblemsContainer 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 MigrationProblemsContainer

use of com.liferay.ide.project.core.upgrade.MigrationProblemsContainer 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 MigrationProblemsContainer

use of com.liferay.ide.project.core.upgrade.MigrationProblemsContainer 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 MigrationProblemsContainer

use of com.liferay.ide.project.core.upgrade.MigrationProblemsContainer 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

MigrationProblemsContainer (com.liferay.ide.project.core.upgrade.MigrationProblemsContainer)9 FileProblems (com.liferay.ide.project.core.upgrade.FileProblems)7 MigrationProblems (com.liferay.ide.project.core.upgrade.MigrationProblems)7 Problem (com.liferay.blade.api.Problem)6 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 File (java.io.File)3 HashSet (java.util.HashSet)3 IFile (org.eclipse.core.resources.IFile)3 FindBreakingChangesPage (com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage)2 List (java.util.List)2 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 Migration (com.liferay.blade.api.Migration)1 ProgressMonitor (com.liferay.blade.api.ProgressMonitor)1 BreakingChangeSelectedProject (com.liferay.ide.project.core.upgrade.BreakingChangeSelectedProject)1