Java Code Examples for org.eclipse.swt.widgets.TableColumn#setAlignment()

The following examples show how to use org.eclipse.swt.widgets.TableColumn#setAlignment() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SellOrderTableViewer.java    From offspring with MIT License 6 votes vote down vote up
private void createColumns() {
  for (int id : SellOrderTable.getColumns()) {
    TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE);
    TableColumn column = viewerColumn.getColumn();

    viewerColumn.setEditingSupport(new SellOrderEditingSupport(this, id));

    viewerColumn.setLabelProvider(SellOrderTable.createLabelProvider(id));
    column.addSelectionListener(getSelectionAdapter(column, id));

    column.setText(SellOrderTable.getColumnLabel(id));
    column.setAlignment(SellOrderTable.getColumnAlignment(id));

    column.setResizable(SellOrderTable.getColumnResizable(id));
    column.setWidth(SellOrderTable.getColumnWidth(id));
  }
}
 
Example 2
Source File: BuyOrderTableViewer.java    From offspring with MIT License 6 votes vote down vote up
private void createColumns() {
  for (int id : BuyOrderTable.getColumns()) {
    TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE);
    TableColumn column = viewerColumn.getColumn();

    viewerColumn.setEditingSupport(new BuyOrderEditingSupport(this, id));

    viewerColumn.setLabelProvider(BuyOrderTable.createLabelProvider(id));
    column.addSelectionListener(getSelectionAdapter(column, id));

    column.setText(BuyOrderTable.getColumnLabel(id));
    column.setAlignment(BuyOrderTable.getColumnAlignment(id));

    column.setResizable(BuyOrderTable.getColumnResizable(id));
    column.setWidth(BuyOrderTable.getColumnWidth(id));
  }
}
 
Example 3
Source File: PeerTableViewer.java    From offspring with MIT License 6 votes vote down vote up
private void createColumns() {
  for (int id : PeerTable.getColumns(peerType)) {
    TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE);
    TableColumn column = viewerColumn.getColumn();

    viewerColumn
        .setLabelProvider(PeerTable.createLabelProvider(id, peerType));
    column.addSelectionListener(getSelectionAdapter(column, id));

    column.setText(PeerTable.getColumnLabel(id));
    column.setAlignment(PeerTable.getColumnAlignment(id));

    column.setResizable(PeerTable.getColumnResizable(id));
    column.setWidth(PeerTable.getColumnWidth(id));
  }
}
 
Example 4
Source File: QueryDataView.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void setDataSize ( final int entries, final Set<String> valueTypes )
{
    clearDataSize ();

    this.colNames = valueTypes.toArray ( new String[0] );
    for ( final String valueType : valueTypes )
    {
        final TableColumn col = new TableColumn ( this.table, SWT.NONE );
        col.setText ( valueType );
        col.setWidth ( 100 );
        col.setAlignment ( SWT.RIGHT );
        this.columns.put ( valueType, col );
    }

    this.countCol = new TableColumn ( this.table, SWT.NONE );
    this.countCol.setText ( Messages.QueryDataView_ColValues );
    this.countCol.setWidth ( 40 );

    this.infoCol = new TableColumn ( this.table, SWT.NONE );
    this.infoCol.setText ( Messages.QueryDataView_ColInfo );
    this.infoCol.setWidth ( 150 );

    this.table.clearAll ();
    this.table.setItemCount ( entries );

    for ( int i = 0; i < entries; i++ )
    {
        final TableItem item = this.table.getItem ( i );
        item.setBackground ( this.invalidColor );
        item.setText ( 0, String.format ( Messages.QueryDataView_Format_Index, i ) );
    }
}
 
Example 5
Source File: CompositeFactory.java    From erflute with Apache License 2.0 5 votes vote down vote up
public static TableColumn createTableColumn(Table table, String text, int width, int style) {
    final TableColumn tableColumn = new TableColumn(table, style);
    tableColumn.setText(DisplayMessages.getMessage(text));
    tableColumn.setWidth(width);
    tableColumn.setAlignment(style);

    return tableColumn;
}
 
Example 6
Source File: BlockTableViewer.java    From offspring with MIT License 5 votes vote down vote up
private void createColumns() {
  for (int id : BlockTable.getColumns()) {
    TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE);
    TableColumn column = viewerColumn.getColumn();

    viewerColumn.setLabelProvider(BlockTable.createLabelProvider(id));

    column.setText(BlockTable.getColumnLabel(id));
    column.setAlignment(BlockTable.getColumnAlignment(id));

    column.setResizable(BlockTable.getColumnResizable(id));
    column.setWidth(BlockTable.getColumnWidth(id));
  }
}
 
