Java Code Examples for org.eclipse.jface.layout.TableColumnLayout#setColumnData()

The following examples show how to use org.eclipse.jface.layout.TableColumnLayout#setColumnData() . 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: RenamingView.java    From MergeProcessor with Apache License 2.0 6 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 RenamingView(Composite parent, int style) {
	super(parent, style);

	final TableColumnLayout layout = new TableColumnLayout();
	setLayout(layout);

	viewer = new TableViewer(this, SWT.FULL_SELECTION);
	viewer.getTable().setHeaderVisible(true);
	viewer.getTable().setLinesVisible(true);

	viewerColumnFrom = new TableViewerColumn(viewer, SWT.NONE);
	viewerColumnFrom.getColumn().setText("From");
	layout.setColumnData(viewerColumnFrom.getColumn(), new ColumnWeightData(1));

	viewerColumnTo = new TableViewerColumn(viewer, SWT.NONE);
	viewerColumnTo.getColumn().setText("To");
	layout.setColumnData(viewerColumnTo.getColumn(), new ColumnWeightData(1));

}
 
Example 2
Source File: MedicationViewerHelper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public static TableViewerColumn createMandantColumn(TableViewer viewer,
	TableColumnLayout layout, int columnIndex){
	TableViewerColumn ret = new TableViewerColumn(viewer, SWT.LEFT);
	TableColumn tblclmnMandant = ret.getColumn();
	ColumnWeightData mandantColumnWeightData =
		new ColumnWeightData(0, 50, true);
	layout.setColumnData(tblclmnMandant, mandantColumnWeightData);
	tblclmnMandant.setText(Messages.MedicationComposite_column_mandant);
	tblclmnMandant.setToolTipText(Messages.MedicationComposite_column_mandant);
	ret.setLabelProvider(new MedicationCellLabelProvider() {
		@Override
		public String getText(Object element){
			return ((MedicationTableViewerItem) element).getPrescriptorLabel();
		}
	});
	return ret;
}
 
Example 3
Source File: MedicationViewerHelper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public static TableViewerColumn createBeginColumn(TableViewer viewer,
	TableColumnLayout layout, int columnIndex){
	TableViewerColumn ret = new TableViewerColumn(viewer, SWT.CENTER);
	TableColumn tblclmnEnacted = ret.getColumn();
	layout.setColumnData(tblclmnEnacted, new ColumnPixelData(60, true, true));
	tblclmnEnacted.setImage(Images.resize(Images.IMG_NEXT_WO_SHADOW.getImage(),
		ImageSize._12x12_TableColumnIconSize));
	tblclmnEnacted.setToolTipText(Messages.MedicationComposite_column_sortBy + " "
		+ Messages.MedicationComposite_column_beginDate);
	tblclmnEnacted
		.addSelectionListener(getSelectionAdapter(viewer, tblclmnEnacted, columnIndex));
	ret.setLabelProvider(new MedicationCellLabelProvider() {
		
		@Override
		public String getText(Object element){
			MedicationTableViewerItem pres = (MedicationTableViewerItem) element;
			return pres.getBeginDate();
		}
	});
	return ret;
}
 
Example 4
Source File: MedicationViewerHelper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public static TableViewerColumn createStopColumn(TableViewer viewer, TableColumnLayout layout,
	int columnIndex){
	TableViewerColumn ret = new TableViewerColumn(viewer, SWT.CENTER);
	TableColumn tblclmnStop = ret.getColumn();
	ColumnPixelData stopColumnPixelData = new ColumnPixelData(60, true, true);
	layout.setColumnData(tblclmnStop, stopColumnPixelData);
	tblclmnStop.setImage(Images.resize(Images.IMG_ARROWSTOP_WO_SHADOW.getImage(),
		ImageSize._12x12_TableColumnIconSize));
	tblclmnStop.setToolTipText(Messages.MedicationComposite_column_sortBy + " "
		+ Messages.MedicationComposite_column_endDate);
	tblclmnStop.addSelectionListener(getSelectionAdapter(viewer, tblclmnStop, columnIndex));
	ret.setLabelProvider(new MedicationCellLabelProvider() {
		@Override
		public String getText(Object element){
			MedicationTableViewerItem pres = (MedicationTableViewerItem) element;
			if (pres.getEntryType() != EntryType.RECIPE
				&& pres.getEntryType() != EntryType.SELF_DISPENSED) {
				return pres.getEndDate();
			}
			return "";
		}
	});
	return ret;
}
 
