use of org.eclipse.swt.widgets.Control in project translationstudio8 by heartsome.
the class SegmentViewer method reset.
/**
* 重置 ;
*/
public void reset() {
StyledText styledText = getTextWidget();
Control[] children = styledText.getChildren();
for (Control child : children) {
if (child != null && !child.isDisposed()) {
child.dispose();
}
}
innerTagCacheList.clear();
errorTagStart = 0;
}
use of org.eclipse.swt.widgets.Control in project translationstudio8 by heartsome.
the class MultiCellEditDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(panel);
GridLayout panelLayout = new GridLayout(allowIncrementDecrement ? 2 : 1, false);
panel.setLayout(panelLayout);
if (allowIncrementDecrement) {
createUpdateCombo(panel);
}
ActiveCellEditor.close();
ActiveCellEditor.activate(cellEditor, panel, originalCanonicalValue, initialEditValue, dataTypeConverter, cellStyle, dataValidator, new MultiEditHandler(), 0, 0, 0, 0);
Control editorControl = ActiveCellEditor.getControl();
// propagate the ESC event from the editor to the dialog
editorControl.addKeyListener(getEscKeyListener());
final GridDataFactory layoutData = GridDataFactory.fillDefaults().grab(true, false).hint(100, 20);
if (allowIncrementDecrement) {
layoutData.indent(5, 0);
}
layoutData.applyTo(editorControl);
return panel;
}
use of org.eclipse.swt.widgets.Control in project translationstudio8 by heartsome.
the class EquivalentPage method deleteEquiCmp.
/**
* 删除加权系数面板
* @param e
*/
public void deleteEquiCmp(SelectionEvent e) {
Button deleteBtn = (Button) e.getSource();
Composite cp = deleteBtn.getParent().getParent();
Composite cp_parent = cp.getParent();
Control[] ctr_cp = cp_parent.getChildren();
Composite currentCp;
Composite nextCp;
Control[] currentCtrls;
Control[] nextCtrls;
Spinner cuSp;
Spinner nextSp;
int next = 0;
int current = 0;
int uplimit = 0;
// get current rows index,we can get Composite by current rows index
current = Integer.parseInt(cp.getData("index").toString());
// if current composite is not the last Component
if (current < ctr_cp.length) {
next = current + 1;
currentCp = (Composite) ctr_cp[current - 1];
nextCp = (Composite) ctr_cp[next - 1];
currentCtrls = currentCp.getChildren();
nextCtrls = nextCp.getChildren();
cuSp = (Spinner) currentCtrls[3];
nextSp = (Spinner) nextCtrls[3];
cuSp.setEnabled(true);
nextSp.setEnabled(true);
nextSp.setSelection(cuSp.getSelection());
nextSp.setEnabled(false);
}
// delete current composite
ctr_cp[current - 1].dispose();
// reset index of whole container
uplimit = ctr_cp.length;
for (int j = current; j < uplimit; j++) {
Composite tempcp = (Composite) ctr_cp[j];
//$NON-NLS-1$
tempcp.setData("index", String.valueOf(j));
cp_parent.setData(String.valueOf(j), tempcp);
}
index = ctr_cp.length - 1;
// 设置每一个匹配区间的最小匹配率
for (int i = 1; i < matchParent.getChildren().length; i++) {
Composite _cmp = (Composite) matchParent.getChildren()[i];
Spinner _minSp = (Spinner) _cmp.getChildren()[0];
_minSp.setMinimum(matchParent.getChildren().length - i - 1);
Spinner _maxSp = (Spinner) _cmp.getChildren()[3];
_minSp.setMaximum(Integer.parseInt(_maxSp.getText()));
}
// cp_parent.pack();
// cp_parent.layout();
// cp_parent.getParent().layout();
// equiCmp.getParent().layout();
// equiCmp.getParent().getParent().layout();
equiCmp.getParent().getParent().getParent().layout();
}
use of org.eclipse.swt.widgets.Control in project translationstudio8 by heartsome.
the class EquivalentPage method selected.
/**
* 改变相对最小匹配率的大小时,动态改变下一行相对最大匹配率的大小
* @param arg0
*/
private void selected(SelectionEvent e) {
Composite currentCp, nextCp, parentCp;
int currentIndex = 0;
int currentValue = 0;
int upValue = 0;
int nextMinValue = 0;
Control[] paCtrls;
Control[] cuCtrls;
Control[] nextCtrls;
Spinner sp3 = (Spinner) e.getSource();
// 当前相对最小匹配值
currentValue = sp3.getSelection();
currentCp = sp3.getParent();
parentCp = currentCp.getParent();
paCtrls = parentCp.getChildren();
cuCtrls = currentCp.getChildren();
Spinner cuMinSp = (Spinner) cuCtrls[0];
cuMinSp.setSelection(currentValue);
Spinner cuMaxSp = (Spinner) cuCtrls[3];
upValue = cuMaxSp.getSelection();
currentIndex = Integer.parseInt(currentCp.getData("index").toString());
cuMinSp.setMinimum(paCtrls.length - currentIndex + MINRATE);
if (currentIndex >= paCtrls.length) {
if (currentValue > upValue) {
cuMinSp.setSelection(upValue);
}
parentCp.layout();
parentCp.redraw();
return;
}
// 从当前加权设置的下一条设置开始,直到结束,
for (int i = currentIndex + 1; i <= paCtrls.length; i++) {
int remain = paCtrls.length - i + MINRATE;
// 获取下一个加权设置面板
nextCp = (Composite) paCtrls[i - 1];
nextCtrls = nextCp.getChildren();
Spinner nextMinSp = (Spinner) nextCtrls[0];
// 最低值不能小于这个匹配之下所有匹配区间的总数
nextMinSp.setMinimum(remain);
nextMinValue = nextMinSp.getSelection();
Spinner nextMaxSp = (Spinner) nextCtrls[3];
// 如果当前循环的相对最小匹配值小于它的最大值,设成等于最大值
if (nextMinValue > (currentValue - 1)) {
nextMinSp.setSelection(currentValue - 1);
}
nextMaxSp.setSelection(currentValue - 1);
nextMinSp.setMaximum(nextMaxSp.getSelection());
currentValue = nextMinSp.getSelection();
}
parentCp.layout();
parentCp.redraw();
}
use of org.eclipse.swt.widgets.Control in project translationstudio8 by heartsome.
the class EquivalentPage method performOk.
@Override
public boolean performOk() {
if (!isInit) {
return true;
}
StringBuffer equivalSB = new StringBuffer();
// 先获取重复文本段的加权系数
Composite interRepeatCmp = (Composite) repeatCmp.getChildren()[0];
Text text = (Text) interRepeatCmp.getChildren()[2];
equivalSB.append(QAConstant._InternalRepeat + ":" + text.getText() + ";");
if (isUltimate) {
Composite exter101Cmp = (Composite) repeatCmp.getChildren()[1];
text = (Text) exter101Cmp.getChildren()[2];
equivalSB.append(QAConstant._External101 + ":" + text.getText() + ";");
}
Composite exter100Cmp = (Composite) repeatCmp.getChildren()[2 - (isUltimate ? 0 : 1)];
text = (Text) exter100Cmp.getChildren()[2];
equivalSB.append(QAConstant._External100 + ":" + text.getText() + ";");
for (int i = 0; i < matchParent.getChildren().length; i++) {
Composite cmp = (Composite) matchParent.getChildren()[i];
Control[] ctr_cmp = cmp.getChildren();
text = (Text) ctr_cmp[6];
Spinner minSp = (Spinner) ctr_cmp[0];
Spinner maxSp = (Spinner) ctr_cmp[3];
equivalSB.append(minSp.getSelection() + "-" + maxSp.getSelection() + ":" + text.getText() + ";");
}
preferenceStore.setValue(QAConstant.FA_PREF_equivalent, equivalSB.toString());
return true;
}
Aggregations