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

The following examples show how to use org.eclipse.swt.widgets.TableColumn#setResizable() . 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: IndexTabWrapper.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private void initTable(Composite parent) {
	GridData gridData = new GridData();
	gridData.horizontalSpan = 3;
	gridData.grabExcessHorizontalSpace = true;
	gridData.horizontalAlignment = GridData.FILL;
	gridData.heightHint = 200;

	this.indexTable = new Table(parent, SWT.BORDER | SWT.HIDE_SELECTION);

	this.indexTable.setHeaderVisible(true);
	this.indexTable.setLayoutData(gridData);
	this.indexTable.setLinesVisible(true);

	CompositeFactory.createTableColumn(this.indexTable,
			"label.column.name", ERTableComposite.NAME_WIDTH, SWT.NONE);
	TableColumn separatorColumn = CompositeFactory.createTableColumn(
			this.indexTable, "", 3, SWT.NONE);
	separatorColumn.setResizable(false);
}
 
Example 2
Source File: TmfSimpleTableViewer.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create a column for the table. The column will have a default width set,
 * and will be resizable, moveable and sortable.
 *
 * @param name
 *            the name of the column
 * @param provider
 *            the label provider of the column
 * @param comparator
 *            the comparator associated with clicking on the column, if it
 *            is null, a string comparator on the label will be used
 * @return the column that was created
 * @since 2.0
 */
public final <T> TableColumn createColumn(String name, ColumnLabelProvider provider, @Nullable Comparator<T> comparator) {
    TableViewerColumn col = new TableViewerColumn(fTableViewer, SWT.NONE);
    col.setLabelProvider(provider);
    final TableColumn column = col.getColumn();
    column.setWidth(DEFAULT_COL_WIDTH);
    column.setText(name);
    column.setResizable(true);
    column.setMoveable(true);
    if (comparator == null) {
        column.addSelectionListener(new ColumnSorter<>(column, new ColumnLabelComparator(provider)));
    } else {
        column.addSelectionListener(new ColumnSorter<>(column, comparator));
    }
    return column;
}
 
Example 3
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createBusinessCardTable(final Composite tables) {
    final Composite businessCardTableComposite = new Composite(tables, SWT.NONE);
    businessCardTableComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create());
    businessCardTableComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final Table businessCardTable = new Table(businessCardTableComposite, SWT.BORDER);
    businessCardTable.setLinesVisible(true);
    businessCardTable.setHeaderVisible(true);

    final String[] businessCardTitles = getBusinessCardItems();
    final TableColumn businessCardColumn = new TableColumn(businessCardTable, SWT.NONE);
    businessCardColumn.setText(Messages.defaultInformationGroupBusinessCardTableTitle);
    businessCardColumn.setResizable(false);

    for (int i = 0; i < businessCardTitles.length; i++) {
        final TableItem item = new TableItem(businessCardTable, SWT.NONE);
        item.setText(businessCardTitles[i]);
    }
    addTableColumLayout(businessCardTable);
}
 
Example 4
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createGeneralDataTable(final Composite tables) {
    final Composite generalDataTableComposite = new Composite(tables, SWT.NONE);
    generalDataTableComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create());
    generalDataTableComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final Table generalDataTable = new Table(generalDataTableComposite, SWT.BORDER);
    generalDataTable.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    generalDataTable.setLinesVisible(true);
    generalDataTable.setHeaderVisible(true);

    final String[] generalDataItems = getGeneralDataItems();
    final TableColumn generalData = new TableColumn(generalDataTable, SWT.NONE);
    generalData.setText(Messages.defaultInformationGroupGeneralDataTableTitle);
    generalData.setResizable(false);

    for (int i = 0; i < generalDataItems.length; i++) {
        final TableItem item = new TableItem(generalDataTable, SWT.NONE | SWT.FILL);
        item.setText(generalDataItems[i]);
    }

    addTableColumLayout(generalDataTable);
}
 
Example 5
Source File: TableCombo.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Defines what columns the drop down table will have.  
 * 
 * @param columnHeaders
 * @param columnBounds
 */
private void defineColumnsInternal(String[] columnHeaders, int[] columnBounds, int totalColumnsToBeCreated) {

    checkWidget();

    int totalColumnHeaders = columnHeaders == null ? 0 : columnHeaders.length;
    int totalColBounds = columnBounds == null ? 0 : columnBounds.length;

    if (totalColumnsToBeCreated > 0) {

        for (int index = 0; index < totalColumnsToBeCreated; index++) {
            TableColumn column = new TableColumn(table, SWT.NONE);

            if (index < totalColumnHeaders) {
                column.setText(columnHeaders[index]);
            }

            if (index < totalColBounds) {
                column.setWidth(columnBounds[index]);
            }

            column.setResizable(true);
            column.setMoveable(true);
        }
    }
}
 
