Search in sources :

Example 1 with StickResTabAction

use of org.hibernate.eclipse.console.actions.StickResTabAction in project jbosstools-hibernate by jbosstools.

the class AbstractQueryEditor method createToolbar.

protected final void createToolbar(Composite parent) {
    ToolBar bar = new ToolBar(parent, SWT.HORIZONTAL);
    bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tbm = new ToolBarManager(bar);
    execAction = new ExecuteQueryAction(this);
    clearAction = new ClearAction(this);
    stickResTabAction = new StickResTabAction(this);
    ActionContributionItem item = new ActionContributionItem(execAction);
    tbm.add(item);
    item = new ActionContributionItem(clearAction);
    tbm.add(item);
    // $NON-NLS-1$
    ControlContribution cc = new ConfigurationCombo("hql-target", this);
    tbm.add(cc);
    tbm.add(new Separator());
    cc = new // $NON-NLS-1$
    ComboContribution(// $NON-NLS-1$
    "maxResults") {

        SelectionAdapter selectionAdapter = new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                Integer maxResults = null;
                try {
                    maxResults = new Integer(getText());
                } catch (NumberFormatException e1) {
                    maxResults = null;
                }
                getQueryInputModel().setMaxResults(maxResults);
            }
        };

        protected Control createControl(Composite parent) {
            Control control = super.createControl(parent);
            comboControl.addModifyListener(new ModifyListener() {

                public void modifyText(ModifyEvent e) {
                    Integer maxResults = null;
                    try {
                        maxResults = new Integer(getText());
                    } catch (NumberFormatException e1) {
                        maxResults = null;
                    }
                    getQueryInputModel().setMaxResults(maxResults);
                }
            });
            return control;
        }

        protected int getComboWidth() {
            return 75;
        }

        protected String getLabelText() {
            return HibernateConsoleMessages.AbstractQueryEditor_max_results;
        }

        protected boolean isReadOnly() {
            return false;
        }

        protected SelectionListener getSelectionAdapter() {
            return selectionAdapter;
        }

        void populateComboBox() {
            comboControl.getDisplay().syncExec(new Runnable() {

                public void run() {
                    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                    String[] items = new String[] { "", "10", "20", "30", "50" };
                    comboControl.setItems(items);
                }
            });
        }
    };
    tbm.add(cc);
    tbm.add(new Separator());
    item = new ActionContributionItem(stickResTabAction);
    tbm.add(item);
    tbm.update(true);
}
Also used : ClearAction(org.hibernate.eclipse.console.actions.ClearAction) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ControlContribution(org.eclipse.jface.action.ControlContribution) ExecuteQueryAction(org.hibernate.eclipse.console.actions.ExecuteQueryAction) ToolBarManager(org.eclipse.jface.action.ToolBarManager) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) Control(org.eclipse.swt.widgets.Control) ModifyEvent(org.eclipse.swt.events.ModifyEvent) StickResTabAction(org.hibernate.eclipse.console.actions.StickResTabAction) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Separator(org.eclipse.jface.action.Separator) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)1 ControlContribution (org.eclipse.jface.action.ControlContribution)1 Separator (org.eclipse.jface.action.Separator)1 ToolBarManager (org.eclipse.jface.action.ToolBarManager)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 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 ToolBar (org.eclipse.swt.widgets.ToolBar)1 ClearAction (org.hibernate.eclipse.console.actions.ClearAction)1 ExecuteQueryAction (org.hibernate.eclipse.console.actions.ExecuteQueryAction)1 StickResTabAction (org.hibernate.eclipse.console.actions.StickResTabAction)1