Search in sources :

Example 46 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project Palladio-Editors-Sirius by PalladioSimulator.

the class EditorSection method createEditorSection.

private void createEditorSection() {
    ToolBar toolBar = createToolBar();
    createTableSection(toolBar);
}
Also used : ToolBar(org.eclipse.swt.widgets.ToolBar)

Example 47 with ToolBar

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

the class ValgrindViewPart method createDynamicContent.

/**
 * Returns a refreshable view specific of a Valgrind tool.
 *
 * @param description     the content description
 * @param toolID          the Valgrind tool identifier
 * @return                the Valgrind tool view
 * @throws CoreException  the toolbar is disposed
 */
public IValgrindToolView createDynamicContent(String description, String toolID) throws CoreException {
    setContentDescription(description);
    // remove tool specific toolbar controls
    IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
    ToolBar tb = ((ToolBarManager) toolbar).getControl();
    if (tb == null || tb.isDisposed()) {
        // $NON-NLS-1$
        throw new CoreException(new Status(IStatus.ERROR, ValgrindUIPlugin.PLUGIN_ID, "Toolbar is disposed"));
    }
    if (dynamicActions != null) {
        for (ActionContributionItem item : dynamicActions) {
            toolbar.remove(item);
        }
    }
    // remove old view controls
    if (dynamicView != null) {
        dynamicView.dispose();
    }
    // remove old messages
    if (messages != null) {
        messagesViewer.getTreeViewer().setInput(null);
        messages = null;
    }
    for (Control child : dynamicViewHolder.getChildren()) {
        if (!child.isDisposed()) {
            child.dispose();
        }
    }
    if (toolID != null) {
        dynamicView = ValgrindUIPlugin.getDefault().getToolView(toolID);
        dynamicView.createPartControl(dynamicViewHolder);
        // create toolbar items
        IAction[] actions = dynamicView.getToolbarActions();
        if (actions != null) {
            dynamicActions = new ActionContributionItem[actions.length];
            for (int i = 0; i < actions.length; i++) {
                dynamicActions[i] = new ActionContributionItem(actions[i]);
                toolbar.appendToGroup(TOOLBAR_LOC_GROUP_ID, dynamicActions[i]);
            }
        }
    } else {
        dynamicView = null;
    }
    // remove old menu items
    IMenuManager menu = getViewSite().getActionBars().getMenuManager();
    menu.removeAll();
    // was content was created?
    hasDynamicContent = dynamicViewHolder.getChildren().length > 0;
    if (hasDynamicContent) {
        menu.add(showCoreAction);
        menu.add(showToolAction);
    }
    menu.update(true);
    toolbar.update(true);
    // Update to notify the workbench items have been changed
    getViewSite().getActionBars().updateActionBars();
    dynamicViewHolder.layout(true);
    return dynamicView;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) Control(org.eclipse.swt.widgets.Control) CoreException(org.eclipse.core.runtime.CoreException) IAction(org.eclipse.jface.action.IAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBar(org.eclipse.swt.widgets.ToolBar) IMenuManager(org.eclipse.jface.action.IMenuManager) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 48 with ToolBar

use of org.eclipse.swt.widgets.ToolBar 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 49 with ToolBar

use of org.eclipse.swt.widgets.ToolBar 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 50 with ToolBar

use of org.eclipse.swt.widgets.ToolBar 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)

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