use of org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource in project dbeaver by serge-rider.
the class PostgreSessionEditor method createSessionViewer.
@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
return new SessionManagerViewer(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.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource in project dbeaver by serge-rider.
the class PostgreBackupWizardPageObjects method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = UIUtils.createPlaceholder(parent, 1);
Group objectsGroup = UIUtils.createControlGroup(composite, "Objects", 1, GridData.FILL_HORIZONTAL, 0);
objectsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
SashForm sash = new CustomSashForm(objectsGroup, SWT.VERTICAL);
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
{
Composite catPanel = UIUtils.createPlaceholder(sash, 1);
catPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
schemasTable = new Table(catPanel, SWT.BORDER | SWT.CHECK);
schemasTable.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem) event.item;
PostgreSchema catalog = (PostgreSchema) item.getData();
if (event.detail == SWT.CHECK) {
schemasTable.select(schemasTable.indexOf(item));
checkedObjects.remove(catalog);
}
loadTables(catalog);
updateState();
}
});
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 50;
schemasTable.setLayoutData(gd);
Composite buttonsPanel = UIUtils.createPlaceholder(catPanel, 3, 5);
buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(buttonsPanel, SWT.NONE).setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
createCheckButtons(buttonsPanel, schemasTable);
}
final Button exportViewsCheck;
{
Composite tablesPanel = UIUtils.createPlaceholder(sash, 1);
tablesPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
tablesTable = new Table(tablesPanel, SWT.BORDER | SWT.CHECK);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 50;
tablesTable.setLayoutData(gd);
tablesTable.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.CHECK) {
updateCheckedTables();
updateState();
}
}
});
Composite buttonsPanel = UIUtils.createPlaceholder(tablesPanel, 3, 5);
buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
exportViewsCheck = UIUtils.createCheckbox(buttonsPanel, "Show views", false);
exportViewsCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
wizard.showViews = exportViewsCheck.getSelection();
loadTables(null);
}
});
exportViewsCheck.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
createCheckButtons(buttonsPanel, tablesTable);
}
dataSource = null;
Set<PostgreSchema> activeCatalogs = new LinkedHashSet<>();
for (DBSObject object : wizard.getDatabaseObjects()) {
if (object instanceof PostgreSchema) {
activeCatalogs.add((PostgreSchema) object);
dataSource = ((PostgreSchema) object).getDataSource();
} else if (object instanceof PostgreTableBase) {
PostgreSchema catalog = ((PostgreTableBase) object).getContainer();
dataSource = catalog.getDataSource();
activeCatalogs.add(catalog);
Set<PostgreTableBase> tables = checkedObjects.get(catalog);
if (tables == null) {
tables = new HashSet<>();
checkedObjects.put(catalog, tables);
}
tables.add((PostgreTableBase) object);
if (((PostgreTableBase) object).isView()) {
wizard.showViews = true;
exportViewsCheck.setSelection(true);
}
} else if (object.getDataSource() instanceof PostgreDataSource) {
dataSource = (PostgreDataSource) object.getDataSource();
}
}
if (dataSource != null) {
boolean tablesLoaded = false;
try {
for (PostgreSchema schema : dataSource.getDefaultInstance().getSchemas(VoidProgressMonitor.INSTANCE)) {
if (schema.isSystem() || schema.isUtility()) {
continue;
}
TableItem item = new TableItem(schemasTable, SWT.NONE);
item.setImage(DBeaverIcons.getImage(DBIcon.TREE_DATABASE));
item.setText(0, schema.getName());
item.setData(schema);
if (activeCatalogs.contains(schema)) {
item.setChecked(true);
schemasTable.select(schemasTable.indexOf(item));
if (!tablesLoaded) {
loadTables(schema);
tablesLoaded = true;
}
}
}
} catch (DBException e) {
log.error(e);
}
}
updateState();
setControl(composite);
}
Aggregations