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);
}
}
}
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();
}
});
}
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());
}
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;
}
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);
}
}
Aggregations