Search in sources :

Example 41 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project tdi-studio-se by Talend.

the class AddArrayIndexForParentsDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite createDialogArea = (Composite) super.createDialogArea(parent);
    FillLayout layout = new FillLayout();
    // layout.horizontalSpacing = 1;
    // layout.numColumns = 1;
    GridData data = new GridData(GridData.FILL_BOTH);
    createDialogArea.setLayout(layout);
    createDialogArea.setLayoutData(data);
    table = new TableViewer(createDialogArea, SWT.FULL_SELECTION | SWT.BORDER);
    new TableColumn(table.getTable(), SWT.LEFT).setText(COLUMN_NAME[0]);
    table.getTable().getColumn(0).pack();
    new TableColumn(table.getTable(), SWT.LEFT).setText(COLUMN_NAME[1]);
    table.getTable().getColumn(1).pack();
    table.getTable().setHeaderVisible(true);
    table.getTable().setLinesVisible(true);
    table.setContentProvider(new IndexContentProvider());
    table.setLabelProvider(new IndexLabelProvider());
    table.setInput(arrayIndexList);
    table.setColumnProperties(COLUMN_NAME);
    CellEditor[] editors = new CellEditor[2];
    editors[0] = null;
    editors[1] = new TextCellEditor(table.getTable());
    table.setCellEditors(editors);
    table.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            if (property.equals(COLUMN_NAME[0]))
                return false;
            return true;
        }

        public Object getValue(Object element, String property) {
            ArrayIndexList index = (ArrayIndexList) element;
            if (property.equals(COLUMN_NAME[1])) {
                if (index.getIndexNum() != null) {
                    return index.getIndexNum();
                } else {
                    return "";
                }
            }
            return null;
        }

        public void modify(Object element, String property, Object value) {
            if (element instanceof Item)
                element = ((Item) element).getData();
            ArrayIndexList index = (ArrayIndexList) element;
            if (property.equals(COLUMN_NAME[1]))
                index.setIndexNum((String) value);
            table.refresh();
        }
    });
    return createDialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) Item(org.eclipse.swt.widgets.Item) GridData(org.eclipse.swt.layout.GridData) ICellModifier(org.eclipse.jface.viewers.ICellModifier) ArrayIndexList(org.talend.designer.webservice.data.ArrayIndexList) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 42 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project tdi-studio-se by Talend.

the class VersionManagementPage method createItemTableColumns.

@Override
protected void createItemTableColumns() {
    TableColumn itemColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    itemColumn.setText(Messages.getString("VersionManagementDialog.Items"));
    itemColumn.setWidth(110);
    TableColumn oldVersionColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    oldVersionColumn.setText(Messages.getString("VersionManagementDialog.Version"));
    oldVersionColumn.setWidth(60);
    TableColumn versionColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    versionColumn.setText(Messages.getString("VersionManagementDialog.NewVersion"));
    versionColumn.setWidth(82);
    final TableColumn delColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    delColumn.setText("");
    delColumn.setWidth(26);
    delColumn.setResizable(false);
    versionColumn.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            if (!isFixedVersion()) {
                refreshTableItems();
            }
        }
    });
    itemTable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            checkButtonsState();
        }
    });
}
Also used : ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 43 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project tdi-studio-se by Talend.

the class StatusConfirmSettingDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    TableViewer viewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.minimumHeight = 200;
    data.heightHint = 200;
    data.minimumWidth = 350;
    data.widthHint = 350;
    viewer.getControl().setLayoutData(data);
    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn column = new TableColumn(table, SWT.NONE);
    //$NON-NLS-1$
    column.setText(Messages.getString("VersionManagementDialog.Items"));
    column.setWidth(140);
    column = new TableColumn(table, SWT.NONE);
    //$NON-NLS-1$
    column.setText(Messages.getString("StatusManagementDialog.Status"));
    column.setWidth(120);
    column = new TableColumn(table, SWT.NONE);
    //$NON-NLS-1$
    column.setText(Messages.getString("StatusManagementDialog.NewStatus"));
    column.setWidth(90);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new ITableLabelProvider() {

        public Image getColumnImage(Object element, int columnIndex) {
            RepositoryObject object = (RepositoryObject) element;
            if (columnIndex == 0) {
                ERepositoryObjectType itemType = object.getRepositoryObjectType();
                return getItemsImage(CoreImageProvider.getIcon(itemType));
            }
            return null;
        }

        public String getColumnText(Object element, int columnIndex) {
            RepositoryObject object = (RepositoryObject) element;
            switch(columnIndex) {
                case 0:
                    return object.getLabel();
                case 1:
                    return statusHelper.getStatusLabel(object.getProperty().getOldStatusCode());
                case 2:
                    if (object.getStatusCode().equals(object.getProperty().getOldStatusCode())) {
                        //$NON-NLS-1$
                        return "-";
                    }
                    return statusHelper.getStatusLabel(object.getStatusCode());
                default:
            }
            return null;
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    viewer.setInput(modifiedVersionItems);
    for (TableItem item : table.getItems()) {
        RepositoryObject object = (RepositoryObject) item.getData();
        // if (!object.getOldVersion().equals(object.getNewVersion())) {
        item.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_RED));
    // }
    }
    return composite;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) RepositoryObject(org.talend.core.model.repository.RepositoryObject) TableItem(org.eclipse.swt.widgets.TableItem) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) TableColumn(org.eclipse.swt.widgets.TableColumn) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 44 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project tdi-studio-se by Talend.

