Search in sources :

Example 51 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project azure-tools-for-java by Microsoft.

the class DropDownHandler method pullDropdown.

public void pullDropdown(Event event) {
    Widget widget = event.widget;
    if (widget instanceof ToolItem) {
        ToolItem toolItem = (ToolItem) widget;
        Listener[] listeners = toolItem.getListeners(SWT.Selection);
        if (listeners.length > 0) {
            Listener listener = listeners[0];
            Event eve = new Event();
            eve.type = SWT.Selection;
            eve.widget = toolItem;
            eve.detail = SWT.DROP_DOWN;
            eve.x = toolItem.getBounds().x;
            eve.y = toolItem.getBounds().height;
            listener.handleEvent(eve);
        }
    }
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Widget(org.eclipse.swt.widgets.Widget) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) Event(org.eclipse.swt.widgets.Event) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 52 with ToolItem

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

the class PluginPathPart method createToolBar.

private void createToolBar(Section section) {
    ToolBar toolbar = new ToolBar(section, SWT.FLAT);
    section.setTextClient(toolbar);
    ToolItem addItem = new ToolItem(toolbar, SWT.PUSH);
    addItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    addItem.setToolTipText("Add Path");
    addItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doAdd();
        }
    });
    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);
    removeItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doRemove();
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 53 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project eclipse.platform.swt by eclipse.

the class AnimatedGraphicsTab method createToolBar.

/**
 * Creates the toolbar controls: play, pause and animation timer.
 *
 * @param parent A composite
 */
void createToolBar(final Composite parent) {
    final Display display = parent.getDisplay();
    toolBar = new ToolBar(parent, SWT.FLAT);
    Listener toolBarListener = event -> {
        switch(event.type) {
            case SWT.Selection:
                {
                    if (event.widget == playItem) {
                        animate = true;
                        playItem.setEnabled(!animate);
                        pauseItem.setEnabled(animate);
                    } else if (event.widget == pauseItem) {
                        animate = false;
                        playItem.setEnabled(!animate);
                        pauseItem.setEnabled(animate);
                    }
                }
                break;
        }
    };
    // play tool item
    playItem = new ToolItem(toolBar, SWT.PUSH);
    // $NON-NLS-1$
    playItem.setText(GraphicsExample.getResourceString("Play"));
    // $NON-NLS-1$
    playItem.setImage(example.loadImage(display, "play.gif"));
    playItem.addListener(SWT.Selection, toolBarListener);
    // pause tool item
    pauseItem = new ToolItem(toolBar, SWT.PUSH);
    // $NON-NLS-1$
    pauseItem.setText(GraphicsExample.getResourceString("Pause"));
    // $NON-NLS-1$
    pauseItem.setImage(example.loadImage(display, "pause.gif"));
    pauseItem.addListener(SWT.Selection, toolBarListener);
    // timer spinner
    Composite comp = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    comp.setLayout(gridLayout);
    Label label = new Label(comp, SWT.CENTER);
    // $NON-NLS-1$
    label.setText(GraphicsExample.getResourceString("Animation"));
    timerSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    timerSpinner.setMaximum(1000);
    playItem.setEnabled(false);
    animate = true;
    timerSpinner.setSelection(getInitialAnimationTime());
}
Also used : RowLayout(org.eclipse.swt.layout.RowLayout) Composite(org.eclipse.swt.widgets.Composite) Listener(org.eclipse.swt.widgets.Listener) SWT(org.eclipse.swt.SWT) ToolBar(org.eclipse.swt.widgets.ToolBar) Spinner(org.eclipse.swt.widgets.Spinner) Display(org.eclipse.swt.widgets.Display) ToolItem(org.eclipse.swt.widgets.ToolItem) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) ToolBar(org.eclipse.swt.widgets.ToolBar) Label(org.eclipse.swt.widgets.Label) ToolItem(org.eclipse.swt.widgets.ToolItem) Display(org.eclipse.swt.widgets.Display)

Example 54 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project eclipse.platform.swt by eclipse.

the class PaintExample method addToolItem.

/**
 * Adds a tool item to the toolbar.
 * Note: Only called by standalone.
 */
