org.eclipse.swt.widgets.Table Java Examples

The following examples show how to use org.eclipse.swt.widgets.Table. 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: RelationshipByExistingColumnsDialog.java    From erflute with Apache License 2.0 6 votes vote down vote up
private void createForeignKeyColumnMapper(Composite composite) {
    final GridData tableGridData = new GridData();
    tableGridData.horizontalSpan = 2;
    tableGridData.heightHint = 100;
    tableGridData.horizontalAlignment = GridData.FILL;
    tableGridData.grabExcessHorizontalSpace = true;
    foreignKeyColumnMapper = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    foreignKeyColumnMapper.setLayoutData(tableGridData);
    foreignKeyColumnMapper.setHeaderVisible(true);
    foreignKeyColumnMapper.setLinesVisible(true);
    final TableColumn referredColumn = new TableColumn(foreignKeyColumnMapper, SWT.NONE);
    referredColumn.setWidth(COLUMN_WIDTH);
    referredColumn.setText("Referred Column");
    final TableColumn foreignKeyColumn = new TableColumn(foreignKeyColumnMapper, SWT.NONE);
    foreignKeyColumn.setWidth(COLUMN_WIDTH);
    foreignKeyColumn.setText("ForeignKey Column");
}
 
Example #2
Source File: CompositeFactory.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
public static Table createTable(final Composite composite, final int height, final int span, final boolean multi) {
    final GridData gridData = new GridData();
    gridData.horizontalSpan = span;
    gridData.heightHint = height;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;

    int style = SWT.SINGLE;
    if (multi) {
        style = SWT.MULTI;
    }

    final Table table = new Table(composite, style | SWT.BORDER | SWT.FULL_SELECTION);
    table.setLayoutData(gridData);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    return table;
}
 
Example #3
Source File: CompositeFactory.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
public static TableEditor createCheckBoxTableEditor(TableItem tableItem,
		boolean selection, int column) {
	Table table = tableItem.getParent();

	final Button checkBox = new Button(table, SWT.CHECK);
	checkBox.pack();

	TableEditor editor = new TableEditor(table);

	editor.minimumWidth = checkBox.getSize().x;
	editor.horizontalAlignment = SWT.CENTER;
	editor.setEditor(checkBox, tableItem, column);

	checkBox.setSelection(selection);

	return editor;
}
 
Example #4
Source File: ResultSetPreviewPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public static ResultSetTableAction createResultSetTableAction(
		Table resultSetTable, int operationID )
{
	assert resultSetTable != null;

	ResultSetTableAction rsTableAction = null;

	if ( operationID == COPY_ACTION )
	{
		rsTableAction = new CopyAction( resultSetTable );
	}
	else if ( operationID == SELECTALL_ACTION )
	{
		rsTableAction = new SelectAllAction( resultSetTable );
	}

	return rsTableAction;
}
 
Example #5
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Returns true if the column is expanded to take extra available space.
 * This is the last non-zero-width visible column in the column order on
 * Linux. This column's width should not be persisted.
 *
 * @param column
 *            the column
 * @return true if the column is expanded.
 */
private static boolean isExpanded(TableColumn column) {
    if (IS_LINUX) {
        Table table = column.getParent();
        int[] order = table.getColumnOrder();
        for (int i = order.length - 1; i >= 0; i--) {
            TableColumn col = table.getColumn(order[i]);
            if (col == column) {
                return true;
            }
            if (col.getWidth() > 0) {
                return false;
            }
        }
    }
    return false;
}
 
Example #6
Source File: BuyOrderTableViewer.java    From offspring with MIT License 6 votes vote down vote up
public BuyOrderTableViewer(Composite parent, UISynchronize sync) {
  super(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION
      | SWT.BORDER);

  this.contentProvider = new BuyOrderContentProvider(sync);
  this.comparator = new BuyOrderComparator();

  setUseHashlookup(false);
  setContentProvider(contentProvider);
  setComparator(comparator);

  createColumns();

  /* Pack the columns */
  for (TableColumn column : getTable().getColumns())
    column.pack();

  Table table = getTable();
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
}
 
