Java Code Examples for org.eclipse.swt.widgets.TableColumn

The following are top voted examples for showing how to use org.eclipse.swt.widgets.TableColumn. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: n4js   File: TableViewerBuilder.java   Source Code and License 6 votes vote down vote up
@Override
protected TableViewer createViewer(final Composite parent, final AbstractColumnLayout columnLayout, final int style) {
	final TableViewer viewer = new TableViewer(parent, style);
	final Table table = viewer.getTable();
	table.setLinesVisible(linesVisible);
	table.setHeaderVisible(headerVisible);

	int columnIndex = 0;
	for (final String columnLabel : columnLabels) {

		final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, NONE);
		final TableColumn column = viewerColumn.getColumn();
		columnLayout.setColumnData(column, createColumnLayoutData(columnIndex));
		column.setText(columnLabel);
		column.setMoveable(moveable);

		columnIndex++;
	}

	return viewer;
}
 
Example 2
Project: eZooKeeper   File: DataModelFormPage.java   Source Code and License 6 votes vote down vote up
protected Section createTableSection(ScrolledForm form, Composite client, FormToolkit toolkit, String title,
        Image image, int sectionStyle, int tableStyle, String[] columnTitles, int[] columnAlignments) {

    Section section = createSection(form, client, toolkit, title, image, sectionStyle);
    Table table = toolkit.createTable(section, tableStyle);

    for (int i = 0; i < columnTitles.length; i++) {
        TableColumn column = new TableColumn(table, SWT.NONE);
        column.setText(columnTitles[i]);
        column.setAlignment(columnAlignments[i]);
    }

    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    section.setClient(table);

    return section;
}
 
Example 3
Project: eZooKeeper   File: DataModelFormPage.java   Source Code and License 6 votes vote down vote up
protected void packTable(Table table, int[] columnWidths) {
    if (table == null) {
        return;
    }

    table.pack();

    TableColumn[] columns = table.getColumns();

    for (int i = 0; i < columns.length; i++) {

        int columnWidth = columnWidths[i];
        if (columnWidth == SWT.DEFAULT) {
            columns[i].pack();
        }
        else {
            columns[i].setWidth(columnWidth);
        }
    }
}
 
Example 4
Project: eZooKeeper   File: BaseElementType.java   Source Code and License 6 votes vote down vote up
@Override
public void packTable(Table table) {
    table.pack();

    TableColumn[] columns = table.getColumns();
    int[] columnWidths = getColumnWidths();
    for (int i = 0; i < columns.length; i++) {

        int columnWidth = columnWidths[i];
        if (columnWidth == SWT.DEFAULT) {
            columns[i].pack();
        }
        else {
            columns[i].setWidth(columnWidth);
        }
    }
}
 
Example 5
Project: eZooKeeper   File: ZnodeAclComposite.java   Source Code and License 6 votes vote down vote up
private void fixLayout() {

        Table table = getTable();

        // HACK to get the removed item to disappear.
        table.pack();
        layout(true);

        int[] columnWidths = TABLE_COLUMN_WIDTHS;
        TableColumn[] columns = table.getColumns();
        for (int i = 0; i < columns.length; i++) {

            if (columnWidths == null) {
                columns[i].pack();
            }
            else {
                int columnWidth = columnWidths[i];
                if (columnWidth == SWT.DEFAULT) {
                    columns[i].pack();
                }
                else {
                    columns[i].setWidth(columnWidth);
                }
            }
        }
    }
 
Example 6
Project: eZooKeeper   File: BaseZnodeModelTableFormPage.java   Source Code and License 6 votes vote down vote up
protected void createTableColumns() {
    Table table = getTable();
    if (table == null) {
        return;
    }

    String[] titles = getTableColumnTitles();
    if (titles != null && titles.length > 0) {

        int[] columnAlignments = getTableColumnAlignments();

        for (int i = 0; i < titles.length; i++) {
            TableColumn column = new TableColumn(table, SWT.NONE);
            column.setText(titles[i]);

            if (columnAlignments != null) {
                column.setAlignment(columnAlignments[i]);
            }
        }

        table.setHeaderVisible(true);
    }
}
 
Example 7
Project: neoscada   File: MonitorsViewTable.java   Source Code and License 6 votes vote down vote up
@Override
public void widgetSelected ( final SelectionEvent e )
{
    final Table table = this.tableViewer.getTable ();
    final TableColumn newColumn = (TableColumn)e.widget;
    final TableColumn currentColumn = table.getSortColumn ();

    final int currentDir = table.getSortDirection ();
    int newDir = SWT.UP;
    if ( newColumn == currentColumn )
    {
        newDir = currentDir == SWT.UP ? SWT.DOWN : SWT.UP;
    }
    else
    {
        table.setSortColumn ( newColumn );
    }
    table.setSortDirection ( newDir );
    this.tableViewer.setSorter ( new Sorter ( (Columns)newColumn.getData ( COLUMN_KEY ), newDir ) );
}
 
Example 8
Project: neoscada   File: EventViewTable.java   Source Code and License 6 votes vote down vote up
@Override
public void widgetSelected ( final SelectionEvent e )
{
    final Table table = this.tableViewer.getTable ();
    final TableColumn newColumn = (TableColumn)e.widget;
    final TableColumn currentColumn = table.getSortColumn ();

    final EventTableColumn column = (EventTableColumn)newColumn.getData ( COLUMN_KEY );
    if ( column == EventTableColumn.reservedColumnSourceTimestamp || column == EventTableColumn.reservedColumnEntryTimestamp )
    {
        final int currentDir = table.getSortDirection ();
        int newDir = SWT.UP;
        if ( newColumn == currentColumn )
        {
            newDir = currentDir == SWT.UP ? SWT.DOWN : SWT.UP;
        }
        else
        {
            table.setSortColumn ( newColumn );
        }
        table.setSortDirection ( newDir );
        this.tableViewer.setSorter ( new EventTableSorter ( column, newDir ) );
    }
}
 
