use of org.eclipse.jface.viewers.ISelection in project translationstudio8 by heartsome.
the class XmlConverterConfigurationDialog method initListener.
public void initListener() {
addBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
AddOrEditXmlConvertConfigDialog dialog = new AddOrEditXmlConvertConfigDialog(getShell(), true);
int result = dialog.open();
if (result == IDialogConstants.OK_ID) {
String curentConvertXMl = dialog.getCurentConverXML();
refreshTable();
setTableSelection(curentConvertXMl);
}
}
});
editBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editConfigXml();
}
});
deleteBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ISelection selection = tableViewer.getSelection();
if (!selection.isEmpty() && selection != null && selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
@SuppressWarnings("unchecked") Iterator<String[]> iter = structuredSelection.iterator();
while (iter.hasNext()) {
String convertXmlName = iter.next()[1];
String convertXmlLoaction = root.getLocation().append(ADConstants.AD_xmlConverterConfigFolder).append(convertXmlName).toOSString();
File convertXml = new File(convertXmlLoaction);
convertXml.delete();
}
refreshTable();
} else {
MessageDialog.openInformation(getShell(), Messages.getString("dialogs.XmlConverterConfigurationDialog.msgTitle"), Messages.getString("dialogs.XmlConverterConfigurationDialog.msg1"));
}
}
});
analysisBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
AnalysisXmlConvertConfigDialg dialog = new AnalysisXmlConvertConfigDialg(getShell());
int result = dialog.open();
if (result == IDialogConstants.OK_ID) {
String curentConvertXMl = dialog.getCurentConverXML();
refreshTable();
setTableSelection(curentConvertXMl);
}
}
});
}
use of org.eclipse.jface.viewers.ISelection in project translationstudio8 by heartsome.
the class XmlConverterConfigurationDialog method editConfigXml.
/**
* 编辑转换配置XML文件 ;
*/
public void editConfigXml() {
ISelection selection = tableViewer.getSelection();
if (!selection.isEmpty() && selection != null && selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
@SuppressWarnings("unchecked") Iterator<String[]> iter = structuredSelection.iterator();
String convertXml = iter.next()[1];
AddOrEditXmlConvertConfigDialog dialog = new AddOrEditXmlConvertConfigDialog(getShell(), false);
dialog.create();
String convertXmlLoaction = root.getLocation().append(ADConstants.AD_xmlConverterConfigFolder).append(convertXml).toOSString();
if (dialog.setInitEditData(convertXmlLoaction)) {
int result = dialog.open();
// 如果点击的是确定按钮,那么更新列表
if (result == IDialogConstants.OK_ID) {
String curentConvertXMl = dialog.getCurentConverXML();
refreshTable();
setTableSelection(curentConvertXMl);
}
}
} else {
MessageDialog.openInformation(getShell(), Messages.getString("dialogs.XmlConverterConfigurationDialog.msgTitle"), Messages.getString("dialogs.XmlConverterConfigurationDialog.msg2"));
}
}
use of org.eclipse.jface.viewers.ISelection 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.jface.viewers.ISelection in project translationstudio8 by heartsome.
the class PluginConfigurationDialog method editPuginConfig.
public void editPuginConfig() {
ISelection selection = tableViewer.getSelection();
if (selection != null && !selection.isEmpty() && selection instanceof StructuredSelection) {
StructuredSelection structuredSelection = (StructuredSelection) selection;
Iterator<PluginConfigBean> it = structuredSelection.iterator();
if (it.hasNext()) {
PluginConfigBean configBean = it.next();
PluginConfigManageDialog dialog = new PluginConfigManageDialog(getShell(), false);
dialog.create();
dialog.setEditInitData(configBean);
int result = dialog.open();
if (result == IDialogConstants.OK_ID) {
refreshTable(dialog.getCurPluginBean());
}
}
} else {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.PluginConfigurationDialog.msgTitle"), Messages.getString("dialog.PluginConfigurationDialog.msg1"));
}
}
use of org.eclipse.jface.viewers.ISelection in project translationstudio8 by heartsome.
the class PluginConfigManage method executePlugin.
/**
* 运行自定义的插件
* @param bean
* ;
*/
@SuppressWarnings("unchecked")
public void executePlugin(PluginConfigBean bean) {
String commandLine = bean.getCommandLine();
if (commandLine == null || "".equals(commandLine)) {
MessageDialog.openInformation(shell, Messages.getString("plugin.PluginConfigManage.msgTitle"), Messages.getString("plugin.PluginConfigManage.msg1"));
return;
}
try {
// 当输出(进程)为当前文档时
if (bean.getOutput().equals(PluginConstants.SEGMENT)) {
// 先检查是否有已经打开的文件,若没有,退出插件执行
XLIFFEditorImplWithNatTable nattable = XLIFFEditorImplWithNatTable.getCurrent();
if (nattable == null) {
MessageDialog.openInformation(shell, Messages.getString("plugin.PluginConfigManage.msgTitle"), Messages.getString("plugin.PluginConfigManage.msg2"));
return;
}
XLFHandler handler = nattable.getXLFHandler();
List<String> selectRowIds = nattable.getSelectedRowIds();
if (selectRowIds.size() <= 0) {
MessageDialog.openInformation(shell, Messages.getString("plugin.PluginConfigManage.msgTitle"), Messages.getString("plugin.PluginConfigManage.msg3"));
return;
}
if (selectRowIds.size() > 1) {
MessageDialog.openInformation(shell, Messages.getString("plugin.PluginConfigManage.msgTitle"), Messages.getString("plugin.PluginConfigManage.msg4"));
}
String rowId = selectRowIds.get(0);
sendSegment(bean, handler, rowId);
// 执行后返回的文件
String returnContent = runPlugin(bean);
// 如果返回为交换文件,则更新当前文本段
if (bean.getInput().equals(PluginConstants.EXCHANGEFILE)) {
handler.updateAndSave(rowId, "", returnContent);
// 更新完后,要刷新界面。此处未做,滞留。
}
}
// 当输出(进程)为当前文档时
if (bean.getOutput().equals(PluginConstants.DOCUMENT)) {
XLFHandler handler;
IFile selectIFile = null;
// 先检查是否有已经打开的文件,若没有,退出插件执行
XLIFFEditorImplWithNatTable nattable = XLIFFEditorImplWithNatTable.getCurrent();
if (nattable == null) {
// 如果当前没有打开的文件,那么获取左边导航框中选中的文件
ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
if (selection == null || selection.isEmpty() || !(selection instanceof StructuredSelection)) {
MessageDialog.openInformation(shell, Messages.getString("plugin.PluginConfigManage.msgTitle"), Messages.getString("plugin.PluginConfigManage.msg5"));
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Iterator<Object> selectIt = structuredSelection.iterator();
if (selectIt.hasNext()) {
Object object = selectIt.next();
if (object instanceof IFile) {
selectIFile = (IFile) object;
String fileExtension = selectIFile.getFileExtension();
if (!CommonFunction.validXlfExtension(fileExtension)) {
MessageDialog.openInformation(shell, Messages.getString("plugin.PluginConfigManage.msgTitle"), Messages.getString("plugin.PluginConfigManage.msg5"));
return;
}
}
}
handler = new XLFHandler();
// 打开该xliff文件
Map<String, Object> resultMap = handler.openFile(selectIFile.getLocation().toOSString());
if (resultMap == null || Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap.get(Constant.RETURNVALUE_RESULT)) {
MessageDialog.openInformation(shell, Messages.getString("plugin.PluginConfigManage.msgTitle"), Messages.getString("plugin.PluginConfigManage.msg5"));
return;
}
} else {
handler = nattable.getXLFHandler();
selectIFile = ResourceUtil.getFile(nattable.getEditorInput());
// IEditorInput fileInput = nattable.getEditorInput();
}
sendDocument(bean, selectIFile);
if (bean.getInput().equals(PluginConstants.DOCUMENT)) {
// 重新解析该文件
Map<String, Object> resultMap = handler.openFile(selectIFile.getLocation().toOSString());
if (resultMap == null || Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap.get(Constant.RETURNVALUE_RESULT)) {
MessageDialog.openError(shell, Messages.getString("plugin.PluginConfigManage.msgTitle"), Messages.getString("plugin.PluginConfigManage.msg6"));
return;
}
}
}
// 当输出(进程)为空时
if (bean.getOutput().equals(PluginConstants.NONE)) {
runPlugin(bean);
}
} catch (Exception e) {
LOGGER.error("", e);
MessageDialog.openError(shell, Messages.getString("plugin.PluginConfigManage.msgTitle"), Messages.getString("plugin.PluginConfigManage.msg7"));
}
}
Aggregations