Search in sources :

Example 1 with StatusPart

use of org.eclipse.ui.internal.part.StatusPart in project dbeaver by serge-rider.

the class ErrorPresentation method createPresentation.

@Override
public void createPresentation(@NotNull IResultSetController controller, @NotNull Composite parent) {
    super.createPresentation(controller, parent);
    CustomSashForm partDivider = UIUtils.createPartDivider(controller.getSite().getPart(), parent, SWT.HORIZONTAL);
    partDivider.setLayoutData(new GridData(GridData.FILL_BOTH));
    errorComposite = UIUtils.createComposite(partDivider, 1);
    errorComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    statusPart = new StatusPart(errorComposite, status);
    for (Control child : errorComposite.getChildren()) {
        if (child instanceof Text) {
            TextEditorUtils.enableHostEditorKeyBindingsSupport(controller.getSite(), child);
        }
    }
    sqlPanel = UIUtils.createComposite(partDivider, 1);
    sqlPanel.setLayout(new FillLayout());
    UIServiceSQL serviceSQL = DBWorkbench.getService(UIServiceSQL.class);
    try {
        editorPanel = serviceSQL.createSQLPanel(controller.getSite(), sqlPanel, controller, "SQL", true, sqlText);
        if (editorPanel instanceof TextViewer) {
            textWidget = ((TextViewer) editorPanel).getTextWidget();
        }
    } catch (DBException e) {
        textWidget = new StyledText(sqlPanel, SWT.BORDER | SWT.READ_ONLY);
        textWidget.setText(sqlText);
    }
    try {
        boolean widthSet = false;
        IDialogSettings viewSettings = ResultSetUtils.getViewerSettings(SETTINGS_SECTION_ERROR_PANEL);
        String errorWidth = viewSettings.get(PROP_ERROR_WIDTH);
        if (errorWidth != null) {
            String[] widthStrs = errorWidth.split(":");
            if (widthStrs.length == 2) {
                partDivider.setWeights(new int[] { Integer.parseInt(widthStrs[0]), Integer.parseInt(widthStrs[1]) });
            }
            widthSet = true;
        }
        if (!widthSet) {
            partDivider.setWeights(new int[] { 700, 300 });
        }
        partDivider.addCustomSashFormListener((firstControlWeight, secondControlWeight) -> {
            int[] weights = partDivider.getWeights();
            viewSettings.put(PROP_ERROR_WIDTH, weights[0] + ":" + weights[1]);
        });
    } catch (Throwable e) {
        log.debug(e);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) StyledText(org.eclipse.swt.custom.StyledText) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) TextViewer(org.eclipse.jface.text.TextViewer) Control(org.eclipse.swt.widgets.Control) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData) UIServiceSQL(org.jkiss.dbeaver.runtime.ui.UIServiceSQL) StatusPart(org.eclipse.ui.internal.part.StatusPart)

Example 2 with StatusPart

use of org.eclipse.ui.internal.part.StatusPart in project dbeaver by dbeaver.

the class ErrorPresentation method createPresentation.

@Override
public void createPresentation(@NotNull IResultSetController controller, @NotNull Composite parent) {
    super.createPresentation(controller, parent);
    CustomSashForm partDivider = UIUtils.createPartDivider(controller.getSite().getPart(), parent, SWT.HORIZONTAL);
    partDivider.setLayoutData(new GridData(GridData.FILL_BOTH));
    errorComposite = UIUtils.createComposite(partDivider, 1);
    errorComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    statusPart = new StatusPart(errorComposite, status);
    for (Control child : errorComposite.getChildren()) {
        if (child instanceof Text) {
            TextEditorUtils.enableHostEditorKeyBindingsSupport(controller.getSite(), child);
        }
    }
    sqlPanel = UIUtils.createComposite(partDivider, 1);
    sqlPanel.setLayout(new FillLayout());
    UIServiceSQL serviceSQL = DBWorkbench.getService(UIServiceSQL.class);
    try {
        editorPanel = serviceSQL.createSQLPanel(controller.getSite(), sqlPanel, controller, "SQL", true, sqlText);
        if (editorPanel instanceof TextViewer) {
            textWidget = ((TextViewer) editorPanel).getTextWidget();
        }
    } catch (DBException e) {
        textWidget = new StyledText(sqlPanel, SWT.BORDER | SWT.READ_ONLY);
        textWidget.setText(sqlText);
    }
    try {
        boolean widthSet = false;
        IDialogSettings viewSettings = ResultSetUtils.getViewerSettings(SETTINGS_SECTION_ERROR_PANEL);
        String errorWidth = viewSettings.get(PROP_ERROR_WIDTH);
        if (errorWidth != null) {
            String[] widthStrs = errorWidth.split(":");
            if (widthStrs.length == 2) {
                partDivider.setWeights(new int[] { Integer.parseInt(widthStrs[0]), Integer.parseInt(widthStrs[1]) });
            }
            widthSet = true;
        }
        if (!widthSet) {
            partDivider.setWeights(new int[] { 700, 300 });
        }
        partDivider.addCustomSashFormListener((firstControlWeight, secondControlWeight) -> {
            int[] weights = partDivider.getWeights();
            viewSettings.put(PROP_ERROR_WIDTH, weights[0] + ":" + weights[1]);
        });
    } catch (Throwable e) {
        log.debug(e);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) StyledText(org.eclipse.swt.custom.StyledText) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) TextViewer(org.eclipse.jface.text.TextViewer) Control(org.eclipse.swt.widgets.Control) CustomSashForm(org.jkiss.dbeaver.ui.controls.CustomSashForm) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData) UIServiceSQL(org.jkiss.dbeaver.runtime.ui.UIServiceSQL) StatusPart(org.eclipse.ui.internal.part.StatusPart)

Aggregations

IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 TextViewer (org.eclipse.jface.text.TextViewer)2 StyledText (org.eclipse.swt.custom.StyledText)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 GridData (org.eclipse.swt.layout.GridData)2 Control (org.eclipse.swt.widgets.Control)2 Text (org.eclipse.swt.widgets.Text)2 StatusPart (org.eclipse.ui.internal.part.StatusPart)2 DBException (org.jkiss.dbeaver.DBException)2 UIServiceSQL (org.jkiss.dbeaver.runtime.ui.UIServiceSQL)2 CustomSashForm (org.jkiss.dbeaver.ui.controls.CustomSashForm)2