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

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

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

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

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

    column.setResizable(SellOrderTable.getColumnResizable(id));
    column.setWidth(SellOrderTable.getColumnWidth(id));
  }
}
 
Example 2
Source File: 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 3
Source File: ViewAttributeList.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new column
 * @param table
 * @param name
 * @param width
 * @param provider
 */
private TableViewerColumn createColumn(PageableTable table,
                                       String name, 
                                       int width,
                                       ColumnLabelProvider provider) {
    
    TableViewerColumn column = new TableViewerColumn(table.getViewer(), SWT.NONE);
    column.setLabelProvider(provider);
    TableColumn tColumn = column.getColumn();
    tColumn.setToolTipText(name);
    tColumn.setText(name);
    tColumn.setWidth(width);
    tColumn.setResizable(true);
    return column;
}
 
Example 4
Source File: TestDataManageDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private void createRightComposite(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.BORDER);

    final GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    composite.setLayoutData(gridData);

    final GridLayout gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 8;
    composite.setLayout(gridLayout);

    final GridData tableGridData = new GridData();
    tableGridData.heightHint = GROUP_LIST_HEIGHT;
    tableGridData.verticalIndent = 15;

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

    final TableColumn nameColumn = new TableColumn(testDataTable, SWT.NONE);
    nameColumn.setWidth(300);
    nameColumn.setResizable(false);
    nameColumn.setText(ResourceString.getResourceString("label.testdata.table.name"));

    final TableColumn dataNumColumn = new TableColumn(testDataTable, SWT.RIGHT);
    dataNumColumn.setResizable(false);
    dataNumColumn.setText(ResourceString.getResourceString("label.testdata.table.test.num"));
    dataNumColumn.pack();
}
 
Example 5
Source File: JDBCPreferencePage.java    From erflute with Apache License 2.0 5 votes vote down vote up
private void initTable(Composite parent) {
    this.table = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);

    final GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 200;
    gridData.horizontalSpan = 3;

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

    final TableColumn nameColumn = new TableColumn(table, SWT.NONE);
    nameColumn.setText(DisplayMessages.getMessage("label.database"));
    nameColumn.setWidth(200);

    final TableColumn driverClassNameColumn = new TableColumn(table, SWT.NONE);
    driverClassNameColumn.setText(DisplayMessages.getMessage("label.driver.class.name"));
    driverClassNameColumn.setWidth(200);

    final TableColumn pathColumn = new TableColumn(table, SWT.NONE);
    pathColumn.setText(DisplayMessages.getMessage("label.path"));
    pathColumn.setWidth(200);

    setData();
}
 
Example 6
Source File: MaplayerTableViewer.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private TableViewerColumn createTableViewerColumn(final String title, final int bound, final int colNumber) {
	final TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE);
	final TableColumn column = viewerColumn.getColumn();
	column.setText(title);
	column.setWidth(bound);
	column.setResizable(true);
	column.setMoveable(true);
	return viewerColumn;
}
 
Example 7
Source File: DefinesViewer.java    From cmake4eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a table viewer column for the table.
 */
private TableViewerColumn createTableViewerColumn(final TableViewer viewer,
    String title, int colWidth, final int colNumber) {
  final TableViewerColumn viewerColumn = new TableViewerColumn(viewer,
      SWT.NONE);
  final TableColumn column = viewerColumn.getColumn();
  column.setText(title);
  column.setWidth(colWidth);
  column.setResizable(true);
  column.setMoveable(true);
  column.addSelectionListener(createSelectionAdapter(column, colNumber));
  return viewerColumn;
}
 
Example 8
Source File: QueryDataView.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void setDataSize ( final int entries, final Set<String> valueTypes )
{
    clearDataSize ();

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

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

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

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

    for ( int i = 0; i < entries; i++ )
    {
        final TableItem item = this.table.getItem ( i );
        item.setBackground ( this.invalidColor );
        item.setText ( 0, String.format ( Messages.QueryDataView_Format_Index, i ) );
    }
}
 
