use of org.eclipse.swt.custom.ScrolledComposite in project translationstudio8 by heartsome.
the class SetSplitPointByWordNumDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridData parentData = new GridData(SWT.FILL, SWT.FILL, true, true);
parentData.widthHint = 400;
parentData.heightHint = 350;
tparent.setLayoutData(parentData);
GridLayoutFactory.swtDefaults().numColumns(1).applyTo(tparent);
Group typeGroup = new Group(tparent, SWT.NONE);
typeGroup.setText(Messages.getString("SetSplitPointByWordNumDialog.splitType"));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(typeGroup);
GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(true).applyTo(typeGroup);
averageBtn = new Button(typeGroup, SWT.RADIO);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(averageBtn);
averageBtn.setText(Messages.getString("SetSplitPointByWordNumDialog.splitByAverWordNum"));
averageBtn.setSelection(true);
wordNumberBtn = new Button(typeGroup, SWT.RADIO);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(wordNumberBtn);
wordNumberBtn.setText(Messages.getString("SetSplitPointByWordNumDialog.splitByFixWordNum"));
// >显示总字数的面板
Composite allNumCmp = new Composite(tparent, SWT.NONE);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).applyTo(allNumCmp);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(allNumCmp);
Label countLbl = new Label(allNumCmp, SWT.NONE);
countLbl.setText(Messages.getString("SetSplitPointByWordNumDialog.curFileTotalWordNum"));
countLbl.setFont(totalLblFont);
Label countValueLbl = new Label(allNumCmp, SWT.NONE);
countValueLbl.setText(totalWordNum + "");
countValueLbl.setFont(totalLblFont);
// >两个面板的父面板
Composite contentCmp = new Composite(tparent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(contentCmp);
contentCmp.setLayout(stack);
// >>平均字数分割方式的面板
averageContentCmp = new Composite(contentCmp, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, true).applyTo(averageContentCmp);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(averageContentCmp);
Label segLbl = new Label(averageContentCmp, SWT.NONE);
segLbl.setText(Messages.getString("SetSplitPointByWordNumDialog.segNumLbl"));
segSpiner = new Spinner(averageContentCmp, SWT.BORDER);
segSpiner.setIncrement(1);
segSpiner.setMinimum(2);
segSpiner.setMaximum(totalTuNum - 1);
segSpiner.setSelection(segList.size());
segSpiner.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent arg0) {
String text = segSpiner.getText();
if (!(text.matches("\\d{1,}") && Integer.parseInt(text) <= (totalTuNum - 1))) {
segSpiner.setSelection(2);
}
}
});
GridDataFactory.swtDefaults().hint(50, SWT.DEFAULT).applyTo(segSpiner);
// >>按指定字数分割的面板
wordNumberScroll = new ScrolledComposite(contentCmp, SWT.NONE | SWT.V_SCROLL | SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, true).applyTo(wordNumberScroll);
GridLayoutFactory.swtDefaults().numColumns(1).applyTo(wordNumberScroll);
wordNumberScroll.setExpandHorizontal(true);
wordNumberScroll.setExpandVertical(true);
segParentCmp = new Composite(wordNumberScroll, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(segParentCmp);
GridLayoutFactory.swtDefaults().spacing(SWT.DEFAULT, 0).numColumns(1).applyTo(segParentCmp);
wordNumberScroll.setContent(segParentCmp);
averageBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
viewerTopControl();
}
public void widgetDefaultSelected(SelectionEvent e) {
viewerTopControl();
}
});
wordNumberBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
viewerTopControl();
}
public void widgetDefaultSelected(SelectionEvent e) {
viewerTopControl();
}
});
stack.topControl = averageContentCmp;
// 开始创建片断列表
for (int i = 0; i < segList.size(); i++) {
SegPointBean bean = segList.get(i);
createSegCmp(bean);
}
wordNumberScroll.setMinSize(segParentCmp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
segParentCmp.layout();
wordNumberScroll.layout();
return tparent;
}
use of org.eclipse.swt.custom.ScrolledComposite in project translationstudio8 by heartsome.
the class ColumnTypeDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
tparent.setLayout(new GridLayout());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(750, 400).grab(true, true).applyTo(tparent);
ScrolledComposite cmpScrolled = new ScrolledComposite(tparent, SWT.V_SCROLL);
cmpScrolled.setAlwaysShowScrollBars(false);
cmpScrolled.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
cmpScrolled.setExpandHorizontal(true);
cmpScrolled.setShowFocusedControl(true);
Composite cmpContent = new Composite(cmpScrolled, SWT.None);
cmpScrolled.setContent(cmpContent);
cmpContent.setLayout(new GridLayout(5, false));
arrCmbLangs = new Combo[size];
arrCmbPropsName = new Combo[size];
arrCmbPropsType = new Combo[size];
arrCmbPropsLevel = new Combo[size];
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column1"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column2"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column3"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column4"));
new Label(cmpContent, SWT.None).setText(Messages.getString("dialog.ColumnTypeDialog.column5"));
for (int i = 0; i < size; i++) {
ColProperties type = colTypes.get(i);
new Label(cmpContent, SWT.None).setText(type.getColName() + " : ");
arrCmbPropsLevel[i] = new Combo(cmpContent, SWT.READ_ONLY);
arrCmbPropsLevel[i].setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
arrCmbPropsName[i] = new Combo(cmpContent, SWT.READ_ONLY);
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
data.widthHint = 120;
arrCmbPropsName[i].setLayoutData(data);
arrCmbPropsType[i] = new Combo(cmpContent, SWT.READ_ONLY);
data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
data.widthHint = 150;
arrCmbPropsType[i].setLayoutData(data);
arrCmbLangs[i] = new Combo(cmpContent, SWT.READ_ONLY);
arrCmbLangs[i].setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
arrCmbPropsLevel[i].setItems(levelValues);
arrCmbPropsLevel[i].select(0);
String propLevel = type.getLevel();
if (!propLevel.equals("")) {
//$NON-NLS-1$
arrCmbPropsLevel[i].setText(propLevel);
if (propLevel.equals(ColProperties.conceptLevel)) {
arrCmbLangs[i].setEnabled(false);
arrCmbPropsName[i].setItems(conceptPropValues);
arrCmbPropsName[i].select(0);
arrCmbPropsType[i].setItems(conceptPropTypeValues);
arrCmbPropsType[i].select(0);
}
if (propLevel.equals(ColProperties.langLevel)) {
arrCmbLangs[i].setEnabled(true);
arrCmbPropsName[i].setItems(TranslationPropValues);
arrCmbPropsName[i].select(0);
arrCmbPropsType[i].setItems(termDescripPropTypeValues);
arrCmbPropsType[i].select(0);
}
}
// fixed a bug 2339 by John.
String propName = type.getPropName();
if (!propName.equals("")) {
//$NON-NLS-1$
arrCmbPropsName[i].setText(propName);
}
// Update content for Prop Type combo
String propType = type.getPropType();
if (!propType.equals("")) {
//$NON-NLS-1$
arrCmbPropsType[i].setText(propType);
}
if (!propLevel.equals("")) {
//$NON-NLS-1$
if (propLevel.equals(ColProperties.conceptLevel)) {
arrCmbPropsType[i].setEnabled(propName.equals(ColProperties.descripName));
arrCmbPropsType[i].setItems(conceptPropTypeValues);
arrCmbPropsType[i].select(0);
}
if (propLevel.equals(ColProperties.langLevel)) {
arrCmbPropsType[i].setEnabled(!propName.equals(ColProperties.termName));
if (propName.equals(ColProperties.descripName)) {
arrCmbPropsType[i].setItems(termDescripPropTypeValues);
} else {
arrCmbPropsType[i].setItems(termTermNotePropTypeValues);
}
arrCmbPropsType[i].select(0);
}
}
// Update content for Language Combo
arrCmbLangs[i].setItems(LocaleService.getLanguages());
arrCmbLangs[i].select(0);
String lang = type.getLanguage();
if (!lang.equals("")) {
//$NON-NLS-1$
arrCmbLangs[i].setText(LocaleService.getLanguage(lang));
}
final int idx = i;
arrCmbPropsName[idx].addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String level = arrCmbPropsLevel[idx].getText();
String name = arrCmbPropsName[idx].getText();
if (name.equals(ColProperties.termName)) {
arrCmbPropsType[idx].setEnabled(false);
arrCmbPropsType[idx].setItems(conceptPropTypeValues);
arrCmbPropsType[idx].select(0);
return;
}
if (name.equals(ColProperties.termNoteName)) {
arrCmbPropsType[idx].setEnabled(true);
arrCmbPropsType[idx].setItems(termTermNotePropTypeValues);
arrCmbPropsType[idx].select(0);
return;
}
if (name.equals(ColProperties.noteName)) {
arrCmbLangs[idx].setEnabled(false);
arrCmbPropsType[idx].setEnabled(false);
return;
}
if (name.equals(ColProperties.descripName)) {
arrCmbPropsType[idx].setEnabled(true);
if (level.equals(ColProperties.conceptLevel)) {
arrCmbPropsType[idx].setItems(conceptPropTypeValues);
} else {
arrCmbPropsType[idx].setItems(termDescripPropTypeValues);
}
arrCmbPropsType[idx].select(0);
return;
}
arrCmbPropsType[idx].setEnabled(false);
}
});
arrCmbPropsLevel[idx].addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String level = arrCmbPropsLevel[idx].getText();
String name = arrCmbPropsName[idx].getText();
if (level.equals(ColProperties.conceptLevel)) {
arrCmbLangs[idx].setEnabled(false);
arrCmbPropsName[idx].setItems(conceptPropValues);
arrCmbPropsName[idx].select(0);
arrCmbPropsType[idx].setEnabled(true);
arrCmbPropsType[idx].setItems(conceptPropTypeValues);
arrCmbPropsType[idx].select(0);
}
if (level.equals(ColProperties.langLevel)) {
arrCmbLangs[idx].setEnabled(true);
arrCmbPropsName[idx].setItems(TranslationPropValues);
arrCmbPropsName[idx].select(0);
arrCmbPropsType[idx].setEnabled(false);
if (name.equals(ColProperties.descripName)) {
arrCmbPropsType[idx].setItems(termDescripPropTypeValues);
} else {
arrCmbPropsType[idx].setItems(termTermNotePropTypeValues);
}
arrCmbPropsType[idx].select(0);
}
}
});
}
cmpContent.setSize(cmpContent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
return tparent;
}
use of org.eclipse.swt.custom.ScrolledComposite in project translationstudio8 by heartsome.
the class CustomFilterDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
gray = parent.getDisplay().getSystemColor(SWT.COLOR_GRAY);
black = parent.getDisplay().getSystemColor(SWT.COLOR_BLACK);
tParent = (Composite) super.createDialogArea(parent);
GridLayoutFactory.swtDefaults().extendedMargins(5, 5, 10, 0).numColumns(2).equalWidth(false).applyTo(tParent);
tParent.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite cmpLeft = new Composite(tParent, SWT.BORDER);
cmpLeft.setLayout(new GridLayout(2, false));
GridDataFactory.swtDefaults().applyTo(cmpLeft);
Composite cmpList = new Composite(cmpLeft, SWT.NONE);
cmpList.setLayout(new GridLayout(1, true));
cmpList.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(cmpList, SWT.NONE).setText(Messages.getString("dialog.CustomFilterDialog.c1Lbl"));
initCustomFilterList(cmpList);
Composite cmpBtn = new Composite(cmpLeft, SWT.None);
cmpBtn.setLayout(new GridLayout());
cmpBtn.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
Button addCustom = new Button(cmpBtn, SWT.PUSH);
addCustom.setText(Messages.getString("dialog.CustomFilterDialog.addCustom"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(addCustom);
addCustom.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (isChange()) {
if (!MessageDialog.openConfirm(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg1"))) {
return;
}
}
refresh();
}
});
Button delCustom = new Button(cmpBtn, SWT.PUSH);
delCustom.setText(Messages.getString("dialog.CustomFilterDialog.delCustom"));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).applyTo(delCustom);
delCustom.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String[] filters = customFilterList.getSelection();
if (filters != null && filters.length > 0) {
if (MessageDialog.openConfirm(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg2"))) {
for (int i = 0; i < filters.length; i++) {
customFilters.remove(filters[i]);
customFiltersAddition.remove(filters[i]);
customFiltersIndex.remove(filters[i]);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IEditorReference[] editors = page.getEditorReferences();
for (IEditorReference ef : editors) {
IEditorPart editor = ef.getEditor(false);
if (editor != null && editor instanceof XLIFFEditorImplWithNatTable) {
Combo cb = ((XLIFFEditorImplWithNatTable) editor).getFilterCombo();
if (cb != null && !cb.isDisposed()) {
cb.remove(filters[i]);
}
}
}
}
}
// cmbFilter.remove(filters[i]);
customFilterList.remove(filters[i]);
XLFHandler.getFilterMap().remove(filters[i]);
}
PreferenceStore.saveMap(IPreferenceConstants.FILTER_CONDITION, customFilters);
PreferenceStore.saveCustomCondition(IPreferenceConstants.FILTER_CONDITION_INDEX, customFiltersIndex);
}
} else {
MessageDialog.openInformation(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg3"));
}
}
});
Button editCustom = new Button(cmpBtn, SWT.PUSH);
editCustom.setText(Messages.getString("dialog.CustomFilterDialog.editCustom"));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).applyTo(editCustom);
editCustom.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
edit();
}
});
Composite cmpRight = new Composite(tParent, SWT.NONE);
cmpRight.setLayout(new GridLayout(1, true));
cmpRight.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite top = new Composite(cmpRight, SWT.NONE);
top.setLayout(new GridLayout(2, false));
top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(top, SWT.NONE).setText(Messages.getString("dialog.CustomFilterDialog.topLbl"));
filterNameTxt = new Text(top, SWT.BORDER);
filterNameTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
filterNameTxt.forceFocus();
top = new Composite(cmpRight, SWT.NONE);
top.setLayout(new GridLayout(2, false));
top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
andBtn = new Button(top, SWT.RADIO);
andBtn.setText(Messages.getString("dialog.CustomFilterDialog.andBtn"));
andBtn.setSelection(true);
orBtn = new Button(top, SWT.RADIO);
orBtn.setText(Messages.getString("dialog.CustomFilterDialog.orBtn"));
scroll = new ScrolledComposite(cmpRight, SWT.V_SCROLL | SWT.BORDER);
scroll.setAlwaysShowScrollBars(true);
scroll.setLayoutData(new GridData(GridData.FILL_BOTH));
scroll.setExpandHorizontal(true);
scroll.setExpandVertical(true);
// scroll.setSize(500, 200);
dynaComp = new Composite(scroll, SWT.None);
scroll.setContent(dynaComp);
dynaComp.setLayout(new GridLayout(1, true));
new DynaComposite(dynaComp, SWT.NONE);
return parent;
}
use of org.eclipse.swt.custom.ScrolledComposite in project translationstudio8 by heartsome.
the class CustomMatchConditionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
gray = parent.getDisplay().getSystemColor(SWT.COLOR_GRAY);
black = parent.getDisplay().getSystemColor(SWT.COLOR_BLACK);
tParent = (Composite) super.createDialogArea(parent);
tParent.setLayout(new GridLayout(2, false));
tParent.setLayoutData(new GridData(720, 410));
Composite c = new Composite(tParent, SWT.BORDER);
c.setLayout(new GridLayout(2, false));
c.setLayoutData(new GridData(200, 388));
Composite c1 = new Composite(c, SWT.NONE);
c1.setLayout(new GridLayout(1, true));
c1.setLayoutData(new GridData(150, 380));
new Label(c1, SWT.NONE).setText("自定义过滤器:");
initCustomFilterList(c1);
Composite c2 = new Composite(c, SWT.NONE);
RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
rowLayout.marginLeft = 0;
rowLayout.marginTop = 150;
rowLayout.spacing = 5;
c2.setLayout(rowLayout);
c2.setLayoutData(new GridData(50, 380));
Button addCustom = new Button(c2, SWT.PUSH);
addCustom.setText("新增");
addCustom.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// 新增自定义过滤器方法
if (isChange()) {
if (!MessageDialog.openConfirm(getShell(), "", "不保存当前内容吗?")) {
return;
}
}
refresh();
}
});
Button delCustom = new Button(c2, SWT.PUSH);
delCustom.setText("删除");
delCustom.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// 删除已保存的自定义过滤器方法
String[] filters = customFilterList.getSelection();
if (filters != null && filters.length > 0) {
if (MessageDialog.openConfirm(getShell(), "", "确定要删除选中的自定义过滤器吗?")) {
deletePreference(filters);
}
} else {
MessageDialog.openInformation(getShell(), "", "请选择要删除的自定义过滤器。");
}
}
});
Button editCustom = new Button(c2, SWT.PUSH);
editCustom.setText("编辑");
editCustom.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// 编辑已有的自定义过滤器方法
edit();
}
});
Composite c3 = new Composite(tParent, SWT.NONE);
c3.setLayout(new GridLayout(1, true));
c3.setLayoutData(new GridData(500, 400));
Composite top = new Composite(c3, SWT.NONE);
top.setLayout(new GridLayout(2, false));
new Label(top, SWT.NONE).setText("过滤器名称:");
filterNameTxt = new Text(top, SWT.BORDER);
filterNameTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
andBtn = new Button(top, SWT.RADIO);
andBtn.setText("满足所有条件");
andBtn.setSelection(true);
orBtn = new Button(top, SWT.RADIO);
orBtn.setText("满足以下任一条件");
scroll = new ScrolledComposite(c3, SWT.V_SCROLL | SWT.BORDER);
scroll.setAlwaysShowScrollBars(true);
scroll.setLayoutData(new GridData(470, 250));
scroll.setExpandHorizontal(true);
scroll.setExpandVertical(true);
dynaComp = new Composite(scroll, SWT.BORDER);
scroll.setContent(dynaComp);
dynaComp.setLayout(new GridLayout(1, true));
new DynaComposite(dynaComp, SWT.NONE);
Composite c4 = new Composite(c3, SWT.BORDER);
c4.setLayout(new GridLayout(2, true));
c4.setLayoutData(new GridData(470, 60));
btnIsTagged = new Button(c4, SWT.CHECK);
btnIsTagged.setText("标记的匹配");
btnQT = new Button(c4, SWT.CHECK);
btnQT.setText("快速翻译匹配");
// propagate translation
btnPT = new Button(c4, SWT.CHECK);
btnPT.setText("自动繁殖翻译匹配");
if (isTEInstalled()) {
btnIsRemoveFromSrc = new Button(c4, SWT.CHECK);
btnIsRemoveFromSrc.setText("从来源中删除");
}
return parent;
}
use of org.eclipse.swt.custom.ScrolledComposite in project translationstudio8 by heartsome.
the class XLFEditor method createEditorPart.
/**
* 创建编辑器组件。
*/
private void createEditorPart(Composite parent) {
bottomComposite = new Composite(parent, SWT.BORDER);
GridLayout glBottomCmp = new GridLayout(2, false);
glBottomCmp.marginHeight = HEIGHT_SPACE;
glBottomCmp.marginWidth = WIDTH_SPACE;
glBottomCmp.horizontalSpacing = 0;
glBottomCmp.verticalSpacing = 0;
bottomComposite.setLayout(glBottomCmp);
bottomComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
// 左上方,第一行,第一列,即表头容器
colHeaderComposite = new Composite(bottomComposite, SWT.NONE);
colHeaderComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
createTableHeader(colHeaderComposite);
// 右方,第二列,占两行。
editorVBar = new Slider(bottomComposite, SWT.V_SCROLL | SWT.BORDER);
GridData gdVBar = new GridData(GridData.FILL_VERTICAL);
// 合并两行,使之占满整个自定义表格位置。
gdVBar.verticalSpan = 2;
editorVBar.setLayoutData(gdVBar);
// 左下方,第二行,第一列,编辑器容器
oScrolledComposite = new ScrolledComposite(bottomComposite, SWT.H_SCROLL);
GridLayout glScrolledComposite = new GridLayout(1, false);
glScrolledComposite.horizontalSpacing = 0;
glScrolledComposite.verticalSpacing = 0;
glScrolledComposite.marginHeight = 0;
glScrolledComposite.marginWidth = 0;
oScrolledComposite.setLayout(glScrolledComposite);
oScrolledComposite.setExpandHorizontal(true);
oScrolledComposite.setExpandVertical(true);
oScrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
editorContentComposite = new Composite(oScrolledComposite, SWT.NONE);
GridLayout glEditorContentComposite = new GridLayout(1, true);
glEditorContentComposite.horizontalSpacing = 0;
glEditorContentComposite.verticalSpacing = 0;
glEditorContentComposite.marginHeight = 0;
glEditorContentComposite.marginWidth = 0;
editorContentComposite.setLayout(glEditorContentComposite);
editorContentComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
oScrolledComposite.setContent(editorContentComposite);
// TODO 需换成真实数据
// 初始化编辑器中表格行组件。
txtComposites = new Composite[ROWSOFPAGE];
tgtComposites = new Composite[ROWSOFPAGE];
statusComposites = new Composite[ROWSOFPAGE];
lblRowIndexs = new Label[ROWSOFPAGE];
for (int i = 0; i < ROWSOFPAGE; i++) {
Composite rowComposite = new Composite(editorContentComposite, SWT.NONE);
GridLayout glRowCmp = new GridLayout(2, false);
glRowCmp.marginHeight = 0;
glRowCmp.marginWidth = 0;
glRowCmp.horizontalSpacing = 0;
glRowCmp.verticalSpacing = 0;
rowComposite.setLayout(glRowCmp);
rowComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
lblRowIndexs[i] = new Label(rowComposite, SWT.BORDER);
lblRowIndexs[i].setAlignment(SWT.CENTER);
lblRowIndexs[i].setText(String.valueOf(i + 1));
GridData gdIndex = new GridData(GridData.FILL_VERTICAL);
gdIndex.widthHint = COLUMN_INDEX_WIDTH;
lblRowIndexs[i].setLayoutData(gdIndex);
txtComposites[i] = new Composite(rowComposite, SWT.NONE);
StyledText stSrc = new StyledText(txtComposites[i], SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.BORDER);
stSrc.setCursor(cursorArrow);
stSrc.setData(DATAKEY_INDEX, i);
stSrc.setText("This is a test." + (i + 1));
GridData gdStSrc = new GridData(GridData.FILL_BOTH);
gdStSrc.minimumHeight = MINIMUM_ROW_HEIGHT;
gdStSrc.grabExcessVerticalSpace = true;
stSrc.setLayoutData(gdStSrc);
stSrc.addModifyListener(textModifyListener);
stSrc.addMouseListener(mouseListener);
stSrc.addKeyListener(keyListener);
stSrc.addMouseTrackListener(mouseTrackListener);
stSrc.setCaretOffset(-1);
tgtComposites[i] = new Composite(txtComposites[i], SWT.NONE);
statusComposites[i] = new Composite(tgtComposites[i], SWT.NONE);
Label lblApprovedStatus = new Label(statusComposites[i], SWT.NONE);
lblApprovedStatus.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
lblApprovedStatus.setToolTipText("翻译单元审批状态:已批准");
lblApprovedStatus.setLayoutData(new GridData(STATUS_FLAG_WIDTH, STATUS_FLAG_HEIGHT));
Label lblTranslatableStatus = new Label(statusComposites[i], SWT.NONE);
lblTranslatableStatus.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
lblTranslatableStatus.setToolTipText("翻译单元可译状态:可译");
lblTranslatableStatus.setLayoutData(new GridData(STATUS_FLAG_WIDTH, STATUS_FLAG_HEIGHT));
Label lblTranslationStatus = new Label(statusComposites[i], SWT.NONE);
lblTranslationStatus.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_CYAN));
lblTranslationStatus.setToolTipText("目标文本段状态:已翻译");
lblTranslationStatus.setLayoutData(new GridData(STATUS_FLAG_WIDTH, STATUS_FLAG_HEIGHT));
StyledText stTgt = new StyledText(tgtComposites[i], SWT.MULTI | SWT.WRAP | SWT.BORDER);
stTgt.setCursor(cursorArrow);
stTgt.setData(DATAKEY_INDEX, i);
GridData gdStTgt = new GridData(GridData.FILL_BOTH);
gdStTgt.minimumHeight = MINIMUM_ROW_HEIGHT;
gdStTgt.grabExcessVerticalSpace = true;
stTgt.setLayoutData(gdStTgt);
stTgt.addModifyListener(textModifyListener);
stTgt.addMouseListener(mouseListener);
stTgt.addKeyListener(keyListener);
stTgt.addMouseTrackListener(mouseTrackListener);
stTgt.setCaretOffset(-1);
}
// 模拟的编辑器数据模型
final List<SimpleModel> models = getModel(1000);
editorVBar.setIncrement(1);
editorVBar.setPageIncrement(ROWSOFPAGE);
editorVBar.setMaximum(models.size());
editorVBar.setMinimum(1);
editorVBar.setThumb(ROWSOFPAGE);
editorVBar.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int y = editorVBar.getSelection();
System.out.println("current y value:" + y);
System.out.println("thumb value:" + editorVBar.getThumb());
refreshContent(models, editorVBar.getSelection());
}
});
// 初始化界面 UI 的显示内容
// refreshContent(models, 1);
// 设置编辑器组件布局
setEditorLayout();
}
Aggregations