Example 5
Source File: MedicationViewerHelper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public static TableViewerColumn createIntakeCommentColumn(TableViewer viewer,
	TableColumnLayout layout, int columnIndex){
	TableViewerColumn ret = new TableViewerColumn(viewer, SWT.NONE);
	TableColumn tblclmnComment = ret.getColumn();
	layout.setColumnData(tblclmnComment,
		new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
	tblclmnComment.setText(Messages.TherapieplanComposite_tblclmnComment_text);
	tblclmnComment.setToolTipText(Messages.MedicationComposite_column_sortBy + " "
		+ Messages.TherapieplanComposite_tblclmnComment_text);
	tblclmnComment
		.addSelectionListener(getSelectionAdapter(viewer, tblclmnComment, columnIndex));
	tblclmnComment.setToolTipText(Messages.MedicationComposite_column_sortBy + " "
		+ Messages.TherapieplanComposite_tblclmnComment_text);
	ret.setLabelProvider(new MedicationCellLabelProvider() {
		
		@Override
		public String getText(Object element){
			MedicationTableViewerItem pres = (MedicationTableViewerItem) element;
			return pres.getRemark();
		}
	});
	return ret;
}
 
Example 6
Source File: InvoiceCorrectionWizard.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent){
	container = new Composite(parent, SWT.NONE);
	container.setLayout(new GridLayout(1, false));
	
	TableViewer viewer =
		new TableViewer(container,
			SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL
				| SWT.READ_ONLY);
	viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.getTable().setLinesVisible(true);
	viewer.setInput(invoiceCorrectionDTO.getHistory());
	viewer.setLabelProvider(new LabelProvider() {
		@Override
		public String getText(Object element){
			int i = invoiceCorrectionDTO.getHistory().indexOf(element);
			return String.valueOf(++i) + ".   "
				+ ((InvoiceHistoryEntryDTO) element).getText();
		}
	});
	
	TableColumn singleColumn = new TableColumn(viewer.getTable(), SWT.NONE);
	TableColumnLayout tableColumnLayout = new TableColumnLayout();
	tableColumnLayout.setColumnData(singleColumn, new ColumnWeightData(100));
	container.setLayout(tableColumnLayout);
	
	setControl(container);
	setPageComplete(!invoiceCorrectionDTO.getHistory().isEmpty());
}
 
Example 7
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 8
Source File: ValidationViewPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createTableComposite(final Composite mainComposite) {
    final Composite tableComposite = new Composite(mainComposite, SWT.NONE);
    tableComposite.setLayout(GridLayoutFactory.fillDefaults().create());
    tableComposite.setLayoutData(GridDataFactory.fillDefaults()
            .grab(true, true).create());

    tableViewer = new TableViewer(tableComposite, SWT.SINGLE | SWT.BORDER
            | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    table.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(400, SWT.DEFAULT).create());
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    addSeverityDescriptionColumn();
    addElementNameColumn();
    addErrorDescriptionColumn();

    final TableColumnLayout tcLayout = new TableColumnLayout();
    tcLayout.setColumnData(table.getColumn(0), new ColumnWeightData(1));
    tcLayout.setColumnData(table.getColumn(1), new ColumnWeightData(5));
    tcLayout.setColumnData(table.getColumn(2), new ColumnWeightData(11));
    table.getParent().setLayout(tcLayout);

    tableViewer.setContentProvider(new ValidationMarkerContentProvider());
    final IEditorPart activeEditor = getSite().getPage().getActiveEditor();
    tableViewer.setInput(activeEditor);

    tableViewer.addSelectionChangedListener(this);
}
 
Example 9
Source File: AbstractOrganizationWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void addTableColumLayout(final Table table) {
    final TableColumnLayout tcLayout = new TableColumnLayout();
    for (final TableColumn col : table.getColumns()) {
        tcLayout.setColumnData(col, new ColumnWeightData(1));
    }
    table.getParent().setLayout(tcLayout);
}
 
Example 10
Source File: StateSpaceLabelProvider.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * @param stateTable
 */