the class BusinessAssignmentComposite method createControls.

public void createControls(Composite parent) {
    composite = widgetFactory.createFlatFormComposite(parent);
    adapterFactory = new BusinessItemProviderAdapterFactory();
    tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
    tableViewer.setLabelProvider(new RepositoryFactoryProxyLabelProvider(adapterFactory));
    Table table = tableViewer.getTable();
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final String[] columnProperties = new String[] { Messages.getString("AssignmentPropertySection.Type"), Messages.getString("AssignmentPropertySection.Name"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Messages.getString("AssignmentPropertySection.Comment") };
    TableColumn column1 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column1.setText(columnProperties[0]);
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column2.setText(columnProperties[1]);
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
    column3.setText(columnProperties[2]);
    tableViewer.setColumnProperties(columnProperties);
    final IItemPropertyDescriptor itemPropertyDescriptor = getItemPropertyDescriptor();
    tableViewer.setCellModifier(new ICellModifier() {

        @Override
        public boolean canModify(Object element, String property) {
            return property.equals(columnProperties[2]);
        }

        @Override
        public Object getValue(Object element, String property) {
            return EmfPropertyHelper.getValue(itemPropertyDescriptor, element);
        }

        @Override
        public void modify(Object element, String property, Object value) {
            if (element instanceof TableItem) {
                TableItem tableItem = (TableItem) element;
                itemPropertyDescriptor.setPropertyValue(tableItem.getData(), value);
            }
        }
    });
    CellEditor[] cellEditors = new CellEditor[3];
    cellEditors[2] = new TextCellEditor(table);
    tableViewer.setCellEditors(cellEditors);
    // createKeyListener(table);
    createSelectionListener();
    createPopupMenu();
    createDoubleClickListener();
    handleLayout(parent, table, column1, column2, column3);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.eclipse.swt.widgets.Table) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) RepositoryFactoryProxyLabelProvider(org.talend.designer.business.diagram.custom.properties.RepositoryFactoryProxyLabelProvider) TableItem(org.eclipse.swt.widgets.TableItem) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) BusinessItemProviderAdapterFactory(org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory) ICellModifier(org.eclipse.jface.viewers.ICellModifier) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IItemPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 45 with TableColumn

use of org.eclipse.swt.widgets.TableColumn 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)

Aggregations

TableColumn (org.eclipse.swt.widgets.TableColumn)305 Table (org.eclipse.swt.widgets.Table)151 GridData (org.eclipse.swt.layout.GridData)105 TableViewer (org.eclipse.jface.viewers.TableViewer)94 Composite (org.eclipse.swt.widgets.Composite)92 SelectionEvent (org.eclipse.swt.events.SelectionEvent)87 GridLayout (org.eclipse.swt.layout.GridLayout)76 TableItem (org.eclipse.swt.widgets.TableItem)76 Point (org.eclipse.swt.graphics.Point)57 Label (org.eclipse.swt.widgets.Label)55 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)52 Button (org.eclipse.swt.widgets.Button)48 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)41 FillLayout (org.eclipse.swt.layout.FillLayout)37 Listener (org.eclipse.swt.widgets.Listener)37 Event (org.eclipse.swt.widgets.Event)35 Shell (org.eclipse.swt.widgets.Shell)35 Test (org.junit.Test)33 SelectionListener (org.eclipse.swt.events.SelectionListener)32 Text (org.eclipse.swt.widgets.Text)30