Example #7
Source File: EventViewTable.java    From neoscada with Eclipse Public License 1.0 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 #8
Source File: PrioritizeStreamsDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  Table table = wFields.table;
  if ( input.getTransformName().length > 0 ) {
    table.removeAll();
  }
  for ( int i = 0; i < input.getTransformName().length; i++ ) {
    TableItem ti = new TableItem( table, SWT.NONE );
    ti.setText( 0, "" + ( i + 1 ) );
    if ( input.getTransformName()[ i ] != null ) {
      ti.setText( 1, input.getTransformName()[ i ] );
    }
  }

  wFields.removeEmptyRows();
  wFields.setRowNums();
  wFields.optWidth( true );

  wTransformName.selectAll();
  wTransformName.setFocus();
}
 
Example #9
Source File: ExportToTranslationDictionaryDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private void createTable(Composite parent) {
	GridData gridData = new GridData();
	gridData.heightHint = 150;
	gridData.horizontalSpan = 2;
	gridData.horizontalAlignment = GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;

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

	TableColumn tableColumn = new TableColumn(this.dictionaryTable,
			SWT.LEFT);
	tableColumn.setWidth(250);
	tableColumn.setText(ResourceString
			.getResourceString("label.physical.name"));

	TableColumn tableColumn1 = new TableColumn(this.dictionaryTable,
			SWT.LEFT);
	tableColumn1.setWidth(250);
	tableColumn1.setText(ResourceString
			.getResourceString("label.logical.name"));

}
 
Example #10
Source File: IndexDialog.java    From erflute with Apache License 2.0 6 votes vote down vote up
private void initializeIndexColumnList(Composite parent) {
    final GridData gridData = new GridData();
    gridData.heightHint = 150;
    gridData.verticalSpan = 2;
    indexColumnList = new Table(parent, SWT.FULL_SELECTION | SWT.BORDER);
    indexColumnList.setHeaderVisible(true);
    indexColumnList.setLayoutData(gridData);
    indexColumnList.setLinesVisible(false);
    final TableColumn tableColumn = new TableColumn(indexColumnList, SWT.CENTER);
    tableColumn.setWidth(150);
    tableColumn.setText(DisplayMessages.getMessage("label.column.name"));
    if (DBManagerFactory.getDBManager(table.getDiagram()).isSupported(DBManager.SUPPORT_DESC_INDEX)) {
        final TableColumn tableColumn1 = new TableColumn(indexColumnList, SWT.CENTER);
        tableColumn1.setWidth(50);
        tableColumn1.setText(DisplayMessages.getMessage("label.order.desc"));
    }
}
 
Example #11
Source File: SetupOptionsPage.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/** Expects one row selected in the table and returns value of second row. */
private String getTableItem(Table table) {
	String result = "";
	if (table == null)
		return result;

	TableItem[] items = table.getSelection();

	if (items.length >= 2) {
		String text = Strings.nullToEmpty(table.getToolTipText());
		if (!text.isEmpty())
			text = " :: " + text;
		throw new RuntimeException("Multiple selections are not supported" + text);
	}

	if (items.length == 1 && items[0] != null)
		// first is the display name, second is data
		result = Strings.nullToEmpty(items[0].getText(1));

	return result;
}
 
Example #12
Source File: MenuStylesDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private CellEditor[] getCellEditors( Table table )
{
	CellEditor[] editors = new CellEditor[COLUMNS.length];
	editors[0] = new TextCellEditor( table ) {

		@Override
		protected void keyReleaseOccured( KeyEvent keyEvent )
		{
			super.keyReleaseOccured( keyEvent );
			if ( keyEvent.character == '\r' )
			{
				fTableViewer.editElement( fTableViewer.getElementAt( fTable.getSelectionIndex( ) ),
					1 );
			}

		}
	};
	editors[1] = new TextCellEditor( table );
	return editors;
}
 
Example #13
Source File: CloneDiffTooltip.java    From JDeodorant with MIT License 6 votes vote down vote up
protected void packAndFillLastColumn(Table table) {
    int columnsWidth = 0;
    for (int i = 0; i < table.getColumnCount() - 1; i++) {
        columnsWidth += table.getColumn(i).getWidth();
    }
    TableColumn lastColumn = table.getColumn(table.getColumnCount() - 1);
    lastColumn.pack();

    Rectangle area = table.getClientArea();

    Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    int width = area.width - 2*table.getBorderWidth();

    if (preferredSize.y > area.height + table.getHeaderHeight()) {
        // Subtract the scrollbar width from the total column width
        // if a vertical scrollbar will be required
        Point vBarSize = table.getVerticalBar().getSize();
        width -= vBarSize.x;
    }

    // last column is packed, so that is the minimum. If more space is available, add it.
    if(lastColumn.getWidth() < width - columnsWidth) {
        lastColumn.setWidth(width - columnsWidth + 4);
    }
}
 
