use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class DatabaseDebugConfigurationTab method loadConnectionDebugTypes.
private void loadConnectionDebugTypes() {
for (Control c : typesGroup.getChildren()) {
c.dispose();
}
DBPDataSourceContainer dataSource = connectionCombo.getSelectedItem();
if (dataSource == null) {
UIUtils.createInfoLabel(typesGroup, "Select a connection to see available debug types");
} else {
List<DebugConfigurationPanelDescriptor> panels = DebugConfigurationPanelRegistry.getInstance().getPanels(dataSource);
if (CommonUtils.isEmpty(panels)) {
UIUtils.createInfoLabel(typesGroup, "Driver '" + dataSource.getDriver().getFullName() + "' doesn't support debugging");
} else {
for (DebugConfigurationPanelDescriptor panel : panels) {
Button typeSelector = new Button(typesGroup, SWT.RADIO);
typeSelector.setText(panel.getName());
if (!CommonUtils.isEmpty(panel.getDescription())) {
typeSelector.setToolTipText(panel.getDescription());
}
typeSelector.setData(panel);
if (panel.isValid()) {
typeSelector.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (typeSelector.getSelection()) {
setDirty(true);
setDebugType(connectionCombo.getSelectedItem(), (DebugConfigurationPanelDescriptor) typeSelector.getData());
typesGroup.getParent().layout(true, true);
}
}
});
} else {
typeSelector.setEnabled(false);
}
}
}
}
setDebugType(dataSource, null);
typesGroup.getParent().layout(true, true);
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class DatabaseDebugConfigurationTab method createConnectionSettingsGroup.
protected void createConnectionSettingsGroup(Composite composite) {
Group group = UIUtils.createControlGroup(composite, DebugUIMessages.DatabaseTab_connection_group_text, 4, GridData.FILL_HORIZONTAL, SWT.DEFAULT);
UIUtils.createControlLabel(group, DebugUIMessages.DatabaseTab_datasource_label_text);
connectionCombo = new SelectDataSourceCombo(group) {
@Override
protected void onDataSourceChange(DBPDataSourceContainer dataSource) {
String driverName = dataSource == null ? "" : dataSource.getDriver().getFullName();
driverText.setText(driverName);
setDirty(true);
loadConnectionDebugTypes();
updateLaunchConfigurationDialog();
}
};
connectionCombo.addItem(null);
for (DBPDataSourceContainer ds : DataSourceRegistry.getAllDataSources()) {
connectionCombo.addItem(ds);
}
driverText = UIUtils.createLabelText(group, DebugUIMessages.DatabaseTab_driver_label_text, "", SWT.READ_ONLY);
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class DatabaseDebugConfigurationTab method initializeFrom.
@Override
public void initializeFrom(ILaunchConfiguration configuration) {
this.currentConfiguration = configuration;
try {
DBPDataSourceContainer dataSource = null;
try {
dataSource = DebugUtils.getDataSourceContainer(configuration);
} catch (CoreException e) {
log.debug(e);
}
connectionCombo.select(dataSource);
if (dataSource != null) {
driverText.setText(dataSource.getDriver().getFullName());
} else {
driverText.setText("");
}
loadConnectionDebugTypes();
String typeId = configuration.getAttribute(DBGConstants.ATTR_DEBUG_TYPE, (String) null);
DebugConfigurationPanelDescriptor savedPanel = null;
if (typeId != null) {
savedPanel = DebugConfigurationPanelRegistry.getInstance().getPanel(typeId);
if (savedPanel == null) {
setWarningMessage("Debug type '" + typeId + "' cannot be resolved");
}
}
setDebugType(dataSource, savedPanel);
} catch (CoreException e) {
setWarningMessage("Error loading debug configuration: " + e.getMessage());
}
scheduleUpdateJob();
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class SelectActiveSchemaHandler method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
if ("true".equals(parameters.get("noCustomLabel"))) {
return;
}
IWorkbenchWindow workbenchWindow = element.getServiceLocator().getService(IWorkbenchWindow.class);
if (workbenchWindow == null || workbenchWindow.getActivePage() == null) {
return;
}
IEditorPart activeEditor = workbenchWindow.getActivePage().getActiveEditor();
if (activeEditor == null) {
return;
}
String schemaName = "< N/A >";
DBIcon schemaIcon = DBIcon.TREE_SCHEMA;
String schemaTooltip = UINavigatorMessages.toolbar_datasource_selector_combo_database_tooltip;
DBPDataSourceContainer dataSource = DataSourceToolbarUtils.getCurrentDataSource(workbenchWindow);
if (dataSource != null && dataSource.isConnected()) {
// schemaName = "<no schema>";
IEditorInput editorInput = activeEditor.getEditorInput();
if (editorInput instanceof IDatabaseEditorInput) {
if (editorInput instanceof DatabaseLazyEditorInput) {
activeEditor.addPropertyListener(new IPropertyListener() {
@Override
public void propertyChanged(Object source, int propId) {
if (EntityEditor.PROP_TITLE == propId) {
DataSourceToolbarUtils.updateCommandsUI();
activeEditor.removePropertyListener(this);
}
}
});
}
DBCExecutionContext executionContext = ((IDatabaseEditorInput) editorInput).getExecutionContext();
if (executionContext != null) {
DBSObject schemaObject = DBUtils.getSelectedObject(executionContext);
if (schemaObject != null && DBUtils.getPublicObjectContainer(schemaObject) != dataSource) {
DBSObject schemaParent = schemaObject.getParentObject();
if (schemaParent instanceof DBSObjectContainer && !(schemaParent instanceof DBPDataSource)) {
schemaName = schemaObject.getName() + "@" + schemaParent.getName();
} else {
schemaName = schemaObject.getName();
}
}
}
} else {
DBCExecutionContext executionContext = getExecutionContextFromPart(activeEditor);
DBCExecutionContextDefaults contextDefaults = null;
if (executionContext != null) {
contextDefaults = executionContext.getContextDefaults();
}
if (contextDefaults != null) {
DBSCatalog defaultCatalog = contextDefaults.getDefaultCatalog();
DBSSchema defaultSchema = contextDefaults.getDefaultSchema();
if (defaultCatalog != null && (defaultSchema != null || contextDefaults.supportsSchemaChange())) {
schemaName = defaultSchema == null ? "?" : defaultSchema.getName() + "@" + defaultCatalog.getName();
schemaIcon = DBIcon.TREE_SCHEMA;
} else if (defaultCatalog != null) {
schemaName = defaultCatalog.getName();
schemaIcon = DBIcon.TREE_DATABASE;
} else if (defaultSchema != null) {
schemaName = defaultSchema.getName();
schemaIcon = DBIcon.TREE_SCHEMA;
}
}
}
}
element.setText(schemaName);
element.setIcon(DBeaverIcons.getImageDescriptor(schemaIcon));
element.setTooltip(schemaTooltip);
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class SQLScriptTaskDataSourceSelectorDialog method createScriptColumns.
static void createScriptColumns(ColumnViewer viewer) {
final ILabelProvider mainLabelProvider = (ILabelProvider) viewer.getLabelProvider();
ViewerColumnController columnController = new ViewerColumnController("sqlTaskScriptViewer", viewer);
columnController.setForceAutoSize(true);
columnController.addColumn(ModelMessages.model_navigator_Name, DTUIMessages.sql_script_task_data_source_selection_dialog_column_description_script, SWT.LEFT, true, true, new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return mainLabelProvider.getText(element);
}
@Override
public Image getImage(Object element) {
return mainLabelProvider.getImage(element);
}
@Override
public String getToolTipText(Object element) {
if (mainLabelProvider instanceof IToolTipProvider) {
return ((IToolTipProvider) mainLabelProvider).getToolTipText(element);
}
return null;
}
});
columnController.addColumn(ModelMessages.model_navigator_Connection, DTUIMessages.sql_script_task_data_source_selection_dialog_column_description_script_data_source, SWT.LEFT, true, true, new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof DBNResource) {
Collection<DBPDataSourceContainer> containers = ((DBNResource) element).getAssociatedDataSources();
if (!CommonUtils.isEmpty(containers)) {
StringBuilder text = new StringBuilder();
for (DBPDataSourceContainer container : containers) {
if (text.length() > 0) {
text.append(", ");
}
text.append(container.getName());
}
return text.toString();
}
}
return "";
}
@Override
public Image getImage(Object element) {
return null;
}
});
columnController.createColumns(true);
}
Aggregations