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