Search in sources :

Example 21 with DBSObject

use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by dbeaver.

the class DebugCore method extractLaunchable.

public static List<DBSObject> extractLaunchable(Object[] scope) {
    List<DBSObject> extracted = new ArrayList<>();
    if (scope == null) {
        return extracted;
    }
    for (int i = 0; i < scope.length; i++) {
        Object object = scope[i];
        DBSObject adapted = Adapters.adapt(object, DBSObject.class, true);
        if (adapted != null) {
            extracted.add(adapted);
        }
    }
    return extracted;
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ArrayList(java.util.ArrayList) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject)

Example 22 with DBSObject

use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by dbeaver.

the class DatabaseBreakpoint method addDatabaseBreakpointAttributes.

protected void addDatabaseBreakpointAttributes(Map<String, Object> attributes, DBSObject databaseObject, DBNNode node) {
    String datasourceId = databaseObject.getDataSource().getContainer().getId();
    attributes.put(BREAKPOINT_ATTRIBUTE_DATASOURCE_ID, datasourceId);
    String nodePath = node.getNodeItemPath();
    attributes.put(BREAKPOINT_ATTRIBUTE_NODE_PATH, nodePath);
    Map<String, Object> context = DebugCore.resolveDatabaseContext(databaseObject);
    if (context.isEmpty()) {
        return;
    }
    attributes.put(BREAKPOINT_ATTRIBUTE_DATABASE_NAME, context.get(DBGController.DATABASE_NAME));
    attributes.put(BREAKPOINT_ATTRIBUTE_SCHEMA_NAME, context.get(DBGController.SCHEMA_NAME));
    attributes.put(BREAKPOINT_ATTRIBUTE_PROCEDURE_NAME, context.get(DBGController.PROCEDURE_NAME));
    Object oid = context.get(DBGController.PROCEDURE_OID);
    attributes.put(BREAKPOINT_ATTRIBUTE_PROCEDURE_OID, String.valueOf(oid));
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject)

Example 23 with DBSObject

use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by dbeaver.

the class DatabaseLaunchShortcut method launch.

protected void launch(DBSObject launchable, String mode) {
    Map<String, Object> databaseContext = DebugCore.resolveDatabaseContext(launchable);
    List<ILaunchConfiguration> configs = getCandidates(launchable, getConfigurationType(), databaseContext);
    if (configs != null) {
        ILaunchConfiguration config = null;
        int count = configs.size();
        if (count == 1) {
            config = configs.get(0);
        } else if (count > 1) {
            config = chooseConfiguration(configs, mode);
            if (config == null) {
                return;
            }
        }
        if (config == null) {
            try {
                config = createConfiguration(launchable);
            } catch (CoreException e) {
                IStatus status = e.getStatus();
                DebugUI.log(status);
                MessageDialog.openError(getShell(), DebugUIMessages.DatabaseLaunchShortcut_e_launch, status.getMessage());
                return;
            }
        }
        if (config != null) {
            DebugUITools.launch(config, mode);
        }
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject)

Example 24 with DBSObject

use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by dbeaver.

the class DatabaseScriptDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    String title = "Specify Script";
    getShell().setText(title);
    Control createdArea = super.createDialogArea(parent);
    sqlViewer = new DatabaseScriptEditor(dbsObject, title);
    try {
        sqlViewer.init(subSite, sqlInput);
        sqlViewer.reloadSyntaxRules();
        Object text = sqlViewer.getAdapter(Control.class);
        if (text instanceof StyledText) {
            ((StyledText) text).setEditable(true);
            ;
        }
    } catch (PartInitException e) {
        DBUserInterface.getInstance().showError(getShell().getText(), null, e);
    }
    Composite panel = UIUtils.createPlaceholder(parent, 1);
    panel.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite editorPH = new Composite(panel, SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.verticalIndent = 3;
    gd.horizontalSpan = 1;
    gd.minimumHeight = 100;
    gd.minimumWidth = 100;
    editorPH.setLayoutData(gd);
    editorPH.setLayout(new FillLayout());
    sqlViewer.createPartControl(editorPH);
    return createdArea;
}
Also used : Control(org.eclipse.swt.widgets.Control) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) PartInitException(org.eclipse.ui.PartInitException) FillLayout(org.eclipse.swt.layout.FillLayout)

Example 25 with DBSObject

use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by dbeaver.

the class MockDataHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    List<DBSObject> selectedObjects;
    if (event.getCommand().getId().endsWith("button")) {
        IResultSetController resultSet = ResultSetCommandHandler.getActiveResultSet(HandlerUtil.getActivePart(event));
        if (resultSet == null) {
            DBeaverUI.getInstance().showError("Mock Data", "No active results viewer");
            return null;
        }
        DBSDataContainer dataContainer = resultSet.getDataContainer();
        if (dataContainer == null || dataContainer.getDataSource() == null) {
            DBeaverUI.getInstance().showError("Mock Data", "Not connected to a database");
            return null;
        }
        if (!(dataContainer instanceof DBSDataManipulator)) {
            DBeaverUI.getInstance().showError("Mock Data", "Mock Data can be generated for a table only");
            return null;
        }
        selectedObjects = new ArrayList<>();
        selectedObjects.add(dataContainer);
    } else {
        selectedObjects = NavigatorUtils.getSelectedObjects(HandlerUtil.getCurrentSelection(event));
    }
    MockDataGenerateTool mockDataGenerator = new MockDataGenerateTool();
    try {
        mockDataGenerator.execute(HandlerUtil.getActiveWorkbenchWindow(event), null, selectedObjects);
    } catch (DBException e) {
        log.error("Error launching the Mock Data Generator", e);
    }
    return null;
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBException(org.jkiss.dbeaver.DBException) DBSDataManipulator(org.jkiss.dbeaver.model.struct.DBSDataManipulator) MockDataGenerateTool(org.jkiss.dbeaver.ext.mockdata.MockDataGenerateTool) IResultSetController(org.jkiss.dbeaver.ui.controls.resultset.IResultSetController) DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer)

Aggregations

DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)374 DBException (org.jkiss.dbeaver.DBException)129 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)66 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)66 ArrayList (java.util.ArrayList)54 InvocationTargetException (java.lang.reflect.InvocationTargetException)52 ISelection (org.eclipse.jface.viewers.ISelection)46 JDBCResultSet (org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet)46 AbstractObjectReference (org.jkiss.dbeaver.model.impl.struct.AbstractObjectReference)44 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)38 GridData (org.eclipse.swt.layout.GridData)38 JDBCPreparedStatement (org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement)38 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)30 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)29 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)29 DBSObjectContainer (org.jkiss.dbeaver.model.struct.DBSObjectContainer)28 Composite (org.eclipse.swt.widgets.Composite)27 IEditorPart (org.eclipse.ui.IEditorPart)26 DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)24 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)22