void createTableColumns(final Table stateTable, final ResultPage page, final TableColumnLayout layout) {
	for (int i = 0; i < COLUMN_TITLES.length; i++) {
		final TableColumn column = new TableColumn(stateTable, SWT.NULL);
		column.setWidth(COLUMN_WIDTHS[i]);
		column.setText(COLUMN_TITLES[i]);

		final int weight = (int)(100.0 * COLUMN_WIDTH_PERCENTAGES[i]);
		layout.setColumnData(column, new ColumnWeightData(weight, COLUMN_WIDTHS[i], true));
		
		// The following statement attaches a listener to the column header.
		//	See the ResultPageColumnListener comments.
		column.addSelectionListener(new ResultPageColumnListener(i, page));
	}
}
 
Example 11
Source File: CoverageLabelProvider.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * @param stateTable
 */
void createTableColumns(final Table stateTable, final TableColumnLayout layout) {
	for (int i = 0; i < COLUMN_TITLES.length; i++) {
		final TableColumn column = new TableColumn(stateTable, SWT.NULL);
		column.setWidth(COLUMN_WIDTHS[i]);
		column.setText(COLUMN_TITLES[i]);
		column.setToolTipText(COLUMN_TOOLTIPS[i]);
		column.setData(COVERAGE_COMPARATOR, COLUMN_COMP[i]);

		final int weight = (int)(100.0 * COLUMN_WIDTH_PERCENTAGES[i]);
		layout.setColumnData(column, new ColumnWeightData(weight, COLUMN_WIDTHS[i], true));
	}
}
 
