Search in sources :

Example 96 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project tdi-studio-se by Talend.

the class MetadataToolbarEditorViewExt method createColumns.

/**
     * qzhang Comment method "createColumns".
     */
private void createColumns() {
    columnSelector = new ToolBar(toolbar, SWT.HORIZONTAL);
    final ToolItem columns = new ToolItem(columnSelector, SWT.DROP_DOWN);
    //$NON-NLS-1$
    columns.setText(Messages.getString("MetadataToolbarEditorViewExt.Columns.Text"));
    createMenu(columns);
    columns.addSelectionListener(new SelectionAdapter() {

        /*
             * (non-Java)
             * 
             * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
        @Override
        public void widgetSelected(SelectionEvent event) {
            // If they clicked the arrow, we show the list
            // if (event.detail == SWT.ARROW) {
            // Determine where to put the dropdown list
            ToolItem item = (ToolItem) event.widget;
            Rectangle rect = item.getBounds();
            Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
            columnsListmenu.setLocation(pt.x, pt.y + rect.height);
            columnsListmenu.setVisible(true);
        // }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 97 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project bndtools by bndtools.

the class EditableParametersPart method createControl.

public Control createControl(Composite parent) {
    this.parent = parent;
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    composite.setLayout(layout);
    Label titleLabel = new Label(composite, SWT.NONE);
    titleLabel.setText(title);
    titleLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
    Table table = new Table(composite, SWT.BORDER | SWT.MULTI);
    viewer = new TableViewer(table);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    final Image iconImg = imageDescriptor.createImage(parent.getDisplay());
    viewer.setLabelProvider(new StyledCellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            @SuppressWarnings("unchecked") Pair<String, Attrs> entry = (Pair<String, Attrs>) cell.getElement();
            StyledString label = new StyledString(entry.getFirst(), BoldStyler.INSTANCE_DEFAULT);
            for (Entry<String, String> attribEntry : entry.getSecond().entrySet()) {
                label.append("; " + attribEntry.getKey() + "=", StyledString.QUALIFIER_STYLER);
                label.append(attribEntry.getValue());
            }
            cell.setText(label.toString());
            cell.setStyleRanges(label.getStyleRanges());
            cell.setImage(iconImg);
        }
    });
    viewer.setInput(entries);
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.widthHint = 280;
    gd.heightHint = 80;
    table.setLayoutData(gd);
    final AddRemoveButtonBarPart buttonBarPart = new AddRemoveButtonBarPart();
    ToolBar buttonBar = buttonBarPart.createControl(composite, SWT.FLAT | SWT.VERTICAL);
    buttonBar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    final Image imgEdit = ImageDescriptor.createFromURL(BUNDLE.getEntry("icons/edit.gif")).createImage(parent.getDisplay());
    final Image imgEditDisabled = ImageDescriptor.createFromURL(BUNDLE.getEntry("icons/edit-disabled.gif")).createImage(parent.getDisplay());
    final ToolItem btnEdit = new ToolItem(buttonBar, SWT.PUSH);
    btnEdit.setImage(imgEdit);
    btnEdit.setDisabledImage(imgEditDisabled);
    buttonBarPart.setRemoveEnabled(false);
    btnEdit.setEnabled(false);
    buttonBarPart.addListener(new AddRemoveListener() {

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

        @Override
        public void removeSelected() {
            doRemove();
        }
    });
    btnEdit.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doEdit();
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            boolean enabled = !viewer.getSelection().isEmpty();
            buttonBarPart.setRemoveEnabled(enabled);
            btnEdit.setEnabled(enabled);
        }
    });
    viewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            doEdit();
        }
    });
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL && e.stateMask == 0)
                doRemove();
        }
    });
    composite.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent ev) {
            iconImg.dispose();
            imgEdit.dispose();
            imgEditDisabled.dispose();
        }
    });
    return composite;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Attrs(aQute.bnd.header.Attrs) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) DisposeEvent(org.eclipse.swt.events.DisposeEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Entry(java.util.Map.Entry) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem) Pair(aQute.libg.tuple.Pair) StyledCellLabelProvider(org.eclipse.jface.viewers.StyledCellLabelProvider) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StyledString(org.eclipse.jface.viewers.StyledString) ViewerCell(org.eclipse.jface.viewers.ViewerCell) AddRemoveButtonBarPart(org.bndtools.utils.swt.AddRemoveButtonBarPart) AddRemoveListener(org.bndtools.utils.swt.AddRemoveButtonBarPart.AddRemoveListener) IOpenListener(org.eclipse.jface.viewers.IOpenListener) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) TableViewer(org.eclipse.jface.viewers.TableViewer) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 98 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project bndtools by bndtools.

the class ProjectListControl method createFilter.

private void createFilter(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginHeight = gridLayout.marginWidth = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    composite.setLayout(gridLayout);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.grabExcessHorizontalSpace = true;
    composite.setLayoutData(gridData);
    FilterPanelPart filterPart = new FilterPanelPart(Activator.getDefault().getScheduler());
    filterPart.createControl(composite, 0, 0);
    filterPart.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            String filter = (String) event.getNewValue();
            updatedFilter(filter);
        }
    });
    ToolBar toolbar = new ToolBar(composite, SWT.FLAT);
    ToolItem tiCheckAll = new ToolItem(toolbar, SWT.FLAT);
    tiCheckAll.setImage(Activator.getImageDescriptor("icons/check_all.gif").createImage());
    tiCheckAll.setToolTipText(Messages.checkAll);
    tiCheckAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Object[] objs = contentProvider.getElements(null);
            for (Object obj : objs) {
                ProjectDiff diff = (ProjectDiff) obj;
                diff.setRelease(true);
            }
            tableViewer.refresh();
        }
    });
    ToolItem tiUncheckAll = new ToolItem(toolbar, SWT.FLAT);
    tiUncheckAll.setImage(Activator.getImageDescriptor("icons/uncheck_all.gif").createImage());
    tiUncheckAll.setToolTipText(Messages.uncheckAll);
    tiUncheckAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Object[] objs = contentProvider.getElements(null);
            for (Object obj : objs) {
                ProjectDiff diff = (ProjectDiff) obj;
                diff.setRelease(false);
            }
            tableViewer.refresh();
        }
    });
}
Also used : FilterPanelPart(org.bndtools.utils.swt.FilterPanelPart) PropertyChangeEvent(java.beans.PropertyChangeEvent) ProjectDiff(bndtools.release.ProjectDiff) Composite(org.eclipse.swt.widgets.Composite) PropertyChangeListener(java.beans.PropertyChangeListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 99 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project bndtools by bndtools.

the class UpDownButtonBarPart method createControl.

public Control createControl(Composite parent, int style) {
    toolbar = new ToolBar(parent, style);
    btnUp = new ToolItem(toolbar, SWT.PUSH);
    btnUp.setImage(imgUp);
    btnUp.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doMoveUp();
        }
    });
    btnDown = new ToolItem(toolbar, SWT.PUSH);
    btnDown.setImage(imgDown);
    btnDown.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doMoveDown();
        }
    });
    toolbar.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent de) {
            if (!imgUp.isDisposed())
                imgUp.dispose();
            if (!imgDown.isDisposed())
                imgDown.dispose();
        }
    });
    return toolbar;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 100 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project bndtools by bndtools.

the class PkgPatternsListPart method createSection.

protected void createSection(Section section, FormToolkit toolkit) {
    Composite composite = toolkit.createComposite(section);
    section.setClient(composite);
    ToolBar toolbar = new ToolBar(section, SWT.FLAT);
    section.setTextClient(toolbar);
    final ToolItem addItem = new ToolItem(toolbar, SWT.PUSH);
    addItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    addItem.setToolTipText("Add");
    final ToolItem insertItem = new ToolItem(toolbar, SWT.PUSH);
    insertItem.setImage(imgInsert);
    insertItem.setToolTipText("Insert");
    insertItem.setEnabled(false);
    final ToolItem removeItem = new ToolItem(toolbar, SWT.PUSH);
    removeItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    removeItem.setDisabledImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE_DISABLED));
    removeItem.setToolTipText("Remove");
    removeItem.setEnabled(false);
    Table table = toolkit.createTable(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    viewer = new TableViewer(table);
    viewer.setUseHashlookup(false);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(labelProvider);
    toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
    final ToolItem btnMoveUp = new ToolItem(toolbar, SWT.PUSH);
    btnMoveUp.setText("Up");
    btnMoveUp.setImage(imgUp);
    btnMoveUp.setEnabled(false);
    final ToolItem btnMoveDown = new ToolItem(toolbar, SWT.PUSH);
    btnMoveDown.setText("Down");
    btnMoveDown.setImage(imgDown);
    btnMoveDown.setEnabled(false);
    // Listeners
    table.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            ISelection selection = viewer.getSelection();
            if (!selection.isEmpty())
                managedForm.fireSelectionChanged(PkgPatternsListPart.this, selection);
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            List<C> oldSelection = selection;
            IStructuredSelection structSel = (IStructuredSelection) event.getSelection();
            @SuppressWarnings("unchecked") List<C> newSelection = structSel.toList();
            selection = newSelection;
            propChangeSupport.firePropertyChange(PROP_SELECTION, oldSelection, selection);
            managedForm.fireSelectionChanged(PkgPatternsListPart.this, event.getSelection());
            boolean enabled = !viewer.getSelection().isEmpty();
            insertItem.setEnabled(enabled);
            removeItem.setEnabled(enabled);
            btnMoveUp.setEnabled(enabled);
            btnMoveDown.setEnabled(enabled);
        }
    });
    viewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { LocalSelectionTransfer.getTransfer(), ResourceTransfer.getInstance(), TextTransfer.getInstance() }, new PackageDropAdapter<C>(viewer) {

        @Override
        protected C createNewEntry(String packageName) {
            return newHeaderClause(packageName);
        }

        @Override
        protected void addRows(int index, Collection<C> rows) {
            doAddClauses(rows, index, true);
        }

        @Override
        protected int indexOf(Object object) {
            return clauses.indexOf(object);
        }
    });
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == SWT.DEL) {
                doRemoveSelectedClauses();
            } else if (e.character == '+') {
                doAddClausesAfterSelection(generateClauses());
            }
        }
    });
    addItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doAddClausesAfterSelection(generateClauses());
        }
    });
    insertItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doInsertClausesAtSelection(generateClauses());
        }
    });
    removeItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doRemoveSelectedClauses();
        }
    });
    btnMoveUp.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doMoveUp();
        }
    });
    btnMoveDown.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doMoveDown();
        }
    });
    // Layout
    GridLayout layout;
    layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    composite.setLayout(layout);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 75;
    gd.heightHint = 75;
    table.setLayoutData(gd);
    toolbar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) ToolItem(org.eclipse.swt.widgets.ToolItem) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

ToolBar (org.eclipse.swt.widgets.ToolBar)127 ToolItem (org.eclipse.swt.widgets.ToolItem)110 SelectionEvent (org.eclipse.swt.events.SelectionEvent)82 GridData (org.eclipse.swt.layout.GridData)81 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)74 GridLayout (org.eclipse.swt.layout.GridLayout)68 Composite (org.eclipse.swt.widgets.Composite)67 Image (org.eclipse.swt.graphics.Image)35 Label (org.eclipse.swt.widgets.Label)34 DisposeEvent (org.eclipse.swt.events.DisposeEvent)27 DisposeListener (org.eclipse.swt.events.DisposeListener)26 Point (org.eclipse.swt.graphics.Point)24 Cursor (org.eclipse.swt.graphics.Cursor)22 TableViewer (org.eclipse.jface.viewers.TableViewer)18 FillLayout (org.eclipse.swt.layout.FillLayout)18 Button (org.eclipse.swt.widgets.Button)17 Text (org.eclipse.swt.widgets.Text)17 ArrayList (java.util.ArrayList)14 SashForm (org.eclipse.swt.custom.SashForm)14 Combo (org.eclipse.swt.widgets.Combo)14