use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class SQLScriptTaskPageSettings method loadSettings.
public void loadSettings() {
SQLScriptExecuteSettings settings = sqlWizard.getSettings();
List<String> scriptFiles = settings.getScriptFiles();
for (String filePath : scriptFiles) {
IFile file = SQLScriptExecuteSettings.getWorkspaceFile(filePath);
if (file == null) {
log.debug("Script file '" + filePath + "' not found");
continue;
}
DBPProject currentProject = DBWorkbench.getPlatform().getWorkspace().getProject(file.getProject());
if (currentProject == null) {
log.debug("Project '" + file.getProject().getName() + "' not found");
continue;
}
DBNProject projectNode = DBWorkbench.getPlatform().getNavigatorModel().getRoot().getProjectNode(currentProject);
if (projectNode != null) {
DBNResource resource = projectNode.findResource(file);
if (resource != null) {
selectedScripts.add(resource);
}
}
}
scriptsViewer.setInput(selectedScripts);
for (DBPDataSourceContainer dataSource : settings.getDataSources()) {
DBNProject projectNode = DBWorkbench.getPlatform().getNavigatorModel().getRoot().getProjectNode(dataSource.getProject());
DBNDataSource dsNode = projectNode.getDatabases().getDataSource(dataSource);
if (dsNode != null) {
selectedDataSources.add(dsNode);
}
}
dataSourceViewer.setInput(selectedDataSources);
// if (!selectedDataSources.isEmpty()) {
// dataSourceTree.getCheckboxViewer().setCheckedElements(selectedDataSources.toArray());
// dataSourceTree.getCheckboxViewer().reveal(selectedDataSources.get(0));
// }
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class SQLScriptExecuteSettings method loadConfiguration.
public void loadConfiguration(DBRRunnableContext runnableContext, Map<String, Object> config) {
// Legacy config support (single datasource
String projectName = JSONUtils.getString(config, "project");
DBPProject project = CommonUtils.isEmpty(projectName) ? null : DBWorkbench.getPlatform().getWorkspace().getProject(projectName);
if (project != null) {
String dataSourceContainerId = JSONUtils.getString(config, "dataSourceContainer");
if (!CommonUtils.isEmpty(dataSourceContainerId)) {
DBPDataSourceContainer dataSource = project.getDataSourceRegistry().getDataSource(dataSourceContainerId);
if (dataSource != null) {
dataSources.add(dataSource);
}
}
} else {
// Modern config (datasource list)
List<Map<String, Object>> dsConfig = JSONUtils.getObjectList(config, "dataSources");
for (Map<String, Object> dsInfo : dsConfig) {
projectName = JSONUtils.getString(dsInfo, "project");
project = CommonUtils.isEmpty(projectName) ? null : DBWorkbench.getPlatform().getWorkspace().getProject(projectName);
if (project != null) {
String dataSourceContainerId = JSONUtils.getString(dsInfo, "dataSource");
if (!CommonUtils.isEmpty(dataSourceContainerId)) {
DBPDataSourceContainer dataSource = project.getDataSourceRegistry().getDataSource(dataSourceContainerId);
if (dataSource != null) {
dataSources.add(dataSource);
}
}
}
}
}
scriptFiles = JSONUtils.deserializeStringList(config, "scriptFiles");
ignoreErrors = JSONUtils.getBoolean(config, "ignoreErrors");
dumpQueryResultsToLog = JSONUtils.getBoolean(config, "dumpQueryResultsToLog");
autoCommit = JSONUtils.getBoolean(config, "autoCommit");
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class DiagramCreateWizard method init.
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
setWindowTitle(ERDUIMessages.wizard_diagram_create_title);
setNeedsProgressMonitor(true);
IFolder diagramFolder = null;
if (selection != null) {
Object element = selection.getFirstElement();
if (element != null) {
diagramFolder = Platform.getAdapterManager().getAdapter(element, IFolder.class);
}
}
if (diagramFolder == null) {
DBPProject activeProject = DBWorkbench.getPlatform().getWorkspace().getActiveProject();
if (activeProject == null) {
errorMessage = "Can't create diagram without active project";
} else {
try {
diagramFolder = ERDResourceHandler.getDiagramsFolder(activeProject, true);
} catch (CoreException e) {
errorMessage = e.getMessage();
}
}
// Check for entity selection
if (selection != null && !selection.isEmpty()) {
if (Platform.getAdapterManager().getAdapter(selection.getFirstElement(), DBSEntity.class) != null) {
entitySelection = selection;
}
}
}
this.folder = diagramFolder;
}
use of org.jkiss.dbeaver.model.app.DBPProject 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.app.DBPProject in project dbeaver by serge-rider.
the class ApplicationWorkbenchWindowAdvisor method computeTitle.
private String computeTitle() {
// Use hardcoded pref constants to avoid E4.7 compile dependency
IPreferenceStore ps = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
// $NON-NLS-1$
StringJoiner sj = new StringJoiner(" - ");
if (ps.getBoolean("SHOW_LOCATION_NAME")) {
String workspaceName = ps.getString("WORKSPACE_NAME");
if (workspaceName != null && workspaceName.length() > 0) {
sj.add(workspaceName);
}
}
if (ps.getBoolean("SHOW_LOCATION")) {
String workspaceLocation = Platform.getLocation().toOSString();
sj.add(workspaceLocation);
}
if (ps.getBoolean("SHOW_PERSPECTIVE_IN_TITLE")) {
DBPProject activeProject = DBWorkbench.getPlatform().getWorkspace().getActiveProject();
if (activeProject != null) {
// $NON-NLS-1$
sj.add(activeProject.getName());
}
}
if (ps.getBoolean("SHOW_PRODUCT_IN_TITLE")) {
sj.add(GeneralUtils.getProductTitle());
}
IWorkbenchWindow window = getWindowConfigurer().getWindow();
if (window != null) {
IWorkbenchPage activePage = window.getActivePage();
if (activePage != null) {
IEditorPart activeEditor = activePage.getActiveEditor();
if (activeEditor != null) {
sj.add(activeEditor.getTitle());
}
}
}
return sj.toString();
}
Aggregations