Search in sources :

Example 41 with ToolBarManager

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);
}
Also used : ToolBarContributionItem(org.eclipse.jface.action.ToolBarContributionItem) GroupMarker(org.eclipse.jface.action.GroupMarker) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 42 with ToolBarManager

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);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) TabFolder(org.eclipse.swt.widgets.TabFolder) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Point(org.eclipse.swt.graphics.Point) ToolBarManager(org.eclipse.jface.action.ToolBarManager) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) AbstractSQLExecution(net.sourceforge.sqlexplorer.sqlpanel.AbstractSQLExecution) CloseSQLResultTab(net.sourceforge.sqlexplorer.sqlpanel.actions.CloseSQLResultTab) GridData(org.eclipse.swt.layout.GridData)

Example 43 with ToolBarManager

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));
}
Also used : ToolBarContributionItem(org.eclipse.jface.action.ToolBarContributionItem) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ChangePerspectiveAction(org.talend.dataprofiler.core.ui.perspective.ChangePerspectiveAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) LinkToolbarLabel(org.talend.dataprofiler.rcp.intro.linksbar.LinkToolbarLabel)

Example 44 with ToolBarManager

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);
}
Also used : ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 45 with ToolBarManager

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);
    }
}
Also used : Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) EmbeddedBrowser(name.abuchen.portfolio.ui.util.EmbeddedBrowser) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) Images(name.abuchen.portfolio.ui.Images) SecurityPriceChartPane(name.abuchen.portfolio.ui.views.panes.SecurityPriceChartPane) TradesPane(name.abuchen.portfolio.ui.views.panes.TradesPane) Inject(javax.inject.Inject) MessageFormat(com.ibm.icu.text.MessageFormat) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) SecurityEventsPane(name.abuchen.portfolio.ui.views.panes.SecurityEventsPane) InformationPanePage(name.abuchen.portfolio.ui.views.panes.InformationPanePage) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) UIConstants(name.abuchen.portfolio.ui.UIConstants) AbstractFinanceView(name.abuchen.portfolio.ui.editor.AbstractFinanceView) ClientFilterDropDown(name.abuchen.portfolio.ui.util.ClientFilterDropDown) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Display(org.eclipse.swt.widgets.Display) HistoricalPricesPane(name.abuchen.portfolio.ui.views.panes.HistoricalPricesPane) Collectors(java.util.stream.Collectors) Preference(org.eclipse.e4.core.di.extensions.Preference) List(java.util.List) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) LocalDate(java.time.LocalDate) TransactionsPane(name.abuchen.portfolio.ui.views.panes.TransactionsPane) PostConstruct(javax.annotation.PostConstruct) ToolBarManager(org.eclipse.jface.action.ToolBarManager) IPieChart(name.abuchen.portfolio.ui.views.IPieChart) ClientSnapshot(name.abuchen.portfolio.snapshot.ClientSnapshot) Control(org.eclipse.swt.widgets.Control) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Aggregations

ToolBarManager (org.eclipse.jface.action.ToolBarManager)113 Composite (org.eclipse.swt.widgets.Composite)63 Action (org.eclipse.jface.action.Action)45 GridData (org.eclipse.swt.layout.GridData)44 Control (org.eclipse.swt.widgets.Control)39 ToolBar (org.eclipse.swt.widgets.ToolBar)33 GridLayout (org.eclipse.swt.layout.GridLayout)31 Separator (org.eclipse.jface.action.Separator)30 List (java.util.List)27 SWT (org.eclipse.swt.SWT)27 IMenuManager (org.eclipse.jface.action.IMenuManager)25 Images (name.abuchen.portfolio.ui.Images)24 Messages (name.abuchen.portfolio.ui.Messages)24 IToolBarManager (org.eclipse.jface.action.IToolBarManager)23 DropDown (name.abuchen.portfolio.ui.util.DropDown)22 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)22 IAction (org.eclipse.jface.action.IAction)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)21 ArrayList (java.util.ArrayList)19 DisposeEvent (org.eclipse.swt.events.DisposeEvent)19