Search in sources :

Example 41 with Problem

use of com.liferay.blade.api.Problem in project liferay-ide by liferay.

the class MigrationProblemPreferencePage method createContents.

@Override
public Control createContents(Composite parent) {
    Composite pageComponent = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    pageComponent.setLayout(layout);
    GridData data = new GridData();
    data.verticalAlignment = GridData.FILL;
    data.horizontalAlignment = GridData.FILL;
    pageComponent.setLayoutData(data);
    data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    Label label = new Label(pageComponent, SWT.LEFT);
    label.setText("These are ignored breaking change problems.\n You can remove them if you want to show this type of " + "problem next time.");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    _ignoredProblemTable = new TableViewer(pageComponent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
    data = new GridData(GridData.FILL_HORIZONTAL);
    _createColumns(_ignoredProblemTable);
    final Table table = _ignoredProblemTable.getTable();
    table.setHeaderVisible(true);
    data.heightHint = 200;
    _ignoredProblemTable.getTable().setLayoutData(data);
    _ignoredProblemTable.setContentProvider(ArrayContentProvider.getInstance());
    Composite groupComponent = new Composite(pageComponent, SWT.NULL);
    GridLayout groupLayout = new GridLayout();
    groupLayout.marginWidth = 0;
    groupLayout.marginHeight = 0;
    groupComponent.setLayout(groupLayout);
    data = new GridData();
    data.verticalAlignment = GridData.FILL;
    data.horizontalAlignment = GridData.FILL;
    groupComponent.setLayoutData(data);
    _removeButton = new Button(groupComponent, SWT.PUSH);
    _removeButton.setText("Remove");
    _removeButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            StructuredSelection selection = (StructuredSelection) _ignoredProblemTable.getSelection();
            if ((selection != null) && (selection.getFirstElement() instanceof Problem)) {
                try {
                    Problem problem = (Problem) selection.getFirstElement();
                    _mpContainer.remove(problem);
                    Map<String, Problem> problemMap = _mpContainer.getProblemMap();
                    _ignoredProblemTable.setInput(problemMap.values().toArray(new Problem[0]));
                } catch (Exception e) {
                    ProjectUI.logError(e);
                }
            }
        }
    });
    setButtonLayoutData(_removeButton);
    label = new Label(pageComponent, SWT.LEFT);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    _detailInfoLabel = new Label(pageComponent, SWT.LEFT);
    _detailInfoLabel.setText("Detail Information");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    _detailInfoLabel.setLayoutData(data);
    _browser = new Browser(pageComponent, SWT.BORDER);
    data = new GridData(GridData.FILL_BOTH);
    _browser.setLayoutData(data);
    groupComponent = new Composite(pageComponent, SWT.NULL);
    groupLayout = new GridLayout();
    groupLayout.marginWidth = 0;
    groupLayout.marginHeight = 0;
    groupComponent.setLayout(groupLayout);
    data = new GridData();
    data.verticalAlignment = GridData.FILL;
    data.horizontalAlignment = GridData.FILL;
    groupComponent.setLayoutData(data);
    _fillIgnoredProblemTable();
    _ignoredProblemTable.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(final SelectionChangedEvent event) {
            UIUtil.async(new Runnable() {

                public void run() {
                    _updateForm(event);
                }
            }, 50);
        }
    });
    return pageComponent;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IOException(java.io.IOException) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Problem(com.liferay.blade.api.Problem) TableViewer(org.eclipse.jface.viewers.TableViewer) Map(java.util.Map) SelectionListener(org.eclipse.swt.events.SelectionListener) Browser(org.eclipse.swt.browser.Browser)

Example 42 with Problem

use of com.liferay.blade.api.Problem in project liferay-ide by liferay.

the class MigrationProblemPreferencePage method _fillIgnoredProblemTable.

