Java Code Examples for org.eclipse.jface.viewers.TableViewerColumn#setLabelProvider()

The following examples show how to use org.eclipse.jface.viewers.TableViewerColumn#setLabelProvider() . 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: QueryExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createValueColumn(final TableViewer tableViewer) {
    final TableViewerColumn valueColumnViewer = new TableViewerColumn(tableViewer, SWT.FILL);
    final TableColumn column = valueColumnViewer.getColumn();
    column.setText(Messages.value);
    final ExpressionColumnLabelProvider expressionLabelProvider = new ExpressionColumnLabelProvider(0);
    valueColumnViewer.setLabelProvider(new LabelProviderBuilder<Expression>()
            .withTextProvider(exp -> exp.getReferencedElements().isEmpty() ? null
                    : expressionLabelProvider.getText(exp.getReferencedElements().get(0)))
            .withImageProvider(exp -> exp.getReferencedElements().isEmpty() ? null
                    : expressionLabelProvider.getImage(exp.getReferencedElements().get(0)))
            .createColumnLabelProvider());

    editingSupport = new ReferencedExpressionEditingSupport(valueColumnViewer.getViewer());
    editingSupport.setFilter(new AvailableExpressionTypeFilter(new String[] { ExpressionConstants.CONSTANT_TYPE,
            ExpressionConstants.VARIABLE_TYPE,
            ExpressionConstants.PARAMETER_TYPE,
            ExpressionConstants.SCRIPT_TYPE,
            ExpressionConstants.CONTRACT_INPUT_TYPE }));
    valueColumnViewer.setEditingSupport(editingSupport);
}
 
Example 2
Source File: QueryDetailsControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createDescriptionColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.description);
    column.setLabelProvider(new LabelProviderBuilder<QueryParameter>()
            .withTextProvider(parameter -> parameter.getDescription())
            .shouldRefreshAllLabels(viewer)
            .createColumnLabelProvider());
    column.setEditingSupport(new EditingSupportBuilder<QueryParameter>(viewer)
            .withCanEditProvider(e -> !isDefault())
            .withValueProvider(parameter -> parameter.getDescription() != null ? parameter.getDescription() : "")
            .withValueUpdater((parameter, newDesc) -> {
                String oldDesc = parameter.getDescription();
                if (!Objects.equals(oldDesc, newDesc)) {
                    parameter.setDescription((String) newDesc);
                    formPage.refreshQueryViewers();
                }
            })
            .create());
}
 
Example 3
Source File: ValidationViewPart.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void addErrorDescriptionColumn() {
    final TableViewerColumn elements = new TableViewerColumn(tableViewer,
            SWT.NONE);
    elements.getColumn().setText(
            Messages.validationViewDescriptionColumnName);
    elements.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {

            final Marker marker = (Marker) element;
            try {
                return (String) marker.getAttribute("message");
            } catch (final CoreException e) {
                return "";
            }
        }
    });
}
 
Example 4
Source File: IndexControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createIndexNameColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.name);
    IndexNameValidator indexNameValidator = new IndexNameValidator(formPage.observeWorkingCopy());

    column.setLabelProvider(new LabelProviderBuilder<Index>()
            .withTextProvider(element -> element.getName())
            .withStatusProvider(indexNameValidator::validate)
            .shouldRefreshAllLabels(viewer)
            .createColumnLabelProvider());
    column.setEditingSupport(new EditingSupportBuilder<Index>(viewer)
            .withId(SWTBotConstants.SWTBOT_ID_UNIQUE_CONSTRAINT_NAME_TEXTEDITOR)
            .withValueProvider(Index::getName)
            .withValueUpdater((index, newName) -> {
                if (!Objects.equals(index.getName(), newName)) {
                    index.setName((String) newName);
                }
            })
            .create());
}
 
Example 5
Source File: TmfSimpleTableViewer.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create a column for the table. The column will have a default width set,
 * and will be resizable, moveable and sortable.
 *
 * @param name
 *            the name of the column
 * @param provider
 *            the label provider of the column
 * @param comparator
 *            the comparator associated with clicking on the column, if it
 *            is null, a string comparator on the label will be used
 * @return the column that was created
 * @since 2.0
 */
