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;
}
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;
}
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();
}
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());
}
Aggregations