Search in sources :

Example 16 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project cubrid-manager by CUBRID.

the class CubridNavigatorView method createPartControl.

/**
	 * Create the part control
	 *
	 * @param parent Composite
	 */
public void createPartControl(Composite parent) {
    ViewForm viewForm = new ViewForm(parent, SWT.NONE);
    viewForm.setLayout(new GridLayout());
    tv = new TreeViewer(viewForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    tv.setFilters(NodeFilterManager.getInstance().getViewerFilter());
    //create the navigator
    createNavigator();
    //get the isShowGroup configuration
    isShowGroup = savedIsShowGroup();
    //set the tree view's input.
    setTreeInput();
    toolTip = new ToolTip(tv.getTree().getShell(), SWT.BALLOON);
    toolTip.setAutoHide(true);
    //Create the context menu
    MenuManager contextMenuManager = new MenuManager("#PopupMenu", "navigatorContextMenu");
    contextMenuManager.setRemoveAllWhenShown(true);
    contextMenuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            buildPopupMenu(manager);
        }
    });
    Menu contextMenu = contextMenuManager.createContextMenu(tv.getControl());
    tv.getControl().setMenu(contextMenu);
    // register the context menu for providing extension by extension point
    IWorkbenchPartSite site = getSite();
    site.registerContextMenu(contextMenuManager, tv);
    site.setSelectionProvider(tv);
    //add the select the object text composite to top left of toolbar
    ToolBar toolBar = new ToolBar(viewForm, SWT.FLAT);
    ToolBarManager toolBarManager = new ToolBarManager(toolBar);
    SelectTreeObjContrItem textContrItem = new SelectTreeObjContrItem(tv);
    toolBarManager.add(textContrItem);
    toolBarManager.update(true);
    viewForm.setContent(tv.getControl());
    viewForm.setTopLeft(toolBar);
    //add the other actions to the top right of toolbar
    toolBar = new ToolBar(viewForm, SWT.FLAT | SWT.CENTER);
    toolBarManager = new ToolBarManager(toolBar);
    buildToolBar(toolBarManager);
    toolBarManager.update(true);
    viewForm.setTopRight(toolBar);
    //Add the actions to view menu bar, you can add them by extension point or code define
    IActionBars actionBar = getViewSite().getActionBars();
    final IMenuManager menuManager = actionBar.getMenuManager();
    menuManager.addMenuListener(new IMenuListener2() {

        //reserve these actions by code define,these codes rebuild every time.
        //hence when hide, remove them not including these actions by extension point
        private IMenuManager lastMenuManager = new MenuManager();

        public void menuAboutToShow(IMenuManager manager) {
            lastMenuManager.removeAll();
            //build the code defined actions
            buildViewMenu(lastMenuManager);
            for (IContributionItem item : lastMenuManager.getItems()) {
                manager.add(item);
            }
        }

        public void menuAboutToHide(IMenuManager manager) {
            for (IContributionItem item : lastMenuManager.getItems()) {
                manager.remove(item);
            }
        }
    });
    menuManager.add(new Separator());
    activeContext();
    addListener();
    setFocus();
}
Also used : ToolTip(org.eclipse.swt.widgets.ToolTip) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IContributionItem(org.eclipse.jface.action.IContributionItem) IMenuListener(org.eclipse.jface.action.IMenuListener) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ViewForm(org.eclipse.swt.custom.ViewForm) GridLayout(org.eclipse.swt.layout.GridLayout) IMenuListener2(org.eclipse.jface.action.IMenuListener2) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolBar(org.eclipse.swt.widgets.ToolBar) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IActionBars(org.eclipse.ui.IActionBars) Separator(org.eclipse.jface.action.Separator)

Example 17 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project tdi-studio-se by Talend.

the class RuntimeGraphcsComposite method addSectionActions.