public final <T> TableColumn createColumn(String name, ColumnLabelProvider provider, @Nullable Comparator<T> comparator) {
    TableViewerColumn col = new TableViewerColumn(fTableViewer, SWT.NONE);
    col.setLabelProvider(provider);
    final TableColumn column = col.getColumn();
    column.setWidth(DEFAULT_COL_WIDTH);
    column.setText(name);
    column.setResizable(true);
    column.setMoveable(true);
    if (comparator == null) {
        column.addSelectionListener(new ColumnSorter<>(column, new ColumnLabelComparator(provider)));
    } else {
        column.addSelectionListener(new ColumnSorter<>(column, comparator));
    }
    return column;
}
 
Example 6
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 7
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 8
Source File: ConstraintEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createConstraintnameColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.name);
    UniqueConstraintNameValidator constraintNameValidator = new UniqueConstraintNameValidator();

    column.setLabelProvider(new LabelProviderBuilder<UniqueConstraint>()
            .withTextProvider(element -> element.getName())
            .withStatusProvider(constraint -> constraintNameValidator.validate(constraint))
            .shouldRefreshAllLabels(viewer)
            .createColumnLabelProvider());
    column.setEditingSupport(new EditingSupportBuilder<UniqueConstraint>(viewer)
            .withId(SWTBotConstants.SWTBOT_ID_UNIQUE_CONSTRAINT_NAME_TEXTEDITOR)
            .withValueProvider(UniqueConstraint::getName)
            .withValueUpdater((constraint, newName) -> {
                if (!Objects.equals(constraint.getName(), newName)) {
                    constraint.setName((String) newName);
                }
            })
            .create());
}
 
Example 9
Source File: ViewAttributeWeights.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new column
 * @param table
 * @param name
 * @param provider
 */
private TableViewerColumn createColumn(PageableTable table,
                                       String name,
                                       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(200);
    tColumn.setResizable(true);
    return column;
}
 
Example 10
Source File: ViewStatisticsQuality.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, 
                                       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(30);
    tColumn.setResizable(false);
    return column;
}
 
Example 11
Source File: LazyPageTableExample.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private static void createColumns(final TableViewer viewer) {

		// First column is for the first name
		TableViewerColumn col = createTableViewerColumn(viewer, "Name", 150);
		col.setLabelProvider(new ColumnLabelProvider() {
			@Override
			public String getText(Object element) {
				String p = (String) element;
				return p;
			}
		});
	}
 
Example 12
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addDisplayNameColumn(final TableViewer tViewer) {
    final TableViewerColumn column = new TableViewerColumn(tViewer, SWT.FILL);
    column.getColumn().setText(Messages.displayName);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            return ((Role) element).getDisplayName();
        }
    });

    column.getColumn().setWidth(90);
    column.getColumn().setMoveable(false);
    column.getColumn().setResizable(true);
}
 
Example 13
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addDescriptionColumn(final TableViewer tViewer) {
    final TableViewerColumn column = new TableViewerColumn(tViewer, SWT.FILL);
    column.getColumn().setText(Messages.description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            return ((Role) element).getDescription();
        }
    });

    column.getColumn().setWidth(90);
    column.getColumn().setMoveable(false);
    column.getColumn().setResizable(true);
}
 
Example 14
Source File: IndexControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createAttributesColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT);
    column.getColumn().setText(Messages.attributes);
    IndexFieldsValidator indexFieldsValidator = new IndexFieldsValidator();
    column.setLabelProvider(new LabelProviderBuilder<Index>()
            .withTextProvider(index -> index.getFieldNames().toString())
            .withStatusProvider(index -> indexFieldsValidator.validate(index))
            .createColumnLabelProvider());
}
 
