Search in sources :

Example 1 with RequirementLabelProvider

use of org.bndtools.core.ui.resource.RequirementLabelProvider in project bndtools by bndtools.

the class RunBlacklistPart method createSection.

private void createSection(Section section, FormToolkit tk) {
    section.setText("Run Blacklist");
    section.setDescription("The specified requirements will be excluded from the resolution.");
    // Create toolbar
    ToolBar toolbar = new ToolBar(section, SWT.FLAT);
    section.setTextClient(toolbar);
    fillToolBar(toolbar);
    // Create main panel
    Composite composite = tk.createComposite(section);
    section.setClient(composite);
    table = tk.createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    viewer = new TableViewer(table);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new RequirementLabelProvider());
    // Listeners
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            removeTool.setEnabled(!viewer.getSelection().isEmpty());
        }
    });
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == SWT.DEL) {
                doRemove();
            } else if (e.character == '+') {
                doAddBundle();
            }
        }
    });
    RequirementViewerDropAdapter dropper = new RequirementViewerDropAdapter();
    dropper.install(viewer);
    // Layout
    GridLayout layout;
    GridData gd;
    layout = new GridLayout(2, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 5;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    gd.widthHint = 50;
    gd.heightHint = 50;
    table.setLayoutData(gd);
    gd = new GridData(SWT.RIGHT, SWT.CENTER, true, false);
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) RequirementLabelProvider(org.bndtools.core.ui.resource.RequirementLabelProvider)

Example 2 with RequirementLabelProvider

use of org.bndtools.core.ui.resource.RequirementLabelProvider in project bndtools by bndtools.

the class RunRequirementsPart method createSection.

private void createSection(Section section, FormToolkit tk) {
    section.setText("Run Requirements");
    section.setDescription("The specified requirements will be used to resolve a set of runtime bundles from available repositories.");
    // Create toolbar
    ToolBar toolbar = new ToolBar(section, SWT.FLAT);
    section.setTextClient(toolbar);
    fillToolBar(toolbar);
    // Create main panel
    Composite composite = tk.createComposite(section);
    section.setClient(composite);
    table = tk.createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    viewer = new TableViewer(table);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new RequirementLabelProvider());
    btnAutoResolve = tk.createButton(composite, "Auto-resolve on save", SWT.CHECK);
    btnResolveNow = tk.createButton(composite, "Resolve", SWT.PUSH);
    btnResolveNow.setImage(resolveIcon);
    // Listeners
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            removeTool.setEnabled(!viewer.getSelection().isEmpty());
        }
    });
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == SWT.DEL) {
                doRemove();
            } else if (e.character == '+') {
                doAddBundle();
            }
        }
    });
    RequirementViewerDropAdapter dropper = new RequirementViewerDropAdapter();
    dropper.install(viewer);
    btnAutoResolve.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ResolveMode old = resolveMode;
            resolveMode = btnAutoResolve.getSelection() ? ResolveMode.auto : ResolveMode.manual;
            updateButtonStates();
            if (old != resolveMode)
                markDirty();
        }
    });
    btnResolveNow.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            btnResolveNow.setEnabled(false);
            doResolve();
        }
    });
    // Layout
    GridLayout layout;
    GridData gd;
    layout = new GridLayout(2, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 5;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    gd.widthHint = 50;
    gd.heightHint = 50;
    table.setLayoutData(gd);
    gd = new GridData(SWT.RIGHT, SWT.CENTER, true, false);
    btnResolveNow.setLayoutData(gd);
}
Also used : ResolveMode(org.bndtools.api.ResolveMode) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) RequirementLabelProvider(org.bndtools.core.ui.resource.RequirementLabelProvider) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

RequirementLabelProvider (org.bndtools.core.ui.resource.RequirementLabelProvider)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 KeyAdapter (org.eclipse.swt.events.KeyAdapter)2 KeyEvent (org.eclipse.swt.events.KeyEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 ToolBar (org.eclipse.swt.widgets.ToolBar)2 ResolveMode (org.bndtools.api.ResolveMode)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1