use of org.jkiss.dbeaver.ext.postgresql.model.PostgreAvailableExtension in project dbeaver by serge-rider.
the class PostgreCreateExtensionDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
final Composite composite = super.createDialogArea(parent);
final Composite group = new Composite(composite, SWT.NONE);
group.setLayout(new GridLayout(2, false));
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 600;
gd.heightHint = 200;
gd.verticalIndent = 0;
gd.horizontalIndent = 0;
group.setLayoutData(gd);
// $NON-NLS-2$
final Text databaseText = UIUtils.createLabelText(group, PostgreMessages.dialog_create_extension_database, newextension.getDatabase().getName(), SWT.BORDER | SWT.READ_ONLY);
final Combo schemaCombo = UIUtils.createLabelCombo(group, PostgreMessages.dialog_create_extension_schema, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
final Label lblExtension = UIUtils.createLabel(group, PostgreMessages.dialog_create_extension_name);
extTable = new TableViewer(group, SWT.BORDER | SWT.UNDERLINE_SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
{
final Table table = extTable.getTable();
table.setLayoutData(new GridData(GridData.FILL_BOTH));
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
UIUtils.packColumns(table);
UIUtils.maxTableColumnsWidth(table);
table.removeControlListener(this);
}
});
}
ViewerColumnController columnController = new ViewerColumnController("AvailabelExtensionDialog", extTable);
columnController.addColumn(PostgreMessages.dialog_create_extension_column_name, null, SWT.NONE, true, true, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(((PostgreAvailableExtension) cell.getElement()).getName());
}
});
columnController.addColumn(PostgreMessages.dialog_create_extension_column_version, null, SWT.NONE, true, true, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(((PostgreAvailableExtension) cell.getElement()).getVersion());
}
});
columnController.addColumn(PostgreMessages.dialog_create_extension_column_description, null, SWT.NONE, true, true, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(((PostgreAvailableExtension) cell.getElement()).getDescription());
}
});
columnController.createColumns();
extTable.addSelectionChangedListener(event -> {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (!selection.isEmpty()) {
// installed.get(extensionCombo.getSelectionIndex());
extension = (PostgreAvailableExtension) selection.getFirstElement();
checkEnabled();
}
});
extTable.setContentProvider(new ListContentProvider());
schemaCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
schema = allSchemas.get(schemaCombo.getSelectionIndex());
checkEnabled();
}
});
new AbstractJob("Load schemas") {
@Override
protected IStatus run(DBRProgressMonitor monitor) {
try {
allSchemas = new ArrayList<>(newextension.getDatabase().getSchemas(monitor));
UIUtils.syncExec(() -> {
for (PostgreSchema schema : allSchemas) {
schemaCombo.add(schema.getName());
}
schema = DBUtils.findObject(allSchemas, PostgreConstants.PUBLIC_SCHEMA_NAME);
if (schema != null) {
schemaCombo.setText(schema.getName());
}
});
} catch (DBException e) {
return GeneralUtils.makeExceptionStatus(e);
}
return Status.OK_STATUS;
}
}.schedule();
new AbstractJob("Load available extensions") {
@Override
protected IStatus run(DBRProgressMonitor monitor) {
try {
final List<PostgreAvailableExtension> installed = new ArrayList<>(newextension.getDatabase().getAvailableExtensions(monitor));
UIUtils.syncExec(() -> {
extTable.setInput(installed);
});
} catch (DBException e) {
return GeneralUtils.makeExceptionStatus(e);
}
return Status.OK_STATUS;
}
}.schedule();
return composite;
}
use of org.jkiss.dbeaver.ext.postgresql.model.PostgreAvailableExtension in project dbeaver by dbeaver.
the class PostgreCreateExtensionDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
final Composite composite = super.createDialogArea(parent);
final Composite group = new Composite(composite, SWT.NONE);
group.setLayout(new GridLayout(2, false));
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 600;
gd.heightHint = 200;
gd.verticalIndent = 0;
gd.horizontalIndent = 0;
group.setLayoutData(gd);
// $NON-NLS-2$
final Text databaseText = UIUtils.createLabelText(group, PostgreMessages.dialog_create_extension_database, newextension.getDatabase().getName(), SWT.BORDER | SWT.READ_ONLY);
final Combo schemaCombo = UIUtils.createLabelCombo(group, PostgreMessages.dialog_create_extension_schema, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
final Label lblExtension = UIUtils.createLabel(group, PostgreMessages.dialog_create_extension_name);
extTable = new TableViewer(group, SWT.BORDER | SWT.UNDERLINE_SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
{
final Table table = extTable.getTable();
table.setLayoutData(new GridData(GridData.FILL_BOTH));
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
UIUtils.packColumns(table);
UIUtils.maxTableColumnsWidth(table);
table.removeControlListener(this);
}
});
}
ViewerColumnController columnController = new ViewerColumnController("AvailabelExtensionDialog", extTable);
columnController.addColumn(PostgreMessages.dialog_create_extension_column_name, null, SWT.NONE, true, true, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(((PostgreAvailableExtension) cell.getElement()).getName());
}
});
columnController.addColumn(PostgreMessages.dialog_create_extension_column_version, null, SWT.NONE, true, true, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(((PostgreAvailableExtension) cell.getElement()).getVersion());
}
});
columnController.addColumn(PostgreMessages.dialog_create_extension_column_description, null, SWT.NONE, true, true, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(((PostgreAvailableExtension) cell.getElement()).getDescription());
}
});
columnController.createColumns();
extTable.addSelectionChangedListener(event -> {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (!selection.isEmpty()) {
// installed.get(extensionCombo.getSelectionIndex());
extension = (PostgreAvailableExtension) selection.getFirstElement();
checkEnabled();
}
});
extTable.setContentProvider(new ListContentProvider());
schemaCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
schema = allSchemas.get(schemaCombo.getSelectionIndex());
checkEnabled();
}
});
new AbstractJob("Load schemas") {
@Override
protected IStatus run(DBRProgressMonitor monitor) {
try {
allSchemas = new ArrayList<>(newextension.getDatabase().getSchemas(monitor));
UIUtils.syncExec(() -> {
for (PostgreSchema schema : allSchemas) {
schemaCombo.add(schema.getName());
}
schema = DBUtils.findObject(allSchemas, PostgreConstants.PUBLIC_SCHEMA_NAME);
if (schema != null) {
schemaCombo.setText(schema.getName());
}
});
} catch (DBException e) {
return GeneralUtils.makeExceptionStatus(e);
}
return Status.OK_STATUS;
}
}.schedule();
new AbstractJob("Load available extensions") {
@Override
protected IStatus run(DBRProgressMonitor monitor) {
try {
final List<PostgreAvailableExtension> installed = new ArrayList<>(newextension.getDatabase().getAvailableExtensions(monitor));
UIUtils.syncExec(() -> {
extTable.setInput(installed);
});
} catch (DBException e) {
return GeneralUtils.makeExceptionStatus(e);
}
return Status.OK_STATUS;
}
}.schedule();
return composite;
}
Aggregations