Example 9
Project: neoscada   File: QueryDataView.java   Source Code and License 6 votes vote down vote up
@Override
public void createPartControl ( final Composite parent )
{
    addListener ();

    parent.setLayout ( new FillLayout () );
    this.table = new Table ( parent, SWT.FULL_SELECTION );
    this.table.setHeaderVisible ( true );

    this.indexCol = new TableColumn ( this.table, SWT.NONE );
    this.indexCol.setText ( Messages.QueryDataView_ColIndex );
    this.indexCol.setWidth ( 50 );

    this.qualityCol = new TableColumn ( this.table, SWT.NONE );
    this.qualityCol.setText ( Messages.QueryDataView_ColQuality );
    this.qualityCol.setWidth ( 75 );

    this.manualCol = new TableColumn ( this.table, SWT.NONE );
    this.manualCol.setText ( Messages.QueryDataView_ColManual );
    this.manualCol.setWidth ( 75 );

    this.invalidColor = JFaceColors.getErrorBackground ( getDisplay () );
}
 
Example 10
Project: neoscada   File: QueryDataView.java   Source Code and License 6 votes vote down vote up
private void clearDataSize ()
{
    this.table.clearAll ();

    for ( final TableColumn col : this.columns.values () )
    {
        col.dispose ();
    }
    this.columns.clear ();

    if ( this.countCol != null )
    {
        this.countCol.dispose ();
        this.countCol = null;
    }

    if ( this.infoCol != null )
    {
        this.infoCol.dispose ();
        this.infoCol = null;
    }
}
 
Example 11
Project: neoscada   File: SecurityEditor.java   Source Code and License 6 votes vote down vote up
protected void createColumns ( final Table table )
{
    final TableColumn typeFilterColumn = new TableColumn ( table, SWT.NONE );
    typeFilterColumn.setText ( getString ( "_UI_TypeFilterColumn_label" ) ); //$NON-NLS-1$
    typeFilterColumn.setResizable ( true );
    typeFilterColumn.setWidth ( 200 );

    final TableColumn idFilterColumn = new TableColumn ( table, SWT.NONE );
    idFilterColumn.setText ( getString ( "_UI_IdFilterColumn_label" ) ); //$NON-NLS-1$
    idFilterColumn.setResizable ( true );
    idFilterColumn.setWidth ( 200 );

    final TableColumn actionFilterColumn = new TableColumn ( table, SWT.NONE );
    actionFilterColumn.setText ( getString ( "_UI_ActionFilterColumn_label" ) ); //$NON-NLS-1$
    actionFilterColumn.setResizable ( true );
    actionFilterColumn.setWidth ( 200 );
}
 
Example 12
Project: gw4e.project   File: TableHelper.java   Source Code and License 6 votes vote down vote up
public static void handleEvent(Event event) {

		Table table = (Table) event.widget;
		int columnCount = table.getColumnCount();
		if (columnCount == 0)
			return;
		Rectangle area = table.getClientArea();
		int totalAreaWdith = area.width;
		int lineWidth = table.getGridLineWidth();
		int totalGridLineWidth = (columnCount - 1) * lineWidth;
		int totalColumnWidth = 0;
		for (TableColumn column : table.getColumns()) {
			totalColumnWidth = totalColumnWidth + column.getWidth();
		}
		int diff = totalAreaWdith - (totalColumnWidth + totalGridLineWidth);

		TableColumn lastCol = table.getColumns()[columnCount - 1];

		lastCol.setWidth(diff + lastCol.getWidth());

	}
 
Example 13
Project: Hydrograph   File: ExcelFormattingDialog.java   Source Code and License 6 votes vote down vote up
private void createSourceTable(SashForm sashForm) {
    avaliableFieldTableViewer = new TableViewer(sashForm, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
	table_1 = avaliableFieldTableViewer.getTable();
	table_1.setLinesVisible(true);
	table_1.setHeaderVisible(true);
	avaliableFieldTableViewer.setContentProvider(new IStructuredContentProvider() {

		@Override
		public Object[] getElements(Object inputElement) {
			return ((List) inputElement).toArray();
		}
	});
	avaliableFieldTableViewer.setInput(schemaFields);

	TableViewerColumn tableViewerColumn_2 = new TableViewerColumn(avaliableFieldTableViewer, SWT.NONE);
	TableColumn tblclmnNewColumn_2 = tableViewerColumn_2.getColumn();
	tblclmnNewColumn_2.setWidth(196);
	tblclmnNewColumn_2.setText(Messages.AVAILABLE_FIELDS_HEADER);
	tableViewerColumn_2.setLabelProvider(new ColumnLabelProvider());

	attachDragListener();
}
 
Example 14
Project: Hydrograph   File: HeaderAndDataFormattingDialog.java   Source Code and License 6 votes vote down vote up
private TableViewer createTableColumns(Composite tableComposite) {
	TableViewer tableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION);
	excelFormatterTable = tableViewer.getTable();
	excelFormatterTable.setHeaderVisible(true);
	excelFormatterTable.setLinesVisible(true);
	excelFormatterTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	TableColumn parameterNameColumn = tableViewerColumn.getColumn();
	parameterNameColumn.setWidth(254);
	parameterNameColumn.setText(Messages.PARAMETER_NAME);
	tableViewerColumn.setLabelProvider(new ParameterNameLabelProvider());

	TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tableViewer, SWT.NONE);
	TableColumn parameterValueColumn = tableViewerColumn_1.getColumn();
	parameterValueColumn.setWidth(251);
	parameterValueColumn.setText(Messages.PARAMETER_VALUE);
	tableViewerColumn_1.setLabelProvider(new ParameterValueLabelProvider());
	return tableViewer;
}
 
Example 15
Project: Hydrograph   File: ELTSchemaGridWidget.java   Source Code and License 6 votes vote down vote up
/**
 * Arrange the columns size in equal ratio
 */
private void arrangeTableViewerColumns() {
 tableViewerComposite.addControlListener(new ControlAdapter() {

	 @Override
	 public void controlResized(ControlEvent e) {
		 int totalWidth = tableViewer.getTable().getColumnCount() * COLUMN_WIDTH;
		 int widthDifference = tableViewerComposite.getSize().x - totalWidth;

		 if (widthDifference > 0) {
			 widthDifference = widthDifference / tableViewer.getTable().getColumnCount();
			 for (TableColumn tableColumn : tableViewer.getTable().getColumns()) {
				 tableColumn.setWidth(COLUMN_WIDTH+widthDifference);
			 }
		 }
	 }

 });
}
 
