use of org.eclipse.jface.action.ToolBarManager in project netxms by netxms.
the class ApplicationActionBarAdvisor method addToolBar.
/**
* Add toolbar.
*
* @param coolBar
* @param id
*/
private void addToolBar(ICoolBarManager coolBar, String id) {
if (coolBar.find(id) != null)
return;
ToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.TRAIL);
toolbar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
coolBar.add(new ToolBarContributionItem(toolbar, id));
coolBar.setLockLayout(true);
}
use of org.eclipse.jface.action.ToolBarManager in project tdq-studio-se by Talend.
the class SqlResultsView method addSQLExecution.
/**
* Add a new (SQL) Execution Tab
*
* @param AbstractSQLExecution
*/
public void addSQLExecution(AbstractSQLExecution sqlExecution) {
if (_tabFolder == null || _tabFolder.isDisposed()) {
clearParent();
// create tab folder for different sessions
_tabFolder = new TabFolder(_parent, SWT.NULL);
_parent.layout();
_parent.redraw();
}
// create tab
_lastTabNumber = _lastTabNumber + 1;
final TabItem tabItem = new TabItem(_tabFolder, SWT.NULL);
// set tab text & tooltip
String labelText = "" + _lastTabNumber;
tabItem.setText(labelText);
tabItem.setData("tabLabel", labelText);
tabItem.setToolTipText(TextUtil.getWrappedText(sqlExecution.getSqlStatement()));
// create composite for our result
Composite composite = new Composite(_tabFolder, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginLeft = 0;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 2;
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
tabItem.setControl(composite);
tabItem.setData(sqlExecution);
tabItem.addDisposeListener(new DisposeListener() {
public void widgetDisposed(final DisposeEvent e) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
// stop all sql execution if still running
TabItem tabItem = (TabItem) e.getSource();
AbstractSQLExecution sqlExecution = (AbstractSQLExecution) tabItem.getData();
sqlExecution.stop();
tabItem.setData(null);
if (_tabFolder != null && !_tabFolder.isDisposed()) {
if (_tabFolder.getItemCount() == 0) {
// this is last tab..
clearParent();
setDefaultMessage();
}
} else if (_tabFolder.isDisposed()) {
clearParent();
setDefaultMessage();
}
}
});
}
});
// add sql statement, first create temp label to calculate correct size
String sqlStatement = sqlExecution.getSqlStatement();
int labelHeight = 60;
int labelStyle = SWT.WRAP | SWT.MULTI;
Text tmpLabel = new Text(composite, labelStyle);
tmpLabel.setText(TextUtil.removeLineBreaks(sqlExecution.getSqlStatement()));
tmpLabel.setLayoutData(new FillLayout());
int parentWidth = _parent.getClientArea().width;
Point idealSize = tmpLabel.computeSize(parentWidth - 30, SWT.DEFAULT);
if (idealSize.y <= 60) {
// we don't need a scroll bar. minimize
labelHeight = idealSize.y;
} else {
// we need a scroll bar
labelStyle = SWT.WRAP | SWT.MULTI | SWT.V_SCROLL;
}
tmpLabel.dispose();
// now create real label
// create spanned cell for table data
Composite headerComposite = new Composite(composite, SWT.FILL);
headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
GridLayout hLayout = new GridLayout();
hLayout.numColumns = 2;
hLayout.marginLeft = 0;
hLayout.horizontalSpacing = 0;
hLayout.verticalSpacing = 0;
hLayout.marginWidth = 0;
hLayout.marginHeight = 0;
headerComposite.setLayout(hLayout);
Text label = new Text(headerComposite, labelStyle);
label.setEditable(false);
label.setBackground(_parent.getBackground());
label.setText(TextUtil.removeLineBreaks(sqlStatement));
label.setToolTipText(TextUtil.getWrappedText(sqlStatement));
GridData labelGridData = new GridData(SWT.FILL, SWT.TOP, true, false);
labelGridData.heightHint = labelHeight;
label.setLayoutData(labelGridData);
// add action bar
ToolBarManager toolBarMgr = new ToolBarManager(SWT.FLAT);
toolBarMgr.createControl(headerComposite);
toolBarMgr.add(new CloseSQLResultTab(tabItem));
toolBarMgr.update(true);
GridData gid = new GridData();
gid.horizontalAlignment = SWT.RIGHT;
gid.verticalAlignment = SWT.TOP;
toolBarMgr.getControl().setLayoutData(gid);
// add detail composite to show progress bar and results
Composite detailComposite = new Composite(composite, SWT.FILL);
detailComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
sqlExecution.setComposite(detailComposite);
sqlExecution.setParentTab(tabItem);
sqlExecution.startExecution();
// set new tab as the active one
_tabFolder.setSelection(_tabFolder.getItemCount() - 1);
// refresh view
composite.layout();
_tabFolder.layout();
_tabFolder.redraw();
// bring this view to top of the view stack
getSite().getPage().bringToTop(this);
}
use of org.eclipse.jface.action.ToolBarManager in project tdq-studio-se by Talend.
the class ApplicationActionBarAdvisor method fillCoolBar.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.application.ActionBarAdvisor#fillCoolBar(org.eclipse.jface.action.ICoolBarManager)
*/
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
// $NON-NLS-1$
coolBar.add(new ToolBarContributionItem(toolbar, "switch_persp"));
toolbar.add(new ChangePerspectiveAction(true));
// $NON-NLS-1$
coolBar.add(new ToolBarContributionItem(toolbar, "save"));
toolbar.add(ActionFactory.SAVE.create(window));
// add feature:15174
// Workbench3xImplementation4CoolBar.createLinksToolbarItem(coolBar);
IToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
toolBarManager.add(new // $NON-NLS-1$
ImageAction(// $NON-NLS-1$
this.window, // $NON-NLS-1$
"icons/demo.png", // $NON-NLS-1$
LinksToolbarItem.LEARN_ORIG_URL, // $NON-NLS-1$
Messages.getString("LinksToolbarItem_0")));
toolBarManager.add(// $NON-NLS-1$
new LinkToolbarLabel(LinksToolbarItem.LEARN_URL, Messages.getString("LinksToolbarItem_0")));
toolBarManager.add(new // $NON-NLS-1$
ImageAction(// $NON-NLS-1$
this.window, // $NON-NLS-1$
"icons/irc_protocol.png", // $NON-NLS-1$
LinksToolbarItem.ASK_ORIG_URL, // $NON-NLS-1$
Messages.getString("LinksToolbarItem_7")));
// $NON-NLS-1$
toolBarManager.add(new LinkToolbarLabel(LinksToolbarItem.ASK_URL, Messages.getString("LinksToolbarItem_7")));
toolBarManager.add(new // $NON-NLS-1$
ImageAction(// $NON-NLS-1$
this.window, // $NON-NLS-1$
"icons/wizard.png", // $NON-NLS-1$
LinksToolbarItem.UPGRADE_ORIG_URL, // $NON-NLS-1$
Messages.getString("LinksToolbarItem_11")));
toolBarManager.add(new LinkToolbarLabel(LinksToolbarItem.UPGRADE_URL, // $NON-NLS-1$
Messages.getString("LinksToolbarItem_11")));
coolBar.add(new ToolBarContributionItem(toolBarManager, LinksToolbarItem.COOLITEM_LINKS_ID));
}
use of org.eclipse.jface.action.ToolBarManager in project portfolio by buchen.
the class DashboardView method recreateDashboardToolItems.
private void recreateDashboardToolItems() {
ToolBarManager toolBar = getViewToolBarManager();
if (toolBar.getControl().isDisposed())
return;
toolBar.removeAll();
createDashboardToolItems(toolBar);
toolBar.update(true);
}
use of org.eclipse.jface.action.ToolBarManager in project portfolio by buchen.
the class HoldingsPieChartView method updateWarningInToolBar.
private void updateWarningInToolBar() {
boolean hasNegativePositions = snapshot.getAssetPositions().anyMatch(p -> p.getValuation().isNegative());
ToolBarManager toolBar = getToolBarManager();
if (hasNegativePositions) {
if (toolBar.find(ID_WARNING_TOOL_ITEM) == null) {
Action warning = new SimpleAction(Messages.HoldingsWarningAssetsWithNegativeValuation, Images.ERROR_NOTICE.descriptor(), a -> {
String details = String.join("\n", // $NON-NLS-1$
snapshot.getAssetPositions().filter(p -> p.getValuation().isNegative()).map(p -> // $NON-NLS-1$
p.getDescription() + " " + Values.Money.format(p.getValuation())).collect(Collectors.toList()));
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.LabelError, MessageFormat.format(Messages.HoldingsWarningAssetsWithNegativeValuationDetails, Values.Money.format(snapshot.getMonetaryAssets()), details));
});
warning.setId(ID_WARNING_TOOL_ITEM);
toolBar.insert(0, new ActionContributionItem(warning));
toolBar.update(true);
}
} else {
if (toolBar.remove(ID_WARNING_TOOL_ITEM) != null)
toolBar.update(true);
}
}
Aggregations