Example #14
Source File: DefinesViewer.java    From cmake4eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private TableViewer createViewer(Composite parent) {
    TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL
        | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);

    createColumns(parent, viewer);

    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    viewer.setContentProvider(new CmakeDefineTableContentProvider());
    viewer.setLabelProvider(new CmakeVariableLabelProvider());

    // Layout the viewer
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
//    gridData.horizontalSpan = 2;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    viewer.getControl().setLayoutData(gridData);
    return viewer;
  }
 
Example #15
Source File: TBXMakerDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite tparent = (Composite) super.createDialogArea(parent);
	// tparent.setLayout(new GridLayout());
	GridLayoutFactory.swtDefaults().spacing(0, 0).numColumns(1).applyTo(tparent);
	GridDataFactory.fillDefaults().hint(750, 500).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tparent);

	createMenu();
	createToolBar(tparent);

	table = new Table(tparent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
	table.setLayoutData(new GridData(GridData.FILL_BOTH));
	Composite cmpStatus = new Composite(tparent, SWT.BORDER);
	cmpStatus.setLayout(new GridLayout(2, true));
	cmpStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	lblRowCount = new Label(cmpStatus, SWT.None);
	lblRowCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblRowCount"), 0));
	lblRowCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
	lblColCount = new Label(cmpStatus, SWT.None);
	lblColCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblColCount"), 0));
	lblColCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

	tparent.layout();
	getShell().layout();
	return tparent;
}
 
Example #16
Source File: ColumnBrowserWidget.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Update the content of the widget
 */
void updateContent() {
	if (columns == null) {
		return;
	}

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

		final Table table = columns.get(i);
		final int index = table.getSelectionIndex();
		table.removeAll();
		if (table.getData() == null) {
			continue;
		}
		for (final ColumnItem c : ((ColumnItem) table.getData()).getItems()) {
			final TableItem item = new TableItem(table, SWT.NONE);
			item.setData(c);
			if (c.getText() != null) {
				item.setText(c.getText());
			}
			if (c.getImage() != null) {
				item.setImage(c.getImage());
			}
		}
		table.setSelection(index);
	}
}
 
Example #17
Source File: DualList.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Cleans the content of a table
 *
 * @param table table to be emptied
 */
private void clean(final Table table) {
	if (table == null) {
		return;
	}

	for (final TableItem item : table.getItems()) {
		item.dispose();
	}
}
 
Example #18
Source File: TaskSelectionDialog.java    From workspacemechanic with Eclipse Public License 1.0 5 votes vote down vote up
private TableColumn newTableColumn(Table table, String name, int width) {
  TableColumn tc = new TableColumn(table, SWT.NONE, 0);
  tc.setResizable(true);
  tc.setText(name);
  tc.setWidth(width);
  return tc;
}
 
Example #19
Source File: RuleDialog.java    From LogViewer with Eclipse Public License 2.0 5 votes vote down vote up
protected Table createEmptyTable(Composite composite, int horizontalSpan)
{
    Table table = new Table(composite, SWT.None);

    GridData gridData = new GridData();
    gridData.horizontalSpan = horizontalSpan;
    gridData.verticalSpan = 1;
    gridData.widthHint = 1;
    gridData.heightHint = 1;
    table.setLayoutData(gridData);
    table.setBackground (composite.getBackground());
    return table;
}
 
Example #20
Source File: WriteToLogDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wLoglevel.select( input.getLogLevelByDesc().getLevel() );

  wPrintHeader.setSelection( input.isdisplayHeader() );
  wLimitRows.setSelection( input.isLimitRows() );
  wLimitRowsNumber.setText( "" + input.getLimitRowsNumber() );

  if ( input.getLogMessage() != null ) {
    wLogMessage.setText( input.getLogMessage() );
  }

  Table table = wFields.table;
  if ( input.getFieldName().length > 0 ) {
    table.removeAll();
  }
  for ( int i = 0; i < input.getFieldName().length; i++ ) {
    TableItem ti = new TableItem( table, SWT.NONE );
    ti.setText( 0, "" + ( i + 1 ) );
    ti.setText( 1, input.getFieldName()[i] );
  }

  wFields.setRowNums();
  wFields.optWidth( true );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example #21
