Search in sources :

Example 1 with URLLabelProvider

use of bndtools.shared.URLLabelProvider in project bndtools by bndtools.

the class ReposPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginRight = 10;
    composite.setLayout(layout);
    Group group = new Group(composite, SWT.NONE);
    group.setText("Templates Repositories");
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    group.setLayout(new GridLayout(2, false));
    final Button btnEnableTemplateRepo = new Button(group, SWT.CHECK);
    btnEnableTemplateRepo.setText("Enable templates repositories");
    btnEnableTemplateRepo.setSelection(enableTemplateRepo);
    btnEnableTemplateRepo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    ControlDecoration decoration = new ControlDecoration(btnEnableTemplateRepo, SWT.RIGHT | SWT.TOP, composite);
    decoration.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
    decoration.setMarginWidth(3);
    decoration.setDescriptionText("These repositories are used to load\ntemplates, in addition to repositories\nconfigured in the Bnd OSGi Workspace.");
    decoration.setShowHover(true);
    decoration.setShowOnlyOnFocus(false);
    Label lblRepos = new Label(group, SWT.NONE);
    lblRepos.setText("Repository URLs:");
    lblRepos.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    final Table tblRepos = new Table(group, SWT.BORDER | SWT.MULTI);
    vwrRepos = new TableViewer(tblRepos);
    vwrRepos.setContentProvider(ArrayContentProvider.getInstance());
    vwrRepos.setLabelProvider(new URLLabelProvider(tblRepos.getDisplay()));
    vwrRepos.setInput(templateRepos);
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.widthHint = 260;
    gd.heightHint = 80;
    tblRepos.setLayoutData(gd);
    tblRepos.setEnabled(enableTemplateRepo);
    final AddRemoveButtonBarPart addRemoveRepoPart = new AddRemoveButtonBarPart();
    Control addRemovePanel = addRemoveRepoPart.createControl(group, SWT.FLAT | SWT.VERTICAL);
    addRemovePanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    addRemoveRepoPart.setRemoveEnabled(false);
    addRemoveRepoPart.addListener(new AddRemoveListener() {

        @Override
        public void addSelected() {
            doAddRepo();
        }

        @Override
        public void removeSelected() {
            doRemoveRepo();
        }
    });
    vwrRepos.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            addRemoveRepoPart.setRemoveEnabled(!vwrRepos.getSelection().isEmpty());
        }
    });
    tblRepos.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL && e.stateMask == 0)
                doRemoveRepo();
        }
    });
    btnEnableTemplateRepo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            enableTemplateRepo = btnEnableTemplateRepo.getSelection();
            tblRepos.setEnabled(enableTemplateRepo);
            validate();
        }
    });
    return composite;
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) AddRemoveButtonBarPart(org.bndtools.utils.swt.AddRemoveButtonBarPart) KeyEvent(org.eclipse.swt.events.KeyEvent) URLLabelProvider(bndtools.shared.URLLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) AddRemoveListener(org.bndtools.utils.swt.AddRemoveButtonBarPart.AddRemoveListener) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

URLLabelProvider (bndtools.shared.URLLabelProvider)1 AddRemoveButtonBarPart (org.bndtools.utils.swt.AddRemoveButtonBarPart)1 AddRemoveListener (org.bndtools.utils.swt.AddRemoveButtonBarPart.AddRemoveListener)1 ControlDecoration (org.eclipse.jface.fieldassist.ControlDecoration)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 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Group (org.eclipse.swt.widgets.Group)1 Label (org.eclipse.swt.widgets.Label)1 Table (org.eclipse.swt.widgets.Table)1