use of org.jkiss.dbeaver.runtime.ui.UIServiceSQL in project dbeaver by serge-rider.
the class NavigatorObjectsDeleter method showScriptWindow.
boolean showScriptWindow() {
final String sql = collectSQL();
boolean result = false;
if (sql.length() > 0) {
UIServiceSQL serviceSQL = DBWorkbench.getService(UIServiceSQL.class);
if (serviceSQL != null) {
result = serviceSQL.openSQLViewer(// command context is not null because sql is not empty, see appendSQL()
commandContext.getExecutionContext(), UINavigatorMessages.actions_navigator_delete_script, UIIcon.SQL_PREVIEW, sql, true, false) == IDialogConstants.PROCEED_ID;
}
} else {
result = UIUtils.confirmAction(window.getShell(), UINavigatorMessages.actions_navigator_delete_script, UINavigatorMessages.question_no_sql_available);
}
commandContext.resetChanges(!result);
return result;
}
use of org.jkiss.dbeaver.runtime.ui.UIServiceSQL in project dbeaver by serge-rider.
the class ResultSetFilterPanel method openEditorForActiveQuery.
private void openEditorForActiveQuery() {
DBSDataContainer dataContainer = viewer.getDataContainer();
String editorName;
if (dataContainer instanceof DBSEntity) {
editorName = dataContainer.getName();
} else {
editorName = "Query";
}
UIServiceSQL serviceSQL = DBWorkbench.getService(UIServiceSQL.class);
if (serviceSQL != null) {
serviceSQL.openSQLConsole(dataContainer == null || dataContainer.getDataSource() == null ? null : dataContainer.getDataSource().getContainer(), viewer.getExecutionContext(), editorName, viewer.getActiveQueryText());
}
}
use of org.jkiss.dbeaver.runtime.ui.UIServiceSQL in project dbeaver by serge-rider.
the class ResultSetFilterPanel method createObjectPanel.
@NotNull
private Control createObjectPanel(Shell popup) throws PartInitException {
Composite panel = new Composite(popup, SWT.NONE);
GridLayout gl = new GridLayout(2, false);
// gl.marginWidth = 0;
gl.marginHeight = 0;
// gl.horizontalSpacing = 0;
panel.setLayout(gl);
Label iconLabel = new Label(panel, SWT.NONE);
DBPImage activeObjectImage = getActiveObjectImage();
if (activeObjectImage != null) {
iconLabel.setImage(DBeaverIcons.getImage(activeObjectImage));
}
iconLabel.setToolTipText(ResultSetMessages.sql_editor_resultset_filter_panel_label);
iconLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
iconLabel.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND));
iconLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
openEditorForActiveQuery();
}
});
Composite editorPH = new Composite(panel, SWT.NONE);
editorPH.setLayoutData(new GridData(GridData.FILL_BOTH));
editorPH.setLayout(new FillLayout());
try {
UIServiceSQL serviceSQL = DBWorkbench.getService(UIServiceSQL.class);
if (serviceSQL != null) {
Object sqlPanel = serviceSQL.createSQLPanel(viewer.getSite(), editorPH, viewer, ResultSetViewer.DEFAULT_QUERY_TEXT, false, viewer.getActiveQueryText());
if (sqlPanel instanceof TextViewer) {
StyledText textWidget = ((TextViewer) sqlPanel).getTextWidget();
// textWidget.setAlwaysShowScrollBars(false);
panel.setBackground(textWidget.getBackground());
return textWidget;
}
}
return null;
} catch (DBException e) {
throw new PartInitException("Error creating SQL panel", e);
}
}
use of org.jkiss.dbeaver.runtime.ui.UIServiceSQL in project dbeaver by serge-rider.
the class DatabaseConsumerPageMapping method showDDL.
private void showDDL(DatabaseMappingContainer mapping) {
final DatabaseConsumerSettings settings = getDatabaseConsumerSettings();
final DBSObjectContainer container = settings.getContainer();
if (container == null) {
return;
}
DBPDataSource dataSource = container.getDataSource();
final DBEPersistAction[][] ddl = new DBEPersistAction[1][];
try {
getWizard().getRunnableContext().run(true, true, monitor -> {
monitor.beginTask(DTUIMessages.database_consumer_page_mapping_monitor_task, 1);
try {
DBCExecutionContext executionContext = DBUtils.getDefaultContext(dataSource, true);
ddl[0] = DatabaseTransferUtils.generateTargetTableDDL(monitor, executionContext, container, mapping);
} catch (DBException e) {
throw new InvocationTargetException(e);
}
monitor.done();
});
} catch (InvocationTargetException e) {
DBWorkbench.getPlatformUI().showError(DTUIMessages.database_consumer_page_mapping_title_target_DDL, DTUIMessages.database_consumer_page_mapping_message_error_generating_target_DDL, e);
return;
} catch (InterruptedException e) {
return;
}
DBEPersistAction[] persistActions = ddl[0];
if (ArrayUtils.isEmpty(persistActions)) {
UIUtils.showMessageBox(getShell(), "No schema changes", "No changes are needed for this mapping", SWT.ICON_INFORMATION);
return;
}
UIServiceSQL serviceSQL = DBWorkbench.getService(UIServiceSQL.class);
if (serviceSQL != null) {
String sql = SQLUtils.generateScript(dataSource, persistActions, false);
int result = serviceSQL.openSQLViewer(DBUtils.getDefaultContext(container, true), DTUIMessages.database_consumer_page_mapping_sqlviewer_title, null, sql, dataSource.getContainer().hasModifyPermission(DBPDataSourcePermission.PERMISSION_EDIT_METADATA), false);
if (result == IDialogConstants.PROCEED_ID) {
if (UIUtils.confirmAction(getShell(), "Create target objects", "Database metadata will be modified by creating new table(s) and column(s).\nAre you sure you want to proceed?")) {
// Create target objects
if (applySchemaChanges(dataSource, mapping, persistActions)) {
autoAssignMappings();
updateMappingsAndButtons();
}
}
}
}
}
use of org.jkiss.dbeaver.runtime.ui.UIServiceSQL in project dbeaver by serge-rider.
the class SaveScriptDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
Composite messageGroup = super.createDialogArea(parent);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.minimumWidth = 400;
messageGroup.setLayoutData(gd);
UIServiceSQL serviceSQL = DBWorkbench.getService(UIServiceSQL.class);
if (serviceSQL != null) {
Composite sqlContainer = new Composite(messageGroup, SWT.NONE);
gd = new GridData(GridData.FILL_BOTH);
sqlContainer.setLayout(new FillLayout());
gd.widthHint = 500;
gd.heightHint = 400;
sqlContainer.setLayoutData(gd);
try {
sqlPanel = serviceSQL.createSQLPanel(viewer.getSite(), sqlContainer, viewer, UINavigatorMessages.editors_entity_dialog_preview_title, true, "");
} catch (Exception e) {
DBWorkbench.getPlatformUI().showError("Can't create SQL panel", "Error creating SQL panel", e);
}
}
populateSQL();
boolean useDeleteCascade = saveReport.isHasReferences() && saveReport.getDeletes() > 0;
createDeleteCascadeControls(messageGroup, saveSettings, useDeleteCascade, this::populateSQL);
return messageGroup;
}
Aggregations