use of org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource in project dbeaver by dbeaver.
the class MySQLSessionEditor method createSessionViewer.
@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
return new SessionManagerViewer<MySQLSession>(this, parent, new MySQLSessionManager((MySQLDataSource) executionContext.getDataSource())) {
private boolean hideSleeping;
@Override
protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
contributionManager.add(killSessionAction);
contributionManager.add(terminateQueryAction);
contributionManager.add(new Separator());
contributionManager.add(new ControlContribution("MySQLSessionHideSleep") {
@Override
protected Control createControl(Composite parent) {
Button hideSleepingCheck = UIUtils.createCheckbox(parent, "Hide sleeping", "Show only active connections", hideSleeping, 0);
hideSleepingCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
hideSleeping = hideSleepingCheck.getSelection();
refreshPart(MySQLSessionEditor.this, true);
}
});
return hideSleepingCheck;
}
});
contributionManager.add(new Separator());
}
@Override
protected void onSessionSelect(DBAServerSession session) {
super.onSessionSelect(session);
killSessionAction.setEnabled(session != null);
terminateQueryAction.setEnabled(session != null && !CommonUtils.isEmpty(session.getActiveQuery()));
}
@Override
public Map<String, Object> getSessionOptions() {
if (hideSleeping) {
return Collections.singletonMap(MySQLSessionManager.OPTION_HIDE_SLEEPING, true);
}
return super.getSessionOptions();
}
};
}
use of org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource in project dbeaver by serge-rider.
the class MySQLConstraintConfigurator method configureObject.
@Override
public MySQLTableConstraint configureObject(DBRProgressMonitor monitor, Object parent, MySQLTableConstraint constraint) {
MySQLDataSource dataSource = constraint.getDataSource();
return UITask.run(() -> {
EditConstraintPage editPage;
if (dataSource.supportsCheckConstraints()) {
editPage = new EditConstraintPage(MySQLUIMessages.edit_constraint_manager_title, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY, DBSEntityConstraintType.CHECK });
} else {
editPage = new EditConstraintPage(MySQLUIMessages.edit_constraint_manager_title, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY });
}
if (!editPage.edit()) {
return null;
}
constraint.setName(editPage.getConstraintName());
constraint.setConstraintType(editPage.getConstraintType());
if (editPage.getConstraintType() == DBSEntityConstraintType.CHECK && dataSource.supportsCheckConstraints()) {
constraint.setCheckClause(editPage.getConstraintExpression());
} else {
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
constraint.addColumn(new MySQLTableConstraintColumn(constraint, (MySQLTableColumn) tableColumn, colIndex++));
}
}
return constraint;
});
}
use of org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource in project dbeaver by serge-rider.
the class MySQLExportWizardPageObjects method loadSettings.
private void loadSettings() {
checkedObjects.clear();
catalogTable.removeAll();
boolean hasViews = false;
MySQLDataSource dataSource = null;
Set<MySQLCatalog> activeCatalogs = new LinkedHashSet<>();
for (MySQLDatabaseExportInfo info : wizard.getSettings().getExportObjects()) {
activeCatalogs.add(info.getDatabase());
dataSource = info.getDatabase().getDataSource();
if (!CommonUtils.isEmpty(info.getTables())) {
Set<MySQLTableBase> tables = checkedObjects.computeIfAbsent(info.getDatabase(), k -> new HashSet<>());
for (MySQLTableBase table : info.getTables()) {
tables.add(table);
if (table.isView()) {
hasViews = true;
}
}
}
}
if (hasViews) {
wizard.getSettings().setShowViews(true);
exportViewsCheck.setSelection(true);
}
if (dataSource != null) {
boolean tablesLoaded = false;
for (MySQLCatalog catalog : dataSource.getCatalogs()) {
TableItem item = new TableItem(catalogTable, SWT.NONE);
item.setImage(DBeaverIcons.getImage(DBIcon.TREE_DATABASE));
item.setText(0, catalog.getName());
item.setData(catalog);
if (activeCatalogs.contains(catalog)) {
item.setChecked(true);
catalogTable.select(catalogTable.indexOf(item));
if (!tablesLoaded) {
loadTables(catalog);
tablesLoaded = true;
}
}
}
}
updateState();
}
use of org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource in project dbeaver by dbeaver.
the class MySQLExportWizardPageObjects method loadSettings.
private void loadSettings() {
checkedObjects.clear();
catalogTable.removeAll();
boolean hasViews = false;
MySQLDataSource dataSource = null;
Set<MySQLCatalog> activeCatalogs = new LinkedHashSet<>();
for (MySQLDatabaseExportInfo info : wizard.getSettings().getExportObjects()) {
activeCatalogs.add(info.getDatabase());
dataSource = info.getDatabase().getDataSource();
if (!CommonUtils.isEmpty(info.getTables())) {
Set<MySQLTableBase> tables = checkedObjects.computeIfAbsent(info.getDatabase(), k -> new HashSet<>());
for (MySQLTableBase table : info.getTables()) {
tables.add(table);
if (table.isView()) {
hasViews = true;
}
}
}
}
if (hasViews) {
wizard.getSettings().setShowViews(true);
exportViewsCheck.setSelection(true);
}
if (dataSource != null) {
boolean tablesLoaded = false;
for (MySQLCatalog catalog : dataSource.getCatalogs()) {
TableItem item = new TableItem(catalogTable, SWT.NONE);
item.setImage(DBeaverIcons.getImage(DBIcon.TREE_DATABASE));
item.setText(0, catalog.getName());
item.setData(catalog);
if (activeCatalogs.contains(catalog)) {
item.setChecked(true);
catalogTable.select(catalogTable.indexOf(item));
if (!tablesLoaded) {
loadTables(catalog);
tablesLoaded = true;
}
}
}
}
updateState();
}
use of org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource in project dbeaver by dbeaver.
the class MySQLCommandChangeUser method getPersistActions.
@Override
public DBEPersistAction[] getPersistActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, Map<String, Object> options) {
List<DBEPersistAction> actions = new ArrayList<>();
boolean newUser = !getObject().isPersisted();
if (newUser) {
actions.add(new // $NON-NLS-2$
SQLDatabasePersistAction(// $NON-NLS-2$
MySQLUIMessages.edit_command_change_user_action_create_new_user, // $NON-NLS-2$
"CREATE USER " + getObject().getFullName()) {
@Override
public void afterExecute(DBCSession session, Throwable error) {
if (error == null) {
getObject().setPersisted(true);
}
}
});
}
boolean hasSet;
final MySQLDataSource dataSource = getObject().getDataSource();
if (MySQLUtils.isAlterUSerSupported(dataSource)) {
StringBuilder script = new StringBuilder();
if (generateAlterScript(script)) {
actions.add(new SQLDatabasePersistAction(MySQLUIMessages.edit_command_change_user_action_update_user_record, script.toString()));
}
} else {
String updateSQL = generateUpdateScript();
if (updateSQL != null) {
actions.add(new SQLDatabasePersistAction(MySQLUIMessages.edit_command_change_user_action_update_user_record, updateSQL));
}
updateSQL = generatePasswordSet();
if (updateSQL != null) {
actions.add(new SQLDatabasePersistAction(MySQLUIMessages.edit_command_change_user_action_update_user_record, updateSQL));
}
}
return actions.toArray(new DBEPersistAction[0]);
}
Aggregations