Example 16
Project: Hydrograph   File: ExportAction.java   Source Code and License 6 votes vote down vote up
@Override
public void run() {
	ViewDataPreferencesVO viewDataPreferencesVO = debugDataViewer.getViewDataPreferences();
	delimiter = viewDataPreferencesVO.getDelimiter();
	quoteCharactor = viewDataPreferencesVO.getQuoteCharactor();
	headerEnabled = viewDataPreferencesVO.getIncludeHeaders();
	TableViewer tableViewer = debugDataViewer.getTableViewer();
	List<RowData> eachRowData = getListOfRowData(tableViewer);
	List<String[]> exportedfileDataList = new ArrayList<String[]>();
	TableColumn[] columns = tableViewer.getTable().getColumns();
	if (headerEnabled != null) {
		addHeadersInList(tableViewer, exportedfileDataList, columns);
	}
	addRowsDataInList(tableViewer, eachRowData, exportedfileDataList);
	FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE);
	String filePath = getPathOfFileDialog(fileDialog);
	writeDataInFile(exportedfileDataList, filePath);
}
 
Example 17
Project: Tarski   File: SelectionWizardPage.java   Source Code and License 6 votes vote down vote up
/**
 * Create contents of the wizard.
 * 
 * @param parent
 */
public void createControl(Composite parent) {
  Composite container = new Composite(parent, SWT.NULL);

  setControl(container);
  container.setLayout(new GridLayout(1, false));

  TableViewer tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION);
  table = tableViewer.getTable();
  table.setLinesVisible(true);
  table.setHeaderVisible(true);
  table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

  tableViewer.setContentProvider(ArrayContentProvider.getInstance());
  tableViewer.setInput(candidateList);
  tableViewer.setLabelProvider(new MarkerColumn());
  // auto size columns
  TableColumn[] columns = tableViewer.getTable().getColumns();
  for (int i = 0; i < columns.length; i++) {
    columns[i].pack();
  }
}
 
Example 18
Project: libraries   File: TableViewerFactory.java   Source Code and License 6 votes vote down vote up
private void createColumns(final TableViewer tableViewer) {
  final String[] titles = { "Icon", "Name", "Small", "Medium", "Large", "Source", "Class" };
  final int[] bounds = { 40, 200, 60, 60, 60, 200, 200 };
  for (int i = 0; i < titles.length; i++) {
    final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    tableViewer.setSorter(new TableViewerSorter(titles));
    viewerColumn.setLabelProvider(new TableCellLabelProvider());
    final TableColumn column = viewerColumn.getColumn();
    column.addSelectionListener(new ColumnSelectionListener(column, tableViewer));
    column.setText(titles[i]);
    column.setWidth(bounds[i]);
    column.setResizable(true);
    column.setMoveable(false);
  }
  final Table table = tableViewer.getTable();
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.RECREATE);
}
 
Example 19
Project: libraries   File: ColumnSelectionListener.java   Source Code and License 6 votes vote down vote up
@Override
public void widgetSelected(final SelectionEvent e) {
  final Table table = this.column.getParent();
  final TableColumn sortColumn = table.getSortColumn();
  if (sortColumn == null || !sortColumn.equals(this.column)) {
    table.setSortColumn(this.column);
    table.setSortDirection(SWT.NONE);
  }
  switch (table.getSortDirection()) {
    case SWT.NONE: {
      table.setSortDirection(SWT.DOWN);
      break;
    }
    case SWT.DOWN: {
      table.setSortDirection(SWT.UP);
      break;
    }
    case SWT.UP: {
      table.setSortDirection(SWT.NONE);
      break;
    }
  }
  this.viewer.refresh();
}
 
Example 20
Project: libraries   File: RelationsTableViewerFactory.java   Source Code and License 6 votes vote down vote up
private void createColumns(final TableViewer tableViewer) {
  final String[] titles = { "Relation", "Type", "Name" };
  final int[] bounds = { 120, 100, 200 };
  for (int i = 0; i < titles.length; i++) {
    final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    tableViewer.setSorter(new TableViewerSorter(titles));
    viewerColumn.setLabelProvider(new TableCellLabelProvider());
    final TableColumn column = viewerColumn.getColumn();
    column.addSelectionListener(new ColumnSelectionListener(column, tableViewer));
    column.setText(titles[i]);
    column.setWidth(bounds[i]);
    column.setResizable(true);
    column.setMoveable(false);
  }
  final Table table = tableViewer.getTable();
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.RECREATE);

  // Object[] projectsToSelect = openProjects.toArray();
  // IViewPart view = window.getActivePage().showView( "org.eclipse.jdt.ui.PackageExplorer" );
  // view.getSite().getSelectionProvider().setSelection( new StructuredSelection( projectsToSelect ) );

}
 
Example 21
Project: TranskribusSwtGui   File: HtrTableLabelProvider.java   Source Code and License 6 votes vote down vote up
@Override
public String getColumnText(Object element, int columnIndex) {
	//logger.trace("get column text: "+element+" id: "+columnIndex);
	
	if (element instanceof TrpHtr) {
		TrpHtr htr = (TrpHtr) element;
		
		TableColumn column = table.getColumn(columnIndex);
		String ct = column.getText();
		
		if (ct.equals(HtrTableWidget.HTR_NAME_COL)) {
			return htr.getName();
		} else if (ct.equals(HtrTableWidget.HTR_LANG_COL)) {
			return htr.getLanguage();
		} else if (ct.equals(HtrTableWidget.HTR_ID_COL)) {
			return ""+htr.getHtrId();
		} else if (ct.equals(HtrTableWidget.HTR_CREATOR_COL)) {
			return htr.getUserName() == null ? "Unknown" : htr.getUserName();
		}
	}
	return "i am error";
}
 
