Search in sources :

Example 1 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project ACS by ACS-Community.

the class ArchivingListPart method postConstruct.

@PostConstruct
public void postConstruct(Composite parent, IEventBroker eventBroker) {
    try {
        em = EventModel.getInstance();
    } catch (Throwable thr) {
        thr.printStackTrace();
        IStatus someStatus = statusReporter.newStatus(IStatus.ERROR, "Connection with NCs failed.", thr);
        statusReporter.report(someStatus, StatusReporter.SHOW);
        throw new RuntimeException(thr);
    }
    logger = em.getLogger();
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.verticalSpacing = 0;
    parent.setLayout(gridLayout);
    //		buildCustomToolBar(parent);
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    /*
		 * "Time "+timeStamp+" "+m_channelName+" "+component+" "+count+"
		 * "+channelEventCount+" " +" "+evtTypeName+"
		 * "+evtCounter.get(evtTypeName)
		 */
    TableViewerColumn tvcol = new TableViewerColumn(viewer, SWT.NONE, 0);
    tvcol.setLabelProvider(new TimeStampLabelProvider());
    TableColumn col = tvcol.getColumn();
    col.setText("Timestamp");
    col.setWidth(190);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 1);
    tvcol.setLabelProvider(new EventSourceLabelProvider());
    col = tvcol.getColumn();
    col.setText("Device");
    col.setWidth(100);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 2);
    tvcol.setLabelProvider(new BaciParameterLabelProvider());
    col = tvcol.getColumn();
    col.setText("Property");
    col.setWidth(100);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 3);
    tvcol.setLabelProvider(new BaciPropertyValueLabelProvider());
    col = tvcol.getColumn();
    col.setText("Value");
    col.setWidth(100);
    col.setAlignment(SWT.LEFT);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getTable());
    viewer.setContentProvider(new ArchivingListContentProvider(em));
    viewer.setInput(new Object());
    pel = new PopulateEventList(logger, viewer, new StatusLineWriter(eventBroker), em.getArchQueue(), "Monitor points");
    eventListThread = pel.getThreadForEventList();
    eventListThread.start();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Table(org.eclipse.swt.widgets.Table) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) StatusLineWriter(alma.acs.eventbrowser.status.StatusLineWriter) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) PostConstruct(javax.annotation.PostConstruct)

Example 2 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project ACS by ACS-Community.

the class EventListPart method postConstruct.

/**
	 */
@PostConstruct
public void postConstruct(Composite parent, final IEclipseContext context, IEventBroker eventBroker, EMenuService menuService) {
    try {
        em = EventModel.getInstance();
    } catch (Throwable thr) {
        thr.printStackTrace();
        IStatus someStatus = statusReporter.newStatus(IStatus.ERROR, "Connection with NCs failed.", thr);
        statusReporter.report(someStatus, StatusReporter.SHOW);
        throw new RuntimeException(thr);
    }
    logger = em.getLogger();
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.verticalSpacing = 0;
    parent.setLayout(gridLayout);
    // TODO: We currently have the filter text control in the regular view toolbar.
    //       The e3 eventGUI had a "custom tool bar" inserted here.
    //       We should decide which way it's better.
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    /*
		 * "Time "+timeStamp+" "+m_channelName+" "+component+" "+count+"
		 * "+channelEventCount+" " +" "+evtTypeName+"
		 * "+evtCounter.get(evtTypeName)
		 */
    TableViewerColumn tvcol = new TableViewerColumn(viewer, SWT.NONE, 0);
    tvcol.setLabelProvider(new TimeStampLabelProvider());
    TableColumn col = tvcol.getColumn();
    col.setText("Timestamp");
    col.setWidth(180);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 1);
    tvcol.setLabelProvider(new EventSourceLabelProvider());
    col = tvcol.getColumn();
    col.setText("Event source");
    col.setWidth(150);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 2);
    tvcol.setLabelProvider(new CountLabelProvider());
    col = tvcol.getColumn();
    col.setText("# Events in channel");
    col.setWidth(50);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 3);
    tvcol.setLabelProvider(new EventTypeLabelProvider());
    col = tvcol.getColumn();
    col.setText("Event type");
    col.setWidth(150);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 4);
    tvcol.setLabelProvider(new EventTypeCountLabelProvider());
    col = tvcol.getColumn();
    col.setText("# Events this type");
    col.setWidth(50);
    col.setAlignment(SWT.LEFT);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getTable());
    viewer.setContentProvider(new EventListViewContentProvider(em));
    // Attach a selection listener to our event list that will post the selected event for the event details list
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() == 1) {
                selectionService.setSelection(selection.getFirstElement());
            }
        }
    });
    viewer.setInput(new Object());
    hookContextMenu(menuService);
    pel = new PopulateEventList(logger, viewer, new StatusLineWriter(eventBroker), em.getEventQueue(), "NC Events");
    eventListThread = pel.getThreadForEventList();
    eventListThread.start();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Table(org.eclipse.swt.widgets.Table) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) StatusLineWriter(alma.acs.eventbrowser.status.StatusLineWriter) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) PostConstruct(javax.annotation.PostConstruct)

