📄 publicmethod.java
字号:
package collector.gui.method;
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.tree.*;
import collector.common.*;
import collector.gui.guiVo.*;
import collector.gui.model.*;
import pbs.service.vo.*;
public class PublicMethod {
public PublicMethod() {
}
public static final String m_psString = "电网参数";
public static final String m_clString = "采集参数";
public static final String m_RootString = "电网模型";
public static final String m_chString = "通道";
public static final String m_TchString = "任务通道";
public static final String m_collectorString = "前置机";
public static final String m_pulseString = "按电量";
public static final String m_meterString = "按电表";
public static final String m_secString = "按区号";
public static final String m_meter = "电表";
public static final String m_pbsString = "电量采集系统";
public static final String m_termdevice = "终端类型";
public static final String m_termserver = "终端服务器类型";
public static final String m_dirmeter = "子母表类型";
public static final String m_channelgroup = "通道组";
//typeconfig
public static final int REPORTDISPTYPE = 1;
public static final int PARAMDISPTYPE = 2;
public static final int METERPURSUETYPE = 3;
public static TermSelectDialog m_TermSelectDialog = null;
public static final int MAXCOMPUTERCOUNT = 10;
public static long LastTerminalId = -1;
public static CodeSetDialog m_CodeSetDialog = null;
public static FuncListSetDialog m_FuncListSetDialog = null;
public static void setAreaNode(JTree m_tree, Object[] toplist,
HashMap m_HashArea, int TerminalMsgType) {
System.out.println("****************************");
System.out.println("setAreaNode: toplist.size = " + toplist.length +
" m_HashArea.size = " + m_HashArea.size());
int startNumber = m_HashArea.size();
HashMap m_tempMap = new HashMap();
m_tempMap.putAll(m_HashArea);
ArrayList m_list = new ArrayList();
for (int i = 0; i < toplist.length; i++) {
DefaultMutableTreeNode top = (DefaultMutableTreeNode) (toplist[i]);
//Object[] LeftArea = m_HashArea.values().toArray();
ArrayList LeftArea_list = new ArrayList(m_HashArea.values());
long topId = ( (area) (top.getUserObject())).getAreaId();
Collections.sort(LeftArea_list, new NameComparator());
for (int j = 0; j < LeftArea_list.size(); j++) {
long thisAreaTopId = ( (area) LeftArea_list.get(j)).getTopAreaId();
if (thisAreaTopId == topId) {
long thisAreaId = ( (area) LeftArea_list.get(j)).getAreaId();
MyAreaTreeNode m_childnode = new MyAreaTreeNode( (area) LeftArea_list.
get(j));
top.add(m_childnode);
int index = top.getIndex(m_childnode);
DefaultTreeModel model = (DefaultTreeModel) (m_tree.getModel());
model.nodesWereInserted(top, new int[] {index});
m_list.add(m_childnode);
m_tempMap.remove(new Long(thisAreaId));
}
}
if (m_tempMap.size() <= 0) {
break;
}
}
for (int i = 0; i < toplist.length; i++) {
MyAreaTreeNode m_node = (MyAreaTreeNode) (toplist[i]);
area m_area = (area) (m_node.getUserObject());
if (m_area.getFactories() != null) {
Object[] m_facs = (m_area.getFactories()).toArray();
for (int j = 0; j < m_facs.length; j++) {
factory m_fac = (factory) (m_facs[j]);
long fac_id = m_fac.getFacId();
factory m_hash_fac = (factory) (CollectorDefine.m_HashFactory.get(new
Long(fac_id)));
if (m_hash_fac != null) {
MyFactoryTreeNode m_facNode = new MyFactoryTreeNode(m_hash_fac);
m_node.add(m_facNode);
int index = m_node.getIndex(m_facNode);
DefaultTreeModel model = (DefaultTreeModel) (m_tree.getModel());
model.nodesWereInserted(m_node, new int[] {index});
}
}
}
}
if (m_tempMap.size() <= 0) {
return;
}
else {
int endNumber = m_tempMap.size();
if (endNumber < startNumber) {
setAreaNode(m_tree, m_list.toArray(), m_tempMap, TerminalMsgType);
}
else {
System.out.println("再不退出又要死循环了啊,有问题哦!!!!!!");
return;
}
}
m_tempMap = null;
}
public static void createNodes(DefaultMutableTreeNode top, JTree m_tree,
int typeconfig,
Map m_HashTerm, HashMap m_HashFac,
HashMap m_HashArea, int TerminalMsgType) {
DefaultMutableTreeNode category = null;
Object nodeInfo = top.getUserObject();
if (top.isRoot() && top.isLeaf() && nodeInfo instanceof String &&
( (String) nodeInfo).equals(PublicMethod.m_RootString)) {
if (m_HashArea == null || m_HashArea.size() <= 0) {
return;
}
HashMap TermAreaHash = new HashMap();
TermAreaHash.putAll(m_HashArea);
ArrayList area_list = new ArrayList(TermAreaHash.values());
for (int i = 0; i < area_list.size(); i++) {
area m_Area = (area) (area_list.get(i));
long topAreaId = m_Area.getTopAreaId();
if (topAreaId == 0) {
MyAreaTreeNode areanode = new MyAreaTreeNode(m_Area);
top.add(areanode);
int index = top.getIndex(areanode);
DefaultTreeModel model = (DefaultTreeModel) (m_tree.getModel());
model.nodesWereInserted(top, new int[] {index});
TermAreaHash.remove(new Long(m_Area.getAreaId()));
}
}
if (TermAreaHash.size() >= 0) {
int childoftopcount = top.getChildCount();
ArrayList m_list = new ArrayList();
for (int i = 0; i < childoftopcount; i++) {
DefaultMutableTreeNode ch_node = (DefaultMutableTreeNode) (top.
getChildAt(i));
m_list.add(ch_node);
}
setAreaNode(m_tree, m_list.toArray(), TermAreaHash, TerminalMsgType);
}
TermAreaHash = null;
}
else if (nodeInfo instanceof area) {
if (top.isLeaf()) {
area m_area = (area) nodeInfo;
long area_id = m_area.getAreaId();
ArrayList area_list = new ArrayList(m_HashArea.values());
Collections.sort(area_list, new NameComparator());
for (int i = 0; i < area_list.size(); i++) {
area m_Area = (area) (area_list.get(i));
if (m_Area.getTopId() == area_id) {
MyAreaTreeNode m_childnode = new MyAreaTreeNode(m_Area);
top.add(m_childnode);
int index = top.getIndex(m_childnode);
DefaultTreeModel model = (DefaultTreeModel) (m_tree.getModel());
model.nodesWereInserted(top, new int[] {index});
}
}
if (m_area.getFactories() != null) {
ArrayList fac_list = new ArrayList(m_area.getFactories());
Collections.sort(fac_list, new NameComparator());
for (int i = 0; i < fac_list.size(); i++) {
factory m_fac = (factory) fac_list.get(i);
long fac_id = m_fac.getFacId();
factory m_factory = (factory) (m_HashFac.get(new Long(fac_id)));
if (m_factory != null) {
MyFactoryTreeNode m_facnode = new MyFactoryTreeNode(m_factory);
top.add(m_facnode);
int index = top.getIndex(m_facnode);
DefaultTreeModel model = (DefaultTreeModel) (m_tree.getModel());
model.nodesWereInserted(top, new int[] {index});
}
}
}
else {
return;
}
}
}
else if (nodeInfo instanceof factory && top.isLeaf()) {
factory m_fac = (factory) nodeInfo;
if (m_fac.getTerminals() == null) {
return;
}
factory m_hash_fac = (factory) (m_HashFac.get(new Long(m_fac.getFacId())));
if (m_hash_fac != null) {
Collection TermCol = m_hash_fac.getTerminals();
if (TermCol != null) {
ArrayList TermList = new ArrayList(TermCol);
if (TermList.size() > 0) {
Collections.sort(TermList, new NameComparator());
for (int i = 0; i < TermList.size(); i++) {
terminal m_terminal = (terminal) (TermList.get(i));
if (m_terminal != null) {
terminal m_hash_term = (terminal) (m_HashTerm.get(new Long(
m_terminal.getTerminalId())));
if (m_hash_term != null) {
MyTerminalTreeNode termnode = new MyTerminalTreeNode(
m_hash_term);
top.add(termnode);
int index = top.getIndex(termnode);
DefaultTreeModel model = (DefaultTreeModel) (m_tree.getModel());
model.nodesWereInserted(top, new int[] {index});
}
}
}
if (typeconfig == PublicMethod.PARAMDISPTYPE) { //参数显示时添加terminal server节点
long fac_id = m_fac.getFacId();
Collection tsCollection = CollectorDefine.m_HashTs.values();
ArrayList tslist = new ArrayList(tsCollection);
Collections.sort(tslist, new NameComparator());
for (int t = 0; t < tslist.size(); t++) {
terminal_server m_ts = (terminal_server) (tslist.get(t));
if (fac_id == m_ts.getFacId()) {
MyTermServerTreeNode termnode = new MyTermServerTreeNode(m_ts);
top.add(termnode);
int index = top.getIndex(termnode);
DefaultTreeModel model = (DefaultTreeModel) (m_tree.getModel());
model.nodesWereInserted(top, new int[] {index});
}
}
}
}
}
}
}
else if (nodeInfo instanceof termdevice) {
if (!top.isLeaf()) { //如果已经扩展过了,删除以前的子节点
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -