use of org.eclipse.jface.action.ControlContribution in project dbeaver by dbeaver.
the class MySQLSessionEditor method createSessionViewer.
@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
return new SessionManagerViewer<MySQLSession>(this, parent, new MySQLSessionManager((MySQLDataSource) executionContext.getDataSource())) {
private boolean hideSleeping;
@Override
protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
contributionManager.add(killSessionAction);
contributionManager.add(terminateQueryAction);
contributionManager.add(new Separator());
contributionManager.add(new ControlContribution("MySQLSessionHideSleep") {
@Override
protected Control createControl(Composite parent) {
Button hideSleepingCheck = UIUtils.createCheckbox(parent, "Hide sleeping", "Show only active connections", hideSleeping, 0);
hideSleepingCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
hideSleeping = hideSleepingCheck.getSelection();
refreshPart(MySQLSessionEditor.this, true);
}
});
return hideSleepingCheck;
}
});
contributionManager.add(new Separator());
}
@Override
protected void onSessionSelect(DBAServerSession session) {
super.onSessionSelect(session);
killSessionAction.setEnabled(session != null);
terminateQueryAction.setEnabled(session != null && !CommonUtils.isEmpty(session.getActiveQuery()));
}
@Override
public Map<String, Object> getSessionOptions() {
if (hideSleeping) {
return Collections.singletonMap(MySQLSessionManager.OPTION_HIDE_SLEEPING, true);
}
return super.getSessionOptions();
}
};
}
use of org.eclipse.jface.action.ControlContribution in project dbeaver by dbeaver.
the class DB2RoutineDDLEditor 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) {
DB2DDLFormat ddlFormat = DB2DDLFormat.getCurrentFormat(getSourceObject().getDataSource());
final Combo ddlFormatCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
ddlFormatCombo.setToolTipText("DDL Format");
for (DB2DDLFormat format : DB2DDLFormat.values()) {
ddlFormatCombo.add(format.getTitle());
if (format == ddlFormat) {
ddlFormatCombo.select(ddlFormatCombo.getItemCount() - 1);
}
}
ddlFormatCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
for (DB2DDLFormat format : DB2DDLFormat.values()) {
if (format.ordinal() == ddlFormatCombo.getSelectionIndex()) {
getEditorInput().getDatabaseObject().getDataSource().getContainer().getPreferenceStore().setValue(DB2Constants.PREF_KEY_DDL_FORMAT, format.name());
refreshPart(this, true);
break;
}
}
}
});
return ddlFormatCombo;
}
});
}
use of org.eclipse.jface.action.ControlContribution in project eclipse-integration-commons by spring-projects.
the class DashboardMainPage method createHeader.
private void createHeader() {
IManagedForm headerForm = dashboardEditor.getHeaderForm();
Form topForm = headerForm.getForm().getForm();
final IToolBarManager toolBarManager = topForm.getToolBarManager();
toolBarManager.removeAll();
toolBarManager.update(true);
toolBarManager.add(new ControlContribution("springSource_search") {
@Override
protected Control createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setBackground(null);
GridLayout layout = new GridLayout(2, false);
layout.marginRight = 0;
layout.marginHeight = 0;
layout.marginTop = 5;
layout.verticalSpacing = 1;
composite.setLayout(layout);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BOTTOM).grab(false, true).applyTo(composite);
createSearchBox(composite);
return composite;
}
});
toolBarManager.add(new ControlContribution("subscribe") {
@Override
protected Control createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setBackground(null);
GridLayout layout = new GridLayout(2, false);
layout.marginRight = 2;
layout.marginLeft = 0;
layout.marginHeight = 0;
layout.marginTop = 12;
layout.verticalSpacing = 1;
composite.setLayout(layout);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BOTTOM).grab(false, true).applyTo(composite);
Button subscribeButton = new Button(composite, SWT.PUSH);
subscribeButton.setText("Subscribe");
subscribeButton.setImage(IdeUiPlugin.getImageDescriptor(SUBSCRIBE_SPRINGSOURCE).createImage());
subscribeButton.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
subscribeButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
TasksUiUtil.openUrl(ResourceProvider.getUrl(RESOURCE_DASHBOARD_SUBSCRIBE));
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
return composite;
}
});
toolBarManager.add(new Action("Spring", IdeUiPlugin.getImageDescriptor(LOGO_SPRINGSOURCE)) {
@Override
public void run() {
TasksUiUtil.openUrl(ResourceProvider.getUrl(RESOURCE_DASHBOARD_LOGO));
}
});
toolBarManager.update(true);
}
use of org.eclipse.jface.action.ControlContribution in project dbeaver by serge-rider.
the class DB2RoutineDDLEditor 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) {
DB2DDLFormat ddlFormat = DB2DDLFormat.getCurrentFormat(getSourceObject().getDataSource());
final Combo ddlFormatCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
ddlFormatCombo.setToolTipText("DDL Format");
for (DB2DDLFormat format : DB2DDLFormat.values()) {
ddlFormatCombo.add(format.getTitle());
if (format == ddlFormat) {
ddlFormatCombo.select(ddlFormatCombo.getItemCount() - 1);
}
}
ddlFormatCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
for (DB2DDLFormat format : DB2DDLFormat.values()) {
if (format.ordinal() == ddlFormatCombo.getSelectionIndex()) {
getSourceObject().getDataSource().getContainer().getPreferenceStore().setValue(DB2Constants.PREF_KEY_DDL_FORMAT, format.name());
refreshPart(this, true);
break;
}
}
}
});
return ddlFormatCombo;
}
});
}
use of org.eclipse.jface.action.ControlContribution in project egit by eclipse.
the class StagingView method updateToolbar.
private void updateToolbar() {
ControlContribution controlContribution = new ControlContribution(// $NON-NLS-1$
"StagingView.searchText") {
@Override
protected Control createControl(Composite parent) {
Composite toolbarComposite = toolkit.createComposite(parent, SWT.NONE);
toolbarComposite.setBackground(null);
GridLayout headLayout = new GridLayout();
headLayout.numColumns = 2;
headLayout.marginHeight = 0;
headLayout.marginWidth = 0;
headLayout.marginTop = 0;
headLayout.marginBottom = 0;
headLayout.marginLeft = 0;
headLayout.marginRight = 0;
toolbarComposite.setLayout(headLayout);
filterText = new Text(toolbarComposite, SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH);
filterText.setMessage(UIText.StagingView_Find);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = 150;
filterText.setLayoutData(data);
final Display display = Display.getCurrent();
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
filterPattern = wildcardToRegex(filterText.getText());
final StagingViewSearchThread searchThread = new StagingViewSearchThread(StagingView.this);
display.timerExec(200, new Runnable() {
@Override
public void run() {
searchThread.start();
}
});
}
});
return toolbarComposite;
}
};
IActionBars actionBars = getViewSite().getActionBars();
IToolBarManager toolbar = actionBars.getToolBarManager();
toolbar.add(controlContribution);
refreshAction = new Action(UIText.StagingView_Refresh, IAction.AS_PUSH_BUTTON) {
@Override
public void run() {
if (cacheEntry != null) {
schedule(cacheEntry.createRefreshResourcesAndIndexDiffJob(), false);
}
}
};
refreshAction.setImageDescriptor(UIIcons.ELCL16_REFRESH);
toolbar.add(refreshAction);
// link with selection
Action linkSelectionAction = new BooleanPrefAction((IPersistentPreferenceStore) getPreferenceStore(), UIPreferences.STAGING_VIEW_SYNC_SELECTION, UIText.StagingView_LinkSelection) {
@Override
public void apply(boolean value) {
reactOnSelection = value;
}
};
linkSelectionAction.setImageDescriptor(UIIcons.ELCL16_SYNCED);
toolbar.add(linkSelectionAction);
toolbar.add(new Separator());
switchRepositoriesAction = new RepositoryToolbarAction(false, () -> realRepository, repo -> {
if (realRepository != repo) {
reload(repo);
}
});
toolbar.add(switchRepositoriesAction);
compareModeAction = new Action(UIText.StagingView_CompareMode, IAction.AS_CHECK_BOX) {
@Override
public void run() {
getPreferenceStore().setValue(UIPreferences.STAGING_VIEW_COMPARE_MODE, isChecked());
}
};
compareModeAction.setImageDescriptor(UIIcons.ELCL16_COMPARE_VIEW);
compareModeAction.setChecked(getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_COMPARE_MODE));
toolbar.add(compareModeAction);
toolbar.add(new Separator());
openNewCommitsAction = new Action(UIText.StagingView_OpenNewCommits, IAction.AS_CHECK_BOX) {
@Override
public void run() {
getPreferenceStore().setValue(UIPreferences.STAGING_VIEW_SHOW_NEW_COMMITS, isChecked());
}
};
openNewCommitsAction.setChecked(getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_SHOW_NEW_COMMITS));
columnLayoutAction = new Action(UIText.StagingView_ColumnLayout, IAction.AS_CHECK_BOX) {
@Override
public void run() {
getPreferenceStore().setValue(UIPreferences.STAGING_VIEW_COLUMN_LAYOUT, isChecked());
stagingSashForm.setOrientation(isChecked() ? SWT.HORIZONTAL : SWT.VERTICAL);
}
};
columnLayoutAction.setChecked(getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_COLUMN_LAYOUT));
fileNameModeAction = new Action(UIText.StagingView_ShowFileNamesFirst, IAction.AS_CHECK_BOX) {
@Override
public void run() {
final boolean enable = isChecked();
getLabelProvider(stagedViewer).setFileNameMode(enable);
getLabelProvider(unstagedViewer).setFileNameMode(enable);
getContentProvider(stagedViewer).setFileNameMode(enable);
getContentProvider(unstagedViewer).setFileNameMode(enable);
StagingEntryComparator comparator = (StagingEntryComparator) unstagedViewer.getComparator();
comparator.setFileNamesFirst(enable);
comparator = (StagingEntryComparator) stagedViewer.getComparator();
comparator.setFileNamesFirst(enable);
getPreferenceStore().setValue(UIPreferences.STAGING_VIEW_FILENAME_MODE, enable);
refreshViewersPreservingExpandedElements();
}
};
fileNameModeAction.setChecked(getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_FILENAME_MODE));
IMenuManager dropdownMenu = actionBars.getMenuManager();
MenuManager presentationMenu = new MenuManager(UIText.StagingView_Presentation);
listPresentationAction = new Action(UIText.StagingView_List, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (!isChecked()) {
return;
}
switchToListMode();
refreshViewers();
}
};
listPresentationAction.setImageDescriptor(UIIcons.FLAT);
presentationMenu.add(listPresentationAction);
treePresentationAction = new Action(UIText.StagingView_Tree, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (!isChecked()) {
return;
}
presentation = Presentation.TREE;
setPresentation(presentation, false);
listPresentationAction.setChecked(false);
compactTreePresentationAction.setChecked(false);
setExpandCollapseActionsVisible(false, isExpandAllowed(false), true);
setExpandCollapseActionsVisible(true, isExpandAllowed(true), true);
refreshViewers();
}
};
treePresentationAction.setImageDescriptor(UIIcons.HIERARCHY);
presentationMenu.add(treePresentationAction);
compactTreePresentationAction = new Action(UIText.StagingView_CompactTree, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (!isChecked()) {
return;
}
switchToCompactModeInternal(false);
refreshViewers();
}
};
compactTreePresentationAction.setImageDescriptor(UIIcons.COMPACT);
presentationMenu.add(compactTreePresentationAction);
presentation = readPresentation(UIPreferences.STAGING_VIEW_PRESENTATION, Presentation.LIST);
switch(presentation) {
case LIST:
listPresentationAction.setChecked(true);
setExpandCollapseActionsVisible(false, false, false);
setExpandCollapseActionsVisible(true, false, false);
break;
case TREE:
treePresentationAction.setChecked(true);
break;
case COMPACT_TREE:
compactTreePresentationAction.setChecked(true);
break;
default:
break;
}
dropdownMenu.add(presentationMenu);
dropdownMenu.add(new Separator());
dropdownMenu.add(openNewCommitsAction);
dropdownMenu.add(columnLayoutAction);
dropdownMenu.add(fileNameModeAction);
dropdownMenu.add(compareModeAction);
actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), new GlobalDeleteActionHandler());
// For the normal resource undo/redo actions to be active, so that files
// deleted via the "Delete" action in the staging view can be restored.
IUndoContext workspaceContext = AdapterUtils.adapt(ResourcesPlugin.getWorkspace(), IUndoContext.class);
undoRedoActionGroup = new UndoRedoActionGroup(getViewSite(), workspaceContext, true);
undoRedoActionGroup.fillActionBars(actionBars);
actionBars.updateActionBars();
}
Aggregations