提交 4e29d499 编写于 作者: S SA357

PostgreSQL table does not show comment in DDL. #9387

Buttons in DDL window is not displayed if their options are not supported


Former-commit-id: a27cb092
上级 23d023d8
......@@ -25,6 +25,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbenchPartSite;
import org.jkiss.dbeaver.model.DBPScriptObject;
import org.jkiss.dbeaver.model.DBPScriptObjectExt2;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.sql.generator.SQLGenerator;
import org.jkiss.dbeaver.ui.UIUtils;
......@@ -47,21 +48,37 @@ class SQLGeneratorDialog extends ViewSQLDialog {
@Override
protected Composite createDialogArea(Composite parent) {
sqlGenerator.setFullyQualifiedNames(
getDialogBoundsSettings().get(PROP_USE_FQ_NAMES) == null ||
sqlGenerator.setFullyQualifiedNames(getDialogBoundsSettings().get(PROP_USE_FQ_NAMES) == null ||
getDialogBoundsSettings().getBoolean(PROP_USE_FQ_NAMES));
sqlGenerator.setCompactSQL(
getDialogBoundsSettings().get(PROP_USE_COMPACT_SQL) != null &&
sqlGenerator.setCompactSQL(getDialogBoundsSettings().get(PROP_USE_COMPACT_SQL) != null &&
getDialogBoundsSettings().getBoolean(PROP_USE_COMPACT_SQL));
sqlGenerator.setShowPermissions(
getDialogBoundsSettings().get(DBPScriptObject.OPTION_INCLUDE_PERMISSIONS) != null &&
getDialogBoundsSettings().getBoolean(DBPScriptObject.OPTION_INCLUDE_PERMISSIONS));
sqlGenerator.setShowComments(
getDialogBoundsSettings().get(DBPScriptObject.OPTION_INCLUDE_COMMENTS) != null &&
getDialogBoundsSettings().getBoolean(DBPScriptObject.OPTION_INCLUDE_COMMENTS));
sqlGenerator.setShowFullDdl(
getDialogBoundsSettings().get(DBPScriptObject.OPTION_INCLUDE_NESTED_OBJECTS) != null &&
getDialogBoundsSettings().getBoolean(DBPScriptObject.OPTION_INCLUDE_NESTED_OBJECTS));
boolean supportPermissions = false;
boolean supportComments = false;
boolean supportFullDDL = false;
for (Object object : sqlGenerator.getObjects()) {
DBPScriptObjectExt2 sourceObject = (DBPScriptObjectExt2) object;
if (sourceObject.supportsObjectDefinitionOption(DBPScriptObject.OPTION_INCLUDE_PERMISSIONS)) {
supportPermissions = true;
}
if (sourceObject.supportsObjectDefinitionOption(DBPScriptObject.OPTION_INCLUDE_COMMENTS)) {
supportComments = true;
}
if (sourceObject.supportsObjectDefinitionOption(DBPScriptObject.OPTION_INCLUDE_NESTED_OBJECTS)) {
supportFullDDL = true;
}
if (supportPermissions && supportComments && supportFullDDL) {
break; //it supports everything
}
}
sqlGenerator.setShowPermissions(getDialogBoundsSettings().get(DBPScriptObject.OPTION_INCLUDE_PERMISSIONS) != null &&
getDialogBoundsSettings().getBoolean(DBPScriptObject.OPTION_INCLUDE_PERMISSIONS));
sqlGenerator.setShowComments(getDialogBoundsSettings().get(DBPScriptObject.OPTION_INCLUDE_COMMENTS) != null &&
getDialogBoundsSettings().getBoolean(DBPScriptObject.OPTION_INCLUDE_COMMENTS));
sqlGenerator.setShowFullDdl(getDialogBoundsSettings().get(DBPScriptObject.OPTION_INCLUDE_NESTED_OBJECTS) != null &&
getDialogBoundsSettings().getBoolean(DBPScriptObject.OPTION_INCLUDE_NESTED_OBJECTS));
UIUtils.runInUI(sqlGenerator);
Object sql = sqlGenerator.getResult();
if (sql != null) {
......@@ -100,51 +117,57 @@ class SQLGeneratorDialog extends ViewSQLDialog {
}
}
});
Button useShowComments = UIUtils.createCheckbox(settings, "Show comments", sqlGenerator.isShowComments());
useShowComments.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sqlGenerator.setShowComments(useShowComments.getSelection());
getDialogBoundsSettings().put(DBPScriptObject.OPTION_INCLUDE_COMMENTS, useShowComments.getSelection());
if (supportComments) {
Button useShowComments = UIUtils.createCheckbox(settings, "Show comments", sqlGenerator.isShowComments());
useShowComments.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sqlGenerator.setShowComments(useShowComments.getSelection());
getDialogBoundsSettings().put(DBPScriptObject.OPTION_INCLUDE_COMMENTS, useShowComments.getSelection());
UIUtils.runInUI(sqlGenerator);
Object sql = sqlGenerator.getResult();
if (sql != null) {
setSQLText(CommonUtils.toString(sql));
updateSQL();
UIUtils.runInUI(sqlGenerator);
Object sql = sqlGenerator.getResult();
if (sql != null) {
setSQLText(CommonUtils.toString(sql));
updateSQL();
}
}
}
});
Button useShowPermissions = UIUtils.createCheckbox(settings, "Show permissions", sqlGenerator.isIncludePermissions());
useShowPermissions.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sqlGenerator.setShowPermissions(useShowPermissions.getSelection());
getDialogBoundsSettings().put(DBPScriptObject.OPTION_INCLUDE_PERMISSIONS, useShowPermissions.getSelection());
});
}
if (supportPermissions) {
Button useShowPermissions = UIUtils.createCheckbox(settings, "Show permissions", sqlGenerator.isIncludePermissions());
useShowPermissions.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sqlGenerator.setShowPermissions(useShowPermissions.getSelection());
getDialogBoundsSettings().put(DBPScriptObject.OPTION_INCLUDE_PERMISSIONS, useShowPermissions.getSelection());
UIUtils.runInUI(sqlGenerator);
Object sql = sqlGenerator.getResult();
if (sql != null) {
setSQLText(CommonUtils.toString(sql));
updateSQL();
UIUtils.runInUI(sqlGenerator);
Object sql = sqlGenerator.getResult();
if (sql != null) {
setSQLText(CommonUtils.toString(sql));
updateSQL();
}
}
}
});
Button useShowFullDdl = UIUtils.createCheckbox(settings, "Show full DDL", sqlGenerator.isShowFullDdl());
useShowFullDdl.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sqlGenerator.setShowFullDdl(useShowFullDdl.getSelection());
getDialogBoundsSettings().put(DBPScriptObject.OPTION_INCLUDE_COMMENTS, useShowFullDdl.getSelection());
});
}
if (supportFullDDL) {
Button useShowFullDdl = UIUtils.createCheckbox(settings, "Show full DDL", sqlGenerator.isShowFullDdl());
useShowFullDdl.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sqlGenerator.setShowFullDdl(useShowFullDdl.getSelection());
getDialogBoundsSettings().put(DBPScriptObject.OPTION_INCLUDE_COMMENTS, useShowFullDdl.getSelection());
UIUtils.runInUI(sqlGenerator);
Object sql = sqlGenerator.getResult();
if (sql != null) {
setSQLText(CommonUtils.toString(sql));
updateSQL();
UIUtils.runInUI(sqlGenerator);
Object sql = sqlGenerator.getResult();
if (sql != null) {
setSQLText(CommonUtils.toString(sql));
updateSQL();
}
}
}
});
});
}
return composite;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册