use of org.eclipse.swt.widgets.Spinner in project translationstudio8 by heartsome.
the class IntegerCellEditor method createControl.
/**
* Create the control.
*
* @param table parent table
*/
private void createControl(JaretTable table) {
if (_spinner == null) {
_table = table;
_spinner = new Spinner(table, SWT.BORDER);
_spinner.setMaximum(_max);
_spinner.setMinimum(_min);
_spinner.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
e.doit = false;
}
});
_spinner.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent event) {
if (event.keyCode == SWT.TAB) {
event.doit = false;
stopEditing(true);
_table.forceFocus();
_table.focusRight();
} else if (event.keyCode == SWT.CR) {
event.doit = false;
stopEditing(true);
_table.forceFocus();
_table.focusDown();
} else if (event.keyCode == SWT.ESC) {
event.doit = false;
stopEditing(false);
_column.setValue(_row, _oldVal);
_table.forceFocus();
}
}
public void keyReleased(KeyEvent arg0) {
}
});
_spinner.addFocusListener(this);
}
}
use of org.eclipse.swt.widgets.Spinner in project translationstudio8 by heartsome.
the class EquivalentPage method createMatchEqui.
/**
* 创建加权系统设置区间
*/
public void createMatchEqui(String equivalStr) {
boolean isDelete = false;
String[] equivalArray = equivalStr.split(";");
for (int i = 0; i < equivalArray.length; i++) {
String equival = equivalArray[i];
String matchStr = equival.substring(0, equival.indexOf(":"));
String equiValue = equival.substring(equival.indexOf(":") + 1, equival.length());
// 先处理所有重复加权系数
if (QAConstant._InternalRepeat.equals(matchStr)) {
Composite interRepeatCmp = (Composite) repeatCmp.getChildren()[0];
Text text = (Text) interRepeatCmp.getChildren()[2];
text.setText(equiValue);
} else if (QAConstant._External101.equals(matchStr)) {
if (isUltimate) {
Composite exter101Cmp = (Composite) repeatCmp.getChildren()[1];
Text text = (Text) exter101Cmp.getChildren()[2];
text.setText(equiValue);
}
} else if (QAConstant._External100.equals(matchStr)) {
Composite exter100Cmp = (Composite) repeatCmp.getChildren()[2 - (isUltimate ? 0 : 1)];
Text text = (Text) exter100Cmp.getChildren()[2];
text.setText(equiValue);
} else {
int minMacth = Integer.parseInt(equival.substring(0, equival.indexOf("-")));
int maxMatch = Integer.parseInt(equival.substring(equival.indexOf("-") + 1, equival.indexOf(":")));
if (maxMatch == 99) {
// 如果最大匹配率是99,那么就是模糊匹配的第一个设置
Composite macthCmp = (Composite) matchParent.getChildren()[0];
Control[] ctls = macthCmp.getChildren();
Text text = (Text) ctls[6];
Spinner minSp = (Spinner) ctls[0];
Spinner maxSp = (Spinner) ctls[3];
text.setText(equiValue);
minSp.setSelection(minMacth);
maxSp.setSelection(maxMatch);
} else {
if (!isDelete) {
// 若模糊匹配区间有两个或两个以上的匹配,那么先删除所有除第一个以外的其他设置
if (matchParent.getChildren().length > 1) {
for (int j = matchParent.getChildren().length - 1; j >= 1; j--) {
Control[] ctls = matchParent.getChildren();
ctls[j].dispose();
}
index = 1;
}
// 创建除第一个模糊匹配之外的其他匹配段
int fixItemNum = equivalStr.indexOf("external101") == -1 ? 3 : 4;
for (int j = 0; j < equivalStr.split(";").length - fixItemNum; j++) {
Composite cmp = (Composite) ((Composite) matchParent.getChildren()[j]).getChildren()[7];
Button addBtn = (Button) cmp.getChildren()[0];
addEquiCmp(null, addBtn);
}
isDelete = true;
}
int fixItemNum = equivalStr.indexOf("external101") == -1 ? 2 : 3;
Composite macthCmp = (Composite) matchParent.getChildren()[i - fixItemNum];
Control[] ctls = macthCmp.getChildren();
Text text = (Text) ctls[6];
Spinner minSp = (Spinner) ctls[0];
Spinner maxSp = (Spinner) ctls[3];
text.setText(equiValue);
minSp.setSelection(minMacth);
maxSp.setSelection(maxMatch);
}
}
}
// matchParent.pack();
matchParent.layout();
// matchParent.getParent().pack();
// matchParent.getParent().layout();
}
use of org.eclipse.swt.widgets.Spinner in project translationstudio8 by heartsome.
the class FileAnalysisInstalPage 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 faGroup = new Group(tparent, SWT.NONE);
faGroup.setLayout(new GridLayout());
faGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
faGroup.setText(Messages.getString("preference.FileAnalysisInstalPage.faGroup"));
String tip = Messages.getString("preference.FileAnalysisInstalPage.faImgLbl");
HsImageLabel faImgLbl = new HsImageLabel(tip, Activator.getImageDescriptor(ImageConstant.PREFERENCE_FA_analysis));
Composite faLblCmp = faImgLbl.createControl(faGroup);
faLblCmp.setLayout(new GridLayout());
faLblCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ignoreCaseBtn = new Button(faLblCmp, SWT.CHECK);
ignoreCaseBtn.setText(Messages.getString("preference.FileAnalysisInstalPage.ignoreCaseBtn"));
ignoreTagBtn = new Button(faLblCmp, SWT.CHECK);
ignoreTagBtn.setText(Messages.getString("preference.FileAnalysisInstalPage.ignoreTagBtn"));
ignoreTagBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
setTagPenaltyEnable();
}
public void widgetDefaultSelected(SelectionEvent e) {
setTagPenaltyEnable();
}
});
GridData spinnerData = new GridData(30, SWT.DEFAULT);
// 罚分制度
Composite tagPenaltyCmp = new Composite(faLblCmp, SWT.NONE);
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(3).applyTo(tagPenaltyCmp);
tagPenaltyCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tagPenaltyLbl = new Label(tagPenaltyCmp, SWT.NONE);
tagPenaltyLbl.setText(Messages.getString("preference.FileAnalysisInstalPage.tagPenalty"));
tagPenaltySpi = new Spinner(tagPenaltyCmp, SWT.BORDER);
tagPenaltySpi.setLayoutData(spinnerData);
GridLayout pGl = new GridLayout(2, false);
pGl.marginHeight = 0;
pGl.marginWidth = 0;
tagPenaltySpi.setMinimum(1);
tagPenaltySpi.setMaximum(100);
if (CommonFunction.checkEdition("U")) {
// 上下文个数
Composite contextCmp = new Composite(faLblCmp, SWT.NONE);
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(3).applyTo(contextCmp);
contextCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label contextLbl = new Label(contextCmp, SWT.NONE);
contextLbl.setText(Messages.getString("preference.FileAnalysisInstalPage.contextLbl"));
contextSpinner = new Spinner(contextCmp, SWT.BORDER);
contextSpinner.setLayoutData(spinnerData);
contextSpinner.setMinimum(1);
contextSpinner.setMaximum(100);
// 步值为1
contextSpinner.setIncrement(1);
contextSpinner.setSelection(1);
Label unitLbl = new Label(contextCmp, SWT.NONE);
unitLbl.setText(Messages.getString("preference.FileAnalysisInstalPage.unitLbl"));
}
faImgLbl.computeSize();
// 分析文件设置
Group faFileGroup = new Group(tparent, SWT.NONE);
faFileGroup.setLayout(new GridLayout());
faFileGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
faFileGroup.setText(Messages.getString("preference.FileAnalysisInstalPage.faFileGroup"));
String faFileTip = Messages.getString("preference.FileAnalysisInstalPage.faFileTip");
HsImageLabel faFileImgLbl = new HsImageLabel(faFileTip, Activator.getImageDescriptor(ImageConstant.PREFERENCE_FA_fileAnalysis));
Composite faFileLblCmp = faFileImgLbl.createControl(faFileGroup);
faFileLblCmp.setLayout(new GridLayout());
faFileLblCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
interRepateBtn = new Button(faFileLblCmp, SWT.CHECK);
interRepateBtn.setText(Messages.getString("preference.FileAnalysisInstalPage.faFileInterRepeate"));
interMatchBtn = new Button(faFileLblCmp, SWT.CHECK);
interMatchBtn.setText(Messages.getString("preference.FileAnalysisInstalPage.faFileInterMatch"));
faFileImgLbl.computeSize();
initListener();
initValue();
return parent;
}
use of org.eclipse.swt.widgets.Spinner in project translationstudio8 by heartsome.
the class TMDatabasePage 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 commonGroup = new Group(tparent, SWT.NONE);
commonGroup.setLayout(new GridLayout());
commonGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
commonGroup.setText(Messages.getString("preference.TMDatabasePage.commonGroup"));
// commonGroup.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
HsImageLabel setLabel = new HsImageLabel(Messages.getString("preference.TMDatabasePage.setLabel"), Activator.getImageDescriptor("images/preference/tm/tm_database_32.png"));
Composite commonComp = setLabel.createControl(commonGroup);
commonComp.setLayout(new GridLayout());
btnCaseSensitive = new Button(commonComp, SWT.CHECK);
btnCaseSensitive.setText(Messages.getString("preference.TMDatabasePage.btnCaseSensitive"));
btnCaseSensitive.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnIsIgnoreMark = new Button(commonComp, SWT.CHECK);
btnIsIgnoreMark.setText(Messages.getString("preference.TMDatabasePage.btnIsIgnoreMark"));
btnIsIgnoreMark.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnIsIgnoreMark.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
setTagPenaltyEnable();
}
public void widgetDefaultSelected(SelectionEvent e) {
setTagPenaltyEnable();
}
});
//罚分制度
Composite tagPenaltyCom = new Composite(commonComp, SWT.NONE);
tagPenaltyLbl = new Label(tagPenaltyCom, SWT.NONE);
tagPenaltyLbl.setText(Messages.getString("preference.TMDatabasePage.tagPenalty"));
tagPenaltySpi = new Spinner(tagPenaltyCom, SWT.BORDER);
GridLayout pGl = new GridLayout(2, false);
pGl.marginHeight = 0;
pGl.marginWidth = 15;
tagPenaltyCom.setLayout(pGl);
tagPenaltySpi.setMinimum(1);
tagPenaltySpi.setMaximum(100);
Composite composite5 = new Composite(commonComp, SWT.NONE);
GridLayout gl = new GridLayout(3, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
composite5.setLayout(gl);
Label minLabel = new Label(composite5, SWT.NONE);
minLabel.setText(Messages.getString("preference.TMDatabasePage.minLabel"));
minMatchSpi = new Spinner(composite5, SWT.BORDER);
minMatchSpi.setMinimum(35);
minMatchSpi.setMaximum(100);
new Label(composite5, SWT.NONE).setText("%");
minMatchSpi.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String value = minMatchSpi.getText();
if (null == value || "".equals(value.trim())) {
setValid(false);
setErrorMessage(Messages.getString("preference.TMDatabasePage.msg1"));
return;
}
try {
float floatValue = Float.parseFloat(value);
if (floatValue < 35 || floatValue > 100) {
setValid(false);
setErrorMessage(Messages.getString("preference.TMDatabasePage.msg2"));
return;
}
} catch (NumberFormatException ex) {
setValid(false);
setErrorMessage(Messages.getString("preference.TMDatabasePage.msg3"));
return;
}
setValid(true);
setErrorMessage(null);
}
});
if (CommonFunction.checkEdition("U")) {
Composite composite4 = new Composite(commonComp, SWT.NONE);
composite4.setLayout(gl);
new Label(composite4, SWT.NONE).setText(Messages.getString("preference.TMDatabasePage.contextSpi"));
contextSpi = new Spinner(composite4, SWT.BORDER);
new Label(composite4, SWT.NONE);
contextSpi.setMinimum(1);
contextSpi.setMaximum(100);
}
Composite matchNumberComp = new Composite(commonComp, SWT.NONE);
new Label(matchNumberComp, SWT.NONE).setText(Messages.getString("preference.TMDatabasePage.matchNumberSpi"));
matchNumberSpi = new Spinner(matchNumberComp, SWT.BORDER);
GridLayout mGl = new GridLayout(2, false);
mGl.marginHeight = 0;
mGl.marginWidth = 0;
matchNumberComp.setLayout(mGl);
matchNumberSpi.setMinimum(1);
matchNumberSpi.setMaximum(10);
// 计算标签大小///////////////
setLabel.computeSize();
Group sortGroup = new Group(tparent, SWT.NONE);
sortGroup.setLayout(new GridLayout());
sortGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
sortGroup.setText(Messages.getString("preference.TMDatabasePage.sortGroup"));
HsImageLabel sortLabel = new HsImageLabel(Messages.getString("preference.TMDatabasePage.sortLabel"), Activator.getImageDescriptor("images/preference/tm/trans_display_oder_32.png"));
Composite sortComp = sortLabel.createControl(sortGroup);
btnDefaultDBPrecedence = new Button(sortComp, SWT.RADIO);
btnDefaultDBPrecedence.setText(Messages.getString("preference.TMDatabasePage.btnDefaultDBPrecedence"));
btnDefaultDBPrecedence.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnDateReverse = new Button(sortComp, SWT.RADIO);
btnDateReverse.setText(Messages.getString("preference.TMDatabasePage.btnDateReverse"));
btnDateReverse.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
sortLabel.computeSize();
Group updateCompGroup = new Group(tparent, SWT.NONE);
updateCompGroup.setLayout(new GridLayout());
updateCompGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
updateCompGroup.setText(Messages.getString("preference.TMDatabasePage.updateCompGroup"));
HsImageLabel updateLabel = new HsImageLabel(Messages.getString("preference.TMDatabasePage.updateLabel"), Activator.getImageDescriptor("images/preference/tm/tm_update_32.png"));
Composite updateComp = updateLabel.createControl(updateCompGroup);
btnAlwaysAdd = new Button(updateComp, SWT.RADIO);
btnAlwaysAdd.setText(Messages.getString("preference.TMDatabasePage.btnAlwaysAdd"));
btnAlwaysAdd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnRepeatOverwrite = new Button(updateComp, SWT.RADIO);
btnRepeatOverwrite.setText(Messages.getString("preference.TMDatabasePage.btnRepeatOverwrite"));
btnRepeatOverwrite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnRepeatIgnore = new Button(updateComp, SWT.RADIO);
btnRepeatIgnore.setText(Messages.getString("preference.TMDatabasePage.btnRepeatIgnore"));
btnRepeatIgnore.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
updateLabel.computeSize();
// boolean showDialog = preferenceStore.getBoolean(DatabaseConstants.SHOW_DIALOG_EACH_OPEN_FILE);
int intMatch = preferenceStore.getInt(TMPreferenceConstants.MATCH_PERCENTAGE_SORT_WITH_EQUAL);
int intUpdateTM = preferenceStore.getInt(TMPreferenceConstants.TM_UPDATE);
setInitValues(false, intMatch, intUpdateTM);
return parent;
}
use of org.eclipse.swt.widgets.Spinner in project cubrid-manager by CUBRID.
the class ImportDataFromFileDialog method createFilePane.
/**
*
* Create the file composite
*
* @param parent Composite
*/
private void createFilePane(Composite parent) {
Group fileGroup = new Group(parent, SWT.NONE);
{
fileGroup.setText(Messages.grpSelectFile);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
fileGroup.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
fileGroup.setLayout(layout);
}
Label fileNameLbl = new Label(fileGroup, SWT.NONE);
fileNameLbl.setText(Messages.importFileNameLBL);
fileNameLbl.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
Composite filePathComp = new Composite(fileGroup, SWT.NONE);
{
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
filePathComp.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 0;
filePathComp.setLayout(layout);
}
fileNameTxt = new Text(filePathComp, SWT.BORDER | SWT.READ_ONLY);
{
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
fileNameTxt.setLayoutData(gridData);
fileNameTxt.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
openFile();
fillParameterTableFileColumn();
validate();
}
});
}
Button browseBtn = new Button(filePathComp, SWT.NONE);
{
GridData gridData = new GridData();
browseBtn.setLayoutData(gridData);
browseBtn.setText(Messages.btnBrowse);
browseBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
openFileDialog();
}
});
}
final Label fileCharsetLabel = new Label(fileGroup, SWT.NONE);
fileCharsetLabel.setText(Messages.lblFileCharset);
fileCharsetLabel.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
fileCharsetCombo = new Combo(fileGroup, SWT.NONE);
{
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
fileCharsetCombo.setLayoutData(gridData);
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
fileCharsetCombo.select(0);
fileCharsetCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
if (validate()) {
openFile();
fillParameterTableFileColumn();
}
}
});
}
Label jdbcCharsetLabel = new Label(fileGroup, SWT.NONE);
jdbcCharsetLabel.setText(Messages.lblJDBCCharset);
jdbcCharsetText = new Text(fileGroup, SWT.BORDER | SWT.READ_ONLY);
{
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
jdbcCharsetText.setLayoutData(gridData);
}
Composite importAttrComp = new Composite(fileGroup, SWT.NONE);
{
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gridData.horizontalSpan = 4;
gridData.horizontalIndent = 0;
importAttrComp.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 6;
layout.marginWidth = 0;
importAttrComp.setLayout(layout);
}
Label totalRowsLabel = new Label(importAttrComp, SWT.NONE);
totalRowsLabel.setText(Messages.lblTotalLines);
totalRowsLabel.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
totalLinesText = new Text(importAttrComp, SWT.BORDER | SWT.READ_ONLY);
{
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
totalLinesText.setLayoutData(gridData);
}
Label threadCountLabel = new Label(importAttrComp, SWT.NONE);
threadCountLabel.setText(Messages.lblThreadCount);
threadCountSpinner = new Spinner(importAttrComp, SWT.BORDER);
{
threadCountSpinner.setMaximum(Integer.MAX_VALUE);
threadCountSpinner.setMinimum(1);
threadCountSpinner.setSelection(1);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
threadCountSpinner.setLayoutData(gridData);
threadCountSpinner.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
validate();
}
});
}
Label lblCommitLine = new Label(importAttrComp, SWT.NONE);
lblCommitLine.setText(Messages.lblCommitLines);
commitLineSpinner = new Spinner(importAttrComp, SWT.BORDER);
{
commitLineSpinner.setMaximum(Integer.MAX_VALUE);
commitLineSpinner.setMinimum(1);
commitLineSpinner.setSelection(1000);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
commitLineSpinner.setLayoutData(gridData);
commitLineSpinner.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
validate();
}
});
}
}
Aggregations