Search in sources :

Example 1 with PackageNameLabelProvider

use of bndtools.internal.pkgselection.PackageNameLabelProvider in project bndtools by bndtools.

the class PackageListWizardPage method createControl.

@SuppressWarnings("unused")
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    setControl(composite);
    composite.setLayout(new GridLayout(3, false));
    Label lblAvailablePackages = new Label(composite, SWT.NONE);
    lblAvailablePackages.setText("Available Packages:");
    new Label(composite, SWT.NONE);
    Label lblSelectedPackages = new Label(composite, SWT.NONE);
    lblSelectedPackages.setText("Selected Packages:");
    tblAvailable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
    tblAvailable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    availableViewer = new TableViewer(tblAvailable);
    availableViewer.setContentProvider(ArrayContentProvider.getInstance());
    availableViewer.setLabelProvider(new PackageNameLabelProvider());
    availableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            updateUI();
        }
    });
    availableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            doAddSelection();
        }
    });
    Composite composite_1 = new Composite(composite, SWT.NONE);
    GridLayout gl_composite_1 = new GridLayout(1, false);
    gl_composite_1.marginWidth = 0;
    gl_composite_1.marginHeight = 0;
    composite_1.setLayout(gl_composite_1);
    btnAdd = new Button(composite_1, SWT.NONE);
    btnAdd.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnAdd.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doAddSelection();
        }
    });
    btnAdd.setText("Add ->");
    btnAdd.setEnabled(false);
    btnAddAll = new Button(composite_1, SWT.NONE);
    btnAddAll.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnAddAll.setText("Add All ->");
    btnAddAll.setEnabled(false);
    btnAddAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doAddAll();
        }
    });
    btnRemove = new Button(composite_1, SWT.NONE);
    btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnRemove.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doRemoveSelection();
        }
    });
    btnRemove.setText("<- Remove");
    btnRemove.setEnabled(false);
    btnRemoveAll = new Button(composite_1, SWT.NONE);
    btnRemoveAll.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnRemoveAll.setText("<- Remove All");
    btnRemoveAll.setEnabled(false);
    btnRemoveAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doRemoveAll();
        }
    });
    tblSelected = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
    tblSelected.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    selectedViewer = new TableViewer(tblSelected);
    selectedViewer.setContentProvider(ArrayContentProvider.getInstance());
    selectedViewer.setLabelProvider(new PackageNameLabelProvider());
    selectedViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            updateUI();
        }
    });
    selectedViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            doRemoveSelection();
        }
    });
    Composite composite_2 = new Composite(composite, SWT.NONE);
    composite_2.setLayout(new GridLayout(2, false));
    composite_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    Label lblNewLabel = new Label(composite_2, SWT.NONE);
    lblNewLabel.setText("Project Name:");
    txtProjectName = new Text(composite_2, SWT.BORDER);
    txtProjectName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtProjectName.setText(projectName != null ? projectName : "");
    txtProjectName.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (!programmaticChange) {
                try {
                    uiChange = true;
                    setProjectName(txtProjectName.getText());
                } finally {
                    uiChange = false;
                }
            }
        }
    });
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) PackageNameLabelProvider(bndtools.internal.pkgselection.PackageNameLabelProvider) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

PackageNameLabelProvider (bndtools.internal.pkgselection.PackageNameLabelProvider)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)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 Label (org.eclipse.swt.widgets.Label)1 Table (org.eclipse.swt.widgets.Table)1 Text (org.eclipse.swt.widgets.Text)1