Example 9
Source File: PyEditorHoverConfigurationBlock.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void showColumn(TableColumn column, boolean show) {
    if (column.getWidth() != 0) {
        fColWidthsMap.put(column, column.getWidth());
    }
    if (fColWidthsMap.get(column) != null) {
        column.setWidth(show ? fColWidthsMap.get(column) : 0);
    }
}
 
Example 10
Source File: IndexTabWrapper.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
private void setTableData() {
	List<Index> indexes = this.copyData.getIndexes();

	TableItem radioTableItem = new TableItem(this.indexTable, SWT.NONE);

	for (int i = 0; i < indexes.size(); i++) {
		TableColumn tableColumn = new TableColumn(this.indexTable,
				SWT.CENTER);
		tableColumn.setWidth(60);
		tableColumn.setResizable(false);
		tableColumn.setText("Index" + (i + 1));

		TableEditor editor = new TableEditor(this.indexTable);

		Button radioButton = new Button(this.indexTable, SWT.RADIO);
		radioButton.addSelectionListener(new SelectionAdapter() {

			/**
			 * {@inheritDoc}
			 */
			@Override
			public void widgetSelected(SelectionEvent event) {
				setButtonEnabled(true);
			}
		});

		radioButton.pack();

		editor.minimumWidth = radioButton.getSize().x;
		editor.horizontalAlignment = SWT.CENTER;
		editor.setEditor(radioButton, radioTableItem, i + 2);

		this.checkButtonList.add(radioButton);
		this.editorList.add(editor);
	}

	for (NormalColumn normalColumn : this.copyData.getExpandedColumns()) {
		TableItem tableItem = new TableItem(this.indexTable, SWT.NONE);
		tableItem.setText(0, Format.null2blank(normalColumn.getName()));

		for (int i = 0; i < indexes.size(); i++) {
			Index index = indexes.get(i);

			List<NormalColumn> indexColumns = index.getColumns();
			for (int j = 0; j < indexColumns.size(); j++) {
				NormalColumn indexColumn = indexColumns.get(j);

				if (normalColumn.equals(indexColumn)) {
					tableItem.setText(i + 2, String.valueOf(j + 1));
					break;
				}
			}
		}
	}

	setButtonEnabled(false);
}
 
Example 11
Source File: BibtexMergeDialog.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
private void buildPreview(Composite container) {
	GridData gridData = new GridData();
	gridData.horizontalAlignment = SWT.RIGHT;
	gridData.verticalAlignment = SWT.TOP;
	gridData.grabExcessVerticalSpace = true;
	gridData.horizontalSpan = 1;
	gridData.verticalSpan = 5;

	Composite composite = new Composite(container, SWT.NONE);
	composite.setLayout(new GridLayout(1, false));
	composite.setLayoutData(gridData);

	// create overview
	Table table = new Table(composite, SWT.BORDER);
	table.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true, 1, 1));

	TableColumn intersection = new TableColumn(table, SWT.CENTER);
	TableColumn mergeConflicts = new TableColumn(table, SWT.CENTER);
	TableColumn unionWithoutConflicts = new TableColumn(table, SWT.CENTER);
	intersection.setText("Intersection");
	mergeConflicts.setText("Merge conflicts");
	unionWithoutConflicts.setText("Union without conflicts");
	intersection.setWidth(80);
	mergeConflicts.setWidth(100);
	unionWithoutConflicts.setWidth(140);
	table.setHeaderVisible(true);

	previewStats = new TableItem(table, SWT.NONE);

	Label label = new Label(composite, SWT.NONE);
	label.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true, 1, 1));
	label.setText("Preview: ");

	preview = new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
	preview.setLayoutData(new GridData(GridData.FILL_BOTH));
	preview.setEditable(false);
	preview.setEnabled(false);
	preview.setBlockSelection(true);

	// highlight current conflict
	initializeConflictIterator();
	preview.addLineStyleListener(new LineStyleListener() {
		public void lineGetStyle(LineStyleEvent event) {
			if (currentConflictedField == null
					|| currentConflictedResource.getConflictForField(currentConflictedField) == null)
				return;

			String currentConflict = currentConflictedResource.getConflictForField(currentConflictedField);
			StyleRange styleRange = new StyleRange();
			styleRange.start = preview.getText().indexOf(currentConflict);
			styleRange.length = currentConflict.length();
			styleRange.background = getParentShell().getDisplay().getSystemColor(SWT.COLOR_YELLOW);
			event.styles = new StyleRange[] { styleRange };
		}
	});

	GridData textGrid = new GridData(500, 500);
	textGrid.horizontalSpan = 2;
	preview.setLayoutData(textGrid);

	updatePreview();
}
 
