Search in sources :

Example 1 with CustomTimeEditor

use of org.jkiss.dbeaver.ui.controls.CustomTimeEditor 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 2 with CustomTimeEditor

use of org.jkiss.dbeaver.ui.controls.CustomTimeEditor in project dbeaver by serge-rider.

the class DateTimeInlineEditor method createControl.

@Override
protected Control createControl(Composite editPlaceholder) {
    boolean inline = valueController.getEditType() == IValueController.EditType.INLINE;
    timeEditor = new CustomTimeEditor(valueController.getEditPlaceholder(), (inline ? SWT.BORDER : SWT.MULTI));
    timeEditor.setEnabled(!valueController.isReadOnly());
    return timeEditor.getControl();
}
Also used : CustomTimeEditor(org.jkiss.dbeaver.ui.controls.CustomTimeEditor)

Aggregations

CustomTimeEditor (org.jkiss.dbeaver.ui.controls.CustomTimeEditor)2 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 GridData (org.eclipse.swt.layout.GridData)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 IValueController (org.jkiss.dbeaver.ui.data.IValueController)1