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;
}
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));
}
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);
}
}
}
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;
}
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;
}
Aggregations