Example 12
Source File: EditAllAttributesDialog.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
/**
 * This method initializes composite2
 * 
 */
private void createTable(Composite composite) {
	GridData tableGridData = new GridData();
	tableGridData.horizontalSpan = 3;
	tableGridData.heightHint = 400;
	tableGridData.horizontalAlignment = GridData.FILL;
	tableGridData.grabExcessHorizontalSpace = true;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	ListenerAppender.addTableEditListener(this.attributeTable,
			this.tableEditor, this);
}
 
Example 13
Source File: TBXMakerDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 删除列 ;
 */
private void removeColumn() {
	if (cols < 2) {
		MessageDialog.openInformation(getShell(), Messages.getString("dialog.TBXMakerDialog.msgTitle"),
				Messages.getString("dialog.TBXMakerDialog.msg2"));
		return;
	}
	Vector<String> columns = new Vector<String>();
	int count = table.getColumnCount();
	for (int i = 0; i < count; i++) {
		columns.add(table.getColumn(i).getText());
	}
	ColumnRemoveDialog removeDialog = new ColumnRemoveDialog(getShell(), columns, imagePath);
	if (removeDialog.open() == IDialogConstants.OK_ID) {
		Vector<String> columnVector = removeDialog.getColumnVector();
		if (columnVector.size() == columns.size()) {
			return;
		}
		for (int i = 0; i < count; i++) {
			TableColumn col = table.getColumn(i);
			boolean found = false;
			for (int j = 0; j < columnVector.size(); j++) {
				if (col.getText().equals(columnVector.get(j))) {
					found = true;
					break;
				}
			}
			if (!found) {
				table.getColumn(i).dispose();
				count--;
				i--;
			}
		}
		lblColCount.setText(MessageFormat.format(
				Messages.getString("dialog.TBXMakerDialog.lblColCount"), table.getColumnCount())); //$NON-NLS-1$
		cols = table.getColumnCount();
		int width = (table.getClientArea().width - table.getBorderWidth() * 2 - table.getVerticalBar().getSize().x)
				/ cols;
		if (width < 100) {
			width = 100;
		}

		for (int i = 0; i < cols; i++) {
			TableColumn column = table.getColumn(i);
			column.setWidth(width);
		}
	}
}
 
Example 14
Source File: MainWalkerGroupManageDialog.java    From erflute with Apache License 2.0 4 votes vote down vote up
private void createCategoryGroup(Composite composite) {
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 4;

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

    CompositeFactory.filler(group, 4);

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

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

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

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

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

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

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

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

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

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

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

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

    final TableColumn tableColumn = new TableColumn(categoryTable, SWT.NONE);
    tableColumn.setWidth(30);
    tableColumn.setResizable(false);
    final TableColumn tableColumn1 = new TableColumn(categoryTable, SWT.NONE);
    tableColumn1.setWidth(230);
    tableColumn1.setResizable(false);
    tableColumn1.setText(DisplayMessages.getMessage("label.category.name"));
}
 
