use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class DiagramLoader method load.
public static void load(DBRProgressMonitor monitor, IProject project, DiagramPart diagramPart, InputStream in) throws XMLException, DBException {
monitor.beginTask("Parse diagram", 1);
final EntityDiagram diagram = diagramPart.getDiagram();
DBPProject projectMeta = DBWorkbench.getPlatform().getWorkspace().getProject(project);
if (projectMeta == null) {
throw new DBException("Cannot find datasource registry for project '" + project.getName() + "'");
}
final Document document = XMLUtils.parseDocument(in);
monitor.done();
loadDiagram(monitor, document, projectMeta, diagram);
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class PrefPageConnectionTypes method performOk.
@Override
public boolean performOk() {
typeId.setEnabled(false);
DataSourceProviderRegistry registry = DataSourceProviderRegistry.getInstance();
List<DBPConnectionType> toRemove = new ArrayList<>();
for (DBPConnectionType type : registry.getConnectionTypes()) {
if (!changedInfo.values().contains(type)) {
// Remove
toRemove.add(type);
}
}
Set<DBPConnectionType> changedSet = new HashSet<>();
for (DBPConnectionType connectionType : toRemove) {
registry.removeConnectionType(connectionType);
changedSet.add(connectionType);
}
for (Map.Entry<DBPConnectionType, DBPConnectionType> entry : changedInfo.entrySet()) {
boolean hasChanges = false;
DBPConnectionType changed = entry.getKey();
DBPConnectionType source = entry.getValue();
if (source == changed) {
// New type
if (CommonUtils.isEmpty(changed.getId())) {
changed.setId(SecurityUtils.generateUniqueId());
}
for (DBPConnectionType type : changedInfo.keySet()) {
if (type != changed && type.getId().equals(changed.getId())) {
changed.setId(SecurityUtils.generateUniqueId());
break;
}
}
entry.setValue(new DBPConnectionType(source));
registry.addConnectionType(changed);
hasChanges = true;
} else if (!source.equals(changed)) {
// Changed type
source.setId(changed.getId());
source.setName(changed.getName());
source.setDescription(changed.getDescription());
source.setAutocommit(changed.isAutocommit());
source.setConfirmExecute(changed.isConfirmExecute());
source.setConfirmDataChange(changed.isConfirmDataChange());
source.setColor(changed.getColor());
source.setModifyPermissions(changed.getModifyPermission());
hasChanges = true;
}
if (hasChanges) {
changedSet.add(source);
}
}
if (!changedSet.isEmpty()) {
registry.saveConnectionTypes();
// Flush projects configs (as they cache connection type information)
for (DBPProject project : DBWorkbench.getPlatform().getWorkspace().getProjects()) {
DBPDataSourceRegistry projectRegistry = project.getDataSourceRegistry();
for (DBPDataSourceContainer ds : projectRegistry.getDataSources()) {
if (changedSet.contains(ds.getConnectionConfiguration().getConnectionType())) {
projectRegistry.flushConfig();
break;
}
}
}
}
return super.performOk();
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class DatabaseConsumerPageMapping method mapExistingTable.
private void mapExistingTable(DatabaseMappingContainer mapping) {
final DatabaseConsumerSettings settings = getDatabaseConsumerSettings();
DBPProject activeProject = DBWorkbench.getPlatform().getWorkspace().getActiveProject();
if (activeProject != null) {
DBNNode rootNode = settings.getContainerNode();
if (rootNode == null) {
rootNode = DBWorkbench.getPlatform().getNavigatorModel().getRoot().getProjectNode(activeProject).getDatabases();
}
DBNNode selectedNode = rootNode;
if (mapping.getTarget() != null) {
selectedNode = DBWorkbench.getPlatform().getNavigatorModel().getNodeByObject(mapping.getTarget());
}
DBNNode node = DBWorkbench.getPlatformUI().selectObject(getShell(), DTUIMessages.database_consumer_page_mapping_node_title, rootNode, selectedNode, new Class[] { DBSObjectContainer.class, DBSDataManipulator.class }, new Class[] { DBSDataManipulator.class }, null);
if (node != null && node instanceof DBSWrapper) {
DBSObject object = ((DBSWrapper) node).getObject();
try {
if (object instanceof DBSDataManipulator) {
mapping.setTarget((DBSDataManipulator) object);
mapping.refreshMappingType(getWizard().getRunnableContext(), DatabaseMappingType.existing);
mapColumns(mapping);
} else {
mapping.setTarget(null);
mapping.refreshMappingType(getWizard().getRunnableContext(), DatabaseMappingType.unspecified);
}
} catch (DBException e) {
DBWorkbench.getPlatformUI().showError(DTUIMessages.database_consumer_page_mapping_title_error_mapping_table, DTUIMessages.database_consumer_page_mapping_message_error_mapping_existing_table, e);
}
updateMappingsAndButtons();
updatePageCompletion();
}
}
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class GITAbstractHandler method getRepositories.
protected Repository[] getRepositories(ExecutionEvent event) {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof IEditorPart) {
IFile editorFile = EditorUtils.getFileFromInput(((IEditorPart) activePart).getEditorInput());
if (editorFile != null) {
Repository repository = SelectionUtils.getRepository(new StructuredSelection(editorFile));
if (repository != null) {
return new Repository[] { repository };
}
}
}
{
INavigatorModelView navigatorModelView = GeneralUtils.adapt(activePart, INavigatorModelView.class);
if (navigatorModelView != null) {
DBNNode rootNode = navigatorModelView.getRootNode();
if (rootNode != null) {
DBPProject ownerProject = rootNode.getOwnerProject();
if (ownerProject != null) {
return getRepositories(new StructuredSelection(ownerProject.getEclipseProject()));
}
}
}
}
IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event);
return getRepositories(selection);
}
use of org.jkiss.dbeaver.model.app.DBPProject in project dbeaver by serge-rider.
the class TaskHandlerCreate method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
DBPProject project = NavigatorUtils.getSelectedProject();
/*
CreateTaskConfigurationDialog dialog = new CreateTaskConfigurationDialog(
HandlerUtil.getActiveShell(event),
project
);
*/
TaskConfigurationWizardDialog dialog = new TaskConfigurationWizardDialog(HandlerUtil.getActiveWorkbenchWindow(event));
if (dialog.open() == IDialogConstants.OK_ID) {
DBTTaskManager taskManager = project.getTaskManager();
try {
/*
DBTTaskConfigurator configurator = dialog.getSelectedCategory().createConfigurator();
DBTTask task = taskManager.createTask(
dialog.getSelectedTaskType(),
dialog.getTaskName(),
dialog.getTaskDescription(),
dialog.getInitialProperties());
if (!configurator.createTaskConfigWizard(task)) {
taskManager.deleteTaskConfiguration(task);
}
*/
} catch (Exception e) {
DBWorkbench.getPlatformUI().showError("Create task failed", "Error while creating new task", e);
}
}
return null;
}
Aggregations