private static void addSectionActions(ExpandableComposite expandableComposite, List<Action> actions) {
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolbar = toolBarManager.createControl(expandableComposite);
    Button button = new Button(expandableComposite, SWT.PUSH);
    //$NON-NLS-1$
    button.setText("Trigger GC");
    button.setVisible(false);
    // set cursor
    final Cursor cursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
    toolbar.setCursor(cursor);
    toolbar.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (!cursor.isDisposed()) {
                cursor.dispose();
            }
        }
    });
    // add menus
    for (Action action : actions) {
        if (action instanceof GarbageAction) {
            toolBarManager.add(action);
        }
    }
    toolBarManager.update(true);
    expandableComposite.setTextClient(button);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) LoadChartAction(org.talend.designer.runtime.visualization.internal.ui.properties.timeline.LoadChartAction) GarbageAction(org.talend.designer.runtime.visualization.internal.ui.properties.memory.GarbageAction) Action(org.eclipse.jface.action.Action) Button(org.eclipse.swt.widgets.Button) GarbageAction(org.talend.designer.runtime.visualization.internal.ui.properties.memory.GarbageAction) ToolBar(org.eclipse.swt.widgets.ToolBar) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 18 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project tdi-studio-se by Talend.

the class TimelineSection method addSectionActions.

/**
     * Adds the menus on expandable composite.
     * 
     * @param expandableComposite The expandable composite
     * @param actions The actions
     */
private static void addSectionActions(ExpandableComposite expandableComposite, List<Action> actions) {
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolbar = toolBarManager.createControl(expandableComposite);
    // set cursor
    final Cursor cursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
    toolbar.setCursor(cursor);
    toolbar.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (!cursor.isDisposed()) {
                cursor.dispose();
            }
        }
    });
    // add menus
    for (Action action : actions) {
        toolBarManager.add(action);
    }
    toolBarManager.update(true);
    expandableComposite.setTextClient(toolbar);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) GarbageCollectorAction(org.talend.designer.runtime.visualization.internal.ui.properties.memory.GarbageCollectorAction) Action(org.eclipse.jface.action.Action) RefreshAction(org.talend.designer.runtime.visualization.internal.actions.RefreshAction) ToolBar(org.eclipse.swt.widgets.ToolBar) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 19 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project tdi-studio-se by Talend.

the class SQLResultComposite method createHeaderComposite.

/**
     * 
     * DOC dev Comment method "createHeaderComposite".
     * 
     * @param parent a TabItem 's Control
     * @param tabItem a TabItem
     */
private void createHeaderComposite(Composite parent, CTabItem tabItem) {
    // add sql statement, first create temp label to calculate correct size
    // int labelStyle = SWT.WRAP | SWT.MULTI | SWT.V_SCROLL;
    //
    // Text tmpLabel = new Text(parent, labelStyle);
    // tmpLabel.setText(TextUtil.removeLineBreaks(sqlExecution.getSqlStatement()));
    // tmpLabel.setLayoutData(new FillLayout());
    // int parentWidth = this.getClientArea().width;
    // Point idealSize = tmpLabel.computeSize(parentWidth - 30, SWT.DEFAULT);
    //
    // if (idealSize.y > 60) {
    // // 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(parent, 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, SWT.H_SCROLL);
    // label.setEnabled(false);
    label.setEditable(false);
    label.setBackground(this.getBackground());
    label.setText(TextUtil.removeLineBreaks(sqlExecution.getSqlStatement()));
    label.setToolTipText(TextUtil.getWrappedText(sqlExecution.getSqlStatement()));
    GridData labelGridData = new GridData(SWT.FILL, SWT.TOP, true, true);
    // labelGridData.heightHint = labelHeight;
    label.setLayoutData(labelGridData);
    label.setVisible(true);
    // add action bar
    ToolBarManager toolBarMgr = new ToolBarManager(SWT.FLAT);
    toolBarMgr.createControl(headerComposite);
    toolBarMgr.add(new CloseSQLResultTabAction(tabItem));
    toolBarMgr.update(true);
    GridData gid = new GridData();
    gid.horizontalAlignment = SWT.RIGHT;
    gid.verticalAlignment = SWT.TOP;
    toolBarMgr.getControl().setLayoutData(gid);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) CloseSQLResultTabAction(org.talend.sqlbuilder.actions.CloseSQLResultTabAction) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 20 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project linuxtools by eclipse.

the class ImportRPMsPage method createFormContent.

