use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class PostgreFDWConfigWizardPageConfig method refreshFDWProperties.
private void refreshFDWProperties() {
{
// Fill options
DBPDataSourceContainer targetDataSource = getWizard().getSelectedDataSource();
PostgreFDWConfigWizard.FDWInfo selectedFDW = getWizard().getSelectedFDW();
PropertySourceCustom propertySource = getWizard().getFdwPropertySource();
propertySource.setDefValueResolver(targetDataSource.getVariablesResolver(false));
propertySource.removeAll();
if (selectedFDW != null && selectedFDW.fdwDescriptor != null) {
propertySource.addProperties(selectedFDW.fdwDescriptor.getProperties());
} else if (selectedFDW != null) {
// Add some default props
propertySource.addProperty(new PropertyDescriptor(null, "host", "host", "Remote database host", false, String.class, "${host}", null));
propertySource.addProperty(new PropertyDescriptor(null, "port", "port", "Remote database port", false, String.class, "${port}", null));
propertySource.addProperty(new PropertyDescriptor(null, "dbname", "dbname", "Remote database name", false, String.class, "${database}", null));
}
propsEditor.loadProperties(propertySource);
}
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class KeepAliveListenerJob method run.
@Override
protected IStatus run(DBRProgressMonitor monitor) {
if (platform.isShuttingDown()) {
return Status.OK_STATUS;
}
if (lastPingTime > 0 && System.currentTimeMillis() - lastPingTime > SYSTEM_SUSPEND_INTERVAL) {
log.debug("System suspend detected! Reinitialize all remote connections.");
}
lastPingTime = System.currentTimeMillis();
final DBPWorkspace workspace = platform.getWorkspace();
for (DBPProject project : workspace.getProjects()) {
if (project.isOpen() && project.isRegistryLoaded()) {
DBPDataSourceRegistry dataSourceRegistry = project.getDataSourceRegistry();
for (DBPDataSourceContainer ds : dataSourceRegistry.getDataSources()) {
checkDataSourceAlive(ds);
}
}
}
if (!platform.isShuttingDown()) {
scheduleMonitor();
}
return Status.OK_STATUS;
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class DashboardOpenTool method execute.
@Override
public void execute(IWorkbenchWindow window, IWorkbenchPart activePart, Collection<DBSObject> objects) throws DBException {
// Just open dashboard view
if (objects.isEmpty()) {
return;
}
DBSObject object = objects.iterator().next();
DBPDataSourceContainer dataSourceContainer = object.getDataSource().getContainer();
if (dataSourceContainer == null) {
return;
}
DashboardView.openView(window, dataSourceContainer);
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class HandlerDashboardOpen method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
DBPDataSourceContainer dataSourceContainer = getActiveDataSourceContainer(event, false);
if (dataSourceContainer == null) {
dataSourceContainer = getActiveDataSourceContainer(event, true);
}
if (dataSourceContainer == null) {
DBWorkbench.getPlatformUI().showError(UIDashboardMessages.error_dashboard_view_no_connection_title, UIDashboardMessages.error_dashboard_view_no_connection_msg);
return null;
}
DashboardView.openView(workbenchWindow, dataSourceContainer);
return null;
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class SQLEditorUtils method createNewScript.
public static IFile createNewScript(DBPProject project, @Nullable IFolder folder, @NotNull SQLNavigatorContext navigatorContext) throws CoreException {
final IProgressMonitor progressMonitor = new NullProgressMonitor();
// Get folder
final IFolder scriptsRootFolder = getScriptsFolder(project, true);
IFolder scriptsFolder = folder;
if (scriptsFolder == null) {
scriptsFolder = scriptsRootFolder;
}
if (!scriptsFolder.exists()) {
scriptsFolder.create(true, true, new NullProgressMonitor());
}
if (CommonUtils.equalObjects(scriptsRootFolder, scriptsFolder)) {
// We are in the root folder
DBPDataSourceContainer dataSourceContainer = navigatorContext.getDataSourceContainer();
if (dataSourceContainer != null) {
if (dataSourceContainer.getPreferenceStore().getBoolean(SQLPreferenceConstants.SCRIPT_CREATE_CONNECTION_FOLDERS)) {
// Create script folders according to connection folders
DBPDataSourceFolder conFolder = dataSourceContainer.getFolder();
if (conFolder != null) {
List<DBPDataSourceFolder> conFolders = new ArrayList<>();
for (DBPDataSourceFolder f = conFolder; f != null; f = f.getParent()) {
conFolders.add(0, f);
}
for (DBPDataSourceFolder f : conFolders) {
IFolder dbFolder = scriptsFolder.getFolder(CommonUtils.escapeFileName(f.getName()));
if (dbFolder != null) {
if (!dbFolder.exists()) {
dbFolder.create(true, true, progressMonitor);
}
scriptsFolder = dbFolder;
}
}
}
}
if (dataSourceContainer.getPreferenceStore().getBoolean(SQLPreferenceConstants.SCRIPT_AUTO_FOLDERS)) {
// Create special folder for connection
IFolder dbFolder = scriptsFolder.getFolder(CommonUtils.escapeFileName(dataSourceContainer.getName()));
if (dbFolder != null) {
if (!dbFolder.exists()) {
dbFolder.create(true, true, progressMonitor);
}
scriptsFolder = dbFolder;
}
}
}
}
// Make new script file
IFile tempFile = ContentUtils.getUniqueFile(scriptsFolder, "Script", SCRIPT_FILE_EXTENSION);
tempFile.create(new ByteArrayInputStream(new byte[] {}), true, progressMonitor);
// Save ds container reference
if (navigatorContext.getDataSourceContainer() != null) {
EditorUtils.setFileDataSource(tempFile, navigatorContext);
}
return tempFile;
}
Aggregations