use of org.eclipse.jface.action.ToolBarManager in project dbeaver by dbeaver.
the class ProgressPageControl method createProgressPanel.
public Composite createProgressPanel(Composite container) {
if (this.ownerPageControl != null) {
// $NON-NLS-1$
throw new IllegalStateException("Can't create page control while substitution control already set");
}
if (showDivider) {
Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
Composite infoGroup = new Composite(container, SWT.NONE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
infoGroup.setLayoutData(gd);
GridLayout gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
infoGroup.setLayout(gl);
listInfoLabel = new Label(infoGroup, SWT.NONE);
// listInfoLabel.setCursor(infoGroup.getDisplay().getSystemCursor(SWT.CURSOR_HELP));
// listInfoLabel.setBackground(container.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = 5;
gd.minimumWidth = 100;
listInfoLabel.setLayoutData(gd);
Composite controlsComposite = UIUtils.createPlaceholder(infoGroup, 2, 5);
controlsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
searchControlsComposite = UIUtils.createPlaceholder(controlsComposite, 1);
// gd.heightHint = listInfoLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false).y + gl.verticalSpacing;
searchControlsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Placeholder toolbar (need to set initial height of search composite)
new ToolBar(searchControlsComposite, SWT.NONE);
customControlsComposite = new Composite(controlsComposite, SWT.NONE);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
// gd.verticalIndent = 3;
customControlsComposite.setLayoutData(gd);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
customControlsComposite.setLayout(gl);
defaultToolbarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
customToolbarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
hideControls(true);
return infoGroup;
}
use of org.eclipse.jface.action.ToolBarManager in project cubrid-manager by CUBRID.
the class QueryResultComposite method makeResult.
/**
* make the result contents.
*
* @param result QueryExecuter
*/
private void makeResult(final QueryExecuter result, CTabFolder parentFolder) {
editor.getCombinedQueryComposite().getRecentlyUsedSQLComposite().refreshRecentlyUsedSQLList();
//final CTabFolder queryResultTabFolder = ((QueryResultComposite)queryResultTabItem.getControl()).queryResultTabFolder;
ViewForm viewForm = new ViewForm(parentFolder, SWT.NONE);
// create the bottom sash
final SashForm tableLogSash = new SashForm(viewForm, SWT.VERTICAL);
tableLogSash.SASH_WIDTH = SASH_WIDTH;
tableLogSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
final Composite resultContainer = new Composite(tableLogSash, SWT.None);
resultContainer.setLayout(new FormLayout());
final Table resultTable = new Table(resultContainer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
setDropTraget(resultTable);
resultTable.setHeaderVisible(true);
resultTable.setLinesVisible(true);
resultTable.setBackground(BACKGROUND_NORMAL);
CommonUITool.hackForYosemite(resultTable);
// display data compare label for multiple queries
if (this.multiResultsCompare == true) {
Composite compareButtonComposite = new Composite(resultContainer, SWT.None);
compareButtonComposite.setLayout(new FillLayout());
displayDataCompareLabel(compareButtonComposite, resultTable);
FormData tableData = new FormData();
tableData.top = new FormAttachment(0, 0);
tableData.bottom = new FormAttachment(100, -28);
tableData.left = new FormAttachment(0, 0);
tableData.right = new FormAttachment(100, 0);
resultTable.setLayoutData(tableData);
FormData compareData = new FormData();
compareData.top = new FormAttachment(100, -28);
compareData.bottom = new FormAttachment(100, 0);
compareData.left = new FormAttachment(0, 0);
compareData.right = new FormAttachment(100, 0);
compareButtonComposite.setLayoutData(compareData);
} else {
FormData tableData = new FormData();
tableData.top = new FormAttachment(0, 0);
tableData.bottom = new FormAttachment(100, 0);
tableData.left = new FormAttachment(0, 0);
tableData.right = new FormAttachment(100, 0);
resultTable.setLayoutData(tableData);
}
final SashForm logSash = new SashForm(tableLogSash, SWT.HORIZONTAL);
logSash.SASH_WIDTH = SASH_WIDTH;
logSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
logSash.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
StyledText messagesArea = new StyledText(logSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY | SWT.WRAP);
CommonUITool.registerCopyPasteContextMenu(messagesArea, false, false);
tableLogSash.setWeights(new int[] { 8, 2 });
messagesArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
messagesArea.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
tableLogSash.setWeights(new int[] { 8, 2 });
}
public void focusGained(FocusEvent e) {
tableLogSash.setWeights(new int[] { 2, 8 });
}
});
TableCursor cursor = new TableCursor(resultTable, SWT.NONE);
TableSelectSupport tableSelectSupport = new TableSelectSupport(resultTable, cursor);
if (this.multiResultsCompare == true) {
result.setMultiResultsCompare(true);
result.setBaseQueryExecuter(this.baseQueryExecuter);
}
result.makeResult(tableSelectSupport, messagesArea, isMutliQuery);
// Auto set column size, maximum is 300px,minimum is 50px
for (int i = 1; i < resultTable.getColumnCount(); i++) {
resultTable.getColumns()[i].pack();
if (resultTable.getColumns()[i].getWidth() > 300) {
resultTable.getColumns()[i].setWidth(300);
}
if (resultTable.getColumns()[i].getWidth() < 50) {
resultTable.getColumns()[i].setWidth(50);
}
}
// fill the view form action on top right corner
ToolBar topRightToolBar = new ToolBar(viewForm, SWT.FLAT);
ToolBarManager toolBarManager = new ToolBarManager(topRightToolBar);
result.makeActions(toolBarManager, resultTable);
// fill the view form action on top right corner
ToolBar topLeftToolBar = new ToolBar(viewForm, SWT.FLAT);
swRecordItem = new ToolItem(topLeftToolBar, SWT.CHECK);
result.swRecordItem = swRecordItem;
swRecordItem.setToolTipText(Messages.getOidOn);
swRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_update.png"));
swRecordItem.setEnabled(true);
swRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (editor.isCollectExecStats()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errNotEditableOnStat);
return;
}
if (!result.isContainPrimayKey()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errNoPrimaryKey);
return;
}
if (!result.isSingleTableQuery()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errNotInOneTable);
return;
}
if (!checkConnection()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
result.tblResult.forceFocus();
if (result.swRecordItem.getSelection()) {
result.swRecordItem.setToolTipText(Messages.getOidOn);
result.setEditMode(true);
result.insertRecordItem.setEnabled(true);
if (result.tblResult.getSelectionCount() > 0) {
result.delRecordItem.setEnabled(true);
}
} else {
if (result.isModifiedResult()) {
result.swRecordItem.setSelection(true);
CommonUITool.openErrorBox(getShell(), Messages.errHasNoCommit);
return;
}
result.swRecordItem.setToolTipText(Messages.getOidOff);
result.setEditMode(false);
result.insertRecordItem.setEnabled(false);
result.delRecordItem.setEnabled(false);
}
}
});
//added by kevin, for insert record
insertRecordItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.insertRecordItem = insertRecordItem;
insertRecordItem.setToolTipText(com.cubrid.common.ui.cubrid.table.Messages.insertInstanceMsgTitle);
insertRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert.png"));
insertRecordItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert_disabled.png"));
insertRecordItem.setEnabled(false);
insertRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!result.getEditable()) {
CommonUITool.openErrorBox(getShell(), Messages.errNotEditable);
return;
}
if (!checkConnection()) {
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
result.insertSaveItem.setEnabled(result.getEditable());
result.rollbackModifiedItem.setEnabled(result.getEditable());
result.addNewItem();
}
});
delRecordItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.delRecordItem = delRecordItem;
delRecordItem.setToolTipText(Messages.delete);
delRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete.png"));
delRecordItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete_disabled.png"));
delRecordItem.setEnabled(false);
delRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!result.getEditable()) {
CommonUITool.openErrorBox(getShell(), Messages.errNotEditable);
return;
}
if (!checkConnection()) {
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
result.tblResult.forceFocus();
result.deleteRecord(result.tblResult, null);
}
});
insertSaveItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.insertSaveItem = insertSaveItem;
insertSaveItem.setToolTipText(Messages.insertCommit);
insertSaveItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit.png"));
insertSaveItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit_disabled.png"));
insertSaveItem.setEnabled(false);
insertSaveItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!checkConnection()) {
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
if (result.getQueryEditor().isActive()) {
CommonUITool.openWarningBox(Messages.msgActiveTran);
return;
}
if (!CommonUITool.openConfirmBox(getShell(), (Messages.msgCommitEdited))) {
return;
}
try {
if (result.saveInsertedUpdatedDeletedRecords()) {
insertSaveItem.setEnabled(false);
result.rollbackModifiedItem.setEnabled(false);
result.swRecordItem.setSelection(false);
}
result.swRecordItem.setSelection(false);
result.insertRecordItem.setEnabled(false);
result.delRecordItem.setEnabled(false);
result.setEditMode(false);
} catch (ParamSetException e) {
if (e.getParameter() != null && !StringUtil.isEmpty(e.getParameter().getDataType())) {
CommonUITool.openErrorBox(Messages.bind(Messages.errTextTypeNotMatch, e.getParameter().getDataType()) + StringUtil.NEWLINE + e.getLocalizedMessage());
} else {
CommonUITool.openErrorBox(getShell(), e.getLocalizedMessage());
}
} catch (SQLException e) {
e.printStackTrace();
CommonUITool.openErrorBox(getShell(), e.getErrorCode() + StringUtil.NEWLINE + e.getMessage());
/*Can't edit any data if necessary*/
// result.setEditMode(false);
// delRecordItem.setEnabled(false);
// insertRecordItem.setEnabled(false);
// insertSaveItem.setEnabled(false) ;
// swRecordItem.setEnabled(false);
// rollbackModifiedItem.setEnabled(false);
result.getTblResult().setBackground(BACKGROUND_DIRTY);
}
}
});
rollbackModifiedItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.rollbackModifiedItem = rollbackModifiedItem;
rollbackModifiedItem.setToolTipText(Messages.insertRollback);
rollbackModifiedItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback.png"));
rollbackModifiedItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback_disabled.png"));
rollbackModifiedItem.setEnabled(false);
rollbackModifiedItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!CommonUITool.openConfirmBox(getShell(), (Messages.msgRollbackEdited))) {
return;
}
result.tblResult.forceFocus();
insertSaveItem.setEnabled(false);
rollbackModifiedItem.setEnabled(false);
result.clearModifiedLog();
QueryInfo queryInfo = result.getQueryInfo();
queryInfo.setCurrentPage(queryInfo.getCurrentPage());
result.makeItem();
result.updateActions();
result.swRecordItem.setSelection(false);
result.insertRecordItem.setEnabled(false);
result.delRecordItem.setEnabled(false);
result.setEditMode(false);
result.tblResult.setBackground(BACKGROUND_NORMAL);
}
});
if (!isMutliQuery) {
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
copyInsertSqlFromRecordsItem = new ToolItem(topLeftToolBar, SWT.PUSH);
copyInsertSqlFromRecordsItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/record_to_insert.png"));
copyInsertSqlFromRecordsItem.setToolTipText(Messages.makeInsertFromSelectedRecord);
copyInsertSqlFromRecordsItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (editor == null) {
return;
}
String text = editor.getQueryExecuter().makeInsertQueryWithSelectedRecords();
if (StringUtil.isEmpty(text)) {
CommonUITool.openErrorBox(getShell(), Messages.canNotMakeQueryBecauseNoSelected);
return;
}
CommonUITool.copyContentToClipboard(text);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
copyUpdateSqlFromRecordsItem = new ToolItem(topLeftToolBar, SWT.PUSH);
copyUpdateSqlFromRecordsItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/record_to_update.png"));
copyUpdateSqlFromRecordsItem.setToolTipText(Messages.makeUpdateFromSelectedRecord);
copyUpdateSqlFromRecordsItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (editor == null) {
return;
}
String text = editor.getQueryExecuter().makeUpdateQueryWithSelectedRecords();
if (StringUtil.isEmpty(text)) {
CommonUITool.openErrorBox(getShell(), Messages.canNotMakeQueryBecauseNoSelected);
return;
}
CommonUITool.copyContentToClipboard(text);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
final ToolItem exportDataItem = new ToolItem(topLeftToolBar, SWT.PUSH);
exportDataItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_data_export.png"));
exportDataItem.setToolTipText(Messages.msgExportAllQueryResults);
exportDataItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
CTabItem[] items = queryResultTabFolder.getItems();
if (items == null || items.length == 0) {
return;
}
List<QueryExecuter> qeList = new ArrayList<QueryExecuter>();
for (CTabItem item : items) {
if (!(item.getData() instanceof QueryExecuter)) {
continue;
}
QueryExecuter qe = (QueryExecuter) item.getData();
qeList.add(qe);
}
if (qeList.isEmpty()) {
return;
}
ExportQueryResultDialog dialog = new ExportQueryResultDialog(getShell(), qeList);
dialog.open();
}
});
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
final ToolItem showLogItem = new ToolItem(topLeftToolBar, SWT.PUSH);
showLogItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
showLogItem.setToolTipText(Messages.tooltip_qedit_log_show_hide);
showLogItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (tableLogSash.getMaximizedControl() == null) {
tableLogSash.setMaximizedControl(resultContainer);
showLogItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_up.png"));
tableLogSash.layout(true);
} else {
tableLogSash.setMaximizedControl(null);
showLogItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
tableLogSash.layout(true);
}
}
});
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
viewForm.setContent(tableLogSash);
viewForm.setTopRight(topRightToolBar);
viewForm.setTopLeft(topLeftToolBar);
final QueryTableTabItem queryTableTabItem = new QueryTableTabItem(parentFolder, SWT.NONE);
queryTableTabItem.setText(Messages.qedit_result + (result.idx + 1));
queryTableTabItem.setControl(viewForm);
queryTableTabItem.setData(result);
queryTableTabItem.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
InfoWindowManager.getInstance().updateContent(editor);
}
});
parentFolder.setSelection(queryTableTabItem);
tableSelectSupport.addSelectChangeListener(new ISelectionChangeListener() {
@SuppressWarnings("unchecked")
public void selectionChanged(SelectionChangeEvent event) {
boolean active = event.selectedArray.length > 0;
boolean canEdit = active && result.getEditable() && result.isEditMode();
if (delRecordItem != null) {
delRecordItem.setEnabled(canEdit);
}
if (copyInsertSqlFromRecordsItem != null) {
copyInsertSqlFromRecordsItem.setEnabled(active);
}
if (copyUpdateSqlFromRecordsItem != null) {
copyUpdateSqlFromRecordsItem.setEnabled(active);
}
/*TOOLS-3632 Add calculation info*/
int count = event.selectedArray.length;
BigDecimal sum = new BigDecimal(0);
BigDecimal average = null;
int numericCount = 0;
QueryResultTableCalcInfo queryResultTableCalcInfo = null;
StatusLineContrItem statusCont = LayoutManager.getInstance().getStatusLineContrItem();
if (count > 1) {
for (Point p : event.selectedArray) {
TableColumn column = result.tblResult.getColumn(p.x);
if (column == null) {
continue;
}
ColumnInfo columnInfo = (ColumnInfo) column.getData();
if (columnInfo == null) {
continue;
}
String dataType = columnInfo.getType();
if (!DataType.isNumberType(dataType)) {
continue;
}
TableItem item = result.tblResult.getItem(p.y);
if (item == null || item.getData() == null) {
continue;
}
Map<String, CellValue> dataMap = (Map<String, CellValue>) item.getData();
CellValue cellValue = dataMap.get(Integer.toString(p.x));
if (cellValue != null && cellValue.getValue() != null) {
numericCount++;
Object value = cellValue.getValue();
if (value instanceof Integer) {
sum = sum.add(new BigDecimal((Integer) value));
} else if (value instanceof Short) {
sum = sum.add(new BigDecimal((Short) value));
} else if (value instanceof Long) {
sum = sum.add(new BigDecimal((Long) value));
} else if (value instanceof Float) {
sum = sum.add(new BigDecimal((Float) value));
} else if (value instanceof Double) {
sum = sum.add(new BigDecimal((Double) value));
} else if (value instanceof BigDecimal) {
sum = sum.add((BigDecimal) value);
}
}
}
if (numericCount > 0) {
average = sum.divide(new BigDecimal(numericCount), 3, RoundingMode.HALF_UP);
queryResultTableCalcInfo = new QueryResultTableCalcInfo(count, average, sum);
} else {
queryResultTableCalcInfo = new QueryResultTableCalcInfo(count);
}
}
queryTableTabItem.setQueryResultTableCalcInfo(queryResultTableCalcInfo);
InfoWindowManager.getInstance().updateContent(editor);
statusCont.changeStuatusLineForViewOrEditPart(editor.getSelectedDatabase(), editor);
}
});
}
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);
}
Aggregations