Example 3 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project translationstudio8 by heartsome.

the class ReverseConversionWizardPage method createFilesGroup.

/**
	 * 创建文件列表区域
	 * @param contents
	 *            ;
	 */
private Composite createFilesGroup(Composite contents) {
    Composite filesComposite = new Composite(contents, SWT.NONE);
    filesComposite.setLayout(new GridLayout(1, false));
    filesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    tableData.heightHint = 100;
    filesTable.setLayoutData(tableData);
    filesTable.setLinesVisible(true);
    filesTable.setHeaderVisible(true);
    filesTable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            TableItem[] selected = filesTable.getSelection();
            if (selected.length == 0) {
                return;
            }
            //$NON-NLS-1$
            String strTgtEnc = "";
            for (int i = 0; i < selected.length; i++) {
                String curTgtEnc = selected[i].getText(2);
                if (i == 0) {
                    strTgtEnc = curTgtEnc;
                } else {
                    if (!strTgtEnc.equals(curTgtEnc)) {
                        //$NON-NLS-1$
                        strTgtEnc = "";
                        break;
                    }
                }
            }
            if (!"".equals(strTgtEnc)) {
                //$NON-NLS-1$
                tgtEncCombo.setText(strTgtEnc);
            } else {
                tgtEncCombo.deselectAll();
            }
        }
    });
    tableViewer = new TableViewer(filesTable);
    lineNumberColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    lineNumberColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.lineNumberColumn"));
    xliffColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    //$NON-NLS-1$
    xliffColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.xliffColumn"));
    tgtEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    //$NON-NLS-1$
    tgtEncColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.tgtEncColumn"));
    targetColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    //$NON-NLS-1$
    targetColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.targetColumn"));
    IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] { "index", "source", "targetEncoding", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "target" });
    ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class), valueProperties);
    filesComposite.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent arg0) {
            int width = filesTable.getClientArea().width;
            lineNumberColumn.setWidth(width * 1 / 10);
            targetColumn.setWidth(width * 4 / 10);
            tgtEncColumn.setWidth(width * 1 / 10);
            xliffColumn.setWidth(width * 4 / 10);
        }
    });
    return filesComposite;
}
Also used : Table(org.eclipse.swt.widgets.Table) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) WritableList(org.eclipse.core.databinding.observable.list.WritableList) ConversionConfigBean(net.heartsome.cat.convert.ui.model.ConversionConfigBean) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IValueProperty(org.eclipse.core.databinding.property.value.IValueProperty) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 4 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project ACS by ACS-Community.

the class TableViewBase method createPartControl.

@Override
public void createPartControl(Composite parent) {
    tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    Table table = tableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    // Set the column
    for (int t = 0; t < colNames.length; t++) {
        int style = t == 0 ? SWT.LEFT : SWT.CENTER;
        final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, style);
        final TableColumn column = viewerColumn.getColumn();
        column.setText(colNames[t]);
        final int index = t;
        // Setting the right sorter
        column.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                sorter.setColumn(index);
                int dir = tableViewer.getTable().getSortDirection();
                if (tableViewer.getTable().getSortColumn() == column) {
                    dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
                } else {
                    dir = SWT.DOWN;
                }
                tableViewer.getTable().setSortDirection(dir);
                tableViewer.getTable().setSortColumn(column);
                tableViewer.refresh();
            }
        });
        column.pack();
        column.setWidth(colWidths[t]);
    }
    tableViewer.setContentProvider(new ViewContentProvider());
}
Also used : Table(org.eclipse.swt.widgets.Table) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 5 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project cubrid-manager by CUBRID.

the class TableSchemaCompareInfoPart method createCommonColumnsOnTable.