Source File: EdgeDisplayTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private void setSortColumn(
    TableColumn column, int colIndex, int direction) {

  ViewerComparator sorter = buildColumnSorter(colIndex);
  if (SWT.UP == direction) {
    sorter = new InverseSorter(sorter);
  }

  Table tableControl = (Table) propViewer.getControl();
  propViewer.setComparator(sorter);
  tableControl.setSortColumn(column);
  tableControl.setSortDirection(direction);
}
 
Example #22
Source File: CSV2TMXConverterDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite tparent = (Composite) super.createDialogArea(parent);
	GridLayoutFactory.swtDefaults().spacing(0, 0).numColumns(1).applyTo(tparent);
	GridDataFactory.fillDefaults().hint(750, 500).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tparent);

	createMenu();
	createToolBar(tparent);

	table = new Table(tparent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
	table.setLayoutData(new GridData(GridData.FILL_BOTH));
	Composite cmpStatus = new Composite(tparent, SWT.BORDER);
	cmpStatus.setLayout(new GridLayout(2, true));
	cmpStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	lblRowCount = new Label(cmpStatus, SWT.None);
	lblRowCount.setText(MessageFormat.format(Messages.getString("dialog.CSV2TMXConverterDialog.lblRowCount"), 0));
	lblRowCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
	lblColCount = new Label(cmpStatus, SWT.None);
	lblColCount.setText(MessageFormat.format(Messages.getString("dialog.CSV2TMXConverterDialog.lblColCount"), 0));
	lblColCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

	tparent.layout();
	getShell().layout();
	return tparent;
}
 
Example #23
Source File: RelationSetTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private void setSortColumn(
    TableColumn column, int colIndex, int direction) {

  ViewerComparator sorter = buildColumnSorter(colIndex);
  if (SWT.UP == direction) {
    sorter = new InverseSorter(sorter);
  }

  Table tableControl = (Table) relSetViewer.getControl();
  relSetViewer.setComparator(sorter);
  tableControl.setSortColumn(column);
  tableControl.setSortDirection(direction);
}
 
Example #24
Source File: ChangePathsFlatViewer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void inputChanged(Object input, Object oldInput) {
  super.inputChanged(input, oldInput);
  this.currentLogEntry = (ILogEntry) input;

  TableItem[] items = ((Table) getControl()).getItems();
  if (items != null && items.length > 0) {
    setSelection(new StructuredSelection(items[0]));
    ((Table) getControl()).showSelection();
  }
}
 
Example #25
Source File: DetectorConfigurationTab.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @param sorter
 * @param column
 */
private void addColumnSelectionListener(final BugPatternTableSorter sorter, final TableColumn column, final COLUMN columnId) {
    column.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            sorter.setSortColumnIndex(columnId);
            Table factoriesTable = availableFactoriesTableViewer.getTable();
            factoriesTable.setSortDirection(sorter.revertOrder ? SWT.UP : SWT.DOWN);
            factoriesTable.setSortColumn(column);
            availableFactoriesTableViewer.refresh();
        }
    });
}
 
Example #26
Source File: FilterTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
public FilterTableControl(Composite parent) {
  super(parent, SWT.NONE);
  setLayout(Widgets.buildContainerLayout(1));

  filterViewer = 
      new TableViewer(this, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI );

  // Set up layout properties.
  Table filterTable = filterViewer.getTable();
  filterTable.setLayoutData(Widgets.buildGrabFillData());

  // Initialize the table.
  filterTable.setHeaderVisible(true);
  filterTable.setToolTipText("Node Filter Editor");
  EditColTableDef.setupTable(TABLE_DEF, filterTable);

  CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length];
  cellEditors[INDEX_NAME] = new TextCellEditor(filterTable);
  cellEditors[INDEX_SUMMARY] = new NodeFilterCellEditor(filterTable);

  // Configure table properties.
  filterViewer.setCellEditors(cellEditors);
  filterViewer.setLabelProvider(LABEL_PROVIDER);
  filterViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF));
  filterViewer.setCellModifier(new ControlCellModifier());

  // Since the order is significant, no sorting capabilities.

  // Avoid setInput() invocations that come with
  // TableContentProvider.initViewer
  filterViewer.setContentProvider(ArrayContentProvider.getInstance());
}
 