Example 22
Project: libraries   File: TypesTableViewerFactory.java   Source Code and License 6 votes vote down vote up
private void createColumns(final TableViewer tableViewer) {
  final String[] titles = { "Class" };
  final int[] bounds = { 120, 100, 200 };
  for (int i = 0; i < titles.length; i++) {
    final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    tableViewer.setSorter(new TableViewerSorter(titles));
    viewerColumn.setLabelProvider(new TableCellLabelProvider());
    final TableColumn column = viewerColumn.getColumn();
    column.addSelectionListener(new ColumnSelectionListener(column, tableViewer));
    column.setText(titles[i]);
    column.setWidth(bounds[i]);
    column.setResizable(true);
    column.setMoveable(false);
  }
  final Table table = tableViewer.getTable();
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.RECREATE);
}
 
Example 23
Project: libraries   File: ColumnSelectionListener.java   Source Code and License 6 votes vote down vote up
@Override
public void widgetSelected(final SelectionEvent e) {
  final Table table = this.column.getParent();
  final TableColumn sortColumn = table.getSortColumn();
  if (sortColumn == null || !sortColumn.equals(this.column)) {
    table.setSortColumn(this.column);
    table.setSortDirection(SWT.NONE);
  }
  switch (table.getSortDirection()) {
    case SWT.NONE: {
      table.setSortDirection(SWT.DOWN);
      break;
    }
    case SWT.DOWN: {
      table.setSortDirection(SWT.UP);
      break;
    }
    case SWT.UP: {
      table.setSortDirection(SWT.NONE);
      break;
    }
  }
  this.viewer.refresh();
}
 
Example 24
Project: TranskribusSwtGui   File: KwsHitTableLabelProvider.java   Source Code and License 6 votes vote down vote up
@Override
public String getColumnText(Object element, int columnIndex) {
	//logger.trace("get column text: "+element+" id: "+columnIndex);
	
	if (element instanceof TrpKwsHit) {
		TrpKwsHit hit = (TrpKwsHit) element;
		
		TableColumn column = table.getColumn(columnIndex);
		String ct = column.getText();
		
		if (ct.equals(KwsHitTableWidget.KWS_CONF_COL)) {
			return DF.format(hit.getConfidence());
		} else if (ct.equals(KwsHitTableWidget.KWS_PAGE_COL)) {
			return ""+hit.getPageNr();
		} else if (ct.equals(KwsHitTableWidget.KWS_TEXT_COL)) {
			return hit.getTranscription();
		} else if (ct.equals(KwsHitTableWidget.KWS_PREVIEW_COL)) {
			if(!icons.containsKey(hit)) {
				return "Loading...";
			} else {
				return "";
			}
		}
	}
	return "i am error";
}
 
Example 25
Project: team-explorer-everywhere   File: SelectChangesetsWizardPage.java   Source Code and License 6 votes vote down vote up
private void addColumns() {
    // Columns
    final TableLayout mergeTableLayout = new TableLayout();
    table.setLayout(mergeTableLayout);

    mergeTableLayout.addColumnData(new ColumnWeightData(15, 10, true));
    final TableColumn changesetTableColumn = new TableColumn(table, SWT.NONE);
    changesetTableColumn.setText(Messages.getString("SelectChangesetsWizardPage.ColumnNameChangeset")); //$NON-NLS-1$

    mergeTableLayout.addColumnData(new ColumnWeightData(25, 10, true));
    final TableColumn changeTableColumn = new TableColumn(table, SWT.NONE);
    changeTableColumn.setText(Messages.getString("SelectChangesetsWizardPage.ColumnNameDate")); //$NON-NLS-1$

    mergeTableLayout.addColumnData(new ColumnWeightData(15, 10, true));
    final TableColumn userTableColumn = new TableColumn(table, SWT.NONE);
    userTableColumn.setText(Messages.getString("SelectChangesetsWizardPage.ColumnNameUser")); //$NON-NLS-1$

    mergeTableLayout.addColumnData(new ColumnWeightData(35, 10, true));
    final TableColumn commentTableColumn = new TableColumn(table, SWT.FILL);
    commentTableColumn.setText(Messages.getString("SelectChangesetsWizardPage.ColumnNameComment")); //$NON-NLS-1$
}
 
Example 26
Project: team-explorer-everywhere   File: WorkItemList.java   Source Code and License 6 votes vote down vote up
private void createTableColumns(final Table table) {
    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setText(Messages.getString("WorkItemList.ColumnNameType")); //$NON-NLS-1$
    column1.setResizable(true);

    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText(Messages.getString("WorkItemList.ColumnNameId")); //$NON-NLS-1$
    column2.setResizable(true);

    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setText(Messages.getString("WorkItemList.ColumnNameTitle")); //$NON-NLS-1$
    column3.setResizable(true);

    final TableColumn column4 = new TableColumn(table, SWT.NONE);
    column4.setText(Messages.getString("WorkItemList.ColumnNameState")); //$NON-NLS-1$
    column4.setResizable(true);
    if (forHistoryDetails == false) {
        final TableColumn column5 = new TableColumn(table, SWT.NONE);
        column5.setText(Messages.getString("WorkItemList.ColumnNameAction")); //$NON-NLS-1$
        column5.setResizable(true);
    }
}
 
Example 27
Project: team-explorer-everywhere   File: BranchesPropertiesControl.java   Source Code and License 6 votes vote down vote up
private void createTableColumns(final Table table) {
    final TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);

    tableLayout.addColumnData(new ColumnWeightData(5, true));
    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setText(Messages.getString("BranchesPropertiesControl.ColumNameFileName")); //$NON-NLS-1$
    column1.setResizable(true);

    tableLayout.addColumnData(new ColumnWeightData(3, true));
    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText(Messages.getString("BranchesPropertiesControl.ColumnNameChange")); //$NON-NLS-1$
    column2.setResizable(true);

    tableLayout.addColumnData(new ColumnWeightData(1, true));
    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setText(Messages.getString("BranchesPropertiesControl.ColumnNameBranchedFrom")); //$NON-NLS-1$
    column3.setResizable(true);

}
 
Example 28
Project: team-explorer-everywhere   File: StatusPropertiesTab.java   Source Code and License 6 votes vote down vote up
private void createTableColumns(final Table table) {
    final TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);

    tableLayout.addColumnData(new ColumnWeightData(1, true));
    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setText(Messages.getString("StatusPropertiesTab.ColumNameUser")); //$NON-NLS-1$
    column1.setResizable(true);

    tableLayout.addColumnData(new ColumnWeightData(1, true));
    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText(Messages.getString("StatusPropertiesTab.ChangeNameChangeType")); //$NON-NLS-1$
    column2.setResizable(true);

    tableLayout.addColumnData(new ColumnWeightData(1, true));
    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setText(Messages.getString("StatusPropertiesTab.ColumnNameWorkspace")); //$NON-NLS-1$
    column3.setResizable(true);
}
 