Example 12
Source File: InvoiceCorrectionWizard.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent){
	container = new Composite(parent, SWT.NONE);
	container.setLayout(new GridLayout(1, false));
	
	Composite tableComp = new Composite(container, SWT.NONE);
	tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	viewer = CheckboxTableViewer.newCheckList(tableComp,
		SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	viewer.getTable().setLinesVisible(true);
	viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setInput(invoiceCorrectionDTO.getHistory());
	viewer.addCheckStateListener(new ICheckStateListener() {
		
		@Override
		public void checkStateChanged(CheckStateChangedEvent event){
			viewer.setChecked(event.getElement(), !event.getChecked());
		}
	});
	viewer.setLabelProvider(new WizardLabelProvider());
	
	TableColumn singleColumn = new TableColumn(viewer.getTable(), SWT.NONE);
	TableColumnLayout tableColumnLayout = new TableColumnLayout();
	tableColumnLayout.setColumnData(singleColumn, new ColumnWeightData(100));
	tableComp.setLayout(tableColumnLayout);
	
	
	Label lblOutput = new Label(container, SWT.NONE);
	lblOutput.setText("Ausgabe");
	GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
	gd.heightHint = 100;
	txtOutput =
		new Text(container,
		SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
	txtOutput.setLayoutData(gd);
	setControl(container);
	setPageComplete(!invoiceCorrectionDTO.getHistory().isEmpty());
}
 
Example 13
Source File: AutoClosingPairConditionalTableWidget.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
public AutoClosingPairConditionalTableWidget(Table table) {
	super(table);
	setLabelProvider(new AutoClosingPairConditionalLabelProvider());
	GC gc = new GC(table.getShell());
	gc.setFont(JFaceResources.getDialogFont());
	TableColumnLayout columnLayout = new TableColumnLayout();

	TableColumn column2 = new TableColumn(table, SWT.NONE);
	column2.setText(LanguageConfigurationMessages.AutoClosingPairConditionalTableWidget_notIn);
	int minWidth = computeMinimumColumnWidth(gc,
			LanguageConfigurationMessages.AutoClosingPairConditionalTableWidget_notIn);
	columnLayout.setColumnData(column2, new ColumnWeightData(2, minWidth, true));
}
 
Example 14
Source File: OnEnterRuleTableWidget.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
public OnEnterRuleTableWidget(Table table) {
	super(table);
	setContentProvider(new OnEnterRuleContentProvider());
	setLabelProvider(new OnEnterRuleLabelProvider());

	GC gc = new GC(table.getShell());
	gc.setFont(JFaceResources.getDialogFont());
	TableColumnLayout columnLayout = new TableColumnLayout();

	TableColumn column1 = new TableColumn(table, SWT.NONE);
	column1.setText(LanguageConfigurationMessages.OnEnterRuleTableWidget_beforeText);
	int minWidth = computeMinimumColumnWidth(gc, LanguageConfigurationMessages.OnEnterRuleTableWidget_beforeText);
	columnLayout.setColumnData(column1, new ColumnWeightData(2, minWidth, true));

	TableColumn column2 = new TableColumn(table, SWT.NONE);
	column2.setText(LanguageConfigurationMessages.OnEnterRuleTableWidget_afterText);
	minWidth = computeMinimumColumnWidth(gc, LanguageConfigurationMessages.OnEnterRuleTableWidget_afterText);
	columnLayout.setColumnData(column2, new ColumnWeightData(2, minWidth, true));

	TableColumn column3 = new TableColumn(table, SWT.NONE);
	column3.setText(LanguageConfigurationMessages.OnEnterRuleTableWidget_indentAction);
	minWidth = computeMinimumColumnWidth(gc, LanguageConfigurationMessages.OnEnterRuleTableWidget_indentAction);
	columnLayout.setColumnData(column3, new ColumnWeightData(1, minWidth, true));

	TableColumn column4 = new TableColumn(table, SWT.NONE);
	column4.setText(LanguageConfigurationMessages.OnEnterRuleTableWidget_appendText);
	minWidth = computeMinimumColumnWidth(gc, LanguageConfigurationMessages.OnEnterRuleTableWidget_appendText);
	columnLayout.setColumnData(column4, new ColumnWeightData(1, minWidth, true));

	TableColumn column5 = new TableColumn(table, SWT.NONE);
	column5.setText(LanguageConfigurationMessages.OnEnterRuleTableWidget_removeText);
	minWidth = computeMinimumColumnWidth(gc, LanguageConfigurationMessages.OnEnterRuleTableWidget_removeText);
	columnLayout.setColumnData(column5, new ColumnWeightData(1, minWidth, true));
}
 
Example 15
Source File: ApplicationOverviewEditorPart.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public LinkTable(Composite composite, FormToolkit toolkit, String projectColumnLabel) {
	// Create a composite for the table so can use TableColumnLayout
	tableComp = toolkit.createComposite(composite, SWT.NONE);
	TableColumnLayout tableColumnLayout = new TableColumnLayout();
	tableComp.setLayout(tableColumnLayout);
	tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
	
	linkTable = toolkit.createTable(tableComp, SWT.BORDER | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
	GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
	data.heightHint = 100;
	linkTable.setLayoutData(data);
	
	// Columns
	projectColumn = new TableColumn(linkTable, SWT.NONE);
	projectColumn.setText(projectColumnLabel);
	projectColumn.setResizable(true);
	
	envVarColumn = new TableColumn(linkTable, SWT.NONE);
	envVarColumn.setText(Messages.LinkMgmtEnvVarColumn);
	envVarColumn.setResizable(true);
	
	linkTable.setHeaderVisible(true);
	linkTable.setLinesVisible(true);
	
	Arrays.stream(linkTable.getColumns()).forEach(TableColumn::pack);
	tableColumnLayout.setColumnData(projectColumn, new ColumnWeightData(10, Math.max(50, projectColumn.getWidth()), true));
	tableColumnLayout.setColumnData(envVarColumn, new ColumnWeightData(10, Math.max(50, envVarColumn.getWidth()), true));
}
 
Example 16
Source File: SdkEnvironmentControl.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create the composite.
 * @param parent
 * @param style
 * @param editedSdk 
 */
public SdkEnvironmentControl(Composite parent, int style, final Sdk editedSdk) {
    super(parent, style);
    this.editedSdk = editedSdk;
    selectedVar = null;
    
    setLayoutData(new GridData(GridData.FILL_BOTH));
    setLayout(SwtUtils.removeMargins(new GridLayout(2, false)));
    
    Composite tableComposite = new Composite(this, SWT.NONE);
    tableComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    tableComposite.setLayout(new GridLayout(1, false));
    
    tableComposite.setBackground(new Color(Display.getDefault(), 255,0,0));
    
    
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    TableColumnLayout tableColumnLayout = new TableColumnLayout();
    tableComposite.setLayout(tableColumnLayout);
    
    tableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION);
    table = tableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    
    columnName = new TableViewerColumn(tableViewer, SWT.NONE);
    tblclmnName = columnName.getColumn();
    tableColumnLayout.setColumnData(tblclmnName, new ColumnPixelData(150, true, true));
    tblclmnName.setText(Messages.SdkEnvironmentControl_Variable);
    
    columnLocation = new TableViewerColumn(tableViewer, SWT.NONE);
    tblclmnLocation = columnLocation.getColumn();
    tableColumnLayout.setColumnData(tblclmnLocation, new ColumnPixelData(150, true, true));
    tblclmnLocation.setText(Messages.SdkEnvironmentControl_Value);
    tableViewer.setContentProvider(new SdkEnvContentProvider());
    tableViewer.setLabelProvider(new SdkEnvLabelProvider());
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            TableItem[] selectedItems = table.getSelection();
            boolean isEnabled = selectedItems.length > 0;
            btnEdit.setEnabled(isEnabled);
            btnDelete.setEnabled(isEnabled);
            selectedVar = isEnabled ? (String)selectedItems[0].getData() : null;
        }
    });
    
    Composite buttonsComposite = new Composite(this, SWT.NONE);
    buttonsComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    buttonsComposite.setLayout(SwtUtils.removeMargins(new GridLayout(1, false)));
    
    btnNew = SWTFactory.createPushButton(buttonsComposite, Messages.SdkEnvironmentControl_New, null);
    btnNew.addSelectionListener(new AddVarButtonHandler());
    
    btnEdit = SWTFactory.createPushButton(buttonsComposite, Messages.SdkEnvironmentControl_Edit, null);
    btnEdit.addSelectionListener(new EditValueButtonHandler());
    btnEdit.setEnabled(false);
    
    btnDelete = SWTFactory.createPushButton(buttonsComposite, Messages.SdkEnvironmentControl_Delete, null);
    btnDelete.setEnabled(false);
    btnDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (selectedVar != null) {
                editedSdk.removeEnvironmentVariable(selectedVar);
                tableViewer.setInput(editedSdk);
            }
        }
    });
    tableViewer.setInput(editedSdk);
}
 
