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