Example 7
Source File: CompositeFactory.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public static TableColumn createTableColumn(Table table, String text,
		int width, int style) {
	TableColumn tableColumn = new TableColumn(table, style);
	tableColumn.setText(ResourceString.getResourceString(text));
	tableColumn.setWidth(width);
	tableColumn.setAlignment(style);

	return tableColumn;
}
 
Example 8
Source File: CheckConfigurationConfigureDialog.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
private Control createTableViewer(Composite parent) {

    mConfiguredModulesGroup = new Group(parent, SWT.NULL);
    mConfiguredModulesGroup.setLayout(new GridLayout());
    mConfiguredModulesGroup.setText("\0"); //$NON-NLS-1$

    Table table = new Table(mConfiguredModulesGroup,
            SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);

    TableColumn column1 = new TableColumn(table, SWT.NULL);
    column1.setAlignment(SWT.CENTER);
    column1.setText(Messages.CheckConfigurationConfigureDialog_colEnabled);
    tableLayout.addColumnData(new ColumnWeightData(15));

    TableColumn column2 = new TableColumn(table, SWT.NULL);
    column2.setText(Messages.CheckConfigurationConfigureDialog_colModule);
    tableLayout.addColumnData(new ColumnWeightData(30));

    TableColumn column3 = new TableColumn(table, SWT.NULL);
    column3.setText(Messages.CheckConfigurationConfigureDialog_colSeverity);
    tableLayout.addColumnData(new ColumnWeightData(20));

    TableColumn column4 = new TableColumn(table, SWT.NULL);
    column4.setText(Messages.CheckConfigurationConfigureDialog_colComment);
    tableLayout.addColumnData(new ColumnWeightData(35));

    mTableViewer = new EnhancedCheckBoxTableViewer(table);
    ModuleLabelProvider multiProvider = new ModuleLabelProvider();
    mTableViewer.setLabelProvider(multiProvider);
    mTableViewer.setTableComparableProvider(multiProvider);
    mTableViewer.setTableSettingsProvider(multiProvider);
    mTableViewer.setContentProvider(new ArrayContentProvider());
    mTableViewer.addFilter(mGroupFilter);
    mTableViewer.installEnhancements();

    mTableViewer.addDoubleClickListener(mController);
    mTableViewer.addSelectionChangedListener(mController);
    mTableViewer.addCheckStateListener(mController);
    mTableViewer.getTable().addKeyListener(mController);

    Composite buttons = new Composite(mConfiguredModulesGroup, SWT.NULL);
    GridLayout layout = new GridLayout(2, true);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttons.setLayout(layout);
    buttons.setLayoutData(new GridData());

    mRemoveButton = new Button(buttons, SWT.PUSH);
    mRemoveButton.setText((Messages.CheckConfigurationConfigureDialog_btnRemove));
    mRemoveButton.setLayoutData(new GridData());
    mRemoveButton.addSelectionListener(mController);

    mEditButton = new Button(buttons, SWT.PUSH);
    mEditButton.setText((Messages.CheckConfigurationConfigureDialog_btnOpen));
    mEditButton.setLayoutData(new GridData());
    mEditButton.addSelectionListener(mController);

    return mConfiguredModulesGroup;
  }
 
Example 9
Source File: GenerericTableViewer.java    From offspring with MIT License 4 votes vote down vote up
private void createColumns() {
  GC gc = new GC(getTable().getParent());

  List<Integer> widths = new ArrayList<Integer>();

  for (final IGenericTableColumn c : table.getColumns()) {
    TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE);

    viewerColumn.setLabelProvider(new GenericLabelProvider(c
        .getDataProvider()));

    if (c.getEditable()) {
      viewerColumn.setEditingSupport(c.getEditingSupport(this));
    }

    TableColumn column = viewerColumn.getColumn();

    if (c.getSortable() && comparator != null) {
      column.addSelectionListener(getSelectionAdapter(column, c));
    }
    column.setText(c.getLabel());
    column.setAlignment(c.getAlignMent());

    int width;
    if (c.getWidth() != -1) {
      width = c.getWidth();
    }
    else if (c.getTextExtent() != null
        && c.getLabel().length() < c.getTextExtent().length()) {
      width = gc.textExtent(c.getTextExtent()).x + 2;
    }
    else {
      width = gc.textExtent(c.getLabel()).x + 2;
    }

    widths.add(width);
    column.setWidth(width);
    column.setResizable(c.getResizable());
  }
  gc.dispose();

  /* All columns have their prefered width set now calculate percentages */
  TableColumnLayout layout = new TableColumnLayout();
  for (int i = 0; i < widths.size(); i++) {
    layout.setColumnData(getTable().getColumns()[i], new ColumnWeightData(
        widths.get(i), widths.get(i), true));
  }
  getTable().getParent().setLayout(layout);
}