use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class CatalogManagerDialog 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 = 700;
parentData.heightHint = 400;
tparent.setLayoutData(parentData);
tableViewer = new TableViewer(tparent, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.MULTI);
table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
String[] columnNames = new String[] { Messages.getString("dialogs.CatalogManagerDialog.columnNames1"), Messages.getString("dialogs.CatalogManagerDialog.columnNames2"), Messages.getString("dialogs.CatalogManagerDialog.columnNames3"), Messages.getString("dialogs.CatalogManagerDialog.columnNames4") };
int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT, SWT.LEFT, SWT.LEFT };
for (int i = 0; i < columnNames.length; i++) {
TableColumn tableColumn = new TableColumn(table, columnAlignments[i]);
tableColumn.setText(columnNames[i]);
tableColumn.setWidth(50);
}
tableViewer.setLabelProvider(new TableViewerLabelProvider());
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setInput(getCatalogValue());
// 让列表列宽动态变化
table.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
final Table table = ((Table) event.widget);
final TableColumn[] columns = table.getColumns();
event.widget.getDisplay().syncExec(new Runnable() {
public void run() {
double[] columnWidths = new double[] { 0.08, 0.15, 0.36, 0.36 };
for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
}
});
}
});
return tparent;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class XmlConverterConfigurationDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridDataFactory.fillDefaults().grab(true, true).hint(400, 450).minSize(400, 450).applyTo(tparent);
tableViewer = new TableViewer(tparent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
table = tableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
tableViewer.setLabelProvider(new TableViewerLabelProvider());
tableViewer.setContentProvider(new ArrayContentProvider());
String[] columnNames = new String[] { Messages.getString("dialogs.XmlConverterConfigurationDialog.columnNames1"), Messages.getString("dialogs.XmlConverterConfigurationDialog.columnNames2") };
int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
for (int i = 0; i < columnNames.length; i++) {
TableColumn tableColumn = new TableColumn(table, columnAlignments[i]);
tableColumn.setText(columnNames[i]);
tableColumn.setWidth(50);
// 处理排序的问题
switch(i) {
case 0:
tableColumn.addSelectionListener(new SelectionAdapter() {
// 升序
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
tableViewer.setSorter(asc ? XmlConvertOrder.index_ASC : XmlConvertOrder.index_DESC);
asc = !asc;
}
});
break;
case 1:
tableColumn.addSelectionListener(new SelectionAdapter() {
// 升序
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
tableViewer.setSorter(asc ? XmlConvertOrder.xmlName_ASC : XmlConvertOrder.xmlName_DESC);
asc = !asc;
}
});
break;
default:
break;
}
}
tableViewer.setInput(getXmlConfigFilesInfo());
// 让列表列宽动态变化
table.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
final Table table = ((Table) event.widget);
final TableColumn[] columns = table.getColumns();
event.widget.getDisplay().syncExec(new Runnable() {
public void run() {
double[] columnWidths = new double[] { 0.1, 0.85 };
for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
}
});
}
});
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
editConfigXml();
}
});
return tparent;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class AddOrEditElementOfXmlConvertDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);
Composite composite = new Composite(tparent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(composite);
// 元素类型下拉框的值, 备注:不能本地化
String[] typeValues = { "segment", "inline", "ignore" };
// 内联类型下拉框的值, 备注:不能本地化
String[] internalValues = { "", "image", "pb", "lb", "x-bold", "x-entry", "x-font", "x-italic", "x-link", "x-underlined", "x-other" };
// 保留空格下拉框的值, 备注:不能本地化
String[] remainSpaceVlaues = { "", "yes", "no" };
GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
textData.widthHint = 100;
// 元素名称
Label nameLbl = new Label(composite, SWT.NONE);
nameLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.nameLbl"));
nameLbl.setAlignment(SWT.RIGHT);
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(nameLbl);
nameTxt = new Text(composite, SWT.BORDER);
nameTxt.setLayoutData(textData);
// 元素类型
Label typeLbl = new Label(composite, SWT.NONE);
typeLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.typeLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(typeLbl);
typeCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
typeCmb.setLayoutData(textData);
typeCmb.setItems(typeValues);
typeCmb.select(0);
// 内联类型
Label inlineLbl = new Label(composite, SWT.NONE);
inlineLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.inlineLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(inlineLbl);
inlineCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
inlineCmb.setLayoutData(textData);
inlineCmb.setItems(internalValues);
inlineCmb.setEnabled(false);
// 可翻译属性
Label transAttriLbl = new Label(composite, SWT.NONE);
transAttriLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.transAttriLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(transAttriLbl);
transAtrriTxt = new Text(composite, SWT.BORDER);
transAtrriTxt.setLayoutData(textData);
// 保留空格
Label remainSpaceLbl = new Label(composite, SWT.NONE);
remainSpaceLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.remainSpaceLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(remainSpaceLbl);
remainSpaceCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
remainSpaceCmb.setLayoutData(textData);
remainSpaceCmb.setItems(remainSpaceVlaues);
// 当元素类型是segment时,禁用内联内型,当元素类型是inline时,禁用可翻译属性。当元素类型是ignore时,禁用可翻译属性与内联内型
typeCmb.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String type = typeCmb.getText();
if ("segment".equals(type)) {
inlineCmb.setText("");
inlineCmb.setEnabled(false);
transAtrriTxt.setEnabled(true);
} else if ("inline".equals(type)) {
inlineCmb.setEnabled(true);
transAtrriTxt.setText("");
transAtrriTxt.setEnabled(false);
} else if ("ignore".equals(type)) {
inlineCmb.setText("");
inlineCmb.setEnabled(false);
transAtrriTxt.setText("");
transAtrriTxt.setEnabled(false);
}
}
});
return tparent;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class AddOrEditXmlConvertConfigDialog method createRootTxt.
/**
* 创建xml根,与存储目录
* @param tparent
* ;
*/
private void createRootTxt(Composite tparent) {
Composite composite = new Composite(tparent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(composite);
GridLayoutFactory.fillDefaults().spacing(0, SWT.DEFAULT).numColumns(5).applyTo(composite);
Label rootLbl = new Label(composite, SWT.NONE);
rootLbl.setText(Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.rootLbl"));
rootTxt = new Text(composite, SWT.BORDER);
GridDataFactory.fillDefaults().indent(6, SWT.DEFAULT).hint(100, SWT.DEFAULT).applyTo(rootTxt);
// 显示一个图标与“被保存到:”
Label iconLbl = new Label(composite, SWT.NONE);
iconLbl.setImage(icon);
GridDataFactory.fillDefaults().indent(4, SWT.DEFAULT).applyTo(iconLbl);
Label textLbl = new Label(composite, SWT.NONE);
textLbl.setText(Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.textLbl"));
rootTipLbl = new Label(composite, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.LEFT, SWT.CENTER).applyTo(rootTipLbl);
rootTxt.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String tipText = root.getFullPath().append(ADConstants.AD_xmlConverterConfigFolder).append("config_" + rootTxt.getText().trim() + ".xml").toOSString();
rootTipLbl.setText(tipText);
rootTipLbl.pack();
rootTipLbl.setToolTipText(tipText);
}
});
// 在添加状态下,当根元素文本框失去焦点后,验证是否为空,验证是否重复
rootTxt.addFocusListener(new org.eclipse.swt.events.FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
String rootStr = rootTxt.getText().trim();
if (isAdd || (!rootStr.equals(curRootStr))) {
if ("".equals(rootStr)) {
MessageDialog.openWarning(getShell(), Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.msgTitle1"), Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.msg1"));
} else {
// 提示文件是否重复
String configXmlLoaction = root.getLocation().append(ADConstants.AD_xmlConverterConfigFolder).append("config_" + rootStr + ".xml").toOSString();
File xmlConfigFile = new File(configXmlLoaction);
if (xmlConfigFile.exists()) {
String configXmlFullPath = root.getFullPath().append(ADConstants.AD_xmlConverterConfigFolder).append("config_" + rootStr + ".xml").toOSString();
MessageDialog.openWarning(getShell(), Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.msgTitle1"), MessageFormat.format(Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.msg2"), configXmlFullPath));
}
}
super.focusLost(e);
}
}
});
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class AddOrEditXmlConvertConfigDialog method createButtonBar.
@Override
protected Control createButtonBar(Composite parent) {
Composite buttonCmp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = false;
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
buttonCmp.setLayout(layout);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
buttonCmp.setLayoutData(data);
buttonCmp.setFont(parent.getFont());
Composite leftCmp = new Composite(buttonCmp, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(leftCmp);
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(3).equalWidth(false).applyTo(leftCmp);
addBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.addBtn"), false);
editBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.editBtn"), false);
deleteBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.deleteBtn"), false);
Composite rightCmp = new Composite(buttonCmp, SWT.NONE);
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(1).equalWidth(false).applyTo(rightCmp);
// createButton(rightCmp, IDialogConstants.CLIENT_ID, "分析XML(&N)", false);
new Label(rightCmp, SWT.NONE);
Label separatorLbl = new Label(buttonCmp, SWT.HORIZONTAL | SWT.SEPARATOR);
GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(separatorLbl);
new Label(buttonCmp, SWT.NONE);
Composite bottomCmp = new Composite(buttonCmp, SWT.NONE);
GridDataFactory.fillDefaults().grab(false, false).applyTo(bottomCmp);
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(2).applyTo(bottomCmp);
createButton(bottomCmp, IDialogConstants.OK_ID, Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.ok"), false);
createButton(bottomCmp, IDialogConstants.CANCEL_ID, Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.cancel"), true).setFocus();
initListener();
return buttonCmp;
}
Aggregations