org.eclipse.swt.widgets.Table#setHeaderVisible ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Table#setHeaderVisible ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cmake4eclipse   文件: DefinesViewer.java
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;
  }
 
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"));
}
 
源代码3 项目: olca-app   文件: ProcessSearchPage.java
private void createResultSection(Composite container) {
	Composite composite = new Composite(container, SWT.NONE);
	composite.setLayout(new GridLayout(1, false));
	UI.gridData(composite, true, true);
	Table table = new Table(composite, SWT.MULTI | SWT.H_SCROLL
			| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
	UI.gridData(table, true, true);
	table.setHeaderVisible(true);
	table.setLinesVisible(false);
	viewer = new SearchResultViewer(table);
	viewer.addSelectionChangedListener((event) -> {
		ISelection selection = event.getSelection();
		if (selection == null || selection.isEmpty()) {
			setPageComplete(false);
		} else {
			setPageComplete(true);
		}
	});
}
 
源代码4 项目: bonita-studio   文件: UsersWizardPage.java
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);
}
 
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);
	container.setLayout(new GridLayout(1, false));

	Composite composite = new Composite(container, SWT.NONE);
	GridLayout gl_composite = new GridLayout(1, false);
	gl_composite.verticalSpacing = 0;
	gl_composite.marginWidth = 0;
	gl_composite.marginHeight = 0;
	composite.setLayout(gl_composite);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
	Table table = tableViewer.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.PreTranslationResultDialog.clmnTitles1"),
			Messages.getString("dialog.PreTranslationResultDialog.clmnTitles2"),
			Messages.getString("dialog.PreTranslationResultDialog.clmnTitles3"),
			Messages.getString("dialog.PreTranslationResultDialog.clmnTitles4"),
			Messages.getString("dialog.PreTranslationResultDialog.clmnTitles5"),
			Messages.getString("dialog.PreTranslationResultDialog.clmnTitles6") };
	int[] clmnBounds = { 60, 200, 100, 110, 110, 110 };
	for (int i = 0; i < clmnTitles.length; i++) {
		createTableViewerColumn(tableViewer, clmnTitles[i], clmnBounds[i], i);
	}

	tableViewer.setLabelProvider(new TableViewerLabelProvider());
	tableViewer.setContentProvider(new ArrayContentProvider());
	tableViewer.setInput(this.getTableViewerInput());
	return container;
}
 
源代码6 项目: scava   文件: MetricDisplay.java
@Override
protected Control createDialogArea(Composite parent) {

	setTitleImage(null);
	setTitle("Metric informations");
	Composite area = (Composite) super.createDialogArea(parent);
	area.setLayout(new GridLayout(1, false));

	Composite textContainer = new Composite(area, SWT.NONE);
	textContainer.setLayout(new FillLayout(SWT.HORIZONTAL));
	textContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));

	table = new Table(textContainer, SWT.BORDER | SWT.FULL_SELECTION);
	table.setLinesVisible(true);
	table.setHeaderVisible(true);

	TableColumn tblclmnNewColumn = new TableColumn(table, SWT.NONE);
	tblclmnNewColumn.setWidth(300);
	tblclmnNewColumn.setText("ID");

	TableColumn tblclmnNewColumn_1 = new TableColumn(table, SWT.NONE);
	tblclmnNewColumn_1.setWidth(100);
	tblclmnNewColumn_1.setText("Value");
	
	TableColumn tblclmnNewColumn_2 = new TableColumn(table, SWT.NONE);
	tblclmnNewColumn_2.setWidth(300);
	tblclmnNewColumn_2.setText("Description");
	

	progressBar = new ProgressBar(area, SWT.SMOOTH);
	progressBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

	refreshMetrics();

	return area;
}
 