Example #27
Source File: SWTUtil.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static int getTableHeightHint(Table table, int rows) {
	if (table.getFont().equals(JFaceResources.getDefaultFont()))
		table.setFont(JFaceResources.getDialogFont());
	int result = table.getItemHeight() * rows + table.getHeaderHeight();
	if (table.getLinesVisible())
		result += table.getGridLineWidth() * (rows - 1);
	return result;
}
 
Example #28
Source File: GitRepositoryPreferencePageView.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * @param parent a widget which will be the parent of the new instance (cannot
 *               be null)
 * @param style  the style of widget to construct
 */
public GitRepositoryPreferencePageView(Composite parent, int style) {
	super(parent, style);
	final TableColumnLayout tableColumnLayout = new TableColumnLayout();
	setLayout(tableColumnLayout);

	tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
	final Table table = tableViewer.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(true);

	columnRepository = new TableViewerColumn(tableViewer, SWT.NONE);
	TableColumn colRepository = columnRepository.getColumn();
	tableColumnLayout.setColumnData(colRepository, new ColumnWeightData(1));
	colRepository.setText("Repository");

	columnLocalPath = new TableViewerColumn(tableViewer, SWT.NONE);
	TableColumn colLocalPath = columnLocalPath.getColumn();
	tableColumnLayout.setColumnData(colLocalPath, new ColumnWeightData(1));
	colLocalPath.setText("Local Path");

	columnMemory = new TableViewerColumn(tableViewer, SWT.RIGHT);
	TableColumn colMemory = columnMemory.getColumn();
	tableColumnLayout.setColumnData(colMemory, new ColumnPixelData(80, true, true));
	colMemory.setText("Memory");

	final Menu menu = new Menu(tableViewer.getTable());
	menuItemGoToRepository = new MenuItem(menu, SWT.NONE);
	menuItemGoToRepository.setText("Go to Repository");
	tableViewer.getTable().setMenu(menu);
}
 
Example #29
Source File: PreMachineTranslationDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建页面内容
 * @param parent
 *            ;
 */
private void createInputPageContent(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	GridLayout gl_composite = new GridLayout(1, false);
	gl_composite.marginHeight = 0;
	gl_composite.marginWidth = 0;
	gl_composite.verticalSpacing = 0;
	composite.setLayout(gl_composite);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	viewer = new TableViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
	final Table table = viewer.getTable();
	GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	tableGd.heightHint = 220;
	table.setLayoutData(tableGd);

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

	String[] clmnTitles = new String[] { Messages.getString("dialog.PreTranslationDialog.clmnTitles1"),
			Messages.getString("dialog.PreTranslationDialog.clmnTitles2"),
			Messages.getString("dialog.PreTranslationDialog.clmnTitles3"),
			Messages.getString("dialog.PreTranslationDialog.clmnTitles4") };
	int[] clmnBounds = { 80, 250, 100, 100 };
	for (int i = 0; i < clmnTitles.length; i++) {
		createTableViewerColumn(viewer, clmnTitles[i], clmnBounds[i], i);
	}

	viewer.setLabelProvider(new TableViewerLabelProvider());
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setInput(this.getTableViewerInput());

}
 
Example #30
Source File: ModelSortPageableTableExample.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(String[] args) {

		Display display = new Display();
		Shell shell = new Shell(display);
		GridLayout layout = new GridLayout(1, false);
		shell.setLayout(layout);

		final List<Person> items = createList();

		// 1) Create pageable table with 10 items per page
		// This SWT Component create internally a SWT Table+JFace TreeViewer
		int pageSize = 10;
		PageableTable pageableTable = new PageableTable(shell, SWT.BORDER,
				SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, pageSize);
		pageableTable.setLayoutData(new GridData(GridData.FILL_BOTH));

		// 2) Initialize the table viewer + SWT Table
		TableViewer viewer = pageableTable.getViewer();
		viewer.setContentProvider(ArrayContentProvider.getInstance());
		viewer.setLabelProvider(new LabelProvider());

		Table table = viewer.getTable();
		table.setHeaderVisible(true);
		table.setLinesVisible(true);

		// 3) Create Table columns with sort of paginated list.
		createColumns(viewer);

		// 3) Set current page to 0 to refresh the table
		pageableTable.setPageLoader(new PageResultLoaderList<Person>(items));
		pageableTable.setCurrentPage(0);

		shell.setSize(400, 250);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}