@Override
protected void createFormContent(IManagedForm managedForm) {
    // setting up the form page
    super.createFormContent(managedForm);
    GridLayout layout = new GridLayout();
    FormToolkit toolkit = managedForm.getToolkit();
    ScrolledForm form = managedForm.getForm();
    form.setText(Messages.ImportRPMsPage_formHeaderText);
    form.setImage(Activator.getImageDescriptor(HEADER_ICON).createImage());
    ToolBarManager toolbarManager = (ToolBarManager) form.getToolBarManager();
    toolkit.decorateFormHeading(form.getForm());
    // add the menuContribution from MANIFEST.MF to the form
    IMenuService menuService = getSite().getService(IMenuService.class);
    menuService.populateContributionManager(toolbarManager, MENU_URI);
    toolbarManager.update(true);
    layout = new GridLayout(2, true);
    layout.marginWidth = 6;
    layout.marginHeight = 12;
    form.getBody().setLayout(layout);
    // Section and its client area to manage importing the RPMs
    Section rpmSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    layout = new GridLayout();
    rpmSection.setText(Messages.ImportRPMsPage_sectionTitle);
    rpmSection.setDescription(Messages.ImportRPMsPage_sectionInstruction);
    rpmSection.setLayoutData(expandComposite());
    // the client area containing the tree + buttons
    Composite sectionClient = toolkit.createComposite(rpmSection);
    layout = new GridLayout(2, false);
    layout.marginWidth = 1;
    layout.marginHeight = 7;
    sectionClient.setLayout(layout);
    TreeViewer viewer = new TreeViewer(sectionClient, SWT.BORDER | SWT.MULTI | SWT.HORIZONTAL | SWT.VERTICAL | SWT.LEFT_TO_RIGHT | SWT.SMOOTH);
    viewer.addDropSupport(DND.DROP_COPY, new Transfer[] { FileTransfer.getInstance() }, new ImportRPMDropListener(viewer, project));
    tree = viewer.getTree();
    tree.setLayoutData(expandComposite());
    Composite buttonList = toolkit.createComposite(sectionClient);
    layout = new GridLayout();
    GridData data = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    buttonList.setLayout(layout);
    buttonList.setLayoutData(data);
    createPushButton(buttonList, Messages.ImportRPMsPage_buttonImportRPMs, toolkit).addSelectionListener(new ImportButtonListener());
    createPushButton(buttonList, Messages.ImportRPMsPage_buttonRemoveRPMs, toolkit).addSelectionListener(new RemoveButtonListener());
    new Label(buttonList, SWT.NONE).setLayoutData(new GridData(0, 0));
    createPushButton(buttonList, Messages.ImportRPMsPage_buttonCreateRepo, toolkit).addSelectionListener(new CreaterepoButtonListener());
    refreshTree();
    rpmSection.setClient(sectionClient);
    managedForm.refresh();
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Label(org.eclipse.swt.widgets.Label) Section(org.eclipse.ui.forms.widgets.Section) ToolBarManager(org.eclipse.jface.action.ToolBarManager) GridLayout(org.eclipse.swt.layout.GridLayout) IMenuService(org.eclipse.ui.menus.IMenuService) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) GridData(org.eclipse.swt.layout.GridData) ImportRPMDropListener(org.eclipse.linuxtools.internal.rpm.createrepo.dnd.ImportRPMDropListener)

Aggregations

ToolBarManager (org.eclipse.jface.action.ToolBarManager)25 GridData (org.eclipse.swt.layout.GridData)15 GridLayout (org.eclipse.swt.layout.GridLayout)13 ToolBar (org.eclipse.swt.widgets.ToolBar)12 Composite (org.eclipse.swt.widgets.Composite)11 IToolBarManager (org.eclipse.jface.action.IToolBarManager)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 Button (org.eclipse.swt.widgets.Button)6 ToolBarContributionItem (org.eclipse.jface.action.ToolBarContributionItem)4 Label (org.eclipse.swt.widgets.Label)4 Action (org.eclipse.jface.action.Action)3 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 DisposeEvent (org.eclipse.swt.events.DisposeEvent)3 DisposeListener (org.eclipse.swt.events.DisposeListener)3 ArrayList (java.util.ArrayList)2 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)2 IAction (org.eclipse.jface.action.IAction)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2