use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by dbeaver.
the class SampleDatabaseHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
DBPProject activeProject = DBWorkbench.getPlatform().getWorkspace().getActiveProject();
if (activeProject == null || !activeProject.isRegistryLoaded()) {
// No active project
return null;
}
DBPDataSourceRegistry registry = activeProject.getDataSourceRegistry();
Shell shell = UIUtils.getActiveWorkbenchShell();
if (WorkbenchInitializerCreateSampleDatabase.isSampleDatabaseExists(registry)) {
UIUtils.showMessageBox(shell, SampleDatabaseMessages.dialog_already_created_title, SampleDatabaseMessages.dialog_already_created_description, SWT.ICON_WARNING);
return null;
}
if (WorkbenchInitializerCreateSampleDatabase.showCreateSampleDatabasePrompt(shell)) {
WorkbenchInitializerCreateSampleDatabase.createSampleDatabase(registry);
}
return null;
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by dbeaver.
the class ResultSetViewer method dispose.
// //////////////////////////////////////////////////////////
// Misc
private void dispose() {
if (themeChangeListener != null) {
PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(themeChangeListener);
themeChangeListener = null;
}
DBWorkbench.getPlatform().getDataSourceProviderRegistry().getGlobalDataSourcePreferenceStore().removePropertyChangeListener(dataPropertyListener);
DBWorkbench.getPlatform().getPreferenceStore().removePropertyChangeListener(dataPropertyListener);
if (activePresentation != null) {
activePresentation.dispose();
}
DBPProject project = container.getProject();
if (project != null) {
project.getDataSourceRegistry().removeDataSourceListener(this);
}
savePresentationSettings();
clearData();
for (ToolBarManager tb : toolbarList) {
try {
tb.dispose();
} catch (Throwable e) {
// ignore
log.debug("Error disposing toolbar " + tb, e);
}
}
toolbarList.clear();
UIUtils.dispose(this.sizingGC);
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by dbeaver.
the class SQLEditorHandlerOpenObjectConsole method openConsole.
void openConsole(IWorkbenchWindow workbenchWindow, DBRRunnableWithResult<String> generator, SQLNavigatorContext navigatorContext, String title, boolean doRun, ISelection currentSelection) throws Exception {
UIUtils.runInUI(workbenchWindow, generator);
String sql = CommonUtils.notEmpty(generator.getResult());
DBPProject project = navigatorContext.getProject();
SQLEditorHandlerOpenEditor.checkProjectIsOpen(project);
IFolder folder = SQLEditorHandlerOpenEditor.getCurrentScriptFolder(currentSelection);
IFile scriptFile = SQLEditorUtils.createNewScript(project, folder, navigatorContext);
FileEditorInput sqlInput = new FileEditorInput(scriptFile);
SQLEditor editor = (SQLEditor) workbenchWindow.getActivePage().openEditor(sqlInput, SQLEditor.class.getName());
if (editor != null) {
editor.getDocument().set(sql);
AbstractJob execJob = new AbstractJob("Execute SQL in console") {
@Override
protected IStatus run(DBRProgressMonitor monitor) {
// So let's give it a chance and wait for 10 seconds
for (int i = 0; i < 100; i++) {
if (editor.getExecutionContext() != null) {
break;
}
RuntimeUtils.pause(100);
}
return Status.OK_STATUS;
}
};
if (doRun) {
execJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
UIUtils.syncExec(() -> editor.processSQL(false, false));
}
});
}
execJob.schedule();
}
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by dbeaver.
the class SQLEditorHandlerOpenEditor method openNewEditor.
public static IFile openNewEditor(@NotNull SQLNavigatorContext editorContext, ISelection selection) throws CoreException {
DBPProject project = editorContext.getProject();
checkProjectIsOpen(project);
IFolder folder = getCurrentScriptFolder(selection);
IFile scriptFile = SQLEditorUtils.createNewScript(project, folder, editorContext);
openResource(scriptFile, editorContext);
return scriptFile;
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by dbeaver.
the class SQLEditorHandlerOpenEditor method openRecentScript.
public static void openRecentScript(@NotNull IWorkbenchWindow workbenchWindow, @NotNull SQLNavigatorContext editorContext, @Nullable IFolder scriptFolder) throws CoreException {
final DBPProject project = editorContext.getProject();
checkProjectIsOpen(project);
SQLEditorUtils.ResourceInfo res = SQLEditorUtils.findRecentScript(project, editorContext);
if (res != null) {
openResourceEditor(workbenchWindow, res, editorContext);
} else {
IFile scriptFile = SQLEditorUtils.createNewScript(project, scriptFolder, editorContext);
openResource(scriptFile, editorContext);
}
}
Aggregations