Example 6
Source File: ViewStatisticsClassificationAttributes.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new column
 * @param table
 * @param name
 * @param width
 * @param provider
 */
private TableViewerColumn createColumn(PageableTable table,
                                       String name, 
                                       int width,
                                       ColumnLabelProvider provider) {
    
    TableViewerColumn column = new TableViewerColumn(table.getViewer(), SWT.NONE);
    column.setLabelProvider(provider);
    TableColumn tColumn = column.getColumn();
    tColumn.setToolTipText(name);
    tColumn.setText(name);
    tColumn.setWidth(width);
    tColumn.setResizable(true);
    return column;
}
 
Example 7
Source File: InvoiceCorrectionView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private TableViewerColumn createTableViewerColumn(String title, int bound, int colIdx){
	final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	TableColumn column = viewerColumn.getColumn();
	column.setText(title);
	tableColumnLayout.setColumnData(column,
		new ColumnWeightData(bound, ColumnWeightData.MINIMUM_WIDTH, true));
	column.setResizable(true);
	column.setMoveable(false);
	viewerColumn.setLabelProvider(new DefaultColumnLabelProvider(colIdx));
	return viewerColumn;
}
 
Example 8
Source File: StringSortPageableTableExample.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private static TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound) {
	final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
	final TableColumn column = viewerColumn.getColumn();
	column.setText(title);
	column.setWidth(bound);
	column.setResizable(true);
	column.setMoveable(true);
	return viewerColumn;
}
 
Example 9
Source File: OneRendererPaginationTableAtHandExample.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private static TableViewerColumn createTableViewerColumn(
		TableViewer viewer, String title, int bound) {
	final TableViewerColumn viewerColumn = new TableViewerColumn(viewer,
			SWT.NONE);
	final TableColumn column = viewerColumn.getColumn();
	column.setText(title);
	column.setWidth(bound);
	column.setResizable(true);
	column.setMoveable(true);
	return viewerColumn;
}
 
Example 10
Source File: ServiceDiagnosePrefs.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void createColumn(final Composite parent, final TableViewer viewer){
	TableViewerColumn tvCol = new TableViewerColumn(viewer, SWT.NONE);
	tvCol.setLabelProvider(new ColumnLabelProvider());
	TableColumn column = tvCol.getColumn();
	column.setText("");
	column.setWidth(150);
	column.setResizable(false);
	column.setMoveable(false);
}
 
Example 11
Source File: ModelSortPageableTableWorkInProcessExample.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private static TableViewerColumn createTableViewerColumn(
		TableViewer viewer, String title, int bound) {
	final TableViewerColumn viewerColumn = new TableViewerColumn(viewer,
			SWT.NONE);
	final TableColumn column = viewerColumn.getColumn();
	column.setText(title);
	column.setWidth(bound);
	column.setResizable(true);
	column.setMoveable(true);
	return viewerColumn;
}
 
Example 12
Source File: CategoryManageDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private void createNodeGroup(final Composite composite) {
    final Group group = new Group(composite, SWT.NONE);
    group.setLayout(new GridLayout());
    group.setText(ResourceString.getResourceString("label.category.object.message"));

    final GridData gridData = new GridData();
    gridData.heightHint = GROUP_HEIGHT;
    group.setLayoutData(gridData);

    CompositeFactory.fillLine(group, 5);

    final GridData tableGridData = new GridData();
    tableGridData.grabExcessVerticalSpace = true;
    tableGridData.verticalAlignment = GridData.FILL;

    nodeTable = new Table(group, SWT.BORDER | SWT.HIDE_SELECTION);
    nodeTable.setHeaderVisible(true);
    nodeTable.setLayoutData(tableGridData);
    nodeTable.setLinesVisible(true);

    final TableColumn tableColumn2 = new TableColumn(nodeTable, SWT.NONE);
    tableColumn2.setWidth(30);
    tableColumn2.setResizable(false);
    tableColumn2.setText("");
    final TableColumn tableColumn3 = new TableColumn(nodeTable, SWT.NONE);
    tableColumn3.setWidth(80);
    tableColumn3.setResizable(false);
    tableColumn3.setText(ResourceString.getResourceString("label.object.type"));
    final TableColumn tableColumn4 = new TableColumn(nodeTable, SWT.NONE);
    tableColumn4.setWidth(200);
    tableColumn4.setResizable(false);
    tableColumn4.setText(ResourceString.getResourceString("label.object.name"));
}
 
Example 13
Source File: VerrechnungsDisplay.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private TableViewerColumn createTableViewerColumn(String title, int weight, int colNumber,
	int style){
	final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, style);
	final TableColumn column = viewerColumn.getColumn();
	column.setText(title);
	column.setResizable(true);
	column.setMoveable(false);
	tableLayout.setColumnData(column, new ColumnWeightData(weight));
	return viewerColumn;
}
 
Example 14
Source File: AbstractNativeHeader.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Sets if the columns are resizable.
 * 
 * @param resizable true if the columns should be resizable; false otherwise.
 */
public void setResizable(boolean resizable) {
    this.resizable = resizable;
    for (Iterator columnsIter = tableColumns.iterator(); columnsIter.hasNext();) {
        TableColumn column = (TableColumn) columnsIter.next();
        column.setResizable(resizable);
    }
}
 
Example 15
Source File: ApplicationOverviewEditorPart.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public LinkTable(Composite composite, FormToolkit toolkit, String projectColumnLabel) {
	// Create a composite for the table so can use TableColumnLayout
	tableComp = toolkit.createComposite(composite, SWT.NONE);
	TableColumnLayout tableColumnLayout = new TableColumnLayout();
	tableComp.setLayout(tableColumnLayout);
	tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
	
	linkTable = toolkit.createTable(tableComp, SWT.BORDER | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
	GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
	data.heightHint = 100;
	linkTable.setLayoutData(data);
	
	// Columns
	projectColumn = new TableColumn(linkTable, SWT.NONE);
	projectColumn.setText(projectColumnLabel);
	projectColumn.setResizable(true);
	
	envVarColumn = new TableColumn(linkTable, SWT.NONE);
	envVarColumn.setText(Messages.LinkMgmtEnvVarColumn);
	envVarColumn.setResizable(true);
	
	linkTable.setHeaderVisible(true);
	linkTable.setLinesVisible(true);
	
	Arrays.stream(linkTable.getColumns()).forEach(TableColumn::pack);
	tableColumnLayout.setColumnData(projectColumn, new ColumnWeightData(10, Math.max(50, projectColumn.getWidth()), true));
	tableColumnLayout.setColumnData(envVarColumn, new ColumnWeightData(10, Math.max(50, envVarColumn.getWidth()), true));
}
 
Example 16
Source File: MarkerStatsView.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Creates the table viewer for the detail view.
 *
 * @param parent
 *          the parent composite
 * @return the detail table viewer
 */
private EnhancedTableViewer createDetailView(Composite parent) {
  // le tableau
  EnhancedTableViewer detailViewer = new EnhancedTableViewer(parent,
          SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
  GridData gridData = new GridData(GridData.FILL_BOTH);
  detailViewer.getControl().setLayoutData(gridData);

  // setup the table columns
  Table table = detailViewer.getTable();
  table.setLinesVisible(true);
  table.setHeaderVisible(true);

  TableColumn severityCol = new TableColumn(table, SWT.CENTER, 0);
  severityCol.setWidth(20);
  severityCol.setResizable(false);

  TableColumn idCol = new TableColumn(table, SWT.LEFT, 1);
  idCol.setText(Messages.MarkerStatsView_fileColumn);
  idCol.setWidth(150);

  TableColumn folderCol = new TableColumn(table, SWT.LEFT, 2);
  folderCol.setText(Messages.MarkerStatsView_folderColumn);
  folderCol.setWidth(300);

  TableColumn countCol = new TableColumn(table, SWT.CENTER, 3);
  countCol.setText(Messages.MarkerStatsView_lineColumn);
  countCol.pack();

  TableColumn messageCol = new TableColumn(table, SWT.LEFT, 4);
  messageCol.setText(Messages.MarkerStatsView_messageColumn);
  messageCol.setWidth(300);

  // set the providers
  detailViewer.setContentProvider(new DetailContentProvider());
  DetailViewMultiProvider multiProvider = new DetailViewMultiProvider();
  detailViewer.setLabelProvider(multiProvider);
  detailViewer.setTableComparableProvider(multiProvider);
  detailViewer.setTableSettingsProvider(multiProvider);
  detailViewer.installEnhancements();

  // add selection listener to maintain action state
  detailViewer.addSelectionChangedListener(new ISelectionChangedListener() {
    @Override
    public void selectionChanged(SelectionChangedEvent event) {
      updateActions();
    }
  });

  // hooks the action to double click
  hookDoubleClickAction(mShowErrorAction, detailViewer);

  // and to the context menu too
  ArrayList<Object> actionList = new ArrayList<>(1);
  actionList.add(mDrillBackAction);
  actionList.add(mShowErrorAction);
  actionList.add(new Separator());
  actionList.add(mChartAction);
  hookContextMenu(actionList, detailViewer);

  return detailViewer;
}
 
Example 17
Source File: CategoryManageDialog.java    From erflute with Apache License 2.0 4 votes vote down vote up
private void createCategoryGroup(Composite composite) {
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 4;

    final Group group = new Group(composite, SWT.NONE);
    group.setText(DisplayMessages.getMessage("label.category.message"));
    group.setLayout(gridLayout);

    CompositeFactory.filler(group, 4);

    final GridData tableGridData = new GridData();
    tableGridData.heightHint = 200;
    tableGridData.horizontalSpan = 3;
    tableGridData.verticalSpan = 2;

    this.categoryTable = new Table(group, SWT.BORDER | SWT.FULL_SELECTION);
    categoryTable.setHeaderVisible(true);
    categoryTable.setLayoutData(tableGridData);
    categoryTable.setLinesVisible(true);

    final GridData upButtonGridData = new GridData();
    upButtonGridData.grabExcessHorizontalSpace = false;
    upButtonGridData.verticalAlignment = GridData.END;
    upButtonGridData.grabExcessVerticalSpace = true;
    upButtonGridData.widthHint = DesignResources.BUTTON_WIDTH;

    final GridData downButtonGridData = new GridData();
    downButtonGridData.grabExcessVerticalSpace = true;
    downButtonGridData.verticalAlignment = GridData.BEGINNING;
    downButtonGridData.widthHint = DesignResources.BUTTON_WIDTH;

    this.upButton = new Button(group, SWT.NONE);
    upButton.setText(DisplayMessages.getMessage("label.up.arrow"));
    upButton.setLayoutData(upButtonGridData);

    this.downButton = new Button(group, SWT.NONE);
    downButton.setText(DisplayMessages.getMessage("label.down.arrow"));
    downButton.setLayoutData(downButtonGridData);

    final GridData textGridData = new GridData();
    textGridData.widthHint = 150;

    this.categoryNameText = new Text(group, SWT.BORDER);
    categoryNameText.setLayoutData(textGridData);

    final GridData buttonGridData = new GridData();
    buttonGridData.widthHint = DesignResources.BUTTON_WIDTH;

    addCategoryButton = new Button(group, SWT.NONE);
    addCategoryButton.setLayoutData(buttonGridData);
    addCategoryButton.setText(DisplayMessages.getMessage("label.button.add"));

    updateCategoryButton = new Button(group, SWT.NONE);
    updateCategoryButton.setLayoutData(buttonGridData);
    updateCategoryButton.setText(DisplayMessages.getMessage("label.button.update"));

    deleteCategoryButton = new Button(group, SWT.NONE);
    deleteCategoryButton.setLayoutData(buttonGridData);
    deleteCategoryButton.setText(DisplayMessages.getMessage("label.button.delete"));

    final TableColumn tableColumn = new TableColumn(categoryTable, SWT.NONE);
    tableColumn.setWidth(30);
    tableColumn.setResizable(false);
    final TableColumn tableColumn1 = new TableColumn(categoryTable, SWT.NONE);
    tableColumn1.setWidth(230);
    tableColumn1.setResizable(false);
    tableColumn1.setText(DisplayMessages.getMessage("label.category.name"));
}
 
Example 18
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);
}
 
Example 19
Source File: NewProjectTbPage.java    From translationstudio8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 设置TableViewer 列属性
 * @param viewer
 * @param title
 *            列标题
 * @param bound
 *            列宽
 * @param colNumber
 *            列序号
 * @return {@link TableViewerColumn};
 */
private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, final int colNumber) {
	final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE | SWT.Resize);
	final TableColumn column = viewerColumn.getColumn();
	column.setText(title);
	column.setWidth(bound);
	column.setResizable(true);
	column.setMoveable(true);
	return viewerColumn;

}
 
Example 20
Source File: PreTranslationResultDialog.java    From tmxeditor8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 设置TableViewer 列属性
 * @param viewer
 * @param title
 *            列标题
 * @param bound
 *            列宽
 * @param colNumber
 *            列序号
 * @return {@link TableViewerColumn};
 */
private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, final int colNumber) {
	final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE | SWT.Resize);
	final TableColumn column = viewerColumn.getColumn();
	column.setText(title);
	column.setWidth(bound);
	column.setResizable(true);
	column.setMoveable(true);
	return viewerColumn;
}