use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class ConnectionPageNetwork method activatePage.
@Override
public void activatePage() {
DataSourceDescriptor dataSource = wizard.getPageSettings().getActiveDataSource();
DriverDescriptor driver = wizard.getSelectedDriver();
NetworkHandlerRegistry registry = NetworkHandlerRegistry.getInstance();
if (prevDataSource == null || prevDataSource != dataSource) {
for (TabItem item : handlersFolder.getItems()) {
item.dispose();
}
for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
try {
createHandlerTab(descriptor);
} catch (DBException e) {
log.warn(e);
}
}
prevDataSource = dataSource;
handlersFolder.layout();
for (TabItem item : handlersFolder.getItems()) {
((Composite) item.getControl()).layout();
}
}
TabItem selectItem = null;
for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
DBWHandlerConfiguration configuration = dataSource.getConnectionConfiguration().getHandler(descriptor.getId());
if (configuration == null) {
configuration = new DBWHandlerConfiguration(descriptor, driver);
}
HandlerBlock handlerBlock = configurations.get(descriptor);
if (handlerBlock == null) {
continue;
}
//handlerBlock.useHandlerCheck.setSelection(configuration.isEnabled());
if (selectItem == null && configuration.isEnabled()) {
selectItem = handlerBlock.tabItem;
}
if (!handlerBlock.loadedConfigs.containsKey(dataSource.getId())) {
handlerBlock.configurator.loadSettings(configuration);
handlerBlock.loadedConfigs.put(dataSource.getId(), configuration);
}
enableHandlerContent(descriptor);
}
if (selectItem != null) {
handlersFolder.setSelection(selectItem);
} else {
handlersFolder.setSelection(0);
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class DefaultValueViewDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogGroup = (Composite) super.createDialogArea(parent);
Label label = new Label(dialogGroup, SWT.NONE);
label.setText(CoreMessages.dialog_data_label_value);
Composite editorPlaceholder = UIUtils.createPlaceholder(dialogGroup, 1);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.minimumHeight = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + 4;
editorPlaceholder.setLayoutData(gd);
editorPlaceholder.setLayout(new FillLayout());
try {
panelEditor = createPanelEditor(editorPlaceholder);
if (panelEditor == null) {
return dialogGroup;
}
panelEditor.primeEditorValue(getValueController().getValue());
} catch (DBException e) {
log.error(e);
return dialogGroup;
}
ReferenceValueEditor referenceValueEditor = new ReferenceValueEditor(getValueController(), this);
if (referenceValueEditor.isReferenceValue()) {
referenceValueEditor.createEditorSelector(dialogGroup);
}
return dialogGroup;
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class GotoObjectDialog method fillContentProvider.
@Override
protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException {
DBSStructureAssistant structureAssistant = DBUtils.getAdapter(DBSStructureAssistant.class, context.getDataSource());
if (structureAssistant == null) {
return;
}
String nameMask = ((ObjectFilter) itemsFilter).getNameMask();
DBRProgressMonitor monitor = RuntimeUtils.makeMonitor(progressMonitor);
try {
monitor.beginTask("Search for '" + nameMask + "'", 100);
List<DBSObjectType> typesToSearch = new ArrayList<>();
for (DBSObjectType type : structureAssistant.getSupportedObjectTypes()) {
Class<? extends DBSObject> typeClass = type.getTypeClass();
if (DBSEntityElement.class.isAssignableFrom(typeClass)) {
// Skipp attributes (columns), methods, etc
continue;
}
typesToSearch.add(type);
}
Collection<DBSObjectReference> result = structureAssistant.findObjectsByMask(monitor, container, typesToSearch.toArray(new DBSObjectType[typesToSearch.size()]), nameMask, false, true, 1000);
DBPDataSourceContainer dsContainer = context.getDataSource().getContainer();
for (DBSObjectReference ref : result) {
DBSObjectFilter filter = dsContainer.getObjectFilter(ref.getObjectClass(), ref.getContainer(), true);
if (filter == null || !filter.isEnabled() || filter.matches(ref.getName())) {
contentProvider.add(ref, itemsFilter);
}
}
} catch (DBException e) {
throw new CoreException(GeneralUtils.makeExceptionStatus(e));
} finally {
monitor.done();
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class ContentValueManager method contributeContentActions.
public static void contributeContentActions(@NotNull IContributionManager manager, @NotNull final IValueController controller, final IValueEditor activeEditor) throws DBCException {
if (controller.getValue() instanceof DBDContent && !((DBDContent) controller.getValue()).isNull()) {
manager.add(new Action(CoreMessages.model_jdbc_save_to_file_, DBeaverIcons.getImageDescriptor(UIIcon.SAVE_AS)) {
@Override
public void run() {
DialogUtils.saveToFile(controller);
}
});
}
manager.add(new Action(CoreMessages.model_jdbc_load_from_file_, DBeaverIcons.getImageDescriptor(UIIcon.LOAD)) {
@Override
public void run() {
if (DialogUtils.loadFromFile(controller)) {
try {
activeEditor.primeEditorValue(controller.getValue());
} catch (DBException e) {
UIUtils.showErrorDialog(null, "Load from file", "Error loading contents from file", e);
}
}
}
});
manager.add(new Separator());
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class BinaryPanelEditor method primeEditorValue.
@Override
public void primeEditorValue(@NotNull DBRProgressMonitor monitor, @NotNull HexEditControl control, @NotNull DBDContent value) throws DBException {
monitor.beginTask("Prime content value", 1);
try {
DBDContentStorage data = value.getContents(monitor);
String charset = null;
monitor.subTask("Read binary value");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
if (data != null) {
try (InputStream contentStream = data.getContentStream()) {
ContentUtils.copyStreams(contentStream, -1, buffer, monitor);
}
charset = data.getCharset();
} else {
charset = DBValueFormatting.getDefaultBinaryFileEncoding(value.getDataSource());
}
control.setContent(buffer.toByteArray(), charset);
} catch (IOException e) {
throw new DBException("Error reading stream value", e);
} finally {
monitor.done();
}
}
Aggregations