use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by dbeaver.
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 dbeaver.
the class QueryLogViewer method openSelectionInEditor.
private void openSelectionInEditor() {
DBPDataSourceContainer dsContainer = null;
StringBuilder sql = new StringBuilder();
TableItem[] items = logTable.getSelection();
for (TableItem item : items) {
QMMetaEvent event = (QMMetaEvent) item.getData();
QMMObject object = event.getObject();
if (object instanceof QMMStatementExecuteInfo) {
QMMStatementExecuteInfo stmtExec = (QMMStatementExecuteInfo) object;
if (dsContainer == null) {
QMMSessionInfo session = stmtExec.getStatement().getSession();
DBPProject project = session.getProject();
String containerId = session.getContainerId();
if (project != null) {
dsContainer = project.getDataSourceRegistry().getDataSource(containerId);
} else {
dsContainer = DBUtils.findDataSource(containerId);
}
}
String queryString = stmtExec.getQueryString();
if (!CommonUtils.isEmptyTrimmed(queryString)) {
if (sql.length() > 0) {
// $NON-NLS-1$
sql.append("\n");
}
queryString = queryString.trim();
sql.append(queryString);
if (!queryString.endsWith(SQLConstants.DEFAULT_STATEMENT_DELIMITER)) {
// $NON-NLS-1$
sql.append(SQLConstants.DEFAULT_STATEMENT_DELIMITER).append("\n");
}
}
}
}
if (sql.length() > 0) {
SQLEditorHandlerOpenEditor.openSQLConsole(UIUtils.getActiveWorkbenchWindow(), new SQLNavigatorContext(dsContainer), // $NON-NLS-1$
"QueryManager", sql.toString());
}
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by dbeaver.
the class SQLEditor method createPartControl.
@Override
public void createPartControl(Composite parent) {
setRangeIndicator(new DefaultRangeIndicator());
// divides editor area and results/panels area
resultsSash = UIUtils.createPartDivider(this, parent, resultSetOrientation.getSashOrientation() | SWT.SMOOTH);
CSSUtils.setCSSClass(resultsSash, DBStyles.COLORED_BY_CONNECTION_TYPE);
resultsSash.setSashWidth(5);
UIUtils.setHelp(resultsSash, IHelpContextIds.CTX_SQL_EDITOR);
Composite editorContainer;
sqlEditorPanel = UIUtils.createPlaceholder(resultsSash, 3, 0);
// Create left vertical toolbar
createControlsBar(sqlEditorPanel);
// Create editor presentations sash
Composite pPlaceholder = null;
if (extraPresentationDescriptor != null) {
presentationSash = UIUtils.createPartDivider(this, sqlEditorPanel, ((resultSetOrientation.getSashOrientation() == SWT.VERTICAL) ? SWT.HORIZONTAL : SWT.VERTICAL) | SWT.SMOOTH);
presentationSash.setSashWidth(5);
presentationSash.setLayoutData(new GridData(GridData.FILL_BOTH));
editorContainer = presentationSash;
pPlaceholder = new Composite(presentationSash, SWT.NONE);
pPlaceholder.setLayout(new FillLayout());
} else {
editorContainer = sqlEditorPanel;
}
super.createPartControl(editorContainer);
getEditorControlWrapper().setLayoutData(new GridData(GridData.FILL_BOTH));
// Create right vertical toolbar
createPresentationSwitchBar(sqlEditorPanel);
if (pPlaceholder != null) {
switch(extraPresentationDescriptor.getActivationType()) {
case HIDDEN:
presentationSash.setMaximizedControl(presentationSash.getChildren()[SQL_EDITOR_CONTROL_INDEX]);
break;
case MAXIMIZED:
case VISIBLE:
extraPresentation.createPresentation(pPlaceholder, this);
if (extraPresentationDescriptor.getActivationType() == SQLEditorPresentation.ActivationType.MAXIMIZED) {
if (presentationSash.getChildren()[EXTRA_CONTROL_INDEX] != null) {
presentationSash.setMaximizedControl(pPlaceholder);
}
}
break;
}
}
getSite().setSelectionProvider(new DynamicSelectionProvider());
DBPProject project = getProject();
if (project != null && project.isRegistryLoaded()) {
createResultTabs();
} else {
UIExecutionQueue.queueExec(this::createResultTabs);
}
setAction(ITextEditorActionConstants.SHOW_INFORMATION, null);
SourceViewer viewer = getViewer();
if (viewer != null) {
StyledText textWidget = viewer.getTextWidget();
if (textWidget != null) {
textWidget.addModifyListener(this::onTextChange);
textWidget.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
refreshActions();
}
});
}
}
SQLEditorFeatures.SQL_EDITOR_OPEN.use();
// Start output reader
new ServerOutputReader().schedule();
updateExecutionContext(null);
// Update controls
UIExecutionQueue.queueExec(this::onDataSourceChange);
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by dbeaver.
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();
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by dbeaver.
the class NavigatorActiveProjectContributor method createMenu.
private void createMenu(final Menu menu) {
final DBPProject activeProject = DBWorkbench.getPlatform().getWorkspace().getActiveProject();
for (final DBPProject project : DBWorkbench.getPlatform().getWorkspace().getProjects()) {
MenuItem txnItem = new MenuItem(menu, SWT.RADIO);
txnItem.setText(project.getName());
txnItem.setSelection(project == activeProject);
txnItem.setData(project);
txnItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
NavigatorHandlerProjectSetActive.setActiveProject(project);
}
});
}
}
Aggregations