Example 17
Source File: ChartMakerDialog.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private void createSeriesCreatorGroup(GridData genericFillGridData) {
    GridLayout creatorLayout = new GridLayout();
    creatorLayout.numColumns = 2;
    creatorLayout.makeColumnsEqualWidth = true;

    Group creatorGroup = new Group(fComposite, SWT.BORDER);
    creatorGroup.setText(Messages.ChartMakerDialog_SeriesCreator);
    creatorGroup.setLayout(creatorLayout);
    creatorGroup.setLayoutData(genericFillGridData);

    GridData creatorLabelGridData = new GridData();
    creatorLabelGridData.horizontalAlignment = SWT.CENTER;
    creatorLabelGridData.verticalAlignment = SWT.BOTTOM;

    /* Top labels */
    Label creatorLabelX = new Label(creatorGroup, SWT.NONE);
    creatorLabelX.setText(Messages.ChartMakerDialog_XAxis);
    creatorLabelX.setLayoutData(creatorLabelGridData);

    Label creatorLabelY = new Label(creatorGroup, SWT.NONE);
    creatorLabelY.setText(Messages.ChartMakerDialog_YAxis);
    creatorLabelY.setLayoutData(creatorLabelGridData);

    /* X axis table */
    TableViewerColumn creatorXColumn = new TableViewerColumn(fSelectionXTable, SWT.NONE);
    creatorXColumn.getColumn().setResizable(false);
    creatorXColumn.setLabelProvider(new DataDescriptorLabelProvider());

    TableColumnLayout creatorXLayout = new TableColumnLayout();
    creatorXLayout.setColumnData(creatorXColumn.getColumn(), new ColumnWeightData(100));

    Composite creatorXComposite = new Composite(creatorGroup, SWT.NONE);
    creatorXComposite.setLayout(creatorXLayout);
    creatorXComposite.setLayoutData(genericFillGridData);

    fSelectionXTable.getTable().setParent(creatorXComposite);
    fSelectionXTable.setContentProvider(ArrayContentProvider.getInstance());
    fSelectionXTable.setInput(fDataProvider.getDataDescriptors());
    fSelectionXTable.setFilters(new ViewerFilter[] { new CreatorXFilter() });
    fSelectionXTable.addSelectionChangedListener(new CreatorXSelectedEvent());

    /* Y axis table */
    TableViewerColumn creatorYColumn = new TableViewerColumn(fSelectionYTable, SWT.NONE);
    creatorYColumn.getColumn().setResizable(false);
    creatorYColumn.setLabelProvider(new DataDescriptorLabelProvider());

    TableColumnLayout creatorYLayout = new TableColumnLayout();
    creatorYLayout.setColumnData(creatorYColumn.getColumn(), new ColumnWeightData(100));

    Composite creatorYComposite = new Composite(creatorGroup, SWT.NONE);
    creatorYComposite.setLayout(creatorYLayout);
    creatorYComposite.setLayoutData(genericFillGridData);

    fSelectionYTable.getTable().setParent(creatorYComposite);
    fSelectionYTable.setContentProvider(ArrayContentProvider.getInstance());
    fSelectionYTable.setInput(fDataProvider.getDataDescriptors());
    fSelectionYTable.setFilters(new ViewerFilter[] { new CreatorYFilter() });
    fSelectionYTable.addCheckStateListener(new CreatorYSelectedEvent());

    /* Selected series warning */
    fWarningLabel.setParent(creatorGroup);
    fWarningLabel.setText(Messages.ChartMakerDialog_SelectionRestrictionWarning);
    fWarningLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
    fWarningLabel.setVisible(false);

    /* Add button */
    GridData creatorButtonGridData = new GridData();
    creatorButtonGridData.horizontalAlignment = SWT.RIGHT;
    creatorButtonGridData.widthHint = 30;
    creatorButtonGridData.heightHint = 30;

    Image addImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD);
    fAddButton.setParent(creatorGroup);
    fAddButton.setLayoutData(creatorButtonGridData);
    fAddButton.setImage(addImage);
    fAddButton.addListener(SWT.Selection, new AddButtonClickedEvent());
}
 
Example 18
Source File: GenerericTableViewer.java    From offspring with MIT License 4 votes vote down vote up
private void createColumns() {
  GC gc = new GC(getTable().getParent());

  List<Integer> widths = new ArrayList<Integer>();

  for (final IGenericTableColumn c : table.getColumns()) {
    TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE);

    viewerColumn.setLabelProvider(new GenericLabelProvider(c
        .getDataProvider()));

    if (c.getEditable()) {
      viewerColumn.setEditingSupport(c.getEditingSupport(this));
    }

    TableColumn column = viewerColumn.getColumn();

    if (c.getSortable() && comparator != null) {
      column.addSelectionListener(getSelectionAdapter(column, c));
    }
    column.setText(c.getLabel());
    column.setAlignment(c.getAlignMent());

    int width;
    if (c.getWidth() != -1) {
      width = c.getWidth();
    }
    else if (c.getTextExtent() != null
        && c.getLabel().length() < c.getTextExtent().length()) {
      width = gc.textExtent(c.getTextExtent()).x + 2;
    }
    else {
      width = gc.textExtent(c.getLabel()).x + 2;
    }

    widths.add(width);
    column.setWidth(width);
    column.setResizable(c.getResizable());
  }
  gc.dispose();

  /* All columns have their prefered width set now calculate percentages */
  TableColumnLayout layout = new TableColumnLayout();
  for (int i = 0; i < widths.size(); i++) {
    layout.setColumnData(getTable().getColumns()[i], new ColumnWeightData(
        widths.get(i), widths.get(i), true));
  }
  getTable().getParent().setLayout(layout);
}
 
