use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class Martif2TBXConverterDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
tparent.setLayout(new GridLayout(3, false));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(400, 160).grab(true, true).applyTo(tparent);
createMenu();
PluginUtil.createLabel(tparent, Messages.getString("dialog.Martif2TBXConverterDialog.txtMartif"));
txtMartif = new Text(tparent, SWT.BORDER);
txtMartif.setEditable(false);
txtMartif.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnMartifBrowse = new Button(tparent, SWT.None);
btnMartifBrowse.setText(Messages.getString("dialog.Martif2TBXConverterDialog.btnMartifBrowse"));
PluginUtil.createLabel(tparent, Messages.getString("dialog.Martif2TBXConverterDialog.txtTBX"));
txtTBX = new Text(tparent, SWT.BORDER);
txtTBX.setEditable(false);
txtTBX.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnTBXBrowse = new Button(tparent, SWT.None);
btnTBXBrowse.setText(Messages.getString("dialog.Martif2TBXConverterDialog.btnTBXBrowse"));
initListener();
tparent.layout();
getShell().layout();
return tparent;
}
use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class TBXMakerDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
// tparent.setLayout(new GridLayout());
GridLayoutFactory.swtDefaults().spacing(0, 0).numColumns(1).applyTo(tparent);
GridDataFactory.fillDefaults().hint(750, 500).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tparent);
createMenu();
createToolBar(tparent);
table = new Table(tparent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite cmpStatus = new Composite(tparent, SWT.BORDER);
cmpStatus.setLayout(new GridLayout(2, true));
cmpStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
lblRowCount = new Label(cmpStatus, SWT.None);
lblRowCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblRowCount"), 0));
lblRowCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
lblColCount = new Label(cmpStatus, SWT.None);
lblColCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblColCount"), 0));
lblColCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
tparent.layout();
getShell().layout();
return tparent;
}
use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.
the class MatchViewPart method createPartControl.
@Override
public void createPartControl(Composite parent) {
GridLayout parentGl = new GridLayout(1, false);
parentGl.marginWidth = 0;
parentGl.marginHeight = 0;
parent.setLayout(parentGl);
final Composite composite = new Composite(parent, SWT.NONE);
GridLayout compositeGl = new GridLayout(1, false);
compositeGl.marginBottom = -1;
compositeGl.marginLeft = -1;
compositeGl.marginRight = -1;
compositeGl.marginTop = 0;
compositeGl.marginWidth = 0;
compositeGl.marginHeight = 0;
compositeGl.verticalSpacing = 0;
composite.setLayout(compositeGl);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// sourceText = new StyledText(composite, SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
// GridData sTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
// Font f = JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT);
// sourceText.setFont(f);
// int lineH = sourceText.getLineHeight() * 3;
// sTextGd.heightHint = lineH;
// sTextGd.minimumHeight = lineH;
// sourceText.setLayoutData(sTextGd);
SashForm sashForm = new SashForm(composite, SWT.VERTICAL);
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
sourceText = new SegmentViewer(sashForm, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL, null);
StyledText srcTextControl = sourceText.getTextWidget();
srcTextControl.setLineSpacing(net.heartsome.cat.ts.ui.Constants.SEGMENT_LINE_SPACING);
srcTextControl.setLeftMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_LEFT_MARGIN);
srcTextControl.setRightMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_RIGHT_MARGIN);
srcTextControl.setTopMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_TOP_MARGIN);
srcTextControl.setBottomMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_TOP_MARGIN);
srcTextControl.setFont(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT));
sourceText.setSource("");
sourceColunmCellRenderer.setSegmentViewer(sourceText);
GridData sTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
Font f = JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT);
srcTextControl.setFont(f);
int lineH = srcTextControl.getLineHeight() * 2;
sTextGd.heightHint = lineH;
sTextGd.minimumHeight = lineH;
srcTextControl.setLayoutData(sTextGd);
net.heartsome.cat.ts.ui.innertag.tagstyle.TagStyleConfigurator.configure(sourceText);
gridTable = new Grid(sashForm, SWT.BORDER | SWT.V_SCROLL);
gridTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
gridTable.setHeaderVisible(false);
gridTable.setAutoHeight(true);
gridTable.setRowsResizeable(true);
gridTable.setData("selectedBgColor", selectedBgColor);
final GridColumn sourceCln = new GridColumn(gridTable, SWT.NONE);
sourceColunmCellRenderer.setFont(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT));
sourceCln.setCellRenderer(sourceColunmCellRenderer);
sourceCln.setText(Messages.getString("view.MatchViewPart.sourceCln"));
sourceCln.setWordWrap(true);
sourceCln.setAlignment(SWT.CENTER);
sourceCln.setResizeable(false);
final GridColumn typeCln = new GridColumn(gridTable, SWT.NONE);
typeColumnCellRenderer.setVerticalAlignment(SWT.CENTER);
typeCln.setCellRenderer(typeColumnCellRenderer);
typeCln.setText(Messages.getString("view.MatchViewPart.typeCln"));
typeCln.setWordWrap(true);
typeCln.setAlignment(SWT.CENTER);
typeCln.setResizeable(false);
final GridColumn targetCln = new GridColumn(gridTable, SWT.NONE);
targetColumnCellRenderer.setFont(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT));
targetCln.setCellRenderer(targetColumnCellRenderer);
targetCln.setText(Messages.getString("view.MatchViewPart.targetCln"));
targetCln.setWordWrap(true);
targetCln.setAlignment(SWT.CENTER);
targetCln.setResizeable(false);
// 设置可复制功能
copyEnable = new GridCopyEnable(gridTable);
sourceColunmCellRenderer.setCopyEnable(copyEnable);
targetColumnCellRenderer.setCopyEnable(copyEnable);
Composite statusComposite = new Composite(composite, SWT.NONE);
GridLayout statusComptGridLayout = new GridLayout(2, false);
statusComptGridLayout.marginBottom = -1;
statusComptGridLayout.marginLeft = -1;
statusComptGridLayout.marginRight = -1;
statusComptGridLayout.marginTop = -1;
statusComptGridLayout.marginWidth = 0;
statusComptGridLayout.marginHeight = 0;
statusComposite.setLayout(statusComptGridLayout);
statusComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
tipLabel = new CLabel(statusComposite, SWT.NONE);
tipLabel.setAlignment(SWT.LEFT);
infoLabel = new CLabel(statusComposite, SWT.NONE);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gd.heightHint = 20;
infoLabel.setLayoutData(gd);
infoLabel.setAlignment(SWT.RIGHT);
// 设置列宽按比例4.5:1:4.5
composite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Rectangle area = composite.getClientArea();
Point preferredSize = gridTable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// - 2 * gridTable.getBorderWidth();
int width = area.width;
if (preferredSize.y > area.height + gridTable.getHeaderHeight()) {
Point vBarSize = gridTable.getVerticalBar().getSize();
width -= vBarSize.x;
}
gridTable.setSize(area.width, area.height);
width = width - 42;
sourceCln.setWidth((int) (width * 0.5));
typeCln.setWidth(42);
targetCln.setWidth((int) (width * 0.5));
}
});
gridTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
StyledText text = sourceText.getTextWidget();
text.setText(text.getText());
updateActionState();
GridItem[] selItems = gridTable.getSelection();
if (selItems.length != 1) {
return;
}
GridItem item = selItems[0];
setMatchMessage(infoLabelImage, item.getData("info").toString(), item.getData("infoTooltip").toString());
composite.layout();
}
});
gridTable.addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event event) {
menuMgr.acceptMatchAction.run();
}
});
createActions();
sashForm.setWeights(new int[] { 3, 8 });
}
use of org.eclipse.swt.layout.GridLayout 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.layout.GridLayout 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;
}
Aggregations