Search in sources :

Example 56 with DBPProject

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);
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) Document(org.w3c.dom.Document)

Example 57 with DBPProject

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();
}
Also used : DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) DataSourceProviderRegistry(org.jkiss.dbeaver.registry.DataSourceProviderRegistry) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 58 with DBPProject

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();
        }
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) DBPProject(org.jkiss.dbeaver.model.app.DBPProject)

Example 59 with DBPProject

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);
}
Also used : Repository(org.eclipse.jgit.lib.Repository) IFile(org.eclipse.core.resources.IFile) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) INavigatorModelView(org.jkiss.dbeaver.ui.navigator.INavigatorModelView) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) IEditorPart(org.eclipse.ui.IEditorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 60 with DBPProject

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;
}
Also used : DBTTaskManager(org.jkiss.dbeaver.model.task.DBTTaskManager) TaskConfigurationWizardDialog(org.jkiss.dbeaver.tasks.ui.wizard.TaskConfigurationWizardDialog) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) ExecutionException(org.eclipse.core.commands.ExecutionException)

Aggregations

DBPProject (org.jkiss.dbeaver.model.app.DBPProject)90 IFile (org.eclipse.core.resources.IFile)20 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)18 DBException (org.jkiss.dbeaver.DBException)14 DBPDataSourceRegistry (org.jkiss.dbeaver.model.app.DBPDataSourceRegistry)14 IFolder (org.eclipse.core.resources.IFolder)8 DBPWorkspace (org.jkiss.dbeaver.model.app.DBPWorkspace)8 IResource (org.eclipse.core.resources.IResource)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 IEditorPart (org.eclipse.ui.IEditorPart)6 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)6 GridData (org.eclipse.swt.layout.GridData)5 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 DBPImage (org.jkiss.dbeaver.model.DBPImage)4 Document (org.w3c.dom.Document)4