use of org.eclipse.swt.events.SelectionEvent 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.events.SelectionEvent 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.events.SelectionEvent in project translationstudio8 by heartsome.
the class ExportDocxDialog method initListener.
/**
* 初始化按钮监听 ;
*/
private void initListener() {
btnBrowseXLIFF.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent event) {
FileFolderSelectionDialog dialog = new FileFolderSelectionDialog(getShell(), false, IResource.FILE) {
// 打开对话框时展开树形目录
public void create() {
super.create();
super.getTreeViewer().expandAll();
}
};
dialog.setTitle(Messages.getString("ExportDocxDialog.browseXLIFFBtn.msg0"));
dialog.setMessage(Messages.getString("ExportDocxDialog.browseXLIFFBtn.msg1"));
dialog.setDoubleClickSelects(true);
dialog.setAllowMultiple(false);
try {
dialog.setInput(EFS.getStore(root.getLocationURI()));
} catch (CoreException e1) {
LOGGER.error(Messages.getString("ExportDocxDialog.logger.getXliffError"), e1);
MessageDialog.openInformation(getShell(), Messages.getString("all.dialog.ok.title"), Messages.getString("ExportDocxDialog.browseXLIFFBtn.msg2"));
}
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof LocalFile) {
LocalFile folder = (LocalFile) element;
if (folder.getName().equalsIgnoreCase(".hsConfig") || folder.getName().equalsIgnoreCase(".metadata")) {
return false;
}
if (lstProject.contains(folder.toString())) {
return true;
}
String xliffFolderPath = folder.toString();
for (String projectPath : lstProject) {
String path1 = projectPath + System.getProperty("file.separator") + Constant.FOLDER_XLIFF;
if (xliffFolderPath.startsWith(path1)) {
return true;
}
}
}
return false;
}
});
dialog.create();
dialog.open();
if (dialog.getResult() != null) {
Object obj = dialog.getFirstResult();
IFile file = root.getFileForLocation(Path.fromOSString(obj.toString()));
xliffPathTxt.setText(file.getFullPath().toOSString());
strXliffFullPath = ResourceUtils.iFileToOSPath(file);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
browseDocxBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setText(Messages.getString("ExportDocxDialog.browseDocxBtn.msg0"));
String defaultPath = System.getProperty("user.home");
if (docxPathTxt.getText() != null && !docxPathTxt.getText().trim().equals("")) {
defaultPath = docxPathTxt.getText();
}
dialog.setFilterPath(defaultPath);
String path = dialog.open();
if (path != null) {
docxPathTxt.setText(path);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
excludeBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
boolean isSelection = excludeBtn.getSelection();
excludeGroup.setEnabled(isSelection);
excludeLockedBtn.setEnabled(isSelection);
exclude101Btn.setEnabled(isSelection);
exclude100Btn.setEnabled(isSelection);
onlyExportGroup.setEnabled(!isSelection);
onlyExportNoteBtn.setEnabled(!isSelection);
onlyExportReviewBtn.setEnabled(!isSelection);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
onlyExportBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
boolean isSelection = onlyExportBtn.getSelection();
excludeGroup.setEnabled(!isSelection);
excludeLockedBtn.setEnabled(!isSelection);
exclude101Btn.setEnabled(!isSelection);
exclude100Btn.setEnabled(!isSelection);
onlyExportGroup.setEnabled(isSelection);
onlyExportNoteBtn.setEnabled(isSelection);
onlyExportReviewBtn.setEnabled(isSelection);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class SrxMapRulesManageDialog method initListener.
public void initListener() {
addBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
AddOrEditMapRuleOfSrxDialog dialog = new AddOrEditMapRuleOfSrxDialog(getShell(), true, mapRulesList, handler, srxLocation);
int result = dialog.open();
if (result == IDialogConstants.OK_ID) {
refreshTable(dialog.getCurMapRuleBean());
}
}
});
editBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editMapRule();
}
});
deleteBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ISelection selection = tableViewer.getSelection();
if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) {
boolean respose = MessageDialog.openConfirm(getShell(), Messages.getString("srx.SrxMapRulesManageDialog.msgTitle"), Messages.getString("srx.SrxMapRulesManageDialog.msg1"));
if (!respose) {
return;
}
StructuredSelection structSelection = (StructuredSelection) selection;
@SuppressWarnings("unchecked") Iterator<MapRuleBean> it = structSelection.iterator();
while (it.hasNext()) {
mapRulesList.remove(it.next());
}
refreshTable(null);
} else {
MessageDialog.openInformation(getShell(), Messages.getString("srx.SrxMapRulesManageDialog.msgTitle2"), Messages.getString("srx.SrxMapRulesManageDialog.msg2"));
}
}
});
}
use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.
the class ExportExternalDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridDataFactory.createFrom(new GridData(GridData.FILL_BOTH)).hint(600, SWT.DEFAULT).applyTo(tparent);
final Group groupFile = new Group(tparent, SWT.NONE);
groupFile.setText(Messages.getString("ExportDocxDialog.lable.xliff"));
groupFile.setLayout(new GridLayout(1, false));
groupFile.setLayoutData(new GridData(GridData.FILL_BOTH));
final TableViewer tbv = new TableViewer(groupFile, SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
final Table table = tbv.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 90).applyTo(table);
tableLayout.addColumnData(new ColumnWeightData(1));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.nodot"));
tableLayout.addColumnData(new ColumnWeightData(10));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.fullPath"));
tableLayout.addColumnData(new ColumnWeightData(2));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.srcLang"));
tableLayout.addColumnData(new ColumnWeightData(2));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.tgtLang"));
tbv.setLabelProvider(new TableViewLabelProvider());
tbv.setContentProvider(new ArrayContentProvider());
tbv.setInput(xlfBeans);
final Group groupExportType = new Group(tparent, SWT.NONE);
groupExportType.setText(Messages.getString("ExportDocxDialog.lable.exporttype"));
groupExportType.setLayout(new GridLayout(3, false));
groupExportType.setLayoutData(new GridData(GridData.FILL_BOTH));
final Label lblExportType = new Label(groupExportType, SWT.NONE);
lblExportType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblExportType.setText(Messages.getString("ExportDocxDialog.lable.exportchoose"));
cmb = new Combo(groupExportType, SWT.NONE | SWT.READ_ONLY);
GridDataFactory.swtDefaults().span(2, 1).grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(cmb);
for (String type : ExportExternal.getExportTypes()) {
cmb.add(type);
}
cmb.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final int exportCode = ExportExternal.getExportTypeCode(cmb.getSelectionIndex());
btnHsproofNote.setEnabled(exportCode == ExportExternal.EXPORT_HSPROOF);
btnHsproofState.setEnabled(btnHsproofNote.getEnabled());
btnNotrans.setEnabled(exportCode != ExportExternal.EXPORT_TMX && btnFilterWhenState.getSelection());
if (ExportExternal.EXPORT_TMX == exportCode && btnFilterWhenState.getSelection()) {
btnNotrans.setSelection(false);
}
}
});
final Label lblR8State = new Label(groupExportType, SWT.NONE);
lblR8State.setText(Messages.getString("ExportDocxDialog.lable.hsproof"));
btnHsproofState = new Button(groupExportType, SWT.CHECK);
btnHsproofState.setText(Messages.getString("ExportDocxDialog.statusBtn"));
btnHsproofNote = new Button(groupExportType, SWT.CHECK);
btnHsproofNote.setText(Messages.getString("ExportDocxDialog.commentBtn"));
final Group groupFilter = new Group(tparent, SWT.NONE);
groupFilter.setText(Messages.getString("ExportDocxDialog.lable.filter"));
groupFilter.setLayout(new GridLayout(3, false));
groupFilter.setLayoutData(new GridData(GridData.FILL_BOTH));
// 过滤大类
btnAllTrans = new Button(groupFilter, SWT.RADIO);
btnAllTrans.setText(Messages.getString("ExportDocxDialog.lable.filterAll"));
btnAllTrans.setSelection(true);
btnAllTrans.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnAllTrans.getSelection()) {
setFilterDefaultValue();
}
}
});
btnOnlySpecial = new Button(groupFilter, SWT.RADIO);
btnOnlySpecial.setText(Messages.getString("ExportDocxDialog.onlyExportBtn"));
btnOnlySpecial.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnOnlySpecial.getSelection()) {
setFilterDefaultValue();
}
}
;
});
btnFilterWhenState = new Button(groupFilter, SWT.RADIO);
btnFilterWhenState.setText(Messages.getString("ExportDocxDialog.lable.hasState"));
btnFilterWhenState.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnFilterWhenState.getSelection()) {
setFilterDefaultValue();
}
}
;
});
// 大类细节
cmpFilterAllTrans = new Composite(groupFilter, SWT.NONE);
cmpFilterAllTrans.setLayout(new GridLayout(1, false));
cmpFilterAllTrans.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
btnExceptLocked = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptLocked.setText(Messages.getString("ExportDocxDialog.lable.exceptLock"));
btnExceptLocked.setEnabled(true);
btnExceptContextMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptContextMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptCxtMatch"));
btnExceptContextMatch.setEnabled(true);
btnExceptFullMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptFullMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptFullMatch"));
cmpFilterOnlySpecial = new Composite(groupFilter, SWT.NONE);
cmpFilterOnlySpecial.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
cmpFilterOnlySpecial.setLayout(new GridLayout(1, false));
btnHasNote = new Button(cmpFilterOnlySpecial, SWT.CHECK);
btnHasNote.setText(Messages.getString("ExportDocxDialog.onlyExportNoteBtn"));
btnNeedReview = new Button(cmpFilterOnlySpecial, SWT.CHECK);
btnNeedReview.setText(Messages.getString("ExportDocxDialog.onlyExportReviewBtn"));
cmpFilterWhenState = new Composite(groupFilter, SWT.NONE);
cmpFilterWhenState.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
cmpFilterWhenState.setLayout(new GridLayout(1, false));
btnNotrans = new Button(cmpFilterWhenState, SWT.CHECK);
btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
btnNewtrans = new Button(cmpFilterWhenState, SWT.CHECK);
btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
btnTransed = new Button(cmpFilterWhenState, SWT.CHECK);
btnTransed.setText(Messages.getString("ExportDocxDialog.lable.state.hasTrans"));
btnApproved = new Button(cmpFilterWhenState, SWT.CHECK);
btnApproved.setText(Messages.getString("ExportDocxDialog.lable.state.hasApprove"));
Composite cmpSaveas = new Composite(tparent, SWT.NONE);
cmpSaveas.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());
cmpSaveas.setLayoutData(new GridData(GridData.FILL_BOTH));
Label lblSaveas = new Label(cmpSaveas, SWT.NONE);
lblSaveas.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblSaveas.setText(Messages.getString("ExportDocxDialog.lable.saveas"));
txtSaveas = new Text(cmpSaveas, SWT.BORDER | SWT.READ_ONLY);
txtSaveas.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtSaveas.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getButton(IDialogConstants.OK_ID).setEnabled(!txtSaveas.getText().isEmpty());
}
});
Button btnSaveas = new Button(cmpSaveas, SWT.NONE);
btnSaveas.setText(Messages.getString("ExportDocxDialog.browseDocxBtn"));
btnSaveas.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setFilterPath(dialogSetting.get("defaultPath"));
String path = dialog.open();
if (path != null) {
txtSaveas.setText(path);
dialogSetting.put("defaultPath", path);
}
}
});
setDefaultValue();
return parent;
}
Aggregations