public void createCommonColumnsOnTable(Composite parent) {
    final Composite tableComposite = new Composite(parent, SWT.NONE);
    tableComposite.setLayout(new FillLayout());
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    tablesSchemaCompareTable = new TableViewer(tableComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    tablesSchemaCompareTable.getTable().setHeaderVisible(true);
    tablesSchemaCompareTable.getTable().setLinesVisible(true);
    final TableViewerColumn statusColumn = new TableViewerColumn(tablesSchemaCompareTable, SWT.NONE);
    statusColumn.getColumn().setWidth(20);
    statusColumn.getColumn().setToolTipText(Messages.compareStatusTip);
    statusColumn.getColumn().setResizable(false);
    tablesSchemaCompareTable.setSorter(TableSchemaCompareTableViewerSorter.STATUS_DESC);
    statusColumn.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        public void widgetSelected(SelectionEvent e) {
            tablesSchemaCompareTable.setSorter(asc ? TableSchemaCompareTableViewerSorter.STATUS_ASC : TableSchemaCompareTableViewerSorter.STATUS_DESC);
            tablesSchemaCompareTable.getTable().setSortColumn(statusColumn.getColumn());
            tablesSchemaCompareTable.getTable().setSortDirection(asc ? SWT.UP : SWT.DOWN);
            asc = !asc;
        }
    });
    final TableViewerColumn sourceDBColumn = new TableViewerColumn(tablesSchemaCompareTable, SWT.LEFT);
    sourceDBColumn.getColumn().setWidth(300);
    sourceDBColumn.getColumn().setText("  " + sourceDB.getDatabaseInfo().getBrokerIP() + "@" + sourceDB.getName() + " [" + Messages.sourceDatabase + "]");
    sourceDBColumn.getColumn().setToolTipText(Messages.sourceDatabaseTip);
    sourceDBColumn.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        public void widgetSelected(SelectionEvent e) {
            tablesSchemaCompareTable.setSorter(asc ? TableSchemaCompareTableViewerSorter.SOURCE_DB_ASC : TableSchemaCompareTableViewerSorter.SOURCE_DB_DESC);
            tablesSchemaCompareTable.getTable().setSortColumn(sourceDBColumn.getColumn());
            tablesSchemaCompareTable.getTable().setSortDirection(asc ? SWT.UP : SWT.DOWN);
            asc = !asc;
        }
    });
    final TableViewerColumn targetDBColoum = new TableViewerColumn(tablesSchemaCompareTable, SWT.LEFT);
    targetDBColoum.getColumn().setWidth(300);
    if (targetDB.isVirtual()) {
        String targetDbName = Messages.erwinVirtualTable;
        if (StringUtil.isNotEmpty(targetDB.getName())) {
            targetDbName += " : " + targetDB.getName();
        }
        targetDBColoum.getColumn().setText(targetDbName);
    } else {
        targetDBColoum.getColumn().setText("  " + targetDB.getDatabaseInfo().getBrokerIP() + "@" + targetDB.getName() + " [" + Messages.targetDatabase + "]");
    }
    targetDBColoum.getColumn().setToolTipText(Messages.targetDatabaseTip);
    targetDBColoum.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        public void widgetSelected(SelectionEvent e) {
            tablesSchemaCompareTable.setSorter(asc ? TableSchemaCompareTableViewerSorter.TARGET_DB_ASC : TableSchemaCompareTableViewerSorter.TARGET_DB_DESC);
            tablesSchemaCompareTable.getTable().setSortColumn(targetDBColoum.getColumn());
            tablesSchemaCompareTable.getTable().setSortDirection(asc ? SWT.UP : SWT.DOWN);
            asc = !asc;
        }
    });
    tablesSchemaCompareTable.setContentProvider(new TableSchemaCompareTableViewerContentProvider());
    tablesSchemaCompareTable.setLabelProvider(new TableSchemaCompareDetailTableViewerLabelProvider());
    tablesSchemaCompareTable.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            TableSchemaCompareModel compSchemaModel = (TableSchemaCompareModel) selection.getFirstElement();
            compSchemaModel.setSourceDB(sourceDB);
            compSchemaModel.setTargetDB(targetDB);
            TableSchema leftTableSchema = (TableSchema) compSchemaModel.getLeft();
            TableSchema rightTableSchema = (TableSchema) compSchemaModel.getRight();
            String tabItemText = leftTableSchema.getName();
            if (StringUtil.isEmpty(leftTableSchema.getName()) || StringUtil.isEmpty(tabItemText)) {
                tabItemText = rightTableSchema.getName();
            }
            //if had opend,set it selection and refresh the contents
            for (CTabItem tabItem : tabFolder.getItems()) {
                if (tabItem.getText().equals(tabItemText)) {
                    tableComp.setInput(compSchemaModel);
                    tableComp.refreshMergeViewer(tabItemText);
                    tabFolder.setSelection(tabItem);
                    return;
                }
            }
            tableComp.setInput(compSchemaModel);
            tableComp.initialize();
        }
    });
    registerContextMenu();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TableSchema(com.cubrid.common.ui.compare.schema.model.TableSchema) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CTabItem(org.eclipse.swt.custom.CTabItem) TableSchemaCompareModel(com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)241 TableViewer (org.eclipse.jface.viewers.TableViewer)125 Composite (org.eclipse.swt.widgets.Composite)99 GridData (org.eclipse.swt.layout.GridData)85 TableColumn (org.eclipse.swt.widgets.TableColumn)73 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)71 SelectionEvent (org.eclipse.swt.events.SelectionEvent)64 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)58 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)55 Table (org.eclipse.swt.widgets.Table)55 GridLayout (org.eclipse.swt.layout.GridLayout)51 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)49 Image (org.eclipse.swt.graphics.Image)37 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)36 Label (org.eclipse.swt.widgets.Label)30 Button (org.eclipse.swt.widgets.Button)29 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)27 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)27 Point (org.eclipse.swt.graphics.Point)26 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)25