Example 19
Source File: SelectionDialog.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
private final void createTableDialogArea(final Composite parent) {

		String[] inputKeys = getSelectableKeys();
		int columnCount = 0;
		Point dimens = getColumnCount( parent, inputKeys, sizeHint.x); 
		int count = dimens.x;

		GridLayout compositeLayout = new GridLayout(count,true);
		parent.setLayout(compositeLayout);
		parent.setLayoutData(new GridData(GridData.FILL_BOTH));
		
		Table table = new Table(parent, SWT.V_SCROLL | SWT.HORIZONTAL | SWT.WRAP | SWT.FULL_SELECTION); //| SWT.MULTI);
		GridData gridData = new GridData(GridData.FILL_BOTH);
		table.setLayoutData(gridData);
		table.setBackground(parent.getBackground());
		table.setLinesVisible(true);
		table.setHeaderVisible(false);
		
		int columnWidth = (sizeHint.x - getSizeAdjustment()) / count;
		
		TableColumn[] columns = new TableColumn[count];
		for (int i = 0; i < count; i++) {
			columns[i] = new TableColumn(table, SWT.LEFT, columnCount++);
			columns[i].setWidth(columnWidth);
		}
		TableColumnLayout layout = new TableColumnLayout();
		for (int i = 0; i < count; i++) {
			layout.setColumnData(columns[i], new ColumnWeightData(100/count,columnWidth,false));
		}
		parent.setLayout(layout);
		
		int len = inputKeys.length;
		int rowCount = len / columnCount;
		if ((len - rowCount * columnCount) > 0) {
			rowCount++;
		}
		for (int i = 0; i < rowCount; i++) {
			String[] row = new String[columnCount];
			for (int j = 0; j < columnCount; j++) {
				int sourceIndex = i * columnCount + j;
				row[j] = (sourceIndex < len ? (String) inputKeys[sourceIndex] : ""); //$NON-NLS-1$ 
			}
			TableItem item = new TableItem(table, SWT.NULL);
			item.setText(row);
		}

		table.pack();
		sizeHint.y = Math.min(table.getBounds().height + getSizeAdjustment(),sizeHint.y);

		Dialog.applyDialogFont(parent);
		addTableListeners(table);
	}
 
Example 20
Source File: DashboardView.java    From MergeProcessor with Apache License 2.0 4 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 DashboardView(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout());

	final Composite tableComposite = new Composite(this, SWT.NONE);
	final TableColumnLayout tableColumnLayout = new TableColumnLayout();
	tableComposite.setLayout(tableColumnLayout);
	tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

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

	statusViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	final TableColumn statusColumn = statusViewerColumn.getColumn();
	tableColumnLayout.setColumnData(statusColumn, new ColumnPixelData(70));
	statusColumn.setText(Messages.View_Column_Status);

	hostViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	final TableColumn hostColumn = hostViewerColumn.getColumn();
	tableColumnLayout.setColumnData(hostColumn, new ColumnPixelData(120));
	hostColumn.setText(Messages.View_Column_Host);

	repositoryViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	final TableColumn repositoryColumn = repositoryViewerColumn.getColumn();
	tableColumnLayout.setColumnData(repositoryColumn, new ColumnPixelData(110));
	repositoryColumn.setText(Messages.View_Column_Repository);

	dateViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	final TableColumn dateColumn = dateViewerColumn.getColumn();
	tableColumnLayout.setColumnData(dateColumn, new ColumnPixelData(130));
	dateColumn.setText(Messages.View_Column_Date);

	revisionViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	final TableColumn revisionColumn = revisionViewerColumn.getColumn();
	tableColumnLayout.setColumnData(revisionColumn, new ColumnPixelData(100));
	revisionColumn.setText(Messages.View_Column_Revision_Range);

	sourceBranchViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	final TableColumn sourceBranchColumn = sourceBranchViewerColumn.getColumn();
	tableColumnLayout.setColumnData(sourceBranchColumn, new ColumnPixelData(120));
	sourceBranchColumn.setText(Messages.View_Column_Source_Branch);

	targetBranchViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	final TableColumn targetBranchColumn = targetBranchViewerColumn.getColumn();
	tableColumnLayout.setColumnData(targetBranchColumn, new ColumnPixelData(120));
	targetBranchColumn.setText(Messages.View_Column_Target_Branch);

	mergeScriptViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	final TableColumn mergeScriptColumn = mergeScriptViewerColumn.getColumn();
	tableColumnLayout.setColumnData(mergeScriptColumn, new ColumnPixelData(0));
	mergeScriptColumn.setText(Messages.View_Column_Merge_Script);

	renameStatusViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
	final TableColumn renameColumn = renameStatusViewerColumn.getColumn();
	tableColumnLayout.setColumnData(renameColumn, new ColumnPixelData(23));
	renameColumn.setText(Messages.View_Column_Renaming);

	final Composite buttonComposite = new Composite(this, SWT.NONE);
	buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
	buttonComposite.setLayout(new FillLayout());

	btnMergeSelection = new Button(buttonComposite, SWT.PUSH);
	btnMergeSelection.setText(Messages.View_Button_Merge_Selection);

	btnIgnoreSelection = new Button(buttonComposite, SWT.PUSH);
	btnIgnoreSelection.setText(Messages.View_Button_Ignore_Selection);

}