use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.
the class PackageNavigateHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final OracleProcedurePackaged procedure = getSelectedProcedure(event);
if (procedure != null) {
OraclePackage procPackage = procedure.getParentObject();
IEditorPart entityEditor = NavigatorHandlerObjectOpen.openEntityEditor(procPackage);
if (entityEditor instanceof EntityEditor) {
((EntityEditor) entityEditor).switchFolder("source.definition");
SQLEditorBase sqlEditor = entityEditor.getAdapter(SQLEditorBase.class);
if (sqlEditor != null) {
new NavigateJob(procedure, sqlEditor).schedule();
}
}
}
return null;
}
use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.
the class WorkbenchContextListener method partDeactivated.
@Override
public void partDeactivated(IWorkbenchPart part) {
IContextService contextService = PlatformUI.getWorkbench().getService(IContextService.class);
if (contextService == null) {
return;
}
try {
contextService.deferUpdates(true);
if (activationNavigator != null && part instanceof INavigatorModelView) {
contextService.deactivateContext(activationNavigator);
activationNavigator = null;
}
if (activationSQL != null && part instanceof SQLEditorBase) {
contextService.deactivateContext(activationSQL);
activationSQL = null;
}
if (activationResults != null) {
contextService.deactivateContext(activationResults);
activationResults = null;
}
} finally {
contextService.deferUpdates(false);
}
// log.info(part.getClass().getSimpleName() + " DEACTIVATED: " + contextService.getActiveContextIds());
}
use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.
the class BaseSQLDialog method createSQLPanel.
protected Composite createSQLPanel(Composite parent) {
Composite panel = UIUtils.createPlaceholder(parent, 1);
panel.setLayoutData(new GridData(GridData.FILL_BOTH));
if (isLabelVisible()) {
UIUtils.createControlLabel(panel, "SQL Preview");
}
// new Label(panel, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
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 = new SQLEditorBase() {
@NotNull
@Override
public SQLDialect getSQLDialect() {
return BaseSQLDialog.this.getSQLDialect();
}
@Override
public DBCExecutionContext getExecutionContext() {
return BaseSQLDialog.this.getExecutionContext();
}
};
updateSQL();
sqlViewer.createPartControl(editorPH);
if (isWordWrap()) {
Object text = sqlViewer.getAdapter(Control.class);
if (text instanceof StyledText) {
((StyledText) text).setWordWrap(true);
}
}
sqlViewer.reloadSyntaxRules();
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
sqlViewer.dispose();
}
});
return panel;
}
use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.
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(CoreMessages.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());
final SQLEditorBase editor = new SQLEditorBase() {
@Nullable
@Override
public DBCExecutionContext getExecutionContext() {
return viewer.getExecutionContext();
}
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
getAction(ITextEditorActionConstants.CONTEXT_PREFERENCES).setEnabled(false);
}
@Override
public boolean isFoldingEnabled() {
return false;
}
};
editor.setHasVerticalRuler(false);
editor.init(new SubEditorSite(viewer.getSite()), new StringEditorInput(DEFAULT_QUERY_TEXT, getActiveQueryText(), true, GeneralUtils.getDefaultFileEncoding()));
editor.createPartControl(editorPH);
editor.reloadSyntaxRules();
StyledText textWidget = editor.getTextViewer().getTextWidget();
// textWidget.setAlwaysShowScrollBars(false);
panel.setBackground(textWidget.getBackground());
panel.addDisposeListener(e -> editor.dispose());
return textWidget;
}
use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.
the class SQLCompletionAnalyzer method createCompletionProposal.
/*
* Turns the vector into an Array of ICompletionProposal objects
*/
static SQLCompletionProposal createCompletionProposal(CompletionRequest request, String replaceString, String displayString, DBPKeywordType proposalType, @Nullable DBPImage image, boolean isObject, @Nullable DBPNamedObject object) {
SQLEditorBase editor = request.editor;
DBPPreferenceStore store = editor.getActivePreferenceStore();
DBPDataSource dataSource = editor.getDataSource();
if (dataSource != null) {
if (isObject) {
// Escape replace string if required
// FIXME: do not escape! it may (will) escape identifiers twice
// replaceString = DBUtils.getQuotedIdentifier(dataSource, replaceString);
}
}
// If we have quoted string then ignore pref settings
boolean quotedString = request.wordDetector.isQuoted(replaceString);
if (!quotedString) {
final int proposalCase = store.getInt(SQLPreferenceConstants.PROPOSAL_INSERT_CASE);
switch(proposalCase) {
case SQLPreferenceConstants.PROPOSAL_CASE_UPPER:
replaceString = replaceString.toUpperCase();
break;
case SQLPreferenceConstants.PROPOSAL_CASE_LOWER:
replaceString = replaceString.toLowerCase();
break;
default:
// Do not convert case if we got it directly from object
if (!isObject) {
SQLDialect dialect = editor.getSyntaxManager().getDialect();
DBPKeywordType keywordType = dialect.getKeywordType(replaceString);
if (keywordType == DBPKeywordType.KEYWORD) {
replaceString = editor.getSyntaxManager().getKeywordCase().transform(replaceString);
} else {
replaceString = dialect.storesUnquotedCase().transform(replaceString);
}
}
break;
}
}
Image img = image == null ? null : DBeaverIcons.getImage(image);
return new SQLCompletionProposal(request, displayString, // replacementString
replaceString, // cursorPosition the position of the cursor following the insert
replaceString.length(), // image to display
img, // new ContextInformation(img, displayString, displayString), //the context information associated with this proposal
null, proposalType, null, object);
}
Aggregations