Search in sources :

Example 1 with FindBreakingChangesPage

use of com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage in project liferay-ide by liferay.

the class ProblemAction method run.

public void run(final Problem problem, final ISelectionProvider provider) {
    final IResource resource = MigrationUtil.getIResourceFromProblem(problem);
    WorkspaceJob migrationJob = new WorkspaceJob("Marking migration problem as done") {

        public IStatus runInWorkspace(IProgressMonitor monitor) {
            IStatus retval = Status.OK_STATUS;
            if ((resource != null) && resource.exists()) {
                final IMarker marker = resource.getMarker(problem.getMarkerId());
                if (marker != null) {
                    retval = runWithMarker(problem, marker);
                    if (provider instanceof Viewer) {
                        final Viewer viewer = (Viewer) provider;
                        FindBreakingChangesPage page = UpgradeView.getPage(Page.findbreackingchangesPageId, FindBreakingChangesPage.class);
                        TreeViewer treeViewer = page.getTreeViewer();
                        UIUtil.async(new Runnable() {

                            public void run() {
                                viewer.refresh();
                                treeViewer.refresh();
                            }
                        });
                    }
                } else {
                    retval = ProjectUI.createErrorStatus("Unable to get marker from file");
                }
            } else {
                retval = ProjectUI.createErrorStatus("Unable to get file from problem");
            }
            return retval;
        }
    };
    migrationJob.schedule();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) 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) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IMarker(org.eclipse.core.resources.IMarker) IResource(org.eclipse.core.resources.IResource)

Example 2 with FindBreakingChangesPage

use of com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage in project liferay-ide by liferay.

the class ProblemAction method refreshTableViewer.

protected void refreshTableViewer() {
    FindBreakingChangesPage page = UpgradeView.getPage(Page.findbreackingchangesPageId, FindBreakingChangesPage.class);
    TableViewer problemsViewer = page.getProblemsViewer();
    UIUtil.async(new Runnable() {

        @Override
        public void run() {
            final Object selection = problemsViewer.getStructuredSelection().getFirstElement();
            List<Problem> problems = null;
            if (selection instanceof IFile) {
                IFile file = (IFile) selection;
                problems = MigrationUtil.getProblemsFromResource(file);
            } else if (selection instanceof Problem) {
                ISelection se = page.getTreeViewer().getSelection();
                if (se instanceof TreeSelection) {
                    problems = MigrationUtil.getCurrentProblemsFromTreeNode((TreeSelection) se);
                }
            }
            if (ListUtil.isNotEmpty(problems)) {
                problemsViewer.setInput(problems.toArray());
                problemsViewer.setSelection(new StructuredSelection(problems.get(0)));
            } else {
                problemsViewer.setInput(null);
            }
        }
    });
}
Also used : IFile(org.eclipse.core.resources.IFile) TreeSelection(org.eclipse.jface.viewers.TreeSelection) FindBreakingChangesPage(com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) List(java.util.List) Problem(com.liferay.blade.api.Problem) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 3 with FindBreakingChangesPage

use of com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage in project liferay-ide by liferay.

the class RemoveAction method run.

@Override
public void run() {
    // final MigrationView mv = (MigrationView) UIUtil.showView( MigrationView.ID );
    // final CommonViewer commonViewer = mv.getCommonViewer();
    final FindBreakingChangesPage page = UpgradeView.getPage(Page.findbreackingchangesPageId, FindBreakingChangesPage.class);
    final TreeViewer treeViewer = page.getTreeViewer();
    Object selection = treeViewer.getStructuredSelection().getFirstElement();
    if (selection instanceof MigrationProblems) {
        MigrationProblems migrationProblem = (MigrationProblems) selection;
        MigrationUtil.removeMigrationProblems(migrationProblem);
        IResource project = MigrationUtil.getResourceFromMigrationProblems(migrationProblem);
        if (project != null) {
            MarkerUtil.clearMarkers(project, MigrationConstants.MARKER_TYPE, null);
        }
    }
    treeViewer.setInput(CoreUtil.getWorkspaceRoot());
    treeViewer.expandToLevel(2);
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) FindBreakingChangesPage(com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage) MigrationProblems(com.liferay.ide.project.core.upgrade.MigrationProblems) IResource(org.eclipse.core.resources.IResource)

Example 4 with FindBreakingChangesPage

use of com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage in project liferay-ide by liferay.

the class MigrateProjectHandler method _setButtonState.

private void _setButtonState(boolean enableState) {
    FindBreakingChangesPage page = UpgradeView.getPage(Page.findbreackingchangesPageId, FindBreakingChangesPage.class);
    page.setButtonState(enableState);
}
Also used : FindBreakingChangesPage(com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage)

Example 5 with FindBreakingChangesPage

use of com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage in project liferay-ide by liferay.

the class MigrateProjectHandler method refreshViewer.

protected void refreshViewer(List<Problem> allProblems) {
    FindBreakingChangesPage page = UpgradeView.getPage(Page.findbreackingchangesPageId, FindBreakingChangesPage.class);
    TableViewer problemsViewer = page.get_problemsViewer();
    TreeViewer treeViewer = page.getTreeViewer();
    UIUtil.async(new Runnable() {

        @Override
        public void run() {
            problemsViewer.setInput(allProblems);
            Object currentTreeNode = treeViewer.getStructuredSelection().getFirstElement();
            String currentPath = null;
            if (currentTreeNode instanceof FileProblems) {
                FileProblems currentNode = (FileProblems) currentTreeNode;
                File currentFile = currentNode.getFile();
                currentPath = currentFile.getAbsolutePath();
            }
            MigrationContentProvider contentProvider = (MigrationContentProvider) treeViewer.getContentProvider();
            MigrationProblemsContainer mc = (MigrationProblemsContainer) contentProvider.getProblems().get(0);
            for (MigrationProblems project : mc.getProblemsArray()) {
                Iterator<FileProblems> fileProblemItertor = new LinkedList<>(Arrays.asList(project.getProblems())).iterator();
                while (fileProblemItertor.hasNext()) {
                    FileProblems fileProblem = fileProblemItertor.next();
                    File file = fileProblem.getFile();
                    String fileAbsolutePath = file.getAbsolutePath();
                    if (fileAbsolutePath.equals(currentPath)) {
                        List<Problem> problems = fileProblem.getProblems();
                        problems.clear();
                        problems.addAll(allProblems);
                        break;
                    }
                }
            }
        }
    });
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) FindBreakingChangesPage(com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage) MigrationProblems(com.liferay.ide.project.core.upgrade.MigrationProblems) MigrationProblemsContainer(com.liferay.ide.project.core.upgrade.MigrationProblemsContainer) LinkedList(java.util.LinkedList) FileProblems(com.liferay.ide.project.core.upgrade.FileProblems) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) TableViewer(org.eclipse.jface.viewers.TableViewer) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

FindBreakingChangesPage (com.liferay.ide.project.ui.upgrade.animated.FindBreakingChangesPage)7 TreeViewer (org.eclipse.jface.viewers.TreeViewer)4 MigrationProblems (com.liferay.ide.project.core.upgrade.MigrationProblems)3 List (java.util.List)3 TableViewer (org.eclipse.jface.viewers.TableViewer)3 Problem (com.liferay.blade.api.Problem)2 FileProblems (com.liferay.ide.project.core.upgrade.FileProblems)2 MigrationProblemsContainer (com.liferay.ide.project.core.upgrade.MigrationProblemsContainer)2 Iterator (java.util.Iterator)2 IFile (org.eclipse.core.resources.IFile)2 IResource (org.eclipse.core.resources.IResource)2 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1