Example 29
Project: TranskribusSwtGui   File: MyTableCombo.java   Source Code and License 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 30
Project: TranskribusSwtGui   File: JobOverviewLabelProvider.java   Source Code and License 6 votes vote down vote up
@Override public Color getForeground(Object element, int columnIndex) {
	if (element instanceof TrpJobStatus) {
		TrpJobStatus job = (TrpJobStatus) element;
		
		TableColumn column = table.getColumn(columnIndex);
		String ct = column.getText();
		
		if (ct.equals(JobOverviewWidget.STATE_COL)) {
			if (job.getState().equals(TrpJobStatus.FINISHED)) {
				return Colors.getSystemColor(SWT.COLOR_DARK_GREEN);
			}
			else if (job.getState().equals(TrpJobStatus.FAILED)) {
				return Colors.getSystemColor(SWT.COLOR_RED);
			}
			else {
				return Colors.getSystemColor(SWT.COLOR_DARK_YELLOW);
			}
		}
	}		
	
	return null;
}
 
Example 31
Project: team-explorer-everywhere   File: TableViewerSorter.java   Source Code and License 6 votes vote down vote up
/**
 * Called to set the column and direction decorations on the specified
 * {@link Table}. Subclasses may override. The base class implementation
 * uses reflection to attempt to call the <code>setSortColumn</code> and
 * <code>setSortDirection</code> methods that were added in Eclipse 3.2.
 *
 * @param table
 *        the {@link Table} to decorate
 * @param sortColumn
 *        the column that should be marked as the sort column
 * @param direction
 *        the direction ({@link SWT#UP} or {@link SWT#DOWN}) to use in the
 *        decoration
 */
protected void setSortColumnAndDirection(final Table table, final TableColumn sortColumn, final int direction) {
    try {
        final Class tableClass = table.getClass();

        final Method setSortColumn = tableClass.getMethod("setSortColumn", new Class[] //$NON-NLS-1$
        {
            TableColumn.class
        });
        final Method setSortDirection = tableClass.getMethod("setSortDirection", new Class[] //$NON-NLS-1$
        {
            Integer.TYPE
        });

        setSortColumn.invoke(table, new Object[] {
            sortColumn
        });
        setSortDirection.invoke(table, new Object[] {
            new Integer(direction)
        });
    } catch (final Exception e) {

    }
}
 
Example 32
Project: team-explorer-everywhere   File: TableColumnWidthsPersistence.java   Source Code and License 6 votes vote down vote up
/**
 * Restores table column widths. Users of this class should have already
 * added some mappings before calling this method. Any persisted widths
 * whose keys do not correspond to indices into the {@link Table}'s columns
 * will be ignored.
 */
public void restore() {
    final Preferences node = getPreferencesNode(key);

    for (final Iterator it = mappings.keySet().iterator(); it.hasNext();) {
        final String columnKey = (String) it.next();
        final int ix = getIndexForKey(columnKey);
        if (ix == -1) {
            continue;
        }
        final TableColumn tableColumn = table.getColumn(ix);
        final int persistedWidth = node.getInt(columnKey, -1);
        if (persistedWidth != -1) {
            tableColumn.setWidth(persistedWidth);
        }
    }
}
 
Example 33
Project: TranskribusSwtGui   File: KwsResultTableLabelProvider.java   Source Code and License 6 votes vote down vote up
@Override
public String getColumnText(Object element, int columnIndex) {
	//logger.trace("get column text: "+element+" id: "+columnIndex);
	
	if (element instanceof TrpKwsResultTableEntry) {
		TrpKwsResultTableEntry res = (TrpKwsResultTableEntry) element;
		
		TableColumn column = table.getColumn(columnIndex);
		String ct = column.getText();
		
		if (ct.equals(KwsResultTableWidget.KWS_CREATED_COL)) {
			return CoreUtils.DATE_FORMAT_USER_FRIENDLY.format(res.getCreated());
		} else if (ct.equals(KwsResultTableWidget.KWS_STATUS_COL)) {
			return res.getStatus();
		} else if (ct.equals(KwsResultTableWidget.KWS_SCOPE_COL)) {
			return res.getScope();
		} else if (ct.equals(KwsResultTableWidget.KWS_DURATION_COL)) {
			return res.getDuration();
		} else if (ct.equals(KwsResultTableWidget.KWS_QUERY_COL)) {
			return res.getQuery();
		}
	}
	return "i am error";
}
 
Example 34
Project: TranskribusSwtGui   File: FeatureTableLabelProvider.java   Source Code and License 6 votes vote down vote up
@Override public String getColumnText(Object element, int columnIndex) {
	if (element instanceof EdFeature) {
		EdFeature feat = (EdFeature) element;
		
		TableColumn column = table.getColumn(columnIndex);
		String ct = column.getText();

		if (ct.equals(EditDeclManagerDialog.FEAT_TITLE_COL)) {
			return feat.getTitle();
		} else if (ct.equals(EditDeclManagerDialog.FEAT_DESC_COL)) {
			return feat.getDescription();
		} else if (ct.equals(EditDeclManagerDialog.FEAT_ID_COL)) {
			return ""+feat.getFeatureId();
		}  else if (ct.equals(EditDeclManagerDialog.FEAT_COL_ID_COL)) {
			final Integer colId = feat.getColId();
			if(colId != null){
				return ""+feat.getColId();
			} else {
				return "preset";
			}
		}
	}

	return "i am error";
}
 
Example 35
Project: ermaster-k   File: IndexTabWrapper.java   Source Code and License 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", -1);
	TableColumn separatorColumn = CompositeFactory.createTableColumn(
			this.indexTable, "", 3);
	separatorColumn.setResizable(false);
}
 
