use of org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor in project dbeaver by serge-rider.
the class PrefPageProjectNetworkProfiles method performDefaults.
@Override
protected void performDefaults() {
super.performDefaults();
profilesTable.removeAll();
if (projectMeta != null) {
for (DBWNetworkProfile profile : projectMeta.getDataSourceRegistry().getNetworkProfiles()) {
TableItem item = new TableItem(profilesTable, SWT.NONE);
item.setText(profile.getProfileName());
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_DOCUMENT));
item.setData(profile);
if (selectedProfile == null) {
selectedProfile = profile;
profilesTable.select(0);
}
for (NetworkHandlerDescriptor nhd : allHandlers) {
HandlerBlock handlerBlock = configurations.get(nhd);
DBWHandlerConfiguration configuration = profile.getConfiguration(nhd);
if (configuration != null) {
handlerBlock.loadedConfigs.put(profile, configuration);
}
}
}
}
updateControlsState();
}
use of org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor in project dbeaver by serge-rider.
the class PrefPageProjectNetworkProfiles method updateControlsState.
private void updateControlsState() {
NetworkHandlerDescriptor descriptor = getSelectedHandler();
enableHandlerContent(descriptor);
if (descriptor != null) {
HandlerBlock handlerBlock = configurations.get(descriptor);
DBWHandlerConfiguration handlerConfiguration = handlerBlock.loadedConfigs.get(selectedProfile);
if (handlerConfiguration == null) {
handlerBlock.configurator.loadSettings(new DBWHandlerConfiguration(descriptor, null));
} else {
handlerBlock.configurator.loadSettings(handlerConfiguration);
}
}
}
use of org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor in project dbeaver by serge-rider.
the class ConnectionPageNetwork method activatePage.
@Override
public void activatePage() {
DataSourceDescriptor dataSource = wizard.getPageSettings().getActiveDataSource();
DBPDriver 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(true, true);
// for (TabItem item : handlersFolder.getItems()) {
// ((Composite)item.getControl()).layout(false);
// }
}
TabItem selectItem = null;
for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
DBWHandlerConfiguration configuration = dataSource.getConnectionConfiguration().getHandler(descriptor.getId());
if (configuration == null) {
configuration = new DBWHandlerConfiguration(descriptor, dataSource);
}
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.registry.network.NetworkHandlerDescriptor in project dbeaver by dbeaver.
the class ConnectionPageNetwork method activatePage.
@Override
public void activatePage() {
DataSourceDescriptor dataSource = wizard.getPageSettings().getActiveDataSource();
DBPDriver 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(true, true);
// for (TabItem item : handlersFolder.getItems()) {
// ((Composite)item.getControl()).layout(false);
// }
}
TabItem selectItem = null;
for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
DBWHandlerConfiguration configuration = dataSource.getConnectionConfiguration().getHandler(descriptor.getId());
if (configuration == null) {
configuration = new DBWHandlerConfiguration(descriptor, dataSource);
}
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.registry.network.NetworkHandlerDescriptor in project dbeaver by serge-rider.
the class ConnectionPageSettings method getSubPages.
@Nullable
@Override
public IDialogPage[] getSubPages(boolean extrasOnly, boolean forceCreate) {
if (extrasOnly) {
return extraPages;
}
if (subPages != null) {
return subPages;
}
if (!forceCreate) {
return new IDialogPage[0];
}
if (this.connectionEditor == null) {
this.connectionEditor = viewDescriptor.createView(IDataSourceConnectionEditor.class);
this.connectionEditor.setSite(this);
}
if (connectionEditor instanceof ICompositeDialogPage) {
subPages = ((ICompositeDialogPage) connectionEditor).getSubPages(extrasOnly, true);
if (!ArrayUtils.isEmpty(subPages)) {
for (IDialogPage page : subPages) {
if (page instanceof IDataSourceConnectionEditor) {
((IDataSourceConnectionEditor) page).setSite(this);
}
}
}
if (isNew() || !getDriver().isEmbedded()) {
// Add network tabs (for new connections or non-embedded drivers)
for (NetworkHandlerDescriptor descriptor : NetworkHandlerRegistry.getInstance().getDescriptors(getActiveDataSource())) {
subPages = ArrayUtils.add(IDialogPage.class, subPages, new ConnectionPageNetworkHandler(this, descriptor));
}
}
if (extraPages != null) {
subPages = ArrayUtils.concatArrays(subPages, extraPages);
}
return subPages;
} else {
return extraPages;
}
}
Aggregations