Search in sources :

Example 1 with DB2DDLFormat

use of org.jkiss.dbeaver.ext.db2.editors.DB2DDLFormat in project dbeaver by dbeaver.

the class DB2RoutineDDLEditor method contributeEditorCommands.

@Override
protected void contributeEditorCommands(IContributionManager contributionManager) {
    super.contributeEditorCommands(contributionManager);
    contributionManager.add(new Separator());
    contributionManager.add(new ControlContribution("DDLFormat") {

        @Override
        protected Control createControl(Composite parent) {
            DB2DDLFormat ddlFormat = DB2DDLFormat.getCurrentFormat(getSourceObject().getDataSource());
            final Combo ddlFormatCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
            ddlFormatCombo.setToolTipText("DDL Format");
            for (DB2DDLFormat format : DB2DDLFormat.values()) {
                ddlFormatCombo.add(format.getTitle());
                if (format == ddlFormat) {
                    ddlFormatCombo.select(ddlFormatCombo.getItemCount() - 1);
                }
            }
            ddlFormatCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    for (DB2DDLFormat format : DB2DDLFormat.values()) {
                        if (format.ordinal() == ddlFormatCombo.getSelectionIndex()) {
                            getSourceObject().getDataSource().getContainer().getPreferenceStore().setValue(DB2Constants.PREF_KEY_DDL_FORMAT, format.name());
                            refreshPart(this, true);
                            break;
                        }
                    }
                }
            });
            return ddlFormatCombo;
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) DB2DDLFormat(org.jkiss.dbeaver.ext.db2.editors.DB2DDLFormat) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlContribution(org.eclipse.jface.action.ControlContribution) Combo(org.eclipse.swt.widgets.Combo) Separator(org.eclipse.jface.action.Separator)

Example 2 with DB2DDLFormat

use of org.jkiss.dbeaver.ext.db2.editors.DB2DDLFormat in project dbeaver by serge-rider.

the class DB2RoutineDDLEditor method contributeEditorCommands.

@Override
protected void contributeEditorCommands(IContributionManager contributionManager) {
    super.contributeEditorCommands(contributionManager);
    contributionManager.add(new Separator());
    contributionManager.add(new ControlContribution("DDLFormat") {

        @Override
        protected Control createControl(Composite parent) {
            DB2DDLFormat ddlFormat = DB2DDLFormat.getCurrentFormat(getSourceObject().getDataSource());
            final Combo ddlFormatCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
            ddlFormatCombo.setToolTipText("DDL Format");
            for (DB2DDLFormat format : DB2DDLFormat.values()) {
                ddlFormatCombo.add(format.getTitle());
                if (format == ddlFormat) {
                    ddlFormatCombo.select(ddlFormatCombo.getItemCount() - 1);
                }
            }
            ddlFormatCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    for (DB2DDLFormat format : DB2DDLFormat.values()) {
                        if (format.ordinal() == ddlFormatCombo.getSelectionIndex()) {
                            getSourceObject().getDataSource().getContainer().getPreferenceStore().setValue(DB2Constants.PREF_KEY_DDL_FORMAT, format.name());
                            refreshPart(this, true);
                            break;
                        }
                    }
                }
            });
            return ddlFormatCombo;
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) DB2DDLFormat(org.jkiss.dbeaver.ext.db2.editors.DB2DDLFormat) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlContribution(org.eclipse.jface.action.ControlContribution) Combo(org.eclipse.swt.widgets.Combo) Separator(org.eclipse.jface.action.Separator)

Aggregations

ControlContribution (org.eclipse.jface.action.ControlContribution)2 Separator (org.eclipse.jface.action.Separator)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Combo (org.eclipse.swt.widgets.Combo)2 Composite (org.eclipse.swt.widgets.Composite)2 Control (org.eclipse.swt.widgets.Control)2 DB2DDLFormat (org.jkiss.dbeaver.ext.db2.editors.DB2DDLFormat)2