private void _fillIgnoredProblemTable() {
    try {
        IgnoredProblemsContainer mpContainer = UpgradeAssistantSettingsUtil.getObjectFromStore(IgnoredProblemsContainer.class);
        if (mpContainer != null) {
            Map<String, Problem> problemMap = mpContainer.getProblemMap();
            Problem[] problems = problemMap.values().toArray(new Problem[0]);
            _ignoredProblemTable.setInput(problems);
        }
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
Also used : IgnoredProblemsContainer(com.liferay.ide.project.core.upgrade.IgnoredProblemsContainer) Problem(com.liferay.blade.api.Problem) IOException(java.io.IOException)

Example 43 with Problem

use of com.liferay.blade.api.Problem in project liferay-ide by liferay.

the class MigrationProblemPreferencePage method _createColumns.

private void _createColumns(final TableViewer problemsViewer) {
    final String[] titles = { "Tickets", "Problem" };
    final int[] bounds = { 65, 55 };
    TableViewerColumn col = _createTableViewerColumn(titles[0], bounds[0], problemsViewer);
    col.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            Problem p = (Problem) element;
            return p.getTicket();
        }
    });
    col = _createTableViewerColumn(titles[1], bounds[1], problemsViewer);
    col.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            Problem p = (Problem) element;
            return p.getTitle();
        }

        @Override
        public void update(ViewerCell cell) {
            super.update(cell);
            Table table = problemsViewer.getTable();
            table.getColumn(1).pack();
        }
    });
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Table(org.eclipse.swt.widgets.Table) Problem(com.liferay.blade.api.Problem) ViewerCell(org.eclipse.jface.viewers.ViewerCell) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 44 with Problem

use of com.liferay.blade.api.Problem in project liferay-ide by liferay.

the class MigrationUtil method updateMigrationProblemToStore.

public static void updateMigrationProblemToStore(Problem problem) {
    File file = problem.getFile();
    try {
        MigrationProblemsContainer container = UpgradeAssistantSettingsUtil.getObjectFromStore(MigrationProblemsContainer.class);
        boolean found = false;
        for (MigrationProblems mp : container.getProblemsArray()) {
            for (FileProblems fileProblem : mp.getProblems()) {
                if (fileProblem.getFile().equals(file)) {
                    for (int i = 0; i < fileProblem.getProblems().size(); i++) {
                        Problem p = fileProblem.getProblems().get(i);
                        if (p.equals(problem)) {
                            fileProblem.getProblems().set(i, problem);
                            found = true;
                            break;
                        }
                    }
                }
                if (found) {
                    break;
                }
            }
            if (found) {
                break;
            }
        }
        UpgradeAssistantSettingsUtil.setObjectToStore(MigrationProblemsContainer.class, container);
    } catch (IOException ioe) {
    }
}
Also used : FileProblems(com.liferay.ide.project.core.upgrade.FileProblems) Problem(com.liferay.blade.api.Problem) IOException(java.io.IOException) MigrationProblems(com.liferay.ide.project.core.upgrade.MigrationProblems) IFile(org.eclipse.core.resources.IFile) File(java.io.File) MigrationProblemsContainer(com.liferay.ide.project.core.upgrade.MigrationProblemsContainer)

Example 45 with Problem

use of com.liferay.blade.api.Problem 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)

Aggregations

Problem (com.liferay.blade.api.Problem)92 Test (org.junit.Test)58 File (java.io.File)42 FileMigrator (com.liferay.blade.api.FileMigrator)31 Migration (com.liferay.blade.api.Migration)29 NullProgressMonitor (com.liferay.blade.util.NullProgressMonitor)26 ArrayList (java.util.ArrayList)16 FileProblems (com.liferay.ide.project.core.upgrade.FileProblems)9 IOException (java.io.IOException)9 ServiceReference (org.osgi.framework.ServiceReference)9 AutoMigrator (com.liferay.blade.api.AutoMigrator)8 IFile (org.eclipse.core.resources.IFile)8 List (java.util.List)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 AutoMigrateException (com.liferay.blade.api.AutoMigrateException)5 SearchResult (com.liferay.blade.api.SearchResult)5 MigrationProblems (com.liferay.ide.project.core.upgrade.MigrationProblems)5 MigrationProblemsContainer (com.liferay.ide.project.core.upgrade.MigrationProblemsContainer)5 HashSet (java.util.HashSet)5 CoreException (org.eclipse.core.runtime.CoreException)5