use of net.heartsome.cat.database.bean.ExportFilterComponentBean in project translationstudio8 by heartsome.
the class ExportFilterStoreConfiger method getFilterRule.
/**
* 获取过滤规则
* @param ruleType
* "TMX" 或者 "TBX"
* @return 空的集合或者带有内容的集合;
*/
public List<ExportFilterBean> getFilterRule(String ruleType) {
Assert.isLegal(ruleType.equals("TMX") || ruleType.equals("TBX"), Messages.getString("core.ExportFilterStoreConfiger.msg1"));
List<ExportFilterBean> filterList = new ArrayList<ExportFilterBean>();
try {
AutoPilot tempAp = new AutoPilot(vu.getVTDNav());
tempAp.selectXPath("/filter/" + ruleType + "/content");
while (tempAp.evalXPath() != -1) {
Hashtable<String, String> attrs = vu.getCurrentElementAttributs();
ExportFilterBean bean = new ExportFilterBean();
bean.setFilterType(ruleType);
bean.setFilterName(attrs.get("name"));
bean.setFilterConnector(attrs.get("type"));
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath("./option");
List<ExportFilterComponentBean> cBeanList = new ArrayList<ExportFilterComponentBean>();
while (ap.evalXPath() != -1) {
Hashtable<String, String> oAttrs = vu.getCurrentElementAttributs();
ExportFilterComponentBean cBean = new ExportFilterComponentBean(ruleType);
cBean.setOptionName(oAttrs.get("name"));
cBean.setCurrentExpression(oAttrs.get("operator"));
cBean.setFilterVlaue(oAttrs.get("value"));
cBeanList.add(cBean);
}
if (cBeanList.size() == 0) {
// deleteFilterRuleByName(bean.getFilterName(),ruleType);
continue;
}
bean.setFilterOption(cBeanList);
filterList.add(bean);
}
} catch (XPathParseException e) {
logger.error("", e);
} catch (XPathEvalException e) {
logger.error("", e);
} catch (NavException e) {
logger.error("", e);
}
return filterList;
}
use of net.heartsome.cat.database.bean.ExportFilterComponentBean in project translationstudio8 by heartsome.
the class ExportFilterComposite method handleEvent.
public void handleEvent(Event event) {
Composite parent = this.getParent();
Composite topParent = parent.getParent();
if (event.widget == addButton) {
// add button
ExportFilterComponentBean bean = new ExportFilterComponentBean(this.ruleType);
bean.setOptionName(this.baseDataBean.getOptionName());
bean.setCurrentExpression(this.baseDataBean.getCurrentExpression());
addComponent(parent, bean);
} else if (event.widget == deleteButton) {
// delete button
this.dispose();
Integer number = (Integer) parent.getData("currentNumber") - 1;
parent.setData("currentNumber", number);
if (number == 1) {
Control c = parent.getChildren()[0];
if (c instanceof ExportFilterComposite) {
ExportFilterComposite temp = (ExportFilterComposite) c;
temp.setDeleteButtonEnabled(false);
}
}
}
if (topParent instanceof ScrolledComposite) {
((ScrolledComposite) topParent).setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
parent.layout(true);
}
use of net.heartsome.cat.database.bean.ExportFilterComponentBean in project translationstudio8 by heartsome.
the class ExportFilterSettingDialog method okPressed.
@Override
protected void okPressed() {
String filterName = this.filterNameText.getText();
if (filterName == null || filterName.equals("")) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportFilterSettingDialog.msgTitle"), Messages.getString("dialog.ExportFilterSettingDialog.msg2"));
return;
}
String filterConnector = "AND";
if (isAnyCbtn.getSelection()) {
filterConnector = "OR";
}
List<ExportFilterComponentBean> filterList = new ArrayList<ExportFilterComponentBean>();
Control[] c = dynaComposite.getChildren();
for (int i = 0; i < c.length; i++) {
if (c[i] instanceof ExportFilterComposite) {
ExportFilterComposite comp = (ExportFilterComposite) c[i];
ExportFilterComponentBean bean = comp.getValue();
if (bean.getFilterVlaue() != null && !bean.getFilterVlaue().equals("")) {
filterList.add(bean);
}
}
}
if (currentFilter != null) {
// 编辑状态,策略:删除原有的内容,重新执行添加
filterStore.deleteFilterRuleByName(currentFilter.getFilterName(), currentFilter.getFilterType());
}
if (filterStore.isFilterNameExist(filterName, getRuleType())) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportFilterSettingDialog.msgTitle"), Messages.getString("dialog.ExportFilterSettingDialog.msg3"));
return;
}
if (filterList.size() == 0) {
logger.error(Messages.getString("dialog.ExportFilterSettingDialog.logger1"));
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportFilterSettingDialog.msgTitle"), Messages.getString("dialog.ExportFilterSettingDialog.msg4"));
return;
}
currentFilter = new ExportFilterBean();
currentFilter.setFilterName(filterName);
currentFilter.setFilterOption(filterList);
currentFilter.setFilterType(getRuleType());
currentFilter.setFilterConnector(filterConnector);
filterStore.saveFilterRule(currentFilter);
super.okPressed();
}
Aggregations