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);
}
Aggregations