private ToolItem addToolItem(final ToolBar toolbar, final Tool tool) {
    final String id = tool.group + '.' + tool.name;
    ToolItem item = new ToolItem(toolbar, tool.type);
    item.setText(getResourceString(id + ".label"));
    item.setToolTipText(getResourceString(id + ".tooltip"));
    item.setImage(tool.image);
    item.addSelectionListener(widgetSelectedAdapter(e -> tool.action.run()));
    final int childID = toolbar.indexOf(item);
    toolbar.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        @Override
        public void getName(org.eclipse.swt.accessibility.AccessibleEvent e) {
            if (e.childID == childID) {
                e.result = getResourceString(id + ".description");
            }
        }
    });
    return item;
}
Also used : Scale(org.eclipse.swt.widgets.Scale) ToolBar(org.eclipse.swt.widgets.ToolBar) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) ImageData(org.eclipse.swt.graphics.ImageData) Point(org.eclipse.swt.graphics.Point) Event(org.eclipse.swt.widgets.Event) MessageFormat(java.text.MessageFormat) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ResourceBundle(java.util.ResourceBundle) Composite(org.eclipse.swt.widgets.Composite) Listener(org.eclipse.swt.widgets.Listener) SWTException(org.eclipse.swt.SWTException) Canvas(org.eclipse.swt.widgets.Canvas) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) Text(org.eclipse.swt.widgets.Text) Shell(org.eclipse.swt.widgets.Shell) MissingResourceException(java.util.MissingResourceException) Display(org.eclipse.swt.widgets.Display) FontDialog(org.eclipse.swt.widgets.FontDialog) ToolItem(org.eclipse.swt.widgets.ToolItem) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) Color(org.eclipse.swt.graphics.Color) SWT(org.eclipse.swt.SWT) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.swt.widgets.Label) InputStream(java.io.InputStream) GridLayout(org.eclipse.swt.layout.GridLayout) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) ToolItem(org.eclipse.swt.widgets.ToolItem) Point(org.eclipse.swt.graphics.Point)

Example 55 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project eclipse.platform.swt by eclipse.

the class PaintExample method createToolBar.

/**
 * Creates the toolbar.
 * Note: Only called by standalone.
 */
private void createToolBar(Composite parent) {
    ToolBar toolbar = new ToolBar(parent, SWT.NONE);
    String group = null;
    for (int i = 0; i < tools.length; i++) {
        Tool tool = tools[i];
        if (group != null && !tool.group.equals(group)) {
            new ToolItem(toolbar, SWT.SEPARATOR);
        }
        group = tool.group;
        ToolItem item = addToolItem(toolbar, tool);
        if (i == Default_tool || i == Default_fill || i == Default_linestyle)
            item.setSelection(true);
    }
}
Also used : ToolBar(org.eclipse.swt.widgets.ToolBar) Point(org.eclipse.swt.graphics.Point) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

ToolItem (org.eclipse.swt.widgets.ToolItem)140 ToolBar (org.eclipse.swt.widgets.ToolBar)110 SelectionEvent (org.eclipse.swt.events.SelectionEvent)91 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)81 GridData (org.eclipse.swt.layout.GridData)73 Composite (org.eclipse.swt.widgets.Composite)64 GridLayout (org.eclipse.swt.layout.GridLayout)58 Image (org.eclipse.swt.graphics.Image)36 Label (org.eclipse.swt.widgets.Label)32 Point (org.eclipse.swt.graphics.Point)26 DisposeEvent (org.eclipse.swt.events.DisposeEvent)25 DisposeListener (org.eclipse.swt.events.DisposeListener)24 Cursor (org.eclipse.swt.graphics.Cursor)20 FillLayout (org.eclipse.swt.layout.FillLayout)18 SelectionListener (org.eclipse.swt.events.SelectionListener)17 TableViewer (org.eclipse.jface.viewers.TableViewer)16 Text (org.eclipse.swt.widgets.Text)16 Display (org.eclipse.swt.widgets.Display)15 ArrayList (java.util.ArrayList)14 List (java.util.List)14