Example 36
Project: ermasterr   File: RelationByExistingColumnsDialog.java   Source Code and License 6 votes vote down vote up
private void createComparisonTable(final Composite composite) {
    final GridData tableGridData = new GridData();
    tableGridData.horizontalSpan = 2;
    tableGridData.heightHint = 100;
    tableGridData.horizontalAlignment = GridData.FILL;
    tableGridData.grabExcessHorizontalSpace = true;

    comparisonTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    comparisonTable.setLayoutData(tableGridData);
    comparisonTable.setHeaderVisible(true);
    comparisonTable.setLinesVisible(true);

    composite.pack();

    final int width = comparisonTable.getBounds().width;

    final TableColumn referencedColumn = new TableColumn(comparisonTable, SWT.NONE);
    referencedColumn.setWidth(width / 2);
    referencedColumn.setText(ResourceString.getResourceString("label.reference.column"));

    final TableColumn foreignKeyColumn = new TableColumn(comparisonTable, SWT.NONE);
    foreignKeyColumn.setWidth(width / 2);
    foreignKeyColumn.setText(ResourceString.getResourceString("label.foreign.key"));
}
 
Example 37
Project: ermasterr   File: IndexTabWrapper.java   Source Code and License 6 votes vote down vote up
private void initTable(final Composite parent) {
    final GridData gridData = new GridData();
    gridData.horizontalSpan = 3;
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.heightHint = 200;

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

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

    CompositeFactory.createTableColumn(indexTable, "label.column.name", -1);
    final TableColumn separatorColumn = CompositeFactory.createTableColumn(indexTable, "", 3);
    separatorColumn.setResizable(false);
}
 
Example 38
Project: TranskribusSwtGui   File: EditDeclTableLabelProvider.java   Source Code and License 6 votes vote down vote up
@Override public String getColumnText(Object element, int columnIndex) {
		if (element instanceof EdFeature) {
			EdFeature feat = (EdFeature) element;
			
			TableColumn column = table.getColumn(columnIndex);
			String ct = column.getText();

			if (ct.equals(EditDeclManagerDialog.EDT_DECL_TITLE_COL)) {
				return feat.getTitle();
			} else if (ct.equals(EditDeclManagerDialog.EDT_DECL_DESC_COL)) {
				return feat.getDescription();
			} else if (ct.equals(EditDeclManagerDialog.EDT_DECL_ID_COL)) {
				return ""+feat.getFeatureId();
			}  else if (ct.equals(EditDeclManagerDialog.EDT_DECL_OPT_COL)) {
				List<EdOption> opts = feat.getOptions();
				for(EdOption o : opts){
//					logger.debug(o.getText());
					if(o.isSelected()) return o.getText();
				}
			}
		}

		return "i am error";
	}
 
Example 39
Project: ermasterr   File: ExportToTranslationDictionaryDialog.java   Source Code and License 6 votes vote down vote up
private void createTable(final Composite parent) {
    final GridData gridData = new GridData();
    gridData.heightHint = 150;
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;

    dictionaryTable = new Table(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);
    dictionaryTable.setHeaderVisible(true);
    dictionaryTable.setLinesVisible(true);
    dictionaryTable.setLayoutData(gridData);

    parent.pack();

    final int width = dictionaryTable.getBounds().width;

    final TableColumn physicalNameTableColumn = new TableColumn(dictionaryTable, SWT.LEFT);
    physicalNameTableColumn.setText(ResourceString.getResourceString("label.physical.name"));
    physicalNameTableColumn.setWidth(width / 2 - 5);

    final TableColumn logicalNameTableColumn = new TableColumn(dictionaryTable, SWT.LEFT);

    logicalNameTableColumn.setText(ResourceString.getResourceString("label.logical.name"));
    logicalNameTableColumn.setWidth(width / 2 - 5);
}
 
Example 40
Project: code   File: ObjectTreeView.java   Source Code and License 6 votes vote down vote up
private void createMenuItem(Menu parent, final TableColumn column) {
	final MenuItem itemName = new MenuItem(parent, SWT.CHECK);
	itemName.setText(column.getText());
	itemName.setSelection(column.getResizable());
	itemName.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event event) {
			if (itemName.getSelection()) {
				column.setWidth(150);
				column.setResizable(true);
			} else {
				column.setWidth(0);
				column.setResizable(false);
			}
		}
	});

}
 
Example 41
Project: ermaster-k   File: IndexDialog.java   Source Code and License 6 votes vote down vote up
private void initializeIndexColumnList(Composite parent) {
	GridData gridData = new GridData();
	gridData.verticalSpan = 2;
	gridData.verticalAlignment = GridData.FILL;
	gridData.grabExcessVerticalSpace = true;

	indexColumnList = new Table(parent, SWT.FULL_SELECTION | SWT.BORDER);
	indexColumnList.setHeaderVisible(true);
	indexColumnList.setLayoutData(gridData);
	indexColumnList.setLinesVisible(false);

	TableColumn tableColumn = new TableColumn(indexColumnList, SWT.CENTER);
	tableColumn.setWidth(150);
	tableColumn.setText(ResourceString
			.getResourceString("label.column.name"));

	if (DBManagerFactory.getDBManager(this.table.getDiagram()).isSupported(
			DBManager.SUPPORT_DESC_INDEX)) {
		TableColumn tableColumn1 = new TableColumn(indexColumnList,
				SWT.CENTER);
		tableColumn1.setWidth(50);
		tableColumn1.setText(ResourceString
				.getResourceString("label.order.desc"));
	}
}
 
Example 42
Project: eZooKeeper   File: ViewerFactory.java   Source Code and License 5 votes vote down vote up
private static void createTableColumns(Table table, IElementType tableElementType) {

        String[] columnTitles = tableElementType.getColumnTitles();
        int[] columnAlignments = tableElementType.getColumnAlignments();

        for (int i = 0; i < columnTitles.length; i++) {
            TableColumn column = new TableColumn(table, SWT.NONE);
            column.setText(columnTitles[i]);
            column.setAlignment(columnAlignments[i]);
            column.setMoveable(true);
        }

        table.setHeaderVisible(true);
    }
 