Example 15
Source File: HeaderLayout.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private void adjustWeights(AbstractNativeHeader header, TableColumn resizedColumn) {
    int totalAvailableWidth = getAvailableWidth(header);
    int resizedColumnNumber = 0;
    int newTotalWidth = 0;
    
    TableColumn[] columns = resizedColumn.getParent().getColumns();
    for (int i = 0; i < columns.length; i++) {
        newTotalWidth += columns[i].getWidth();
        if (columns[i] == resizedColumn) {
            resizedColumnNumber = i;
        }
    }

    Table table = resizedColumn.getParent();
    int[] columnOrder = table.getColumnOrder();
    int resizedColumnPosition = 0;
    
    for (int i = 0; i < columnOrder.length; i++) {
        if (columnOrder[i] == resizedColumnNumber) {
            resizedColumnPosition = i;
            break;
        }
    } 
    
    if (resizedColumnIsNotTheLastColumn(resizedColumnPosition, resizedColumn.getParent())) {
        // Compute resized column width change and make sure the resized 
        // column's width is sane
        int resizedColumnWidth = resizedColumn.getWidth();
        
        // int columnWidthChange = lastWidths[resizedColumnPosition] - resizedColumnWidth;
        int columnWidthChange = lastWidths[columnOrder[resizedColumnPosition]] - resizedColumnWidth;
        
        int columnWidthChangeTooFar = MINIMUM_COL_WIDTH - resizedColumnWidth;
        if (columnWidthChangeTooFar > 0) {
            columnWidthChange -= columnWidthChangeTooFar;
            resizedColumnWidth = MINIMUM_COL_WIDTH;
            resizedColumn.setWidth(resizedColumnWidth);
        }
        
        // Fix the width of the column to the right of the resized column
        int columnToTheRightOfResizedColumnWidth = 
            lastWidths[columnOrder[resizedColumnPosition+1]] + columnWidthChange;
        
        // int columnToTheRightOfResizedColumnWidth = 
        //     lastWidths[resizedColumnPosition+1] + columnWidthChange;
        
        columnWidthChangeTooFar = MINIMUM_COL_WIDTH - columnToTheRightOfResizedColumnWidth;
        if (columnWidthChangeTooFar > 0) {
            columnWidthChange += columnWidthChangeTooFar;
            resizedColumnWidth -= columnWidthChangeTooFar;
            resizedColumn.setWidth(resizedColumnWidth);
            columnToTheRightOfResizedColumnWidth = MINIMUM_COL_WIDTH;
        }
        TableColumn columnToTheRightOfResizedColumn = columns[columnOrder[resizedColumnPosition+1]];
        columnToTheRightOfResizedColumn.setWidth(columnToTheRightOfResizedColumnWidth);

        if (isFittingHorizontally()) {
            adjustWeightedHeader(header, resizedColumnPosition,
                    resizedColumn, columnToTheRightOfResizedColumn,
                    totalAvailableWidth, newTotalWidth);
        } else {
            // Fix the weights based on if the column sizes are being scaled
            if (isWidthWiderThanAllColumns(header)) {
                adjustScaledAbsoluteWidthWeights(resizedColumnPosition,
                        resizedColumnWidth,
                        columnToTheRightOfResizedColumnWidth, 
                        header.getSize().x);
            } else {
                adjustNonScaledAbsoluteWidthWeights(resizedColumnPosition,
                        resizedColumnWidth,
                        columnToTheRightOfResizedColumnWidth);
            }
        }
        
        fireColumnResizedEvent(resizedColumnPosition,
                        resizedColumnWidth,
                        columnToTheRightOfResizedColumnWidth);
    } else {
        // Re-layout; the rightmost column can't be resized
        layout(header, true);
    }
}
 
Example 16
Source File: ExtendedPropertyEditorComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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( );
}
 
Example 17
Source File: NewProjectTmPage.java    From translationstudio8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 设置TableViewer 列属性
 * @param viewer
 * @param title
 *            列标题
 * @param bound
 *            列宽
 * @param colNumber
 *            列序号
 * @return {@link TableViewerColumn};
 */
private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, final int colNumber) {
	final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE | SWT.Resize);
	final TableColumn column = viewerColumn.getColumn();
	column.setText(title);
	column.setWidth(bound);
	column.setResizable(true);
	column.setMoveable(true);
	return viewerColumn;

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

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

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