package com.vci.client.auth2.utils;
|
|
import java.awt.GridBagConstraints;
|
import java.awt.GridBagLayout;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.awt.event.ItemEvent;
|
import java.awt.event.ItemListener;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.Iterator;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Map.Entry;
|
import java.util.Set;
|
|
import javax.swing.DefaultListModel;
|
import javax.swing.JButton;
|
import javax.swing.JCheckBox;
|
import javax.swing.JComboBox;
|
import javax.swing.JDialog;
|
import javax.swing.JLabel;
|
import javax.swing.JList;
|
import javax.swing.JOptionPane;
|
import javax.swing.JPanel;
|
import javax.swing.JRadioButton;
|
import javax.swing.JTable;
|
import javax.swing.JTextField;
|
import javax.swing.ListModel;
|
import javax.swing.table.JTableHeader;
|
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumnModel;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreeSelectionModel;
|
|
import org.dom4j.Document;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.auth2.model.BooleanTableModel;
|
import com.vci.client.auth2.view.AbstractUIFunclet;
|
import com.vci.client.auth2.view.OrdinaryOpPanel;
|
import com.vci.client.auth2.view.RelationAndLifeCycleOpPanel;
|
import com.vci.client.auth2.vo.OpItem;
|
import com.vci.client.auth2.vo.SelectedSubjectItem;
|
import com.vci.client.omd.btm.wrapper.BtmItemWrapper;
|
import com.vci.client.omd.provider.BtmProvider;
|
import com.vci.client.omd.provider.LifeCycleProvider;
|
import com.vci.client.omd.provider.LinkTypeProvider;
|
import com.vci.client.oq.ui.ConditionPanel;
|
import com.vci.client.common.ClientLog4j;
|
import com.vci.client.common.oq.OQTool;
|
import com.vci.client.common.providers.ServiceProvider;
|
import com.vci.common.qt.object.QueryTemplate;
|
import com.vci.common.qt.object.Symbol;
|
//import com.vci.corba.auth2.Auth2ServicePrx;
|
import com.vci.corba.framework.data.GrandValue;
|
import com.vci.corba.framework.FrameworkServicePrx;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.omd.btm.BtmItem;
|
import com.vci.corba.omd.lcm.LifeCycle;
|
import com.vci.corba.omd.lcm.TransitionVO;
|
import com.vci.corba.omd.ltm.LinkType;
|
import com.vci.corba.omd.qtm.QTD;
|
import com.vci.corba.omd.qtm.QTInfo;
|
import com.vci.corba.portal.data.PLAction;
|
|
public class RightManagerHelper {
|
// private static FrameworkServicePrx frameService = null;
|
//
|
// public static FrameworkServicePrx getFrameworkService() throws VCIError {
|
// if (frameService != null) {
|
// return frameService;
|
// }
|
// try {
|
//
|
// return frameService = ServiceProvider.getFrameService();
|
// } catch (Exception e) {
|
// ClientLog4j.logger.error(e.getMessage(), e);
|
// throw new VCIError("1", new String[] { e.getMessage() });
|
// }
|
// }
|
|
|
public static BtmItem getResourceType(AbstractUIFunclet funclet) {
|
TreeSelectionModel model = (TreeSelectionModel) funclet.getResourceTree().getSelectionModel();
|
TreePath path = model.getSelectionPath();
|
if (null == path) {
|
return null;
|
}
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
|
if (!(node.getUserObject() instanceof BtmItemWrapper)) {
|
return null;
|
}
|
// 类型信息
|
BtmItemWrapper btmWrap = (BtmItemWrapper) node.getUserObject();
|
if (null == btmWrap || btmWrap.btmItem == null) {
|
return null;
|
}
|
return btmWrap.btmItem;
|
}
|
|
public static GrandValue[] getRightDatas(String typeName) {
|
GrandValue[] dataSets = null;
|
try {
|
dataSets = ServiceProvider.getFrameService().queryGrand(typeName);
|
} catch (Throwable e) {
|
JOptionPane.showMessageDialog(LogonApplication.frame,
|
((VCIError) e).messages[0], "错误提示", JOptionPane.ERROR_MESSAGE);
|
return dataSets;
|
}
|
return dataSets;
|
}
|
|
public static void setRuleListDatas(AbstractUIFunclet funclet, GrandValue[] values, String typeName) {
|
BooleanTableModel ruleModel = (BooleanTableModel) funclet.getRightMainPanel().getRuleTable().getModel();
|
// 刷新页面缓存
|
funclet.getRightMainPanel().getRuleTable().removeAll();
|
// ruleModel.RemoveAllConditionValue();
|
setRuleTableHeader(funclet, values, typeName); // add by caill 2015.12.18 增加参数typeName
|
setColunmData(funclet, values, typeName); // add by caill 2015.12.18 增加参数typeName
|
funclet.getRightMainPanel().getRuleTable().setModel(ruleModel);
|
}
|
|
private static void setColunmData(AbstractUIFunclet funclet, GrandValue[] values, String typeName) {
|
BooleanTableModel ruleModel = (BooleanTableModel) funclet.getRightMainPanel().getRuleTable().getModel();
|
// 依据规则名称,规则分类
|
Map<String, List<GrandValue>> splitRuleMap = splitRuleByName(values);
|
// 依据规则名称
|
int row = 0;
|
// 设置规则记录行数
|
ruleModel.setRowCount(splitRuleMap.size());
|
// add by caill start 2016.1.11 得到btm、link、lifeCyles
|
LinkType[] links = null;
|
LifeCycle lifeCycle = null;
|
BtmItem btm = null;
|
try {
|
btm = BtmProvider.getInstance().getBtmItemByName(typeName);
|
links = LinkTypeProvider.getInstance().getLinkTypeByBtmName(btm.name, Symbol.FROM);
|
LifeCycle[] lifeCyles = LifeCycleProvider.getInstance().getLifeCyles();
|
for (int m = 0; m < lifeCyles.length; m++) {
|
if (lifeCyles[m].name.equals(btm.lifeCycle)) {
|
lifeCycle = lifeCyles[m];
|
break;
|
}
|
}
|
} catch (Throwable e) {
|
e.printStackTrace();
|
}
|
|
// add by caill end
|
ActionConstants act = new ActionConstants();
|
PLAction[] allActions = act.getAllPLActionEntityByType(typeName);
|
for (Iterator<Map.Entry<String, List<GrandValue>>> iter = splitRuleMap.entrySet().iterator(); iter.hasNext();) {
|
Entry<String, List<GrandValue>> entry = iter.next();
|
List<GrandValue> rules = entry.getValue();
|
|
// 增加页面缓存
|
ruleModel.setConditionValue(row, rules);
|
// add by caill start 2015 12.18 将查出的action放到map中,注意不要落下“查询”
|
Map<String, String> actionMap = new HashMap<String, String>();
|
actionMap.put("query", "查询"); // 将操作中的query放入actionMap中
|
for (int i = 0; i < allActions.length; i++) {
|
if (allActions[i].plTypeType.equals("business")) {
|
actionMap.put(allActions[i].plCode, allActions[i].plName); // 将操作放入actionMap中
|
}
|
}
|
for (int j = 0; j < links.length; j++) {
|
for (int i = 0; i < allActions.length; i++) {
|
if (allActions[i].plTypeType.equals("link")) {
|
actionMap.put(links[j].name + "." + allActions[i].plCode,
|
links[j].name + "." + allActions[i].plName);// 将关系放入actionMap中
|
}
|
}
|
actionMap.put(links[j].name + "." + "query", links[j].name + "." + "查询"); // 将关系中的query放入actionMap中
|
}
|
|
TransitionVO[] transitions = lifeCycle != null ? lifeCycle.routes : new TransitionVO[0];
|
for (int j = 0; j < transitions.length; j++) {
|
String name = lifeCycle.name + "." + transitions[j].connect;
|
actionMap.put(name, name); // 将跃迁放入actionMap中
|
}
|
// add by caill end
|
for (int j = 0; j < rules.size(); j++) {
|
// 规则名和类型
|
ruleModel.setValueAt(rules.get(j).ruleName, row, 0);
|
if (rules.get(j).ruleType.equals(IRightConstant.RULETYPE__HAS)) {
|
ruleModel.setValueAt("允许规则", row, 1);
|
} else if (rules.get(j).ruleType.equals(IRightConstant.RULETYPE__NOTHAS)) {
|
ruleModel.setValueAt("拒绝规则", row, 1);
|
} else if (rules.get(j).ruleType.equals(IRightConstant.RULETYPE_ALL_HAS)) {
|
ruleModel.setValueAt("全部有权", row, 1);
|
} else {
|
ruleModel.setValueAt("全部无权", row, 1);
|
}
|
// 指定的操作赋值
|
TableColumnModel columnModel = funclet.getRightMainPanel().getRuleTable().getColumnModel();
|
int start = rules.get(j).identifier.lastIndexOf("_") + 1;
|
String op = rules.get(j).identifier.substring(start, rules.get(j).identifier.length());
|
// add by caill start 2015.12.18 遍历map,根据英文名称找到相应的中文名称,并根据中文名称找到对应的列
|
String headerName = null;
|
Set<String> keys = null;
|
if (actionMap.size() > 0) {
|
keys = actionMap.keySet();
|
}
|
if (keys.size() != 0) {
|
for (Iterator<String> iterator = keys.iterator(); iterator.hasNext();) {
|
String key = iterator.next();
|
if (op.equals(key)) {
|
headerName = actionMap.get(key);
|
break;
|
}
|
}
|
}
|
|
int columnIndex = -1;
|
if (headerName != null) {
|
columnIndex = columnModel.getColumnIndex(headerName);
|
}
|
// add by caill end
|
// int columnIndex = columnModel.getColumnIndex(op);
|
if (columnIndex >= 0) {
|
ruleModel.setValueAt(rules.get(j).isGrand == '1' ? true : false, row, columnIndex);
|
}
|
|
}
|
++row;
|
}
|
}
|
|
private static Map<String, List<GrandValue>> splitRuleByName(GrandValue[] values) {
|
Map<String, List<GrandValue>> splitRuleMap = new HashMap<String, List<GrandValue>>();
|
for (int i = 0; i < values.length; i++) {
|
if (splitRuleMap.get(values[i].ruleName) == null) {
|
List<GrandValue> ruleOfOneName = new ArrayList<GrandValue>();
|
ruleOfOneName.add(values[i]);
|
splitRuleMap.put(values[i].ruleName, ruleOfOneName);
|
} else {
|
splitRuleMap.get(values[i].ruleName).add(values[i]);
|
}
|
|
}
|
return splitRuleMap;
|
|
}
|
|
private static void setRuleTableHeader(AbstractUIFunclet funclet, GrandValue[] values, String typeName) {
|
BooleanTableModel ruleModel = (BooleanTableModel) funclet.getRightMainPanel().getRuleTable().getModel();
|
// 操作信息
|
List<String> ops = new ArrayList<String>();
|
for (int i = 0; i < values.length; i++) {
|
int start = values[i].identifier.lastIndexOf("_") + 1;
|
String op = values[i].identifier.substring(start, values[i].identifier.length());
|
if (!ops.contains(op)) {
|
ops.add(op);
|
}
|
}
|
// 操作信息
|
String[] operations = ops.toArray(new String[ops.size()]);
|
// 设置Table列头信息
|
List<String> tableHeader = new ArrayList<String>();
|
List<String> tablerule = new ArrayList<String>();
|
tableHeader.add("规则名称");
|
tableHeader.add("规则类型");
|
|
// add by caill start 2015.12.18 将中文名称装入表头
|
ActionConstants act = new ActionConstants();
|
PLAction[] allActions = act.getAllPLActionEntityByType(typeName);
|
for (int m = 0; m < operations.length; m++) {
|
if (allActions != null && allActions.length != 0) {
|
for (int i = 0; i < allActions.length; i++) {
|
if (allActions[i].plCode.equals(operations[m])) {
|
tableHeader.add(allActions[i].plName);
|
break;
|
} else if (operations[m].endsWith("." + allActions[i].plCode)) {
|
int index = operations[m].indexOf("." + allActions[i].plCode);
|
StringBuilder sb = new StringBuilder(operations[m]);
|
StringBuilder actionChina = sb.replace(index + 1, operations[m].length(), allActions[i].plName);
|
tableHeader.add(actionChina.toString());
|
break;
|
} else if (operations[m].equals("query")) {
|
tableHeader.add("查询"); // 注意不要落下写死的“查询”
|
break;
|
} else if (operations[m].endsWith(".query")) {
|
int index = operations[m].indexOf(".query");
|
StringBuilder sb = new StringBuilder(operations[m]);
|
StringBuilder actionChina = sb.replace(index + 1, operations[m].length(), "查询");
|
tableHeader.add(actionChina.toString());
|
break;
|
}
|
|
}
|
/*
|
* if(sign == allActions.length){ tableHeader.add(operations[m]); }
|
*/
|
} else {
|
if (operations[m].equals("query")) {
|
tableHeader.add("查询"); // 注意不要落下写死的“查询”
|
}
|
if (operations[m].endsWith(".query")) {
|
int index = operations[m].indexOf(".query");
|
StringBuilder sb = new StringBuilder(operations[m]);
|
StringBuilder actionChina = sb.replace(index + 1, operations[m].length(), "查询");
|
tableHeader.add(actionChina.toString());
|
}
|
}
|
|
}
|
LifeCycle lifeCycle = null;
|
BtmItem btm = null;
|
try {
|
btm = BtmProvider.getInstance().getBtmItemByName(typeName);
|
// links = ClientCacheFacade.getInstance().getLinkType(btm.name,
|
// ICacheConstant.Direction_From);
|
LifeCycle[] lifeCyles = LifeCycleProvider.getInstance().getLifeCyles();
|
for (int j = 0; j < lifeCyles.length; j++) {
|
if (lifeCyles[j].name.equals(btm.lifeCycle)) {
|
lifeCycle = lifeCyles[j];
|
break;
|
}
|
}
|
} catch (Throwable e) {
|
e.printStackTrace();
|
}
|
TransitionVO[] transitions = lifeCycle != null ? lifeCycle.routes : new TransitionVO[0];
|
for (int j = 0; j < transitions.length; j++) {
|
tableHeader.add(lifeCycle.name + "." + transitions[j].connect);
|
}
|
// add by caill end
|
// ruleModel.setColumnCount(tableHeader.size());
|
ruleModel.setColumnIdentifiers(tableHeader.toArray(new String[tableHeader.size()]));
|
// 设置列宽
|
// JTable table = funclet.getRightMainPanel().getRuleTable();
|
// TableColumnModel columnModel = table.getColumnModel();
|
// double maxWidth = 0;
|
// for (int i = 0; i < columnModel.getColumnCount(); i++) {
|
// TableColumn column = columnModel.getColumn(i);
|
// TableCellRenderer cellRenderer = column.getHeaderRenderer();
|
// if (cellRenderer == null)
|
// cellRenderer = table.getDefaultRenderer(columnModel
|
// .getColumn(i).getClass());
|
// Object headerValue = column.getHeaderValue();
|
// Component columnComp = cellRenderer.getTableCellRendererComponent(
|
// (JTable) table, headerValue, false, false, 0, i);
|
//
|
// maxWidth = Math.max(maxWidth, columnComp.getPreferredSize()
|
// .getWidth());
|
// }
|
// JTableHeader jtableHeader = table.getTableHeader();
|
//
|
// Dimension size = jtableHeader.getPreferredSize();
|
// size.width = (int) maxWidth;
|
// jtableHeader.setPreferredSize(size);
|
// int i =columnModel.getTotalColumnWidth();
|
setPreferSizeColumnWidth(funclet);
|
|
}
|
|
public static void setPreferSizeColumnWidth(AbstractUIFunclet funclet) {
|
JTable table = funclet.getRightMainPanel().getRuleTable();
|
JTableHeader jtableHeader = table.getTableHeader();
|
TableColumnModel columnModel = table.getColumnModel();
|
// double maxWidth = 0;
|
for (int i = 0; i < columnModel.getColumnCount(); i++) {
|
TableColumn column = columnModel.getColumn(i);
|
int col = jtableHeader.getColumnModel().getColumnIndex(column.getIdentifier());
|
int width = (int) jtableHeader.getDefaultRenderer()
|
.getTableCellRendererComponent(table, column.getIdentifier(), false, false, -1, col)
|
.getPreferredSize().getWidth();
|
for (int row = 0; row < table.getRowCount(); row++) {
|
int preferSize = (int) table.getCellRenderer(row, col)
|
.getTableCellRendererComponent(table, table.getValueAt(row, col), false, false, row, col)
|
.getPreferredSize().getWidth();
|
width = Math.max(width, preferSize);
|
}
|
jtableHeader.setResizingColumn(column);
|
column.setWidth(width + table.getIntercellSpacing().width);
|
}
|
}
|
|
public static void setRuleConditionDatas(AbstractUIFunclet funclet, int selectedRow, GrandValue value,
|
String typeName) {
|
if (value == null) {
|
return;
|
}
|
// 设置规则的类型(会触发事件)
|
funclet.getRightMainPanel().setRuleType(value.ruleType);
|
if (value.ruleType.equals(IRightConstant.RULETYPE__NOTHAS)
|
|| value.ruleType.equals(IRightConstant.RULETYPE__HAS)) {
|
ConditionPanel conditonPanel = (ConditionPanel) funclet.getRightMainPanel().getRightRulePanel();
|
if ((conditonPanel instanceof ConditionPanel)) {
|
if ((conditonPanel.getRadioBtm().isSelected() && isBtm(funclet, value))
|
|| conditonPanel.getRadioLinkType().isSelected() && !isBtm(funclet, value)) {
|
// 重新绘制表达式面板
|
((ConditionPanel) conditonPanel).setQTUI(getQtWraper(value, typeName, conditonPanel));
|
// 刷新界面
|
((ConditionPanel) conditonPanel).updateUI();
|
}
|
addRadioListener(funclet, selectedRow, typeName, conditonPanel.getRadioBtm());
|
addRadioListener(funclet, selectedRow, typeName, conditonPanel.getRadioLinkType());
|
}
|
}
|
// 设置规则的名称
|
funclet.getRightMainPanel().getRuleNameTextField().setText(value.ruleName);
|
}
|
|
private static boolean isBtm(AbstractUIFunclet funclet, GrandValue value) {
|
ConditionPanel conditonPanel = (ConditionPanel) funclet.getRightMainPanel().getRightRulePanel();
|
int flag = conditonPanel.getRadioFlag();
|
if ((flag == 0 && value != null && value.ruleText != null && !value.ruleText.equals(""))
|
|| (flag == 1 && value != null && value.seniorRuleText != null && !value.seniorRuleText.equals(""))) {
|
return true;
|
}
|
return false;
|
}
|
|
private static void addRadioListener(final AbstractUIFunclet funclet, final int selectedRow, final String typeName,
|
JRadioButton radioBtn) {
|
// 设置radio的监听事件(保留最初的监听)
|
ItemListener[] ls = radioBtn.getItemListeners();
|
List<ItemListener> oldLs = new ArrayList<ItemListener>();
|
ItemListener old = ls[0];
|
for (int i = 0; i < ls.length; i++) {
|
oldLs.add(ls[i]);
|
}
|
|
for (int j = 0; j < oldLs.size(); j++) {
|
radioBtn.removeItemListener(oldLs.get(j));
|
}
|
|
radioBtn.addItemListener(new ItemListener() {
|
@Override
|
public void itemStateChanged(ItemEvent e) {
|
try {
|
BooleanTableModel ruleModel = (BooleanTableModel) funclet.getRightMainPanel().getRuleTable()
|
.getModel();
|
GrandValue value = ((List<GrandValue>) ruleModel.getConditionValueAt(selectedRow)).get(0);
|
BtmItem btm = RightManagerHelper.getResourceType(funclet);
|
if (btm == null || value == null) {
|
return;
|
}
|
// 重新绘制表达式面板
|
ConditionPanel conditonPanel = (ConditionPanel) funclet.getRightMainPanel().getRightRulePanel();
|
if ((conditonPanel.getRadioBtm().isSelected() && isBtm(funclet, value))
|
|| conditonPanel.getRadioLinkType().isSelected() && !isBtm(funclet, value)) {
|
// 刷新规则面板数据
|
conditonPanel.setQTUI(getQtWraper(value, typeName, conditonPanel));
|
// 刷新界面
|
conditonPanel.updateUI();
|
}
|
} catch (Exception ex) {
|
ex.printStackTrace();
|
}
|
}
|
});
|
radioBtn.addItemListener(old);
|
}
|
|
private static QTInfo getQtWraper(GrandValue value, String typeName, ConditionPanel conditonPanel) {
|
QTInfo qtWrapper = new QTInfo();
|
qtWrapper.btmName = typeName;
|
qtWrapper.qtName = value.ruleName;
|
// 业务类型
|
if (!conditonPanel.isLinkTypeSelected()) {
|
qtWrapper.qtText = value.ruleText;
|
qtWrapper.qtUIText = value.seniorRuleText;
|
if (value.seniorRuleText == null || value.seniorRuleText.equals(""))
|
qtWrapper.levelFlag = 0;
|
else
|
qtWrapper.levelFlag = 1;
|
} else {
|
// 链接类型
|
qtWrapper.qtText = value.lruleText;
|
qtWrapper.qtUIText = value.lseniorRuleText;
|
if (value.lseniorRuleText == null || value.lseniorRuleText.equals(""))
|
qtWrapper.levelFlag = 0;
|
else
|
qtWrapper.levelFlag = 1;
|
}
|
return qtWrapper;
|
}
|
|
public static void setSubjectDatas(AbstractUIFunclet funclet, GrandValue value) {
|
JList selectedSubjects = funclet.getRightMainPanel().getSelectedSubjectComponent();
|
Object[] users = value.users.split(",");
|
Object[] roles = value.roles.split(",");
|
Object[] userGroups = value.userGroups.split(",");
|
ListModel selectListModel = (ListModel) selectedSubjects.getModel();
|
// 初始化数据模型,清空数据
|
selectListModel = new DefaultListModel();
|
((DefaultListModel) selectListModel).setSize(users.length + roles.length + userGroups.length);
|
for (int i = 0; i < users.length; i++) {
|
if (users[i] != null && !users[i].equals("")) {
|
SelectedSubjectItem item = new SelectedSubjectItem();
|
item.setCode((String) (users[i]));
|
item.setName((String) (users[i]));
|
item.setType(IRightConstant.User);
|
((DefaultListModel) selectListModel).setElementAt(item, i);
|
}
|
|
}
|
for (int i = users.length; i < users.length + roles.length; i++) {
|
if (roles[i - users.length] != null && !roles[i - users.length].equals("")) {
|
SelectedSubjectItem item = new SelectedSubjectItem();
|
item.setCode((String) roles[i - users.length]);
|
item.setName((String) roles[i - users.length]);
|
item.setType(IRightConstant.Role);
|
|
((DefaultListModel) selectListModel).setElementAt(item, i);
|
}
|
}
|
|
for (int i = users.length + roles.length; i < users.length + roles.length + userGroups.length; i++) {
|
if (userGroups[i - users.length - roles.length] != null
|
&& !userGroups[i - users.length - roles.length].equals("")) {
|
SelectedSubjectItem item = new SelectedSubjectItem();
|
item.setCode((String) userGroups[i - users.length - roles.length]);
|
item.setName((String) userGroups[i - users.length - roles.length]);
|
item.setType(IRightConstant.UserGroup);
|
|
((DefaultListModel) selectListModel).setElementAt(item, i);
|
}
|
}
|
selectedSubjects.setModel(selectListModel);
|
int selected[] = new int[users.length + roles.length + userGroups.length];
|
for (int i = 0; i < users.length; i++) {
|
selected[i] = i;
|
}
|
for (int i = users.length; i < users.length + roles.length; i++) {
|
selected[i] = i;
|
|
}
|
for (int i = users.length + roles.length; i < users.length + roles.length + userGroups.length; i++) {
|
selected[i] = i;
|
|
}
|
selectedSubjects.setSelectedIndices(selected);
|
selectedSubjects.updateUI();
|
}
|
|
public static List<GrandValue> fillOperationsInfo(AbstractUIFunclet funclet, String typeName) {
|
List<GrandValue> values = new ArrayList<GrandValue>();
|
// 一般操作信息
|
OpItem[] ops = ((OrdinaryOpPanel) funclet.getRightMainPanel().getOrdinaryOpPanel()).getOpObject();
|
// 关系和跃迁
|
OpItem[] rlops = ((RelationAndLifeCycleOpPanel) funclet.getRightMainPanel().getRelationAndLifeCycleOpPanel())
|
.getOpObject();
|
for (OpItem op : ops) {
|
GrandValue value = new GrandValue();
|
value.identifier = typeName + "_" + op.getName();
|
value.ID = "";
|
value.isGrand = (((Boolean) op.getValue()) == false ? (byte)'0' : (byte)'1');
|
values.add(value);
|
}
|
// 关系和跃迁
|
for (OpItem op : rlops) {
|
GrandValue value = new GrandValue();
|
value.identifier = typeName + "_" + op.getName();
|
value.ID = "";
|
value.isGrand = (((Boolean) op.getValue()) == false ? (byte)'0' : (byte)'1');
|
values.add(value);
|
}
|
return values;
|
|
}
|
|
public static boolean fillSubjectInfo(AbstractUIFunclet funclet, List<GrandValue> values) {
|
|
JList selectedSubjects = funclet.getRightMainPanel().getSelectedSubjectComponent();
|
Object[] subjects = selectedSubjects.getSelectedValues();
|
|
if (subjects == null || subjects.length == 0) {
|
JOptionPane.showMessageDialog(com.vci.client.LogonApplication.frame, "请选择授权主体信息", "提示",
|
JOptionPane.INFORMATION_MESSAGE);
|
return false;
|
}
|
|
// user
|
StringBuffer user = new StringBuffer("");
|
// role
|
StringBuffer role = new StringBuffer("");
|
// roleGroup
|
StringBuffer userGroup = new StringBuffer("");
|
for (int i = 0; i < subjects.length; i++) {
|
SelectedSubjectItem vec = (SelectedSubjectItem) subjects[i];
|
if (vec == null) {
|
continue;
|
}
|
if (vec.getType().equals(IRightConstant.User)) {
|
user.append(vec.getCode()).append(",");
|
} else if (vec.getType().equals(IRightConstant.Role)) {
|
role.append(vec.getCode()).append(",");
|
} else {
|
userGroup.append(vec.getCode()).append(",");
|
}
|
}
|
|
for (int i = 0; i < values.size(); i++) {
|
values.get(i).roles = role.length() == 0 ? "" : role.toString();
|
values.get(i).users = user.length() == 0 ? "" : user.toString();
|
values.get(i).userGroups = userGroup.length() == 0 ? "" : userGroup.toString();
|
}
|
return true;
|
}
|
|
public static boolean fillObjectInfo(AbstractUIFunclet funclet, List<GrandValue> values) {
|
JPanel conditionPanel = funclet.getRightMainPanel().getRightRulePanel();
|
QueryTemplate qt = null;
|
if ((conditionPanel instanceof ConditionPanel)) {
|
ConditionPanel conditionPane = ((ConditionPanel) conditionPanel);
|
qt = ((ConditionPanel) conditionPanel).getQT();
|
String checkInfo = OQTool.checkQT(qt);
|
if (!checkInfo.equals("OK")) {
|
return false;
|
}
|
// 获取规则名称
|
if (funclet.getRightMainPanel().getRuleName() == null
|
|| funclet.getRightMainPanel().getRuleName().equals("")) {
|
JOptionPane.showMessageDialog(com.vci.client.LogonApplication.frame, "请设置规则名称", "提示",
|
JOptionPane.INFORMATION_MESSAGE);
|
return false;
|
}
|
|
qt = conditionPane.getQT();
|
qt.setId(funclet.getRightMainPanel().getRuleName());
|
qt.setLinkType("");
|
for (int i = 0; i < values.size(); i++) {
|
values.get(i).ruleName = funclet.getRightMainPanel().getRuleName();
|
values.get(i).ruleType = funclet.getRightMainPanel().getRuleType();
|
// 业务类型
|
if (!((ConditionPanel) conditionPanel).isLinkTypeSelected()) {
|
Document doc = conditionPane.getSeniorTreeDoc();
|
if (doc == null) {
|
values.get(i).seniorRuleText = "";
|
} else {
|
values.get(i).seniorRuleText = doc.asXML();
|
}
|
values.get(i).ruleText = OQTool.qtTOXMl(qt).asXML();
|
// Parser parser = new Parser(qt);
|
// parser.setAddGrandRightFlag(false);
|
// String sql = parser.parseToSql();
|
// values.get(i).expToSQL = sql.substring(sql.indexOf("where") + 6, sql.length());
|
values.get(i).expToSQL = "";
|
// 链接类型属性
|
values.get(i).lruleText = "";
|
values.get(i).lseniorRuleText = "";
|
values.get(i).lexpToSQL = "";
|
} else {
|
// 链接类型
|
Document doc = conditionPane.getSeniorTreeDoc();
|
if (doc == null) {
|
values.get(i).lseniorRuleText = "";
|
} else {
|
values.get(i).lseniorRuleText = doc.asXML();
|
}
|
values.get(i).lruleText = OQTool.qtTOXMl(qt).asXML();
|
// Parser parser = new Parser(qt);
|
// parser.setAddGrandRightFlag(false);
|
// String sql = parser.parseToSql();
|
// values.get(i).lexpToSQL = sql.substring(sql.indexOf("where") + 6, sql.length());
|
values.get(i).lexpToSQL = "";
|
// 业务类型属性
|
values.get(i).ruleText = "";
|
values.get(i).seniorRuleText = "";
|
values.get(i).expToSQL = "";
|
}
|
}
|
} else {
|
// 获取规则名称
|
if (funclet.getRightMainPanel().getRuleName() == null
|
|| funclet.getRightMainPanel().getRuleName().equals("")) {
|
JOptionPane.showMessageDialog(com.vci.client.LogonApplication.frame, "请设置规则名称", "提示",
|
JOptionPane.INFORMATION_MESSAGE);
|
return false;
|
}
|
for (int i = 0; i < values.size(); i++) {
|
values.get(i).ruleText = "";
|
values.get(i).seniorRuleText = "";
|
values.get(i).expToSQL = "";
|
values.get(i).lruleText = "";
|
values.get(i).lseniorRuleText = "";
|
values.get(i).lexpToSQL = "";
|
values.get(i).ruleName = funclet.getRightMainPanel().getRuleName();
|
values.get(i).ruleType = funclet.getRightMainPanel().getRuleType();
|
}
|
|
}
|
return true;
|
}
|
|
public static void setOpDatas(final AbstractUIFunclet funclet, List<OpItem> ops) {
|
// 规则table
|
JCheckBox[] checkBoxs = ((OrdinaryOpPanel) funclet.getRightMainPanel().getOrdinaryOpPanel()).getOpCheckBoxs();
|
for (JCheckBox cb : checkBoxs) {
|
for (OpItem op : ops) {
|
if (cb.getText().equals(op.getName())) {
|
cb.setSelected((Boolean) op.getValue() == null ? false : (Boolean) op.getValue());
|
}
|
}
|
}
|
// 关系和跃迁
|
JCheckBox[] rlcheckBoxs = ((RelationAndLifeCycleOpPanel) funclet.getRightMainPanel()
|
.getRelationAndLifeCycleOpPanel()).getOpCheckBoxs();
|
for (JCheckBox cb : rlcheckBoxs) {
|
for (OpItem op : ops) {
|
if (cb.getText().equals(op.getName())) {
|
cb.setSelected((Boolean) op.getValue() == null ? false : (Boolean) op.getValue());
|
}
|
}
|
}
|
}
|
|
public static void initTipPanel(QTD qtd, final AbstractUIFunclet funclet) {
|
JDialog dialog = new JDialog();
|
|
dialog.add(funclet.getTipPanel());
|
// JRadioButton rdGeneral = new JRadioButton();
|
// JRadioButton rdSenior = new JRadioButton();
|
funclet.getTipPanel().removeAll();
|
funclet.getTipPanel().updateUI();
|
funclet.getTipPanel().setAutoscrolls(true);
|
funclet.getTipPanel().setLayout(new GridBagLayout());
|
String[] abNames = "a,s,d,d".split(",");// qtd.abNames;
|
if (true) {
|
for (int i = 0; i < abNames.length; i++) {
|
GridBagConstraints g = new GridBagConstraints();
|
g.anchor = GridBagConstraints.WEST;
|
g.gridx = 0;
|
g.gridy = i;
|
final JButton btnRemove = new JButton("x");
|
funclet.getTipPanel().add(btnRemove, g);
|
final JLabel labName = new JLabel(abNames[i]);
|
g.gridx = 1;
|
funclet.getTipPanel().add(labName, g);
|
g.gridx = 2;
|
final JComboBox combCons = new JComboBox();
|
combCons.addItem("=");
|
combCons.addItem("!=");
|
combCons.addItem("鍖呭惈");
|
funclet.getTipPanel().add(combCons, g);
|
g.gridx = 3;
|
g.gridwidth = GridBagConstraints.REMAINDER;
|
final JTextField tfValue = new JTextField(10);
|
funclet.getTipPanel().add(tfValue, g);
|
|
btnRemove.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
funclet.getTipPanel().remove(btnRemove);
|
funclet.getTipPanel().remove(labName);
|
funclet.getTipPanel().remove(combCons);
|
funclet.getTipPanel().remove(tfValue);
|
funclet.getTipPanel().updateUI();
|
}
|
});
|
}
|
dialog.setVisible(true);
|
}
|
}
|
|
public static void clear(AbstractUIFunclet funclet) {
|
BooleanTableModel ruleModel = (BooleanTableModel) funclet.getRightMainPanel().getRuleTable().getModel();
|
// 刷新页面缓存
|
ruleModel.RemoveAllConditionValue();
|
ruleModel.setRowCount(0);
|
}
|
|
}
|