Example 43
Project: eZooKeeper   File: BaseZnodeModelTableFormPage.java   Source Code and License 5 votes vote down vote up
protected final void initFromModelInternal() {

        Table table = getTable();

        if (table == null || getModel().isDestroyed()) {
            return;
        }

        table.setRedraw(false);

        try {
            initTableItemsFromZnode();
            setDirtyInternal(false);
        }
        finally {
            table.setRedraw(true);
        }

        table.pack();
        forceLayout();

        TableColumn[] columns = getTable().getColumns();
        int[] columnWidths = getTableColumnWidths();
        for (int i = 0; i < columns.length; i++) {

            if (columnWidths == null) {
                columns[i].pack();
            }
            else {
                int columnWidth = columnWidths[i];
                if (columnWidth == SWT.DEFAULT) {
                    columns[i].pack();
                }
                else {
                    columns[i].setWidth(columnWidth);
                }
            }
        }
    }
 
Example 44
Project: neoscada   File: MonitorsViewTable.java   Source Code and License 5 votes vote down vote up
public List<ColumnProperties> getColumnSettings ()
{
    final List<ColumnProperties> result = new ArrayList<ColumnProperties> ();
    int i = 0;
    final int[] order = this.tableViewer.getTable ().getColumnOrder ();
    for ( final TableColumn col : this.tableViewer.getTable ().getColumns () )
    {
        result.add ( new ColumnProperties ( order[i], col.getWidth () ) );
        i += 1;
    }
    return result;
}
 
Example 45
Project: neoscada   File: EventViewTable.java   Source Code and License 5 votes vote down vote up
public List<ColumnProperties> getColumnSettings ()
{
    final List<ColumnProperties> result = new ArrayList<ColumnProperties> ();
    int i = 0;
    final int[] order = this.tableViewer.getTable ().getColumnOrder ();
    for ( final TableColumn col : this.tableViewer.getTable ().getColumns () )
    {
        result.add ( new ColumnProperties ( order[i], col.getWidth () ) );
        i += 1;
    }
    return result;
}
 
Example 46
Project: neoscada   File: QueryDataView.java   Source Code and License 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 47
Project: AppleCommander   File: DiskExplorerTab.java   Source Code and License 5 votes vote down vote up
/**
 * Preserve the column widths.
 */
protected void preserveColumnWidths() {
	TableColumn[] columns = fileTable.getColumns();
	int[] widths = new int[columns.length];
	for (int i=0; i<columns.length; i++) {
		widths[i] = columns[i].getWidth();
	}
	columnWidths.put(new Integer(currentFormat), widths);
}
 
Example 48
Project: gw4e.project   File: PerformanceView.java   Source Code and License 5 votes vote down vote up
private void setColumnsName (TableViewer tv) {
  for (int i = 0; i < ColumnsConst.COLUMNS.length; i++) {
   TableColumn col = new TableColumn(tv.getTable(), SWT.LEFT );
       col.setText(ColumnsConst.COLUMNS[i]);
       col.setData(new Integer (i));
       col.addSelectionListener(new SelectionAdapter() {
           public void widgetSelected(SelectionEvent event) {
           	TableColumn tc  = (TableColumn)event.getSource();
           	Integer index = (Integer)tc.getData();
               ((PerformanceStatsViewerSorter) tv.getComparator()).doSort(index);
               tv.refresh();
           }
      });
  }
}
 
Example 49
Project: gw4e.project   File: BuildPoliciesCheckboxTableViewer.java   Source Code and License 5 votes vote down vote up
public void init (Listener listener,GridData gd) {
	getTable().setLayoutData(new GridData(GridData.FILL_BOTH));

	getTable().setLayoutData(gd);
	
			
	setContentProvider(new IStructuredContentProvider() {
		@Override
		public Object[] getElements(Object inputElement) {
			BuildPolicy[] ret = (BuildPolicy[]) inputElement;
			return ret;
		}
	});

	setLabelProvider(new LabelProvider() {
		@Override
		public String getText(Object element) {
			BuildPolicy bp = (BuildPolicy) element;
			return bp.getPathGenerator();
		}

	});
	getTable().addListener(SWT.Resize, new Listener() {
		@Override
		public void handleEvent(Event event) {
			TableHelper.handleEvent(event);
		}
	});

	TableColumn column = new TableColumn(getTable(), SWT.LEFT);
	column.setText("");
	column.pack();

	getTable().setHeaderVisible(true);
	getTable().setLinesVisible(true);

	getTable().addListener(SWT.Selection, listener);

}
 
Example 50
Project: gw4e.project   File: ModelSearchPage.java   Source Code and License 5 votes vote down vote up
private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, final int colNumber) {
    final TableViewerColumn viewerColumn = new TableViewerColumn(viewer,SWT.NONE);
    final TableColumn column = viewerColumn.getColumn();
    column.setText(title);
    column.setResizable(true);
    return viewerColumn;
}
 
Example 51
Project: gw4e.project   File: CustomProperties.java   Source Code and License 5 votes vote down vote up
private SelectionAdapter getSelectionAdapter(final TableColumn column, final int index) {
	SelectionAdapter selectionAdapter = new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			comparator.setColumn(index);
			int dir = comparator.getDirection();
			listViewer.getTable().setSortDirection(dir);
			listViewer.getTable().setSortColumn(column);
			listViewer.refresh();
		}
	};
	return selectionAdapter;
}
 
Example 52
Project: applecommander   File: DiskExplorerTab.java   Source Code and License 5 votes vote down vote up
/**
 * Preserve the column widths.
 */
protected void preserveColumnWidths() {
	TableColumn[] columns = fileTable.getColumns();
	int[] widths = new int[columns.length];
	for (int i=0; i<columns.length; i++) {
		widths[i] = columns[i].getWidth();
	}
	columnWidths.put(new Integer(currentFormat), widths);
}
 
Example 53
Project: Hydrograph   File: AvailableFieldsComposite.java   Source Code and License 5 votes vote down vote up
/**
 * Create the composite.
 * @param parent
 * @param style
 */
