use of org.eclipse.jface.action.ControlContribution in project cubrid-manager by CUBRID.
the class ApplicationActionBarAdvisor method fillCoolBar.
/**
* Fills the cool bar with the main toolbars for the window.
*
* @param coolBar the cool bar manager
*/
protected void fillCoolBar(ICoolBarManager coolBarManager) {
ActionManager manager = ActionManager.getInstance();
coolBarManager.setLockLayout(true);
IToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT | SWT.WRAP | SWT.BOTTOM);
coolBarManager.add(new ToolBarContributionItem(toolbarManager, IActionConstants.TOOL_NEW1));
Bundle cqbBundle = Platform.getBundle(ApplicationUtil.CQB_PLUGIN_ID);
/* Active the CQB plugin */
if (cqbBundle != null) {
try {
cqbBundle.start();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
Bundle cmBundle = Platform.getBundle(ApplicationUtil.CM_PLUGIN_ID);
/* Active the CM plugin */
if (cmBundle != null) {
try {
cmBundle.start();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
// Change view actions
if (cqbBundle != null) {
DropDownAction viewAction = new DropDownAction(Messages.modeActionBig, IAction.AS_DROP_DOWN_MENU, CubridManagerAppPlugin.getImageDescriptor("icons/cubridmanager32.gif"));
viewAction.setDisabledImageDescriptor(CubridManagerAppPlugin.getImageDescriptor("icons/cubridmanager32.gif"));
MenuManager viewActionManager = viewAction.getMenuManager();
viewActionManager.add(manager.getAction(OpenCMPerspectiveAction.ID));
viewActionManager.add(manager.getAction(OpenCQBPerspectiveAction.ID));
ActionContributionItem viewItems = new ActionContributionItem(viewAction);
viewItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
viewItems.setId(IPerspectiveConstance.PERSPECTIVE_ACTION_CONTRIBUTION_ID);
toolbarManager.add(viewItems);
toolbarManager.add(new Separator());
}
/*TOOLS-3988 There still is the install option after installing cmt plugin.*/
Bundle bundle = Platform.getBundle(ApplicationUtil.CMT_PLUGIN_ID);
if (bundle == null) {
toolbarManager.add(new Separator());
IAction action = ActionManager.getInstance().getAction(InstallMigrationToolkitAction.ID);
if (action != null) {
ActionContributionItem item = new ActionContributionItem(action);
item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
toolbarManager.add(item);
item.setId(IPerspectiveConstance.MIGRATION_ACTION_CONTRIBUTION_ID);
}
} else {
/*Active the CMT plugin */
try {
bundle.start();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
// Help
toolbarManager.add(new Separator());
DropDownAction helpDropAction = new DropDownAction(Messages.helpActionNameBig, IAction.AS_DROP_DOWN_MENU, CubridManagerUIPlugin.getImageDescriptor("icons/action/help_big.png"));
helpDropAction.setDisabledImageDescriptor(CubridManagerUIPlugin.getImageDescriptor("icons/action/help_big.png"));
MenuManager helpActionManager = helpDropAction.getMenuManager();
helpActionManager.add(manager.getAction(HelpDocumentAction.ID));
if ("ko".equals(Messages.language)) {
helpActionManager.add(newFeatureAction);
}
helpActionManager.add(new Separator());
helpActionManager.add(createItem(ReportBugAction.ID));
helpActionManager.add(new Separator());
helpActionManager.add(manager.getAction(ViewServerVersionAction.ID));
helpActionManager.add(clientVersionAction);
ActionContributionItem helpItems = new ActionContributionItem(helpDropAction);
helpItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
helpItems.setId(IPerspectiveConstance.HELP_ACTION_CONTRIBUTION_ID);
toolbarManager.add(helpItems);
ControlContribution searchContribution = new ControlContribution(SearchContributionComposite.class.getName()) {
protected Control createControl(Composite parent) {
return new SearchContributionComposite(parent, SWT.None);
}
};
searchContribution.setId(IPerspectiveConstance.SEARCH_ACTION_CONTRIBUTION_ID);
toolbarManager.add(new Separator());
toolbarManager.add(searchContribution);
}
use of org.eclipse.jface.action.ControlContribution in project dbeaver by dbeaver.
the class OracleObjectDDLEditor method contributeEditorCommands.
@Override
protected void contributeEditorCommands(IContributionManager contributionManager) {
super.contributeEditorCommands(contributionManager);
contributionManager.add(new Separator());
contributionManager.add(new ControlContribution("DDLFormat") {
@Override
protected Control createControl(Composite parent) {
OracleDDLFormat ddlFormat = OracleDDLFormat.getCurrentFormat(getSourceObject().getDataSource());
final Combo ddlFormatCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
ddlFormatCombo.setToolTipText("DDL Format");
for (OracleDDLFormat format : OracleDDLFormat.values()) {
ddlFormatCombo.add(format.getTitle());
if (format == ddlFormat) {
ddlFormatCombo.select(ddlFormatCombo.getItemCount() - 1);
}
}
ddlFormatCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
for (OracleDDLFormat format : OracleDDLFormat.values()) {
if (format.ordinal() == ddlFormatCombo.getSelectionIndex()) {
getEditorInput().getDatabaseObject().getDataSource().getContainer().getPreferenceStore().setValue(OracleConstants.PREF_KEY_DDL_FORMAT, format.name());
refreshPart(this, true);
break;
}
}
}
});
return ddlFormatCombo;
}
});
}
use of org.eclipse.jface.action.ControlContribution in project jbosstools-hibernate by jbosstools.
the class AbstractQueryEditor method createToolbar.
protected final void createToolbar(Composite parent) {
ToolBar bar = new ToolBar(parent, SWT.HORIZONTAL);
bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tbm = new ToolBarManager(bar);
execAction = new ExecuteQueryAction(this);
clearAction = new ClearAction(this);
stickResTabAction = new StickResTabAction(this);
ActionContributionItem item = new ActionContributionItem(execAction);
tbm.add(item);
item = new ActionContributionItem(clearAction);
tbm.add(item);
// $NON-NLS-1$
ControlContribution cc = new ConfigurationCombo("hql-target", this);
tbm.add(cc);
tbm.add(new Separator());
cc = new // $NON-NLS-1$
ComboContribution(// $NON-NLS-1$
"maxResults") {
SelectionAdapter selectionAdapter = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Integer maxResults = null;
try {
maxResults = new Integer(getText());
} catch (NumberFormatException e1) {
maxResults = null;
}
getQueryInputModel().setMaxResults(maxResults);
}
};
protected Control createControl(Composite parent) {
Control control = super.createControl(parent);
comboControl.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Integer maxResults = null;
try {
maxResults = new Integer(getText());
} catch (NumberFormatException e1) {
maxResults = null;
}
getQueryInputModel().setMaxResults(maxResults);
}
});
return control;
}
protected int getComboWidth() {
return 75;
}
protected String getLabelText() {
return HibernateConsoleMessages.AbstractQueryEditor_max_results;
}
protected boolean isReadOnly() {
return false;
}
protected SelectionListener getSelectionAdapter() {
return selectionAdapter;
}
void populateComboBox() {
comboControl.getDisplay().syncExec(new Runnable() {
public void run() {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
String[] items = new String[] { "", "10", "20", "30", "50" };
comboControl.setItems(items);
}
});
}
};
tbm.add(cc);
tbm.add(new Separator());
item = new ActionContributionItem(stickResTabAction);
tbm.add(item);
tbm.update(true);
}
use of org.eclipse.jface.action.ControlContribution in project egit by eclipse.
the class CommitEditor method createHeaderContents.
/**
* @see org.eclipse.ui.forms.editor.SharedHeaderFormEditor#createHeaderContents(org.eclipse.ui.forms.IManagedForm)
*/
@Override
protected void createHeaderContents(IManagedForm headerForm) {
headerForm.addPart(new FocusManagerFormPart(headerFocusTracker) {
@Override
public void setDefaultFocus() {
headerForm.getForm().getForm().setFocus();
}
});
RepositoryCommit commit = getCommit();
ScrolledForm form = headerForm.getForm();
String commitName = commit.getRevCommit().name();
String title = getFormattedHeaderTitle(commitName);
HeaderText text = new HeaderText(form.getForm(), title, commitName);
Control textControl = text.getControl();
if (textControl != null) {
headerFocusTracker.addToFocusTracking(textControl);
}
form.setToolTipText(commitName);
getToolkit().decorateFormHeading(form.getForm());
toolbar = form.getToolBarManager();
ControlContribution repositoryLabelControl = new ControlContribution(// $NON-NLS-1$
"repositoryLabel") {
@Override
protected Control createControl(Composite parent) {
FormToolkit toolkit = getHeaderForm().getToolkit();
String label = getCommit().getRepositoryName();
ImageHyperlink link = new ImageHyperlink(parent, SWT.NONE);
// Focus tracking on this link doesn't really work. It's a
// focusable control inside another focusable control (the
// toolbar). When focus leaves this control through tabbing
// or deactivating the editor, the toolbar gets the focus (and
// possibly loses it right away again). Thus the focus tracker
// will always see the toolbar as the last focused control.
// Unfortunately there is no other way to get some text onto
// the first line of a FormHeading.
headerFocusTracker.addToFocusTracking(link);
link.setText(label);
link.setFont(JFaceResources.getBannerFont());
link.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
link.setToolTipText(UIText.CommitEditor_showGitRepo);
link.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent event) {
RepositoriesView view;
try {
view = (RepositoriesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(RepositoriesView.VIEW_ID);
view.showRepository(getCommit().getRepository());
} catch (PartInitException e) {
Activator.handleError(UIText.CommitEditor_couldNotShowRepository, e, false);
}
}
});
return link;
}
};
toolbar.add(repositoryLabelControl);
CommonUtils.getService(getSite(), IPartService.class).addPartListener(activationListener);
if (commit.isStash()) {
toolbar.add(createActionContributionItem(StashApplyHandler.ID, UIText.CommitEditor_toolbarApplyStash, UIIcons.STASH_APPLY));
toolbar.add(createActionContributionItem(StashDropHandler.ID, UIText.CommitEditor_toolbarDeleteStash, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)));
} else {
toolbar.add(createActionContributionItem(CreateTagHandler.ID, UIText.CommitEditor_toolbarCreateTag, UIIcons.TAG));
toolbar.add(createActionContributionItem(CreateBranchHandler.ID, UIText.CommitEditor_toolbarCreateBranch, UIIcons.BRANCH));
toolbar.add(createActionContributionItem(CheckoutHandler.ID, UIText.CommitEditor_toolbarCheckOut, UIIcons.CHECKOUT));
toolbar.add(createActionContributionItem(CherryPickHandler.ID, UIText.CommitEditor_toolbarCherryPick, UIIcons.CHERRY_PICK));
toolbar.add(createActionContributionItem(RevertHandler.ID, UIText.CommitEditor_toolbarRevert, UIIcons.REVERT));
toolbar.add(createActionContributionItem(ShowInHistoryHandler.ID, UIText.CommitEditor_toolbarShowInHistory, UIIcons.HISTORY));
}
addContributions(toolbar);
toolbar.update(true);
getSite().setSelectionProvider(new ISelectionProvider() {
@Override
public void setSelection(ISelection selection) {
// Ignored
}
@Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
// Ignored
}
@Override
public ISelection getSelection() {
return new StructuredSelection(getCommit());
}
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
// Ignored
}
});
if (toolbar instanceof ToolBarManager) {
Control control = ((ToolBarManager) toolbar).getControl();
if (control != null) {
headerFocusTracker.addToFocusTracking(control);
}
}
}
use of org.eclipse.jface.action.ControlContribution in project dbeaver by serge-rider.
the class OracleEditorUtils method addDDLControl.
public static void addDDLControl(IContributionManager contributionManager, OracleTableBase sourceObject, SQLSourceViewer source) {
contributionManager.add(new Separator());
contributionManager.add(new ControlContribution("DDLFormat") {
@Override
protected Control createControl(Composite parent) {
OracleDDLFormat ddlFormat = OracleDDLFormat.getCurrentFormat(sourceObject.getDataSource());
final Combo ddlFormatCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
ddlFormatCombo.setToolTipText("DDL Format");
for (OracleDDLFormat format : OracleDDLFormat.values()) {
ddlFormatCombo.add(format.getTitle());
if (format == ddlFormat) {
ddlFormatCombo.select(ddlFormatCombo.getItemCount() - 1);
}
}
ddlFormatCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
for (OracleDDLFormat format : OracleDDLFormat.values()) {
if (format.ordinal() == ddlFormatCombo.getSelectionIndex()) {
if (source instanceof OracleDDLOptions) {
((OracleDDLOptions) source).putDDLOptions(OracleConstants.PREF_KEY_DDL_FORMAT, format);
}
sourceObject.getDataSource().getContainer().getPreferenceStore().setValue(OracleConstants.PREF_KEY_DDL_FORMAT, format.name());
source.refreshPart(this, true);
break;
}
}
}
});
return ddlFormatCombo;
}
});
}
Aggregations