Search in sources :

Example 1 with MarkUndoneAction

use of com.liferay.ide.project.ui.migration.MarkUndoneAction in project liferay-ide by liferay.

the class FindBreakingChangesPage method createTableView.

public void createTableView(Composite container) {
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.minimumWidth = 200;
    gridData.minimumHeight = 200;
    Composite tableComposite = new Composite(container, SWT.NONE);
    _problemsViewer = new TableViewer(tableComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL);
    _problemsViewer.getTable().setLayoutData(gridData);
    _createColumns(_problemsViewer);
    final Table table = _problemsViewer.getTable();
    table.setHeaderVisible(true);
    _problemsViewer.setContentProvider(ArrayContentProvider.getInstance());
    _problemsViewer.setComparer(null);
    _comparator = new MigratorComparator();
    _problemsViewer.setComparator(_comparator);
    MenuManager menuMgr = new MenuManager();
    IAction markDoneAction = new MarkDoneAction(_problemsViewer);
    IAction markUndoneAction = new MarkUndoneAction(_problemsViewer);
    IAction ignoreAction = new IgnoreAction(_problemsViewer);
    IAction ignoreAlways = new IgnoreAlwaysAction(_problemsViewer);
    IAction autoCorrectAction = new AutoCorrectAction(_problemsViewer);
    menuMgr.add(markDoneAction);
    menuMgr.add(markUndoneAction);
    menuMgr.add(ignoreAction);
    menuMgr.add(autoCorrectAction);
    menuMgr.add(ignoreAlways);
    Menu menu = menuMgr.createContextMenu(table);
    table.setMenu(menu);
    _problemsViewer.addDoubleClickListener(this);
}
Also used : MigratorComparator(com.liferay.ide.project.ui.migration.MigratorComparator) Table(org.eclipse.swt.widgets.Table) MarkDoneAction(com.liferay.ide.project.ui.migration.MarkDoneAction) Composite(org.eclipse.swt.widgets.Composite) IAction(org.eclipse.jface.action.IAction) AutoCorrectAction(com.liferay.ide.project.ui.migration.AutoCorrectAction) MarkUndoneAction(com.liferay.ide.project.ui.migration.MarkUndoneAction) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IgnoreAlwaysAction(com.liferay.ide.project.ui.migration.IgnoreAlwaysAction) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) IgnoreAction(com.liferay.ide.project.ui.migration.IgnoreAction)

Example 2 with MarkUndoneAction

use of com.liferay.ide.project.ui.migration.MarkUndoneAction in project liferay-ide by liferay.

the class FindBreakingChangesPage method _createColumns.

private void _createColumns(final TableViewer problemsViewer) {
    final String[] titles = { "Resolved", "Line", "Problem" };
    TableViewerColumn col0 = _createTableViewerColumn(titles[0], problemsViewer);
    col0.getColumn().pack();
    col0.setEditingSupport(new EditingSupport(problemsViewer) {

        @Override
        protected boolean canEdit(Object element) {
            return true;
        }

        @Override
        protected CellEditor getCellEditor(Object element) {
            return new CheckboxCellEditor(problemsViewer.getTable());
        }

        @Override
        protected Object getValue(Object element) {
            return ((Problem) element).getStatus() == Problem.STATUS_RESOLVED;
        }

        @Override
        protected void setValue(Object element, Object value) {
            if (value == Boolean.TRUE) {
                new MarkDoneAction().run((Problem) element, problemsViewer);
            } else {
                new MarkUndoneAction().run((Problem) element, problemsViewer);
            }
        }
    });
    col0.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public Image getImage(Object element) {
            Problem p = (Problem) element;
            if (p.getStatus() == Problem.STATUS_RESOLVED) {
                return _imageChecked;
            } else {
                return _imageUnchecked;
            }
        }

        @Override
        public String getText(Object element) {
            return null;
        }
    });
    TableViewerColumn col1 = _createTableViewerColumn(titles[1], problemsViewer);
    col1.getColumn().pack();
    col1.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            Problem p = (Problem) element;
            return p.lineNumber > -1 ? (p.lineNumber + "") : "";
        }
    });
    TableViewerColumn col2 = _createTableViewerColumn(titles[2], problemsViewer);
    col2.getColumn().pack();
    col2.setLabelProvider(new ColumnLabelProvider() {

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

        @Override
        public void update(ViewerCell cell) {
            super.update(cell);
            Table table = problemsViewer.getTable();
            table.getColumn(2).pack();
        }
    });
    TableColumnLayout tableLayout = new TableColumnLayout();
    TableColumn column0 = col0.getColumn();
    TableColumn column1 = col1.getColumn();
    TableColumn column2 = col2.getColumn();
    tableLayout.setColumnData(column0, new ColumnWeightData(50, column0.getWidth()));
    tableLayout.setColumnData(column1, new ColumnWeightData(50, column1.getWidth()));
    tableLayout.setColumnData(column2, new ColumnWeightData(100, column2.getWidth()));
    Table table = problemsViewer.getTable();
    table.getParent().setLayout(tableLayout);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) MarkDoneAction(com.liferay.ide.project.ui.migration.MarkDoneAction) Table(org.eclipse.swt.widgets.Table) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) EditingSupport(org.eclipse.jface.viewers.EditingSupport) MarkUndoneAction(com.liferay.ide.project.ui.migration.MarkUndoneAction) Image(org.eclipse.swt.graphics.Image) ViewerCell(org.eclipse.jface.viewers.ViewerCell) TableColumn(org.eclipse.swt.widgets.TableColumn) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) Problem(com.liferay.blade.api.Problem) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

MarkDoneAction (com.liferay.ide.project.ui.migration.MarkDoneAction)2 MarkUndoneAction (com.liferay.ide.project.ui.migration.MarkUndoneAction)2 Table (org.eclipse.swt.widgets.Table)2 Problem (com.liferay.blade.api.Problem)1 AutoCorrectAction (com.liferay.ide.project.ui.migration.AutoCorrectAction)1 IgnoreAction (com.liferay.ide.project.ui.migration.IgnoreAction)1 IgnoreAlwaysAction (com.liferay.ide.project.ui.migration.IgnoreAlwaysAction)1 MigratorComparator (com.liferay.ide.project.ui.migration.MigratorComparator)1 IAction (org.eclipse.jface.action.IAction)1 MenuManager (org.eclipse.jface.action.MenuManager)1 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1 CellEditor (org.eclipse.jface.viewers.CellEditor)1 CheckboxCellEditor (org.eclipse.jface.viewers.CheckboxCellEditor)1 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)1 EditingSupport (org.eclipse.jface.viewers.EditingSupport)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 ViewerCell (org.eclipse.jface.viewers.ViewerCell)1 Image (org.eclipse.swt.graphics.Image)1