public AvailableFieldsComposite(Composite parent, int style , Map<String,Class<?>> fieldMap) {
	super(parent, style);
	setLayout(new GridLayout(1, false));
	this.inputFields=new ArrayList<>(fieldMap.keySet());
	this.fieldMap=fieldMap;
	headerComposite_1 = new Composite(this, SWT.NONE);
	headerComposite_1.setLayout(new GridLayout(2, false));
	GridData gd_headerComposite_1 = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
	gd_headerComposite_1.widthHint = 437;
	gd_headerComposite_1.heightHint = 39;
	headerComposite_1.setLayoutData(gd_headerComposite_1);
	
	Label lblAvailableFields = new Label(headerComposite_1, SWT.NONE);
	lblAvailableFields.setText(Messages.AVAILABLE_INPUT_FIELDS);
	
	createSearchTextBox(headerComposite_1);
	
	tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
	table = tableViewer.getTable();
	table.setLinesVisible(true);
	table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	table.setHeaderVisible(true);
	availableFieldsNameColumn = new TableColumn(table, SWT.NONE);
	availableFieldsNameColumn.setText(Messages.FIELD_NAME);
	availableFieldsDataTypeColumn = new TableColumn(table, SWT.NONE);
	availableFieldsDataTypeColumn.setText(Messages.DATA_TYPE);
	ExpressionEditorUtil.INSTANCE.addDragSupport(table);
	loadData();
	addControlListener();
	addDoubleClickListener();
	
}
 
Example 54
Project: Hydrograph   File: HiveFieldDialogHelper.java   Source Code and License 5 votes vote down vote up
/**
 * Disposes all columns in table
 * @param tableViewer
 */
public void disposeAllColumns(TableViewer tableViewer ,List<HivePartitionFields> fieldsDialogList){
	fieldsDialogList.clear();
	tableViewer.refresh();
	
	TableColumn[] columns = tableViewer.getTable().getColumns();
	for (TableColumn tc : columns) {
		tc.dispose();
	}
	tableViewer.getTable().redraw();
	}
 
Example 55
Project: Hydrograph   File: WidgetUtility.java   Source Code and License 5 votes vote down vote up
/**
 * Creates the table columns.
 * 
 * @param table
 *            the table
 * @param fields
 *            the fields
 */
public static void createTableColumns(Table table,String[] fields){
	for (String field : fields) {
		TableColumn tc = new TableColumn(table, SWT.CENTER);
		tc.setText(field);
		tc.setMoveable(true);
	}
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
}
 
Example 56
Project: Hydrograph   File: ELTSWTWidgets.java   Source Code and License 5 votes vote down vote up
public void createTableColumns(Table table, String[] fields, int width) {
	for (String field : fields) {
		TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
		tableColumn.setText(field);
		tableColumn.setWidth(width);
		// tableColumn.pack();
	}
	table.setHeaderVisible(true);
	table.setLinesVisible(true);

}
 
Example 57
Project: Hydrograph   File: SchemaPreviewPage.java   Source Code and License 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
	container = new Composite(parent, SWT.NONE);
	container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
			
	setControl(container);
	container.setLayout(new GridLayout(1, false));
	
	grpSchemaPreview = new Group(container, SWT.NONE);
	grpSchemaPreview.setText(SCHEMA_PREVIEW);
	grpSchemaPreview.setLayout(new GridLayout(1, false));
	grpSchemaPreview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	
	composite = new Composite(grpSchemaPreview, SWT.NONE);
	composite.setLayout(new GridLayout(1, false));
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	
	availableFieldTableViewer=new TableViewer(composite,SWT.BORDER);
	
	TableViewerColumn availableFieldsColumn = new TableViewerColumn(availableFieldTableViewer, SWT.NONE);
	availableFieldsColumn.setLabelProvider(new AvailableFieldsColumnLabelProvider());
	TableColumn tableColumn = availableFieldsColumn.getColumn();
	tableColumn.setText(AVAILABLE_FIELDS);
	
	Table table=availableFieldTableViewer.getTable();
	table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
	addControlListener(table, tableColumn);
   }
 
Example 58
Project: Hydrograph   File: SchemaPreviewPage.java   Source Code and License 5 votes vote down vote up
private void addControlListener(Table table, TableColumn tableColumn) {
	ControlListener controlistener= new ControlAdapter() {
		@Override
		public void controlResized(ControlEvent e) {
			for (TableColumn column : table.getColumns()) {
				column.setWidth(table.getSize().x / table.getColumnCount() - (4 - table.getColumnCount()));
			}
		}
	};
	table.addControlListener(controlistener);
}
 
Example 59
Project: Hydrograph   File: ELTOperationClassDialog.java   Source Code and License 5 votes vote down vote up
public static void createTableColumns(Table table, String[] fields) {
	for (String field : fields) {
		TableColumn tableColumn = new TableColumn(table, SWT.FILL);
		tableColumn.setText(field);

		tableColumn.setWidth(100);
		tableColumn.pack();
	}
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
}
 
Example 60
Project: Hydrograph   File: SecondaryColumnKeysDialog.java   Source Code and License 5 votes vote down vote up
private void createSourceTable(Composite composite_2) {
	sourceTable = new Table(composite_2, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
	sourceTable.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDoubleClick(MouseEvent e) {
			if(sourceTable.getSelection().length==1){
				addNewProperty(targetTableViewer, sourceTable.getSelection()[0].getText());
				enableControlButtons();
			}
		}
	});
	GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
	gd_table.widthHint = 221;
	gd_table.heightHint = 407;
	sourceTable.setLayoutData(gd_table);
	sourceTable.setHeaderVisible(true);
	sourceTable.setLinesVisible(true);

	TableColumn sourceTableColumnFieldName = new TableColumn(sourceTable, SWT.LEFT);
	if(OSValidator.isMac()){
		sourceTableColumnFieldName.setWidth(212);
	}else{
		sourceTableColumnFieldName.setWidth(202);
	}
	
	sourceTableColumnFieldName.setText(Messages.AVAILABLE_FIELDS_HEADER);
	getSourceFieldsFromPropagatedSchema(sourceTable);
	dragSource = new DragSource(sourceTable, DND.DROP_MOVE);
	dragSource.setTransfer(new Transfer[] { TextTransfer.getInstance() });
	dragSource.addDragListener(new DragSourceAdapter() {
		public void dragSetData(DragSourceEvent event) {
			// Set the data to be the first selected item's text
			event.data = formatDataToTransfer(sourceTable.getSelection());
		}

	});
}