源代码7 项目: tm4e   文件: TableAndButtonsWidget.java
private void createTable(Composite parent) {
	Table table = new Table(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
	table.setHeaderVisible(false);
	table.setLinesVisible(false);

	viewer = new TableViewer(table);
	table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	
}
 
源代码8 项目: ice   文件: MOOSETreePropertySection.java
/**
 * Creates the table that displays properties for viewing and editing.
 * 
 * @param client
 *            The client <code>Composite</code> that should contain the
 *            table of properties.
 * @return The <code>TableViewer</code> for the table of properties.
 */
@Override
protected TableViewer createTableViewer(Composite client) {

	CheckboxTableViewer tableViewer = null;

	if (client != null) {
		Table table;

		// Create the TableViewer and the underlying Table Control.
		tableViewer = CheckboxTableViewer.newCheckList(client,
				SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
		// Set some properties for the table.
		table = tableViewer.getTable();
		table.setHeaderVisible(true);
		table.setLinesVisible(true);

		// Set up the content provider for the table viewer. Now the table
		// viewer's input can be set.
		tableViewer.setContentProvider(new TreePropertyContentProvider());

		// Enable tool tips for the Table's cells.
		ColumnViewerToolTipSupport.enableFor(tableViewer,
				ToolTip.NO_RECREATE);

		// Populate the TableViewer with its columns.
		addTableViewerColumns(tableViewer);
	}

	return tableViewer;
}
 
源代码9 项目: ermasterr   文件: TestDataDialog.java
private void createSelectedTableTable(final Composite composite) {
    final GridData gridData = new GridData();
    gridData.verticalSpan = 2;
    gridData.grabExcessVerticalSpace = true;
    gridData.verticalAlignment = GridData.FILL;

    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;

    final Group group = new Group(composite, SWT.NONE);
    group.setText(ResourceString.getResourceString("label.testdata.table.list"));
    group.setLayout(gridLayout);
    group.setLayoutData(gridData);

    final GridData tableGridData = new GridData();
    tableGridData.grabExcessVerticalSpace = true;
    tableGridData.verticalAlignment = GridData.FILL;
    tableGridData.widthHint = 300;
    tableGridData.verticalSpan = 2;

    selectedTableTable = new Table(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);
    selectedTableTable.setHeaderVisible(false);
    selectedTableTable.setLayoutData(tableGridData);
    selectedTableTable.setLinesVisible(false);

    final TableColumn tableColumn = new TableColumn(selectedTableTable, SWT.CENTER);
    tableColumn.setWidth(200);
    tableColumn.setText(ResourceString.getResourceString("label.testdata.table.name"));

    final TableColumn numColumn = new TableColumn(selectedTableTable, SWT.CENTER);
    numColumn.setWidth(80);
    numColumn.setText(ResourceString.getResourceString("label.testdata.table.test.num"));
}
 
源代码10 项目: nebula   文件: ModelSortPageableTableExample.java
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();
	}
 
源代码11 项目: nebula   文件: DualList.java
/**
 * @return a table that will contain data
 */
private Table createTable() {
	final Table table = new Table(this, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
	table.setLinesVisible(false);
	table.setHeaderVisible(false);
	final GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true, 1, 4);
	gd.widthHint = 200;
	table.setLayoutData(gd);
	new TableColumn(table, SWT.CENTER);
	new TableColumn(table, SWT.LEFT);
	table.setData(-1);
	return table;
}
 
源代码12 项目: gama   文件: MaplayerTableViewer.java
/**
 * Constructor.
 *
 * <p>
 * <b>Note</b> that after the object is built and before actually using it, the has to be set through the method.
 * </p>
 *
 * @param parent
 * @param style
 */
public MaplayerTableViewer(final Composite parent, final int style) {
	super(parent, style);

	this.setContentProvider(new ArrayContentProvider());
	this.addSelectionChangedListener(this);

	createColumns(parent, this);
	final Table table = this.getTable();
	table.setHeaderVisible(true);
	// table.setLinesVisible(true);

	this.setInput(layersList);
}
 
源代码13 项目: APICloud-Studio   文件: TasksPreferencePage.java
/**
 * @param parent
 */
private void createTaskTableArea(Composite parent)
{
	fTasksTableViewer = new TableViewer(parent, SWT.BORDER | SWT.SINGLE);
	Table table = fTasksTableViewer.getTable();
	table.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	table.setFont(parent.getFont());

	TableColumn tagNameColumn = new TableColumn(table, SWT.NONE);
	tagNameColumn.setText(Messages.TasksPreferencePage_TagNameColumnHeader);
	tagNameColumn.setWidth(100);
	TableColumn tagPriorityColumn = new TableColumn(table, SWT.NONE);
	tagPriorityColumn.setText(Messages.TasksPreferencePage_PriorityColumnHeader);
	tagPriorityColumn.setWidth(100);

	fTasksTableViewer.setContentProvider(ArrayContentProvider.getInstance());
	fTasksTableViewer.setLabelProvider(new TaskLabelProvider());
	fTasksTableViewer.setComparator(new ViewerComparator());
	fTasksTableViewer.setInput(getTaskTags());

	fTasksTableViewer.addSelectionChangedListener(new ISelectionChangedListener()
	{
		public void selectionChanged(SelectionChangedEvent event)
		{
			// Enable/disable buttons
			updateButtonStates();
		}
	});

	createTaskButtons(parent);
}
 
源代码14 项目: birt   文件: ExtendedPropertyEditorComposite.java
private void placeComponents( )
{
	GridLayout glContent = new GridLayout( );
	glContent.horizontalSpacing = 5;
	glContent.verticalSpacing = 5;
	glContent.marginHeight = 7;
	glContent.marginWidth = 7;

	this.setLayout( glContent );

	table = new Table( this, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER );
	GridData gdTable = new GridData( GridData.FILL_BOTH );
	table.setLayoutData( gdTable );
	table.setHeaderVisible( true );
	table.setLinesVisible( true );

	TableColumn tcKey = new TableColumn( table, SWT.CENTER );
	tcKey.setWidth( 186 );
	tcKey.setText( Messages.getString( "PropertyEditorDialog.Lbl.Key" ) ); //$NON-NLS-1$

	TableColumn tcValue = new TableColumn( table, SWT.LEFT );
	tcValue.setWidth( 186 );
	tcValue.setText( Messages.getString( "PropertyEditorDialog.Lbl.Value" ) ); //$NON-NLS-1$

	editorValue = new TableEditor( table );
	editorValue.setColumn( 1 );
	editorValue.grabHorizontal = true;
	editorValue.minimumWidth = 30;

	table.addSelectionListener( this );

	// Layout for buttons panel
	GridLayout glButtons = new GridLayout( );
	glButtons.numColumns = 3;
	glButtons.horizontalSpacing = 5;
	glButtons.verticalSpacing = 5;
	glButtons.marginWidth = 0;
	glButtons.marginHeight = 0;

	Composite cmpButtons = new Composite( this, SWT.NONE );
	GridData gdCMPButtons = new GridData( GridData.FILL_HORIZONTAL );
	cmpButtons.setLayoutData( gdCMPButtons );
	cmpButtons.setLayout( glButtons );

	txtNewKey = new Text( cmpButtons, SWT.SINGLE | SWT.BORDER );
	GridData gdTXTNewKey = new GridData( GridData.FILL_HORIZONTAL );
	gdTXTNewKey.grabExcessHorizontalSpace = true;
	txtNewKey.setLayoutData( gdTXTNewKey );

	btnAdd = new Button( cmpButtons, SWT.PUSH );
	GridData gdBTNAdd = new GridData( GridData.HORIZONTAL_ALIGN_END );
	gdBTNAdd.grabExcessHorizontalSpace = false;
	btnAdd.setLayoutData( gdBTNAdd );
	btnAdd.setText( Messages.getString( "PropertyEditorDialog.Lbl.Add" ) ); //$NON-NLS-1$
	btnAdd.addSelectionListener( this );

	btnRemove = new Button( cmpButtons, SWT.PUSH );
	GridData gdBTNRemove = new GridData( GridData.HORIZONTAL_ALIGN_END );
	gdBTNRemove.grabExcessHorizontalSpace = false;
	btnRemove.setLayoutData( gdBTNRemove );
	btnRemove.setText( Messages.getString( "PropertyEditorDialog.Lbl.Remove" ) ); //$NON-NLS-1$
	btnRemove.addSelectionListener( this );

	populateTable( );
}
 
@Override
protected void initialize(final Composite composite) {
    CompositeFactory.createLabel(composite, "label.tablespace.size.calculate.1", 3);

    restoreDefaultButton1 = new Button(composite, SWT.NONE);
    restoreDefaultButton1.setText(ResourceString.getResourceString("label.restore.default"));

    CompositeFactory.filler(composite, 1, INDENT);
    kcbhText = CompositeFactory.createNumText(this, composite, "KCBH", 1, NUM_WIDTH);
    CompositeFactory.filler(composite, 1);

    CompositeFactory.filler(composite, 1, INDENT);
    ub4Text = CompositeFactory.createNumText(this, composite, "UB4", 1, NUM_WIDTH);
    CompositeFactory.filler(composite, 1);

    CompositeFactory.filler(composite, 1, INDENT);
    ktbbhText = CompositeFactory.createNumText(this, composite, "KTBBH", 1, NUM_WIDTH);
    CompositeFactory.filler(composite, 1);

    CompositeFactory.filler(composite, 1, INDENT);
    ktbitText = CompositeFactory.createNumText(this, composite, "KTBIT", 1, NUM_WIDTH);
    CompositeFactory.filler(composite, 1);

    CompositeFactory.filler(composite, 1);
    kdbhText = CompositeFactory.createNumText(this, composite, "KDBH", 1, NUM_WIDTH);
    CompositeFactory.filler(composite, 1);

    CompositeFactory.filler(composite, 1, INDENT);
    kdbtText = CompositeFactory.createNumText(this, composite, "KDBT", 1, NUM_WIDTH);
    CompositeFactory.filler(composite, 1);

    CompositeFactory.filler(composite, 1);
    ub1Text = CompositeFactory.createNumText(this, composite, "UB1", 1, NUM_WIDTH);
    CompositeFactory.filler(composite, 1);

    CompositeFactory.filler(composite, 1, INDENT);
    sb2Text = CompositeFactory.createNumText(this, composite, "SB2", 1, NUM_WIDTH);
    CompositeFactory.filler(composite, 1);

    CompositeFactory.filler(composite, 4);

    CompositeFactory.createLabel(composite, "label.tablespace.size.calculate.2", 3);
    restoreDefaultButton2 = new Button(composite, SWT.NONE);
    restoreDefaultButton2.setText(ResourceString.getResourceString("label.restore.default"));

    CompositeFactory.filler(composite, 1, INDENT);
    dbBlockSizeText = CompositeFactory.createNumText(this, composite, "DB_BLOCK_SIZE", 1, NUM_WIDTH);
    CompositeFactory.filler(composite, 1);

    CompositeFactory.filler(composite, 4);

    CompositeFactory.createLabel(composite, "label.tablespace.size.calculate.3", 4);

    CompositeFactory.filler(composite, 4);

    final GridData tableGridData = new GridData();
    tableGridData.horizontalSpan = 4;
    tableGridData.horizontalAlignment = GridData.FILL;
    tableGridData.grabExcessHorizontalSpace = true;
    tableGridData.heightHint = 100;

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

    final TableColumn tableLogicalName = new TableColumn(tableTable, SWT.NONE);
    tableLogicalName.setWidth(NAME_WIDTH);
    tableLogicalName.setText(ResourceString.getResourceString("label.table.logical.name"));

    final TableColumn num = new TableColumn(tableTable, SWT.RIGHT);
    num.setWidth(TABLE_NUM_WIDTH);
    num.setText(ResourceString.getResourceString("label.record.num"));

    tableEditor = new TableEditor(tableTable);
    tableEditor.grabHorizontal = true;

    CompositeFactory.createLabel(composite, "label.tablespace.size.calculated", 2);

    tablespaceSizeText = new Text(composite, SWT.BORDER | SWT.READ_ONLY | SWT.RIGHT);
    final GridData textGridData = new GridData();
    textGridData.horizontalAlignment = GridData.FILL;
    textGridData.grabExcessHorizontalSpace = true;
    tablespaceSizeText.setLayoutData(textGridData);

    CompositeFactory.filler(composite, 1);
}
 
源代码16 项目: birt   文件: ResultSetPreviewPage.java
public Control createPageControl( Composite parent )
{
	Composite resultSetComposite = new Composite( parent, SWT.NONE );
	GridLayout layout = new GridLayout( );
	layout.verticalSpacing = 15;
	resultSetComposite.setLayout( layout );
	resultSetComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	resultSetTable = new Table( resultSetComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.VIRTUAL | SWT.BORDER );
	resultSetTable.setHeaderVisible( true );
	resultSetTable.setLinesVisible( true );
	resultSetTable.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	( (DataSetHandle) getContainer( ).getModel( ) ).addListener( this );

	resultSetTable.addMouseListener( new MouseAdapter( ) {

		public void mouseUp( MouseEvent e )
		{
			// if not mouse left button
			if ( e.button != 1 )
			{
				MenuManager menuManager = new MenuManager( );

				ResultSetTableAction copyAction = ResultSetTableActionFactory.createResultSetTableAction( resultSetTable,
						ResultSetTableActionFactory.COPY_ACTION );
				ResultSetTableAction selectAllAction = ResultSetTableActionFactory.createResultSetTableAction( resultSetTable,
						ResultSetTableActionFactory.SELECTALL_ACTION );
				menuManager.add( copyAction );
				menuManager.add( selectAllAction );

				menuManager.update( );

				copyAction.update( );
				selectAllAction.update( );

				Menu contextMenu = menuManager.createContextMenu( resultSetTable );

				contextMenu.setEnabled( true );
				contextMenu.setVisible( true );
			}
		}
	} );

	createResultSetTableViewer( );
	promptLabel = new CLabel( resultSetComposite, SWT.WRAP );
	GridData labelData = new GridData( GridData.FILL_HORIZONTAL );
	promptLabel.setLayoutData( labelData );
	
	return resultSetComposite;
}
 
源代码17 项目: ermaster-b   文件: ModelPropertiesDialog.java
/**
 * This method initializes composite1
 * 
 */
private void createTableComposite(Composite parent) {
	GridLayout gridLayout = new GridLayout();
	gridLayout.numColumns = 3;

	GridData gridData = new GridData();
	gridData.heightHint = 320;

	GridData tableGridData = new GridData();
	tableGridData.horizontalSpan = 3;
	tableGridData.heightHint = 185;

	Composite composite = new Composite(parent, SWT.BORDER);
	composite.setLayout(gridLayout);
	composite.setLayoutData(gridData);

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

	TableColumn tableColumn0 = new TableColumn(table, SWT.NONE);
	tableColumn0.setWidth(200);
	tableColumn0.setText(ResourceString
			.getResourceString("label.property.name"));
	TableColumn tableColumn1 = new TableColumn(table, SWT.NONE);
	tableColumn1.setWidth(200);
	tableColumn1.setText(ResourceString
			.getResourceString("label.property.value"));

	this.tableEditor = new TableEditor(table);
	this.tableEditor.grabHorizontal = true;

	this.table.addMouseListener(new MouseAdapter() {

		@Override
		public void mouseDown(MouseEvent event) {
			int index = table.getSelectionIndex();
			if (index == -1) {
				return;
			}

			TableItem item = table.getItem(index);
			Point selectedPoint = new Point(event.x, event.y);

			targetColumn = -1;

			for (int i = 0; i < table.getColumnCount(); i++) {
				Rectangle rect = item.getBounds(i);
				if (rect.contains(selectedPoint)) {
					targetColumn = i;
					break;
				}
			}

			if (targetColumn == -1) {
				return;
			}

			edit(item, tableEditor);
		}

	});
}
 
源代码18 项目: ermasterr   文件: EditAllAttributesDialog.java
/**
 * This method initializes composite2
 */
private void createTable(final Composite composite) {
    final GridData tableGridData = new GridData();
    tableGridData.horizontalSpan = 3;
    tableGridData.heightHint = 400;
    tableGridData.horizontalAlignment = GridData.FILL;
    tableGridData.grabExcessHorizontalSpace = true;

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

    final TableColumn columnLogicalName = new TableColumn(attributeTable, SWT.NONE);
    columnLogicalName.setWidth(NAME_WIDTH);
    columnLogicalName.setText(ResourceString.getResourceString("label.column.logical.name"));

    final TableColumn columnPhysicalName = new TableColumn(attributeTable, SWT.NONE);
    columnPhysicalName.setWidth(NAME_WIDTH);
    columnPhysicalName.setText(ResourceString.getResourceString("label.column.physical.name"));

    final TableColumn tableLogicalName = new TableColumn(attributeTable, SWT.NONE);
    tableLogicalName.setWidth(NAME_WIDTH);
    tableLogicalName.setText(ResourceString.getResourceString("label.table.logical.name"));

    final TableColumn tablePhysicalName = new TableColumn(attributeTable, SWT.NONE);
    tablePhysicalName.setWidth(NAME_WIDTH);
    tablePhysicalName.setText(ResourceString.getResourceString("label.table.physical.name"));

    final TableColumn tableWord = new TableColumn(attributeTable, SWT.NONE);
    tableWord.setWidth(NAME_WIDTH);
    tableWord.setText(ResourceString.getResourceString("label.word"));

    final TableColumn columnType = new TableColumn(attributeTable, SWT.NONE);
    columnType.setWidth(TYPE_WIDTH);
    columnType.setText(ResourceString.getResourceString("label.column.type"));

    final TableColumn columnLength = new TableColumn(attributeTable, SWT.RIGHT);
    columnLength.setWidth(TYPE_WIDTH);
    columnLength.setText(ResourceString.getResourceString("label.column.length"));

    final TableColumn columnDecimal = new TableColumn(attributeTable, SWT.RIGHT);
    columnDecimal.setWidth(TYPE_WIDTH);
    columnDecimal.setText(ResourceString.getResourceString("label.column.decimal"));

    final TableColumn columnKey = new TableColumn(attributeTable, SWT.CENTER);
    columnKey.setText("PK");
    columnKey.setWidth(KEY_WIDTH);
    new CenteredContentCellPaint(attributeTable, 8);

    final TableColumn columnForeignKey = new TableColumn(attributeTable, SWT.CENTER);
    columnForeignKey.setText("FK");
    columnForeignKey.setWidth(KEY_WIDTH);
    new CenteredContentCellPaint(attributeTable, 9);

    final TableColumn columnNotNull = new TableColumn(attributeTable, SWT.CENTER);
    columnNotNull.setWidth(NOT_NULL_WIDTH);
    columnNotNull.setText(ResourceString.getResourceString("label.not.null"));
    new CenteredContentCellPaint(attributeTable, 10);

    final TableColumn columnUnique = new TableColumn(attributeTable, SWT.CENTER);
    columnUnique.setWidth(UNIQUE_KEY_WIDTH);
    columnUnique.setText(ResourceString.getResourceString("label.unique.key"));
    new CenteredContentCellPaint(attributeTable, 11);

    tableEditor = new TableEditor(attributeTable);
    tableEditor.grabHorizontal = true;

    ListenerAppender.addTableEditListener(attributeTable, tableEditor, this);
}
 
protected StructuredViewer createViewer(final Composite parent) {
    final Composite viewerComposite = new Composite(parent, SWT.NONE);
    viewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewerComposite.setLayout(
            GridLayoutFactory.fillDefaults().numColumns(1).equalWidth(true).margins(0, 0).spacing(0, 5).create());

    final Text searchBox = new Text(viewerComposite, SWT.SEARCH | SWT.ICON_SEARCH | SWT.BORDER | SWT.CANCEL);
    searchBox.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    searchBox.setMessage(Messages.search);

    final Composite tableViewerComposite = new Composite(viewerComposite, SWT.NONE);
    tableViewerComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create());
    tableViewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final TableViewer tableViewer = new TableViewer(tableViewerComposite,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    final Table table = tableViewer.getTable();
    table.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 270).create());
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
            return viewerSelect(element, searchQuery);
        }
    });

    searchBox.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            searchQuery = searchBox.getText();
            tableViewer.refresh();
        }

    });

    return tableViewer;
}
 
