use of org.eclipse.swt.widgets.Spinner in project pmd-eclipse-plugin by pmd.
the class MultiIntegerEditorFactory method setValue.
protected void setValue(Control widget, Integer valueIn) {
Spinner spinner = (Spinner) widget;
int value = valueIn == null ? spinner.getMinimum() : valueIn;
spinner.setSelection(value);
}
use of org.eclipse.swt.widgets.Spinner in project pmd-eclipse-plugin by pmd.
the class CPDCheckDialog method createTileSizeSpinner.
private void createTileSizeSpinner(Composite container) {
final GridData gridData5 = new GridData();
gridData5.horizontalAlignment = GridData.FILL;
gridData5.grabExcessHorizontalSpace = true;
gridData5.horizontalIndent = 10;
gridData5.heightHint = -1;
gridData5.verticalAlignment = GridData.CENTER;
minTileSizeSpinner = new Spinner(container, SWT.BORDER);
minTileSizeSpinner.setLayoutData(gridData5);
minTileSizeSpinner.setToolTipText(getString(StringKeys.DIALOG_TOOLTIP_CPD_MIN_TILESIZE));
minTileSizeSpinner.setMinimum(tileSize);
minTileSizeSpinner.setTextLimit(3);
minTileSizeSpinner.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
tileSize = Integer.parseInt(minTileSizeSpinner.getText());
}
});
}
use of org.eclipse.swt.widgets.Spinner in project dbeaver by serge-rider.
the class MySQLUserEditorGeneral method createPartControl.
@Override
public void createPartControl(Composite parent) {
pageControl = new PageControl(parent);
Composite container = UIUtils.createPlaceholder(pageControl, 2, 5);
GridData gd = new GridData(GridData.FILL_VERTICAL);
container.setLayoutData(gd);
newUser = !getDatabaseObject().isPersisted();
{
Composite loginGroup = UIUtils.createControlGroup(container, MySQLUIMessages.editors_user_editor_general_group_login, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 200);
userNameText = UIUtils.createLabelText(loginGroup, MySQLUIMessages.editors_user_editor_general_label_user_name, getDatabaseObject().getUserName());
userNameText.setEditable(newUser);
if (newUser) {
ControlPropertyCommandListener.create(this, userNameText, UserPropertyHandler.NAME);
}
hostText = UIUtils.createLabelText(loginGroup, MySQLUIMessages.editors_user_editor_general_label_host, getDatabaseObject().getHost());
hostText.setEditable(newUser);
if (newUser) {
ControlPropertyCommandListener.create(this, hostText, UserPropertyHandler.HOST);
}
// $NON-NLS-1$
String password = newUser ? "" : DEF_PASSWORD_VALUE;
Text passwordText = UIUtils.createLabelText(loginGroup, MySQLUIMessages.editors_user_editor_general_label_password, password, SWT.BORDER | SWT.PASSWORD);
ControlPropertyCommandListener.create(this, passwordText, UserPropertyHandler.PASSWORD);
Text confirmText = UIUtils.createLabelText(loginGroup, MySQLUIMessages.editors_user_editor_general_label_confirm, password, SWT.BORDER | SWT.PASSWORD);
ControlPropertyCommandListener.create(this, confirmText, UserPropertyHandler.PASSWORD_CONFIRM);
}
{
Composite limitsGroup = UIUtils.createControlGroup(container, MySQLUIMessages.editors_user_editor_general_group_limits, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
Spinner maxQueriesText = UIUtils.createLabelSpinner(limitsGroup, MySQLUIMessages.editors_user_editor_general_spinner_max_queries, getDatabaseObject().getMaxQuestions(), 0, Integer.MAX_VALUE);
ControlPropertyCommandListener.create(this, maxQueriesText, UserPropertyHandler.MAX_QUERIES);
Spinner maxUpdatesText = UIUtils.createLabelSpinner(limitsGroup, MySQLUIMessages.editors_user_editor_general_spinner_max_updates, getDatabaseObject().getMaxUpdates(), 0, Integer.MAX_VALUE);
ControlPropertyCommandListener.create(this, maxUpdatesText, UserPropertyHandler.MAX_UPDATES);
Spinner maxConnectionsText = UIUtils.createLabelSpinner(limitsGroup, MySQLUIMessages.editors_user_editor_general_spinner_max_connections, getDatabaseObject().getMaxConnections(), 0, Integer.MAX_VALUE);
ControlPropertyCommandListener.create(this, maxConnectionsText, UserPropertyHandler.MAX_CONNECTIONS);
Spinner maxUserConnectionsText = UIUtils.createLabelSpinner(limitsGroup, MySQLUIMessages.editors_user_editor_general_spinner_max_user_connections, getDatabaseObject().getMaxUserConnections(), 0, Integer.MAX_VALUE);
ControlPropertyCommandListener.create(this, maxUserConnectionsText, UserPropertyHandler.MAX_USER_CONNECTIONS);
}
{
privTable = new PrivilegeTableControl(container, MySQLUIMessages.editors_user_editor_general_control_dba_privileges, true);
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
privTable.setLayoutData(gd);
privTable.addListener(SWT.Modify, event -> {
final MySQLPrivilege privilege = (MySQLPrivilege) event.data;
final boolean grant = event.detail == 1;
addChangeCommand(new MySQLCommandGrantPrivilege(getDatabaseObject(), grant, null, null, privilege), new DBECommandReflector<MySQLUser, MySQLCommandGrantPrivilege>() {
@Override
public void redoCommand(MySQLCommandGrantPrivilege mySQLCommandGrantPrivilege) {
if (!privTable.isDisposed()) {
privTable.checkPrivilege(privilege, grant);
}
}
@Override
public void undoCommand(MySQLCommandGrantPrivilege mySQLCommandGrantPrivilege) {
if (!privTable.isDisposed()) {
privTable.checkPrivilege(privilege, !grant);
}
}
});
});
}
pageControl.createProgressPanel();
commandlistener = new CommandListener();
getEditorInput().getCommandContext().addCommandListener(commandlistener);
}
use of org.eclipse.swt.widgets.Spinner in project cogtool by cogtool.
the class SNIFACTDialog method addMoreFields.
@Override
protected void addMoreFields() {
super.addMoreFields();
responseBox.setEditable(false);
Label lbl = new Label(dialog, SWT.NONE);
lbl.setText(L10N.get("PM.NumTrials", "Number of Trials") + ": ");
GridData lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_END);
lbl.setLayoutData(lblLayout);
numRunsSpinner = new Spinner(dialog, SWT.NONE);
numRunsSpinner.setMinimum(1);
numRunsSpinner.setMaximum(1000);
numRunsSpinner.setSelection(defaultParameters.numRuns);
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
lblLayout.grabExcessHorizontalSpace = true;
lblLayout.horizontalSpan = 3;
numRunsSpinner.setLayoutData(lblLayout);
lbl = new Label(dialog, SWT.NONE);
lbl.setText(L10N.get("PM.KValue", "Eagerness to satisfy (smaller is more eager)") + ": ");
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
lbl.setLayoutData(lblLayout);
kValueSpinner = new Spinner(dialog, SWT.NONE);
kValueSpinner.setMinimum(1);
kValueSpinner.setMaximum(999);
kValueSpinner.setSelection(defaultParameters.kValue);
kValueSpinner.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (addGroupMode == ENABLED) {
boolean equal = kValueSpinner.getSelection() == defaultParameters.kValue;
addToGroup.setEnabled(equal);
if (!equal) {
addToGroup.setSelection(false);
}
}
}
});
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
lblLayout.grabExcessHorizontalSpace = true;
lblLayout.horizontalSpan = 3;
kValueSpinner.setLayoutData(lblLayout);
lbl = new Label(dialog, SWT.NONE);
lbl.setText(L10N.get("PM.StartFrame", "Start Frame") + ": ");
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_END);
lbl.setLayoutData(lblLayout);
startFrameCombo = new ComboWithEnableFix(dialog, SWT.DROP_DOWN | SWT.READ_ONLY);
startFrameCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (addGroupMode == ENABLED) {
int selIndex = startFrameCombo.getSelectionIndex();
String frameName = startFrameCombo.getItem(selIndex);
String defaultName = defaultParameters.startFrame;
boolean equal = frameName.equals(defaultName);
addToGroup.setEnabled(equal);
if (!equal) {
addToGroup.setSelection(false);
}
}
}
});
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
lblLayout.grabExcessHorizontalSpace = true;
lblLayout.horizontalSpan = 3;
startFrameCombo.setLayoutData(lblLayout);
lbl = new Label(dialog, SWT.NONE);
lbl.setText(L10N.get("PM.TargetFrames", "Target Frames") + ": ");
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_END);
lbl.setLayoutData(lblLayout);
targetFrameList = new org.eclipse.swt.widgets.List(dialog, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
targetFrameList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
okButton.setEnabled(targetFrameList.getSelectionCount() > 0);
if (addGroupMode == ENABLED) {
// Need to test whether the list of selected frame names
// is identical (except for order) to the list of frame
// names specified in defaultParameters.targetFrames, so
// check if they are the same size and then test whether
// any names in one list don't appear in the other
String[] targets = targetFrameList.getSelection();
java.util.List<String> defaultTargets = defaultParameters.targetFrames;
boolean equal = targets.length == defaultTargets.size();
if (equal) {
for (int i = 0; i < targets.length; i++) {
String curDefault = defaultTargets.get(i);
if (!(curDefault.equals(targets[i]))) {
equal = false;
}
}
}
addToGroup.setEnabled(equal);
if (!equal) {
addToGroup.setSelection(false);
}
}
}
});
for (int i = 0; i < sortedFrames.size(); i++) {
String name = sortedFrames.get(i).getName();
String display = SWTStringUtil.insertEllipsis(name, WIDTH, StringUtil.NO_FRONT, SWTStringUtil.DEFAULT_FONT);
startFrameCombo.add(display);
targetFrameList.add(display);
if (name.equals(defaultParameters.startFrame)) {
startFrameCombo.select(i);
}
if (defaultParameters.targetFrames.contains(name)) {
targetFrameList.select(i);
}
}
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
lblLayout.grabExcessHorizontalSpace = true;
lblLayout.horizontalSpan = 3;
lblLayout.heightHint = 100;
targetFrameList.setLayoutData(lblLayout);
if (algorithmSet.size() > 1) {
lbl = new Label(dialog, SWT.NONE);
lbl.setText(L10N.get("PM.Algorithm", "Algorithm") + ": ");
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_END);
lbl.setLayoutData(lblLayout);
algCombo = new ComboWithEnableFix(dialog, SWT.DROP_DOWN | SWT.READ_ONLY);
algCombo.add(L10N.get("PM.All", "All"));
int i = 0;
algArray[i++] = null;
int selectIndex = 0;
Iterator<ITermSimilarity> algs = algorithmSet.iterator();
while (algs.hasNext()) {
ITermSimilarity alg = algs.next();
algArray[i] = alg;
algCombo.add(DictionaryEditorUIModel.getAlgLabel(alg));
if (alg.getClass().isInstance(defaultParameters.algorithm)) {
selectIndex = i;
}
i++;
}
algCombo.select(selectIndex);
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
lblLayout.grabExcessHorizontalSpace = true;
lblLayout.horizontalSpan = 3;
algCombo.setLayoutData(lblLayout);
}
numRunsSpinner.forceFocus();
if (addGroupMode != NONE) {
addToGroup = new Button(dialog, SWT.CHECK);
addToGroup.setText(L10N.get("PM.AddToGroup", "Add scripts to existing task group"));
addToGroup.setEnabled(true);
addToGroup.setSelection(true);
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
lblLayout.grabExcessHorizontalSpace = true;
lblLayout.horizontalSpan = 3;
addToGroup.setLayoutData(lblLayout);
}
exportOnly = new Button(dialog, SWT.CHECK);
exportOnly.setText(L10N.get("PM.ExportOnly", "Only export model, do not run it"));
exportOnly.setEnabled(true);
exportOnly.setSelection(false);
lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
lblLayout.grabExcessHorizontalSpace = true;
lblLayout.horizontalSpan = 3;
exportOnly.setLayoutData(lblLayout);
}
use of org.eclipse.swt.widgets.Spinner in project translationstudio8 by heartsome.
the class SystemPreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
isInit = true;
Composite tparent = new Composite(parent, SWT.NONE);
tparent.setLayout(new GridLayout());
tparent.setLayoutData(new GridData(GridData.FILL_BOTH));
Group groupCommon = new Group(tparent, SWT.NONE);
groupCommon.setLayout(new GridLayout());
groupCommon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
groupCommon.setText(Messages.getString("preferencepage.SystemPreferencePage.groupCommon"));
HsImageLabel imageLabel1 = new HsImageLabel(Messages.getString("preferencepage.SystemPreferencePage.imageLabel1"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_UPDATE));
Composite cmpCommon = imageLabel1.createControl(groupCommon);
cmpCommon.setLayout(new GridLayout());
cmpCommon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnCheckUpdateWithStartup = new Button(cmpCommon, SWT.RADIO);
btnCheckUpdateWithStartup.setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithStartup"));
GridDataFactory.fillDefaults().applyTo(btnCheckUpdateWithStartup);
btnCheckUpdateWithStartup.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (btnCheckUpdateWithStartup.getSelection()) {
btnCheckUpdateWithMonthly.setSelection(false);
btnCheckUpdateWithWeekly.setSelection(false);
btnCheckUpdateWithNever.setSelection(false);
selectDateSpi.setEnabled(false);
cmbSelectWeek.setEnabled(false);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
cmpMonthly = new Composite(cmpCommon, SWT.None);
GridLayoutFactory.swtDefaults().numColumns(3).equalWidth(false).margins(0, 0).spacing(0, 0).applyTo(cmpMonthly);
cmpMonthly.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnCheckUpdateWithMonthly = new Button(cmpMonthly, SWT.RADIO);
btnCheckUpdateWithMonthly.setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithMonthly1"));
GridData spinnaData = new GridData();
spinnaData.widthHint = 20;
selectDateSpi = new Spinner(cmpMonthly, SWT.BORDER);
selectDateSpi.setMinimum(1);
selectDateSpi.setMaximum(31);
selectDateSpi.setTextLimit(2);
selectDateSpi.setEnabled(false);
selectDateSpi.setLayoutData(spinnaData);
selectDateSpi.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String text = selectDateSpi.getText();
if (text != null && !text.trim().equals("")) {
if (Integer.parseInt(text.trim()) > 31) {
selectDateSpi.setSelection(31);
} else if (Integer.parseInt(text.trim()) < 1) {
selectDateSpi.setSelection(1);
}
}
}
});
new Label(cmpMonthly, SWT.None).setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithMonthly2"));
btnCheckUpdateWithMonthly.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
selectDateSpi.setEnabled(btnCheckUpdateWithMonthly.getSelection());
if (btnCheckUpdateWithMonthly.getSelection()) {
btnCheckUpdateWithStartup.setSelection(false);
btnCheckUpdateWithWeekly.setSelection(false);
btnCheckUpdateWithNever.setSelection(false);
cmbSelectWeek.setEnabled(false);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
cmpWeekly = new Composite(cmpCommon, SWT.None);
GridLayoutFactory.swtDefaults().numColumns(3).equalWidth(false).margins(0, 0).spacing(0, 0).applyTo(cmpWeekly);
cmpWeekly.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnCheckUpdateWithWeekly = new Button(cmpWeekly, SWT.RADIO);
btnCheckUpdateWithWeekly.setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithWeekly1"));
cmbSelectWeek = new Combo(cmpWeekly, SWT.READ_ONLY);
cmbSelectWeek.setItems(arrWeek);
cmbSelectWeek.setEnabled(false);
cmbSelectWeek.select(0);
GridDataFactory.swtDefaults().applyTo(cmbSelectWeek);
new Label(cmpWeekly, SWT.NONE).setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithWeekly2"));
btnCheckUpdateWithWeekly.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
cmbSelectWeek.setEnabled(btnCheckUpdateWithWeekly.getSelection());
if (btnCheckUpdateWithWeekly.getSelection()) {
btnCheckUpdateWithStartup.setSelection(false);
btnCheckUpdateWithMonthly.setSelection(false);
btnCheckUpdateWithNever.setSelection(false);
selectDateSpi.setEnabled(false);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
btnCheckUpdateWithNever = new Button(cmpCommon, SWT.RADIO);
btnCheckUpdateWithNever.setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithNever"));
btnCheckUpdateWithNever.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridDataFactory.fillDefaults().applyTo(btnCheckUpdateWithNever);
btnCheckUpdateWithNever.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (btnCheckUpdateWithNever.getSelection()) {
btnCheckUpdateWithMonthly.setSelection(false);
btnCheckUpdateWithWeekly.setSelection(false);
btnCheckUpdateWithStartup.setSelection(false);
selectDateSpi.setEnabled(false);
cmbSelectWeek.setEnabled(false);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
Group groupLanguage = new Group(tparent, SWT.NONE);
groupLanguage.setLayout(new GridLayout());
groupLanguage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
groupLanguage.setText(Messages.getString("preferencepage.SystemPreferencePage.groupLanguage"));
HsImageLabel imageLabel2 = new HsImageLabel(Messages.getString("preferencepage.SystemPreferencePage.imageLabel3"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_LANGUAGE));
Composite cmpLang = imageLabel2.createControl(groupLanguage);
cmpLang.setLayout(new GridLayout());
cmpLang.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnLanguageWithEN = new Button(cmpLang, SWT.RADIO);
btnLanguageWithEN.setText(Messages.getString("preferencepage.SystemPreferencePage.btnLanguageWithEN"));
btnLanguageWithEN.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnLanguageWithZHCN = new Button(cmpLang, SWT.RADIO);
btnLanguageWithZHCN.setText(Messages.getString("preferencepage.SystemPreferencePage.btnLanguageWithZHCN"));
btnLanguageWithZHCN.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Group groupFont = new Group(tparent, SWT.NONE);
groupFont.setLayout(new GridLayout());
groupFont.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
groupFont.setText(Messages.getString("preferencepage.SystemPreferencePage.groupFont"));
HsImageLabel imageLabel4 = new HsImageLabel(Messages.getString("preferencepage.SystemPreferencePage.groupFont.desc"), Activator.getImageDescriptor("images/preference/system/font.png"));
Composite cmpFont = imageLabel4.createControl(groupFont);
GridLayout cmpFontGl = new GridLayout(2, true);
cmpFontGl.marginLeft = 0;
cmpFontGl.marginRight = 0;
cmpFontGl.marginTop = 0;
cmpFontGl.marginBottom = 0;
cmpFontGl.marginWidth = 0;
cmpFontGl.marginHeight = 0;
cmpFont.setLayout(cmpFontGl);
GridData cmpFontGd = new GridData(SWT.FILL, SWT.FILL, true, true);
cmpFont.setLayoutData(cmpFontGd);
editorFontSetting = new HSFontSettingComposite(cmpFont, SWT.NONE, Messages.getString("preferencepage.fontsetting.editor.title"));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
editorFontSetting.setLayoutData(gd);
matchViewFontSetting = new HSFontSettingComposite(cmpFont, SWT.NONE, Messages.getString("preferencepage.fontsetting.matchView.title"));
matchViewFontSetting.setLayoutData(gd);
Group groupSystemUser = new Group(tparent, SWT.NONE);
groupSystemUser.setLayout(new GridLayout());
groupSystemUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
groupSystemUser.setText(Messages.getString("preferencepage.SystemPreferencePage.groupSystemUser"));
HsImageLabel imageLabel3 = new HsImageLabel(Messages.getString("preferencepage.SystemPreferencePage.imageLabel4"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_USER));
Composite cmpUser = imageLabel3.createControl(groupSystemUser);
cmpUser.setLayout(new GridLayout(2, false));
cmpUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(cmpUser, SWT.NONE).setText(Messages.getString("preferencepage.SystemPreferencePage.lblUser"));
txtSystemUser = new Text(cmpUser, SWT.BORDER);
txtSystemUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
imageLabel1.computeSize();
imageLabel2.computeSize();
imageLabel3.computeSize();
imageLabel4.computeSize();
setInitValues(false);
return parent;
}
Aggregations