use of org.eclipse.jface.action.IContributionManager 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.IContributionManager in project dbeaver by dbeaver.
the class ExasolServerSessionEditor method createSessionViewer.
@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
return new SessionManagerViewer<ExasolServerSession>(this, parent, new ExasolServerSessionManager((ExasolDataSource) executionContext.getDataSource())) {
@Override
@SuppressWarnings("rawtypes")
protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
contributionManager.add(killSessionAction);
contributionManager.add(terminateQueryAction);
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()));
}
};
}
use of org.eclipse.jface.action.IContributionManager in project dbeaver by dbeaver.
the class OracleSessionEditor method createSessionViewer.
@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
return new SessionManagerViewer<OracleServerSession>(this, parent, new OracleServerSessionManager(getExecutionContext())) {
@Override
protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
contributionManager.add(killSessionAction);
contributionManager.add(disconnectSessionAction);
contributionManager.add(new Separator());
}
@Override
protected void onSessionSelect(DBAServerSession session) {
super.onSessionSelect(session);
killSessionAction.setEnabled(session != null);
disconnectSessionAction.setEnabled(session != null);
}
};
}
use of org.eclipse.jface.action.IContributionManager in project dbeaver by dbeaver.
the class PostgreSessionEditor method createSessionViewer.
@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
return new SessionManagerViewer<PostgreSession>(this, parent, new PostgreSessionManager((PostgreDataSource) executionContext.getDataSource())) {
@Override
protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
contributionManager.add(terminateQueryAction);
contributionManager.add(new Separator());
}
@Override
protected void onSessionSelect(DBAServerSession session) {
super.onSessionSelect(session);
terminateQueryAction.setEnabled(session != null && !CommonUtils.isEmpty(session.getActiveQuery()));
}
};
}
use of org.eclipse.jface.action.IContributionManager in project dbeaver by dbeaver.
the class SelectObjectDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite group = (Composite) super.createDialogArea(parent);
GridData gd = new GridData(GridData.FILL_BOTH);
group.setLayoutData(gd);
final DatabaseObjectListControl<T> objectList = new DatabaseObjectListControl<T>(group, (singleSelection ? SWT.SINGLE : SWT.MULTI), null, new ListContentProvider()) {
private ISearchExecutor searcher = new SearcherFilter();
@NotNull
@Override
protected String getListConfigId(List<Class<?>> classList) {
return listId;
}
@Override
protected LoadingJob<Collection<T>> createLoadService() {
return LoadingJob.createService(new AbstractLoadService<Collection<T>>() {
@Override
public Collection<T> evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
return objects;
}
@Override
public Object getFamily() {
return SelectObjectDialog.this;
}
}, new ObjectsLoadVisualizer() {
@Override
public void completeLoading(Collection<T> items) {
super.completeLoading(items);
performSearch(ISearchContextProvider.SearchType.NONE);
getItemsViewer().getControl().setFocus();
closeOnFocusLost(getItemsViewer().getControl(), getSearchTextControl());
}
});
}
protected CellLabelProvider getColumnLabelProvider(ObjectColumn objectColumn) {
return new ObjectLabelProvider(objectColumn);
}
@Override
protected Object getObjectValue(T item) {
if (item instanceof DBSWrapper) {
return ((DBSWrapper) item).getObject();
}
return super.getObjectValue(item);
}
@Override
protected DBPImage getObjectImage(T item) {
if (item instanceof DBNDatabaseNode) {
return ((DBNDatabaseNode) item).getNodeIcon();
}
return null;
}
@Override
protected void setListData(Collection<T> items, boolean append) {
super.setListData(items, append);
if (selectedObjects != null) {
getItemsViewer().setSelection(new StructuredSelection(selectedObjects), true);
}
}
@Override
protected void fillCustomActions(IContributionManager contributionManager) {
super.fillCustomActions(contributionManager);
addColumnConfigAction(contributionManager);
}
protected void addSearchAction(IContributionManager contributionManager) {
contributionManager.add(new Action("Filter objects", DBeaverIcons.getImageDescriptor(UIIcon.SEARCH)) {
@Override
public void run() {
performSearch(ISearchContextProvider.SearchType.NONE);
}
});
}
@Override
protected ISearchExecutor getSearchRunner() {
return searcher;
}
class ObjectLabelProvider extends ObjectColumnLabelProvider implements IFontProvider {
ObjectLabelProvider(ObjectColumn objectColumn) {
super(objectColumn);
}
@Override
public Font getFont(Object element) {
if (selectedObjects.contains(element)) {
return boldFont;
}
return null;
}
}
};
objectList.createProgressPanel();
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 300;
gd.minimumWidth = 300;
objectList.setLayoutData(gd);
objectList.getSelectionProvider().addSelectionChangedListener(event -> {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
selectedObjects.clear();
selectedObjects.addAll(selection.toList());
if (!isModeless()) {
getButton(IDialogConstants.OK_ID).setEnabled(!selectedObjects.isEmpty());
}
});
objectList.setDoubleClickHandler(event -> {
if (isModeless() || getButton(IDialogConstants.OK_ID).isEnabled()) {
okPressed();
}
});
objectList.loadData();
return group;
}
Aggregations