use of org.eclipse.ui.menus.CommandContributionItem in project egit by eclipse.
the class ResetMenu method getCommandContributionItem.
private static CommandContributionItem getCommandContributionItem(String commandId, String menuLabel, Map<String, String> parameters, IWorkbenchSite site) {
CommandContributionItemParameter parameter = new CommandContributionItemParameter(site, commandId, commandId, CommandContributionItem.STYLE_PUSH);
parameter.label = menuLabel;
parameter.parameters = parameters;
return new CommandContributionItem(parameter);
}
use of org.eclipse.ui.menus.CommandContributionItem in project jbosstools-openshift by jbosstools.
the class ScaleDeploymentContributionItem method getContributionItems.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected IContributionItem[] getContributionItems() {
if (!isRelevant()) {
return new IContributionItem[0];
}
Map mapUp = new HashMap();
mapUp.put(ScaleDeploymentHandler.REPLICA_DIFF, "1");
CommandContributionItemParameter pUp = new CommandContributionItemParameter(fServiceLocator, DYNAMIC_ITEM_ID + ".up", COMMAND_ID, mapUp, OpenShiftImages.TREND_UP, null, null, "Up", null, "Increment the number of deployed replicas by one.", 0, null, true);
Map mapDown = new HashMap();
mapDown.put(ScaleDeploymentHandler.REPLICA_DIFF, "-1");
CommandContributionItemParameter pDown = new CommandContributionItemParameter(fServiceLocator, DYNAMIC_ITEM_ID + ".down", COMMAND_ID, mapDown, OpenShiftImages.TREND_DOWN, null, null, "Down", null, "Increment the number of deployed replicas by one.", 0, null, true);
CommandContributionItemParameter pTo = new CommandContributionItemParameter(fServiceLocator, DYNAMIC_ITEM_ID + ".to", COMMAND_ID, new HashMap(), null, null, null, "To...", null, "Scale the number of deployed replicas to a specific value.", 0, null, true);
return new IContributionItem[] { new CommandContributionItem(pUp), new CommandContributionItem(pDown), new CommandContributionItem(pTo) };
}
use of org.eclipse.ui.menus.CommandContributionItem in project mdw-designer by CenturyLinkCloud.
the class ShowViewMenu method fillMenu.
private void fillMenu(IMenuManager innerMgr) {
innerMgr.removeAll();
IWorkbenchPage page = window.getActivePage();
if (page == null || page.getPerspective() == null)
return;
// visible actions
List<String> viewIds = Arrays.asList(page.getShowViewShortcuts());
List<CommandContributionItemParameter> actions = new ArrayList<CommandContributionItemParameter>(viewIds.size());
for (String id : viewIds) {
if (id.equals("org.eclipse.ui.internal.introview"))
continue;
CommandContributionItemParameter item = getItem(id);
if (item != null)
actions.add(item);
}
Collections.sort(actions, actionComparator);
for (CommandContributionItemParameter ccip : actions) {
if (WorkbenchActivityHelper.filterItem(ccip))
continue;
CommandContributionItem item = new CommandContributionItem(ccip);
innerMgr.add(item);
}
}
use of org.eclipse.ui.menus.CommandContributionItem in project dbeaver by serge-rider.
the class NavigatorHandlerObjectCreateNew method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
if (!updateUI) {
return;
}
IWorkbenchWindow workbenchWindow = element.getServiceLocator().getService(IWorkbenchWindow.class);
if (workbenchWindow == null || workbenchWindow.getActivePage() == null) {
return;
}
Object typeName = parameters.get(NavigatorCommands.PARAM_OBJECT_TYPE_NAME);
Object objectIcon = parameters.get(NavigatorCommands.PARAM_OBJECT_TYPE_ICON);
if (typeName == null) {
// Try to get type from active selection
DBNNode node = NavigatorUtils.getSelectedNode(element);
if (node != null && !node.isDisposed()) {
List<IContributionItem> actions = fillCreateMenuItems(workbenchWindow.getActivePage().getActivePart().getSite(), node);
for (IContributionItem item : actions) {
if (item instanceof CommandContributionItem) {
ParameterizedCommand command = ((CommandContributionItem) item).getCommand();
if (command != null) {
typeName = command.getParameterMap().get(NavigatorCommands.PARAM_OBJECT_TYPE_NAME);
if (typeName != null) {
// Prepend "Create new" as it is a single node
typeName = NLS.bind(UINavigatorMessages.actions_navigator_create_new, typeName);
// Do not use object icon ()
// if (!(node instanceof DBNDatabaseFolder)) {
// objectIcon = command.getParameterMap().get(NavigatorCommands.PARAM_OBJECT_TYPE_ICON);
// }
}
break;
}
}
}
}
}
if (typeName != null) {
element.setText(typeName.toString());
} else {
element.setText(NLS.bind(UINavigatorMessages.actions_navigator_create_new, getObjectTypeName(element)));
}
if (objectIcon != null) {
element.setIcon(DBeaverIcons.getImageDescriptor(new DBIcon(objectIcon.toString())));
} else {
DBPImage image = getObjectTypeIcon(element);
if (image == null) {
image = DBIcon.TYPE_OBJECT;
}
element.setIcon(DBeaverIcons.getImageDescriptor(image));
}
}
use of org.eclipse.ui.menus.CommandContributionItem in project dbeaver by serge-rider.
the class ResultSetViewer method createStatusBar.
private void createStatusBar() {
Composite statusComposite = UIUtils.createPlaceholder(viewerPanel, 3);
statusComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
statusBar = new Composite(statusComposite, SWT.NONE);
statusBar.setBackgroundMode(SWT.INHERIT_FORCE);
statusBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
CSSUtils.setCSSClass(statusBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
RowLayout toolbarsLayout = new RowLayout(SWT.HORIZONTAL);
toolbarsLayout.marginTop = 0;
toolbarsLayout.marginBottom = 0;
toolbarsLayout.center = true;
toolbarsLayout.wrap = true;
toolbarsLayout.pack = true;
// toolbarsLayout.fill = true;
statusBar.setLayout(toolbarsLayout);
{
ToolBarManager editToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
// handle own commands
editToolBarManager.add(new Separator());
editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_APPLY_CHANGES, "Save", null, null, true));
editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_REJECT_CHANGES, "Cancel", null, null, true));
editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_GENERATE_SCRIPT, "Script", null, null, true));
editToolBarManager.add(new Separator());
editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_EDIT));
editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_ADD));
editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_COPY));
editToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_DELETE));
ToolBar editorToolBar = editToolBarManager.createControl(statusBar);
CSSUtils.setCSSClass(editorToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
toolbarList.add(editToolBarManager);
}
{
ToolBarManager navToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
navToolBarManager.add(new ToolbarSeparatorContribution(true));
navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_FIRST));
navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_PREVIOUS));
navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_NEXT));
navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ROW_LAST));
navToolBarManager.add(new Separator());
navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_FETCH_PAGE));
navToolBarManager.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_FETCH_ALL));
navToolBarManager.add(new Separator(TOOLBAR_GROUP_NAVIGATION));
ToolBar navToolBar = navToolBarManager.createControl(statusBar);
CSSUtils.setCSSClass(navToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
toolbarList.add(navToolBarManager);
}
{
ToolBarManager configToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
configToolBarManager.add(new ToolbarSeparatorContribution(true));
/*
if (supportsPanels()) {
CommandContributionItemParameter ciParam = new CommandContributionItemParameter(
site,
"org.jkiss.dbeaver.core.resultset.panels",
ResultSetHandlerMain.CMD_TOGGLE_PANELS,
CommandContributionItem.STYLE_PULLDOWN);
ciParam.label = ResultSetMessages.controls_resultset_config_panels;
ciParam.mode = CommandContributionItem.MODE_FORCE_TEXT;
configToolBarManager.add(new CommandContributionItem(ciParam));
}
configToolBarManager.add(new ToolbarSeparatorContribution(true));
*/
ToolBar configToolBar = configToolBarManager.createControl(statusBar);
CSSUtils.setCSSClass(configToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
toolbarList.add(configToolBarManager);
}
{
ToolBarManager addToolbBarManagerar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
addToolbBarManagerar.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_EXPORT));
addToolbBarManagerar.add(new GroupMarker(TOOLBAR_GROUP_PRESENTATIONS));
addToolbBarManagerar.add(new Separator(TOOLBAR_GROUP_ADDITIONS));
final IMenuService menuService = getSite().getService(IMenuService.class);
if (menuService != null) {
menuService.populateContributionManager(addToolbBarManagerar, TOOLBAR_CONTRIBUTION_ID);
}
ToolBar addToolBar = addToolbBarManagerar.createControl(statusBar);
CSSUtils.setCSSClass(addToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
toolbarList.add(addToolbBarManagerar);
}
{
// Config toolbar
ToolBarManager configToolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
configToolBarManager.add(new ToolbarSeparatorContribution(true));
configToolBarManager.add(new ConfigAction());
configToolBarManager.update(true);
ToolBar configToolBar = configToolBarManager.createControl(statusBar);
CSSUtils.setCSSClass(configToolBar, DBStyles.COLORED_BY_CONNECTION_TYPE);
toolbarList.add(configToolBarManager);
}
{
final int fontHeight = UIUtils.getFontHeight(statusBar);
resultSetSize = new Text(statusBar, SWT.BORDER);
resultSetSize.setLayoutData(new RowData(5 * fontHeight, SWT.DEFAULT));
resultSetSize.setBackground(UIStyles.getDefaultTextBackground());
resultSetSize.setToolTipText(DataEditorsMessages.resultset_segment_size);
resultSetSize.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
String realValue = String.valueOf(getSegmentMaxRows());
if (!realValue.equals(resultSetSize.getText())) {
resultSetSize.setText(realValue);
}
}
});
resultSetSize.addModifyListener(e -> {
DBSDataContainer dataContainer = getDataContainer();
int fetchSize = CommonUtils.toInt(resultSetSize.getText());
if (fetchSize > 0 && fetchSize < ResultSetPreferences.MIN_SEGMENT_SIZE) {
fetchSize = ResultSetPreferences.MIN_SEGMENT_SIZE;
}
if (dataContainer != null && dataContainer.getDataSource() != null) {
DBPPreferenceStore store = dataContainer.getDataSource().getContainer().getPreferenceStore();
int oldFetchSize = store.getInt(ModelPreferences.RESULT_SET_MAX_ROWS);
if (oldFetchSize != fetchSize) {
store.setValue(ModelPreferences.RESULT_SET_MAX_ROWS, fetchSize);
PrefUtils.savePreferenceStore(store);
}
}
});
UIUtils.addDefaultEditActionsSupport(site, resultSetSize);
rowCountLabel = new ActiveStatusMessage(statusBar, DBeaverIcons.getImage(UIIcon.RS_REFRESH), ResultSetMessages.controls_resultset_viewer_calculate_row_count, this) {
@Override
protected boolean isActionEnabled() {
return hasData();
}
@Override
protected ILoadService<String> createLoadService() {
return new DatabaseLoadService<String>("Load row count", getExecutionContext()) {
@Override
public String evaluate(DBRProgressMonitor monitor) throws InvocationTargetException {
try {
long rowCount = readRowCount(monitor);
return ROW_COUNT_FORMAT.format(rowCount);
} catch (DBException e) {
log.error(e);
throw new InvocationTargetException(e);
}
}
};
}
};
// rowCountLabel.setLayoutData();
CSSUtils.setCSSClass(rowCountLabel, DBStyles.COLORED_BY_CONNECTION_TYPE);
rowCountLabel.setMessage("Row Count");
rowCountLabel.setToolTipText("Calculates total row count in the current dataset");
UIUtils.createToolBarSeparator(statusBar, SWT.VERTICAL);
selectionStatLabel = new Text(statusBar, SWT.READ_ONLY);
selectionStatLabel.setToolTipText("Selected rows/columns/cells");
CSSUtils.setCSSClass(selectionStatLabel, DBStyles.COLORED_BY_CONNECTION_TYPE);
Label filler = new Label(statusComposite, SWT.NONE);
filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
statusLabel = new StatusLabel(statusComposite, SWT.NONE, this);
GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
gd.widthHint = 30 * fontHeight;
statusLabel.setLayoutData(gd);
CSSUtils.setCSSClass(statusLabel, DBStyles.COLORED_BY_CONNECTION_TYPE);
statusBar.addListener(SWT.Resize, event -> {
});
}
}
Aggregations