Example 15
Source File: ConstraintEditionControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createAttributesColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT);
    column.getColumn().setText(Messages.attributes);
    UniqueConstraintFieldsValidator uniqueConstraintFieldsValidator = new UniqueConstraintFieldsValidator();
    column.setLabelProvider(new LabelProviderBuilder<UniqueConstraint>()
            .withTextProvider(constraint -> constraint.getFieldNames().toString())
            .withStatusProvider(constraint -> uniqueConstraintFieldsValidator.validate(constraint))
            .createColumnLabelProvider());
}
 
Example 16
Source File: Bug469441.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private static void createColumns(final TableViewer viewer) {

		// First column is for the first name
		TableViewerColumn col = createTableViewerColumn(viewer, "Name", 150);
		col.setLabelProvider(new ColumnLabelProvider() {

			@Override
			public String getText(Object element) {
				Bug469441Person p = (Bug469441Person) element;
				return p.getFirstName();
			}

			@Override
			public void update(ViewerCell cell) {
				Bug469441Person obj = (Bug469441Person) cell.getItem().getData();

				TableItem item = (TableItem) cell.getItem();
				TableEditor editor = new TableEditor(item.getParent());
				editor.grabHorizontal = true;
				editor.grabVertical = true;

				Button button = new Button(viewer.getTable(), SWT.NONE);
				button.setText(obj.getFirstName());
				editor.setEditor(button, item, cell.getColumnIndex());
				editor.layout();

				editors.add(editor);
			}

		});
		col.getColumn().addSelectionListener(new SortTableColumnSelectionListener("name"));

	}
 
Example 17
Source File: ChartMakerDialog.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private void createSelectedSeriesGroup(GridData genericFillGridData) {
    /**
     * FIXME: The labels in the first column cannot be aligned to the
     * center. The workaround is to put a dummy column that won't appear.
     */
    GridLayout genericGridLayout = new GridLayout();

    TableViewerColumn dummyColumn = new TableViewerColumn(fSeriesTable, SWT.NONE);
    dummyColumn.setLabelProvider(new SeriesDummyLabelProvider());

    /* X series column */
    TableViewerColumn xSelectionColumn = new TableViewerColumn(fSeriesTable, SWT.NONE);
    xSelectionColumn.getColumn().setText(Messages.ChartMakerDialog_XSeries);
    xSelectionColumn.getColumn().setAlignment(SWT.CENTER);
    xSelectionColumn.getColumn().setResizable(false);
    xSelectionColumn.setLabelProvider(new SeriesXLabelProvider());

    /* Y series column */
    TableViewerColumn ySelectionColumn = new TableViewerColumn(fSeriesTable, SWT.NONE);
    ySelectionColumn.getColumn().setText(Messages.ChartMakerDialog_YSeries);
    ySelectionColumn.getColumn().setAlignment(SWT.CENTER);
    ySelectionColumn.getColumn().setResizable(false);
    ySelectionColumn.setLabelProvider(new SeriesYLabelProvider());

    /* Remove buttons column */
    TableViewerColumn removeColumn = new TableViewerColumn(fSeriesTable, SWT.NONE);
    removeColumn.getColumn().setResizable(false);
    removeColumn.setLabelProvider(new SeriesRemoveLabelProvider());

    TableColumnLayout seriesLayout = new TableColumnLayout();
    seriesLayout.setColumnData(dummyColumn.getColumn(), new ColumnPixelData(0));
    seriesLayout.setColumnData(xSelectionColumn.getColumn(), new ColumnWeightData(50));
    seriesLayout.setColumnData(ySelectionColumn.getColumn(), new ColumnWeightData(50));
    seriesLayout.setColumnData(removeColumn.getColumn(), new ColumnPixelData(34));

    Group seriesGroup = new Group(fComposite, SWT.BORDER | SWT.FILL);
    seriesGroup.setText(Messages.ChartMakerDialog_SelectedSeries);
    seriesGroup.setLayout(genericGridLayout);
    seriesGroup.setLayoutData(genericFillGridData);

    Composite seriesComposite = new Composite(seriesGroup, SWT.NONE);
    seriesComposite.setLayout(seriesLayout);
    seriesComposite.setLayoutData(genericFillGridData);

    fSeriesTable.getTable().setParent(seriesComposite);
    fSeriesTable.getTable().setHeaderVisible(true);
    fSeriesTable.getTable().addListener(SWT.MeasureItem, new SeriesRowResize());
    fSeriesTable.setContentProvider(ArrayContentProvider.getInstance());
    fSeriesTable.setInput(fSelectedSeries);
}
 