源代码20 项目: spotbugs   文件: DetectorConfigurationTab.java
/**
 * Build rule table viewer
 */
private Table createDetectorsTableViewer(Composite parent, IProject project) {
    final BugPatternTableSorter sorter = new BugPatternTableSorter(this);

    int tableStyle = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION | SWT.CHECK;
    availableFactoriesTableViewer = CheckboxTableViewer.newCheckList(parent, tableStyle);
    availableFactoriesTableViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            syncUserPreferencesWithTable();
        }
    });

    int currentColumnIdx = 0;
    Table factoriesTable = availableFactoriesTableViewer.getTable();

    TableColumn factoryNameColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.detectorName"), 230,
            COLUMN.DETECTOR_NAME);
    addColumnSelectionListener(sorter, factoryNameColumn, COLUMN.DETECTOR_NAME);

    currentColumnIdx++;
    TableColumn bugsAbbrevColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.bugCodes"), 75,
            COLUMN.BUG_CODES);
    addColumnSelectionListener(sorter, bugsAbbrevColumn, COLUMN.BUG_CODES);

    currentColumnIdx++;
    TableColumn speedColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.speed"), 70,
            COLUMN.DETECTOR_SPEED);
    addColumnSelectionListener(sorter, speedColumn, COLUMN.DETECTOR_SPEED);

    currentColumnIdx++;
    TableColumn pluginColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.provider"), 100,
            COLUMN.PLUGIN);
    addColumnSelectionListener(sorter, pluginColumn, COLUMN.PLUGIN);

    currentColumnIdx++;
    TableColumn categoryColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.category"), 75,
            COLUMN.BUG_CATEGORIES);
    addColumnSelectionListener(sorter, categoryColumn, COLUMN.BUG_CATEGORIES);

    factoriesTable.setLinesVisible(true);
    factoriesTable.setHeaderVisible(true);
    // initial sort indicator
    factoriesTable.setSortDirection(sorter.revertOrder ? SWT.UP : SWT.DOWN);
    factoriesTable.setSortColumn(factoryNameColumn);
    sorter.setSortColumnIndex(COLUMN.DETECTOR_NAME);

    availableFactoriesTableViewer.setContentProvider(new DetectorFactoriesContentProvider());
    availableFactoriesTableViewer.setLabelProvider(new DetectorFactoryLabelProvider(this));

    availableFactoriesTableViewer.setSorter(sorter);

    populateAvailableRulesTable(project);
    factoriesTable.setEnabled(true);

    return factoriesTable;
}