Search in sources :

Example 1 with IValueController

use of org.jkiss.dbeaver.ui.data.IValueController in project dbeaver by serge-rider.

the class CursorViewDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    final IValueController valueController = getValueController();
    value = (DBDCursor) valueController.getValue();
    Composite dialogGroup = (Composite) super.createDialogArea(parent);
    if (value != null) {
        DBPPreferenceStore globalPreferenceStore = DBeaverCore.getGlobalPreferenceStore();
        if (!globalPreferenceStore.getBoolean(DBeaverPreferences.KEEP_STATEMENT_OPEN)) {
            if (ConfirmationDialog.showConfirmDialog(getShell(), DBeaverPreferences.CONFIRM_KEEP_STATEMENT_OPEN, ConfirmationDialog.QUESTION) == IDialogConstants.YES_ID) {
                globalPreferenceStore.setValue(DBeaverPreferences.KEEP_STATEMENT_OPEN, true);
                if (valueController.getValueSite().getPart() instanceof IResultSetContainer) {
                    IResultSetController rsv = ((IResultSetContainer) valueController.getValueSite().getPart()).getResultSetController();
                    if (rsv != null) {
                        rsv.refresh();
                    }
                }
            }
            DBeaverUI.asyncExec(new Runnable() {

                @Override
                public void run() {
                    close();
                }
            });
        }
    }
    resultSetViewer = new ResultSetViewer(dialogGroup, valueController.getValueSite(), this);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 300;
    gd.grabExcessVerticalSpace = true;
    resultSetViewer.getControl().setLayoutData(gd);
    resultSetViewer.refresh();
    return dialogGroup;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) IResultSetContainer(org.jkiss.dbeaver.ui.controls.resultset.IResultSetContainer) GridData(org.eclipse.swt.layout.GridData) IResultSetController(org.jkiss.dbeaver.ui.controls.resultset.IResultSetController) IValueController(org.jkiss.dbeaver.ui.data.IValueController) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) ResultSetViewer(org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer)

Example 2 with IValueController

use of org.jkiss.dbeaver.ui.data.IValueController in project dbeaver by serge-rider.

the class TextViewDialog method primeEditorValue.

@Override
public void primeEditorValue(@Nullable Object value) {
    if (value instanceof DBDContentCached) {
        value = ((DBDContentCached) value).getCachedValue();
    }
    if (value instanceof byte[]) {
        // Binary
        byte[] bytes = (byte[]) value;
        textEdit.setText(GeneralUtils.convertToString(bytes, 0, bytes.length));
        if (hexEditControl != null) {
            hexEditControl.setContent(bytes, getDefaultCharset());
        }
    } else {
        // Should be string
        final IValueController valueController = getValueController();
        final String strValue = valueController.getValueHandler().getValueDisplayString(valueController.getValueType(), value, DBDDisplayFormat.EDIT);
        textEdit.setText(strValue);
        if (hexEditControl != null) {
            setBinaryContent(strValue);
        }
    }
}
Also used : DBDContentCached(org.jkiss.dbeaver.model.data.DBDContentCached) IValueController(org.jkiss.dbeaver.ui.data.IValueController)

Example 3 with IValueController

use of org.jkiss.dbeaver.ui.data.IValueController in project dbeaver by serge-rider.

the class DateTimeStandaloneEditor method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    IValueController valueController = getValueController();
    Object value = valueController.getValue();
    Composite dialogGroup = (Composite) super.createDialogArea(parent);
    Composite panel = UIUtils.createPlaceholder(dialogGroup, 3);
    panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    int style = SWT.BORDER;
    if (valueController.isReadOnly()) {
        style |= SWT.READ_ONLY;
    }
    UIUtils.createControlLabel(panel, "Time").setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    timeEditor = new CustomTimeEditor(panel, style);
    timeEditor.getControl().addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            dirty = true;
        }
    });
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    timeEditor.getControl().setLayoutData(gd);
    primeEditorValue(value);
    Button button = UIUtils.createPushButton(panel, "Set Current", null);
    button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    button.setEnabled(!valueController.isReadOnly());
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            primeEditorValue(new Date());
        }
    });
    return dialogGroup;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) CustomTimeEditor(org.jkiss.dbeaver.ui.controls.CustomTimeEditor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Date(java.util.Date) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IValueController(org.jkiss.dbeaver.ui.data.IValueController)

Example 4 with IValueController

use of org.jkiss.dbeaver.ui.data.IValueController in project dbeaver by serge-rider.

the class ContentEditor method createPageContainer.

@Override
protected Composite createPageContainer(Composite parent) {
    Composite panel = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    panel.setLayout(layout);
    if (parent.getLayout() instanceof GridLayout) {
        panel.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
    {
        IValueController valueController = getValueController();
        assert valueController != null;
        infoPanel = new ColumnInfoPanel(panel, SWT.NONE, valueController);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.exclude = true;
        infoPanel.setLayoutData(gd);
        infoPanel.setVisible(false);
    }
    Composite editotPanel = new Composite(panel, SWT.NONE);
    layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    editotPanel.setLayout(layout);
    editotPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
    return editotPanel;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) ColumnInfoPanel(org.jkiss.dbeaver.ui.dialogs.ColumnInfoPanel) IValueController(org.jkiss.dbeaver.ui.data.IValueController)

Example 5 with IValueController

use of org.jkiss.dbeaver.ui.data.IValueController in project dbeaver by serge-rider.

the class ContentEditor method primeEditorValue.

@Override
public void primeEditorValue(@Nullable Object value) throws DBException {
    ContentEditorInput input = getEditorInput();
    IValueController valueController = input.getValueController();
    LOBInitializer initializer = new LOBInitializer(valueController, input.getEditors(), input.getDefaultEditor(), input);
    try {
        //valueController.getValueSite().getWorkbenchWindow().run(true, true, initializer);
        DBeaverUI.runInProgressService(initializer);
    } catch (InvocationTargetException e) {
        UIUtils.showErrorDialog(valueController.getValueSite().getShell(), "Cannot refresh content editor", null, e);
    } catch (InterruptedException e) {
    // ignore
    }
}
Also used : IValueController(org.jkiss.dbeaver.ui.data.IValueController) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

IValueController (org.jkiss.dbeaver.ui.data.IValueController)7 GridData (org.eclipse.swt.layout.GridData)3 Composite (org.eclipse.swt.widgets.Composite)3 Nullable (org.jkiss.code.Nullable)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Date (java.util.Date)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 DBDContent (org.jkiss.dbeaver.model.data.DBDContent)1 DBDContentCached (org.jkiss.dbeaver.model.data.DBDContentCached)1 DBPPreferenceStore (org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)1 CustomTimeEditor (org.jkiss.dbeaver.ui.controls.CustomTimeEditor)1 GridCell (org.jkiss.dbeaver.ui.controls.lightgrid.GridCell)1 IGridLabelProvider (org.jkiss.dbeaver.ui.controls.lightgrid.IGridLabelProvider)1 IResultSetContainer (org.jkiss.dbeaver.ui.controls.resultset.IResultSetContainer)1 IResultSetController (org.jkiss.dbeaver.ui.controls.resultset.IResultSetController)1