Example 18
Source File: AdditionalResourcesPropertySection.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createNameColumn() {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.setLabelProvider(new LabelProviderBuilder<AdditionalResource>()
            .withStyledStringProvider(this::getStyledLabel)
            .createStyledCellLabelProvider());
}
 
Example 19
Source File: ImportWizardPagePreview.java    From arx with Apache License 2.0 4 votes vote down vote up
/**
 * Adds input to table once page gets visible to the user
 * 
 * This retrieves the preview data {@link ImportWizardModel#getPreviewData()} and applies it to the given {@link #tableViewer}. Only columns that have been enabled will be shown.
 * New names and reordering is also considered.
 *
 * @param visible
 */
@Override
public void setVisible(boolean visible) {

    super.setVisible(visible);

    if (visible) {

        /* Disable rendering until everything is finished */
        table.setRedraw(false);

        /* Remove old columns */
        while (table.getColumnCount() > 0) {
            table.getColumns()[0].dispose();
        }

        /* Add enabled columns with appropriate label providers */
        int columns = 0;
        for (ImportColumn column : wizardImport.getData().getEnabledColumns()) {

            columns++;
            if (columns > MAX_COLUMS) {
                setMessage(Resources.getMessage("ImportWizardPageCSV.21"), WARNING); //$NON-NLS-1$
                break;
            }
            
            TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
            tableViewerColumn.setLabelProvider(new PreviewColumnLabelProvider(((IImportColumnIndexed) column).getIndex()));

            TableColumn tblclmnColumn = tableViewerColumn.getColumn();
            tblclmnColumn.setToolTipText(Resources.getMessage("ImportWizardPagePreview.5") + //$NON-NLS-1$
                                         column.getDataType());
            tblclmnColumn.setWidth(100);
            tblclmnColumn.setText(column.getAliasName());
        }

        ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);

        /* Apply input to tableViewer */
        tableViewer.setInput(wizardImport.getData().getPreviewData());

        /* Make table visible again */
        table.layout();
        table.setRedraw(true);

        setPageComplete(true);

    } else {
        setPageComplete(false);
    }
}
 
Example 20
Source File: ValidationViewPart.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void addElementNameColumn() {
    final TableViewerColumn elements = new TableViewerColumn(tableViewer,
            SWT.NONE);
    elements.getColumn().setText(Messages.validationViewElementColumnName);
    elements.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            final Marker marker = (Marker) element;
            try {

                final String elementId = (String) marker
                        .getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID);
                String location = (String) marker.getAttribute("location");
                int idx = location.lastIndexOf(":");
                if (idx > 0) {
                    String result = location.substring(idx + 1);

                    // get parent name if name is empty
                    if (result.trim().isEmpty() && idx - 1 > 0) {
                        location = location.substring(0, idx - 1);
                        idx = location.lastIndexOf(":");
                        result = location.substring(idx + 1);
                    }

                    if (!(result.startsWith("<") && result.endsWith(">"))) {
                        return result;
                    } else {
                        final DiagramRepositoryStore store = RepositoryManager
                                .getInstance().getRepositoryStore(
                                        DiagramRepositoryStore.class);
                        final DiagramFileStore file = store.getChild(marker
                                .getResource().getLocation().toFile()
                                .getName(), true);
                        if (file != null) {
                            final EObject view = file.getEMFResource()
                                    .getEObject(elementId);
                            if (view != null) {
                                for (final EObject object : view
                                        .eCrossReferences()) {
                                    if (object instanceof Element) {
                                        return ((Element) object).getName();
                                    }
                                }
                            }
                        }
                        return "";
                    }
                }

                return location;
            } catch (final CoreException e) {
                BonitaStudioLog.error(e);
                return "";
            }
        }
    });

}