Search in sources :

Example 1 with VersionedClauseLabelProvider

use of bndtools.model.clauses.VersionedClauseLabelProvider in project bndtools by bndtools.

the class RunBundlesPart method getLabelProvider.

@Override
protected IBaseLabelProvider getLabelProvider() {
    return new VersionedClauseLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            Object element = cell.getElement();
            if (element instanceof String) {
                String builder = (String) element;
                StyledString label = new StyledString(builder, StyledString.QUALIFIER_STYLER);
                cell.setText(label.getString());
                cell.setStyleRanges(label.getStyleRanges());
                cell.setImage(projectImg);
            } else {
                super.update(cell);
            }
        }
    };
}
Also used : VersionedClauseLabelProvider(bndtools.model.clauses.VersionedClauseLabelProvider) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) ViewerCell(org.eclipse.jface.viewers.ViewerCell)

Example 2 with VersionedClauseLabelProvider

use of bndtools.model.clauses.VersionedClauseLabelProvider in project bndtools by bndtools.

the class MapValuesContentProvider method createSelectedBundlesPanel.

Control createSelectedBundlesPanel(Composite parent) {
    Composite panel = new Composite(parent, SWT.NONE);
    new Label(panel, SWT.NONE).setText("Selected Bundles:");
    Table selectedTable = new Table(panel, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    selectedViewer = new TableViewer(selectedTable);
    selectedViewer.setContentProvider(new MapValuesContentProvider());
    selectedViewer.setLabelProvider(new VersionedClauseLabelProvider());
    selectedViewer.setInput(selectedBundles);
    selectedViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        // Enable the remove button when a bundle is selected on the right
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection sel = selectedViewer.getSelection();
            removeButton.setEnabled(!sel.isEmpty());
        }
    });
    selectedViewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            doRemove();
        }
    });
    GridLayout layout;
    GridData gd;
    layout = new GridLayout(1, false);
    panel.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.heightHint = 300;
    gd.widthHint = 250;
    selectedTable.setLayoutData(gd);
    return panel;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) VersionedClauseLabelProvider(bndtools.model.clauses.VersionedClauseLabelProvider) IOpenListener(org.eclipse.jface.viewers.IOpenListener) GridLayout(org.eclipse.swt.layout.GridLayout) ISelection(org.eclipse.jface.viewers.ISelection) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Aggregations

VersionedClauseLabelProvider (bndtools.model.clauses.VersionedClauseLabelProvider)2 IOpenListener (org.eclipse.jface.viewers.IOpenListener)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 OpenEvent (org.eclipse.jface.viewers.OpenEvent)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StyledString (org.eclipse.jface.viewers.StyledString)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 ViewerCell (org.eclipse.jface.viewers.ViewerCell)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Table (org.eclipse.swt.widgets.Table)1