use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class AnalysisXmlConvertConfigDialg method createRootTxt.
private void createRootTxt(Composite tparent) {
Composite composite = new Composite(tparent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(composite);
GridLayoutFactory.fillDefaults().spacing(0, 1).numColumns(5).applyTo(composite);
Label analysisXmlLbl = new Label(composite, SWT.NONE);
analysisXmlLbl.setText(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.analysisXmlLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(analysisXmlLbl);
Composite browseCmp = new Composite(composite, SWT.NONE);
GridDataFactory.fillDefaults().indent(6, SWT.DEFAULT).grab(true, false).span(4, SWT.DEFAULT).applyTo(browseCmp);
GridLayoutFactory.fillDefaults().numColumns(2).extendedMargins(0, 0, 0, 0).applyTo(browseCmp);
analysisTxt = new Text(browseCmp, SWT.BORDER);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(analysisTxt);
Button browseBtn = new Button(browseCmp, SWT.NONE);
browseBtn.setText(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.browseBtn"));
Label rootLbl = new Label(composite, SWT.NONE);
rootLbl.setText(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.rootLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(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.AnalysisXmlConvertConfigDialg.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().toLowerCase() + ".xml").toOSString();
rootTipLbl.setText(tipText);
rootTipLbl.pack();
rootTipLbl.setToolTipText(tipText);
}
});
// 在添加状态下,当根元素文本框失去焦点后,验证是否为空,验证是否重复
rootTxt.addFocusListener(new org.eclipse.swt.events.FocusAdapter() {
public void focusLost(FocusEvent e) {
String rootStr = rootTxt.getText().trim().toLowerCase();
if ("".equals(rootStr)) {
MessageDialog.openInformation(getShell(), Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.msgTitle"), Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.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.openInformation(getShell(), Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.msgTitle"), MessageFormat.format(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.msg2"), configXmlFullPath));
}
}
super.focusLost(e);
}
});
browseBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
String[] extensions = { "*.xml", "*" };
String[] names = { Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.filterXML"), Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.filterAll") };
fd.setText(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.fdTitle"));
fd.setFilterExtensions(extensions);
fd.setFilterNames(names);
String xmlLocation = fd.open();
analysisTxt.setText(xmlLocation);
// 解析XML文件并且填充到列表
analysisXml(xmlLocation);
}
});
analysisTxt.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
analysisXml(analysisTxt.getText());
super.focusLost(e);
}
});
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class AnalysisXmlConvertConfigDialg method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridDataFactory.fillDefaults().grab(true, true).hint(700, 500).applyTo(tparent);
createRootTxt(tparent);
createTable(tparent);
return tparent;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class AnalysisXmlConvertConfigDialg 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.AnalysisXmlConvertConfigDialg.addBtn"), false);
editBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.editBtn"), false);
deleteBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.deleteBtn"), false);
Composite rightCmp = new Composite(buttonCmp, SWT.NONE);
GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(1).equalWidth(false).applyTo(rightCmp);
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);
okBtn = createButton(bottomCmp, IDialogConstants.OK_ID, Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.ok"), false);
// 禁用确定按钮
okBtn.setEnabled(false);
createButton(bottomCmp, IDialogConstants.CANCEL_ID, Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.cancel"), true).setFocus();
initListener();
return buttonCmp;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class AddOrEditCatalogDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tParent = (Composite) super.createDialogArea(parent);
GridDataFactory.fillDefaults().hint(600, 150).grab(true, true).applyTo(tParent);
Composite contentCmp = new Composite(tParent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(contentCmp);
GridLayoutFactory.fillDefaults().numColumns(3).applyTo(contentCmp);
GridData labelData = new GridData(SWT.FILL, SWT.CENTER, false, false);
// 第一行,类型选择行
Label typeLbl = new Label(contentCmp, SWT.RIGHT | SWT.NONE);
typeLbl.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.typeLbl"));
typeLbl.setLayoutData(labelData);
Composite radioCmp = new Composite(contentCmp, SWT.NONE);
radioCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, SWT.DEFAULT));
radioCmp.setLayout(new GridLayout(4, false));
publicBtn = new Button(radioCmp, SWT.RADIO);
publicBtn.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.publicBtn"));
systermBtn = new Button(radioCmp, SWT.RADIO);
systermBtn.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.systermBtn"));
uriBtn = new Button(radioCmp, SWT.RADIO);
uriBtn.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.uriBtn"));
nextCataBtn = new Button(radioCmp, SWT.RADIO);
nextCataBtn.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.nextCataBtn"));
// 第二行--id行
idLbl = new Label(contentCmp, SWT.RIGHT);
idLbl.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.idLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(idLbl);
idTxt = new Text(contentCmp, SWT.BORDER);
idTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, SWT.DEFAULT));
// 第三行--url选择行
Label urlLbl = new Label(contentCmp, SWT.RIGHT);
urlLbl.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.urlLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(urlLbl);
urlTxt = new Text(contentCmp, SWT.BORDER);
urlTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
urlTxt.setEditable(false);
Button browseBtn = new Button(contentCmp, SWT.NONE);
browseBtn.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.browseBtn"));
browseBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
browseFiles();
}
public void widgetDefaultSelected(SelectionEvent e) {
browseFiles();
}
});
publicBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
displayIdTxt(true);
}
});
systermBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
displayIdTxt(true);
}
});
uriBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
displayIdTxt(true);
}
});
nextCataBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
displayIdTxt(false);
}
});
return tParent;
}
use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.
the class ErrorTipDialog method createTipsTextGroup.
private void createTipsTextGroup(Composite parent) {
Composite parentCmp = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().extendedMargins(9, 9, 0, 0).numColumns(1).applyTo(parentCmp);
GridDataFactory.fillDefaults().grab(true, true).applyTo(parentCmp);
Text text = new Text(parentCmp, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
GridDataFactory.fillDefaults().grab(true, true).applyTo(text);
text.setText(errorTip);
}
Aggregations