Search in sources :

Example 1 with ResolveMode

use of org.bndtools.api.ResolveMode in project bndtools by bndtools.

the class BndEditor method doSave.

@Override
public void doSave(IProgressMonitor monitor) {
    // Commit dirty pages
    if (sourcePage.isActive() && sourcePage.isDirty()) {
        sourcePage.commit(true);
    } else {
        commitPages(true);
        sourcePage.refresh();
    }
    ResolveMode resolveMode = getResolveMode();
    // If auto resolve, then resolve and save in background thread.
    if (resolveMode == ResolveMode.auto && !PlatformUI.getWorkbench().isClosing()) {
        doAutoResolveOnSave(monitor);
    } else {
        // Not auto-resolving, just save
        reallySave(monitor);
    }
}
Also used : ResolveMode(org.bndtools.api.ResolveMode)

Example 2 with ResolveMode

use of org.bndtools.api.ResolveMode 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

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