use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class BookmarksHandlerImpl method createBookmark.
/*
static DBNDatabaseNode getTargetBookmarkNode(DBRProgressMonitor monitor, DBNBookmark bookmark)
{
IFile resource = (IFile) bookmark.getResource();
final DBNProject projectNode = DBWorkbench.getPlatform().getNavigatorModel().getRoot().getProjectNode(resource.getProject());
if (projectNode != null) {
BookmarkStorage storage = bookmark.getStorage();
final DBPDataSourceContainer dataSourceContainer = projectNode.getDatabases().getDataSourceRegistry().getDataSource(storage.getDataSourceId());
if (dataSourceContainer != null) {
final DBNDataSource dsNode = (DBNDataSource) DBNUtils.getNodeByObject(dataSourceContainer);
if (dsNode != null) {
DBNDatabaseNode[] result = new DBNDatabaseNode[1];
dsNode.initializeNode(monitor, status -> {
if (status.isOK()) {
try {
BookmarkNodeLoader nodeLoader = new BookmarkNodeLoader(dsNode, storage, resource);
nodeLoader.run(monitor);
result[0] = nodeLoader.databaseNode;
} catch (Exception e) {
// Doesn't matter
}
}
});
return result[0];
}
}
}
return null;
}
*/
public static void createBookmark(final DBNDatabaseNode node, String title, IFolder folder) throws DBException {
if (folder == null) {
final DBPProject project = node.getOwnerProject();
if (project != null) {
folder = getBookmarksFolder(project, true);
}
}
if (folder == null) {
throw new DBException("Can't detect folder for bookmark");
}
ContentUtils.checkFolderExists(folder);
IFile file = ContentUtils.getUniqueFile(folder, CommonUtils.escapeFileName(title), BOOKMARK_EXT);
updateBookmark(node, title, file);
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class ProjectHandlerImpl method openResource.
@Override
public void openResource(@NotNull IResource resource) {
DBPProject project = DBWorkbench.getPlatform().getWorkspace().getProject((IProject) resource);
if (project == null) {
DBWorkbench.getPlatformUI().showError("No project", "Can't get project metadata for resource " + resource.getName());
return;
}
MultiPageWizardDialog dialog = new MultiPageWizardDialog(UIUtils.getActiveWorkbenchWindow(), new EditProjectWizard(project));
dialog.open();
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class ProjectHandlerImpl method getFeatures.
@Override
public int getFeatures(IResource resource) {
int features = FEATURE_CREATE_FOLDER | FEATURE_RENAME;
DBPProject activeProject = DBWorkbench.getPlatform().getWorkspace().getActiveProject();
if (activeProject == null || resource != activeProject.getEclipseProject()) {
features |= FEATURE_DELETE;
}
return features;
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
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 serge-rider.
the class WorkbenchInitializerCreateSampleDatabase method initializeWorkbenchWindow.
@Override
public void initializeWorkbenchWindow(IWorkbenchWindow window) {
if (DBWorkbench.getPlatform().getPreferenceStore().getBoolean(PROP_SAMPLE_DB_CANCELED)) {
// Create was canceled
return;
}
if (DataSourceRegistry.getAllDataSources().size() > 1) {
// Seems to be experienced user - no need in sampel db
return;
}
DBPProject activeProject = DBWorkbench.getPlatform().getWorkspace().getActiveProject();
if (activeProject == null || !activeProject.isRegistryLoaded()) {
// No active project
return;
}
DBPDataSourceRegistry registry = activeProject.getDataSourceRegistry();
if (isSampleDatabaseExists(registry)) {
// Already exist
return;
}
if (!showCreateSampleDatabasePrompt(window.getShell())) {
DBWorkbench.getPlatform().getPreferenceStore().setValue(PROP_SAMPLE_DB_CANCELED, true);
return;
}
createSampleDatabase(registry);
}
Aggregations