[转载]自定义窗口组件,继承于JPanel

package ums.caf.pm.client.stat.origindata; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Point; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.text.DateFormat; import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Vector; import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTabbedPane; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JToolBar; import javax.swing.KeyStroke; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.DefaultTableModel; import javax.swing.table.JTableHeader; import javax.swing.table.TableColumn; import ums.caf.component.gui.table.SortColumn; import ums.caf.component.gui.table.SortInfo; import ums.caf.component.gui.table.SortModel; import ums.caf.component.gui.table.Table; import ums.caf.component.gui.table.TableActionForPm; import ums.caf.pm.AttributeFilterEntry; import ums.caf.pm.CafPmConst; import ums.caf.pm.CafPmException; import ums.caf.pm.CafPmUtility; import ums.caf.pm.NeDescription; import ums.caf.pm.OriginDataResultSet; import ums.caf.pm.POAttribute; import ums.caf.pm.QueryOriginDataPara; import ums.caf.pm.TableOrder; import ums.uep.gui.component.ZJDoubleField; import ums.uep.gui.component.ZJShowMsgPane; import ums.uep.gui.component.ZJToolBarButton; /** *

文件名称: ShowOriginDataPanel.java

*

文件描述: 显示原始数据窗口

*

内容摘要: 显示原始数据窗口,主要用于显示查询结果

*/ class ShowOriginDataPanel extends JPanel { private static final long serialVersionUID = -6208915409784997152L; // private static com.zte.ums.uep.api.util.DebugPrn dMsg = // new com.zte.ums.uep.api.util.DebugPrn(ShowOriginDataPanel.class.getName()); private JPanel panelMain = new JPanel(); /** * 主要用来显示日志信息的标签,如是日志的页数 */ private JLabel[] jLabelDataMessage = null; /** * 工具条 */ private JToolBar jToolBarMain = new JToolBar(); /** * 工具条:下一页按钮 */ private ZJToolBarButton jToolBarButtonNextPage = null; /** * 工具条:最后一页按钮 */ private ZJToolBarButton jToolBarButtonLastPage = null; /** * 工具条:上一页按钮 */ private ZJToolBarButton jToolBarButtonPrevPage = null; /** * 工具条:第一页按钮 */ private ZJToolBarButton jToolBarButtonFirstPage = null; /** * 工具条:刷新数据 * */ private ZJToolBarButton jToolBarButtonRefreshData = null; /** * 工具条按钮图标:第一页按钮图标 */ private ImageIcon iconFirstPage= null; /** * 工具条按钮图标:前一页按钮图标 */ private ImageIcon iconPrevPage= null; /** * 工具条按钮图标:下一页按钮图标 */ private ImageIcon iconNextPage= null; /** * 工具条按钮图标:最后一页按钮图标 */ private ImageIcon iconLastPage= null; /** * 工具条按钮图标:刷新当前数据图标 * */ private ImageIcon iconRefreshData = null; private ZJDoubleField jTextFiledJumpTo = new ZJDoubleField(); // 跳转到第x页 private ZJToolBarButton jToolBarButtonJumpTo = new ZJToolBarButton(); // 跳转到第x页按钮 private ImageIcon iconJumpTo = null; // 跳转到第x页图标 private JPanel[] jPanelTable = null; private SpecificAttribute[] sAttributes = null; private Table[] tableOriginResult= null; private JScrollPane[] scrollPane = null; private String[] remoteServerId = null; private String[] serverAlias = null; /** * WSF的Controller,用于获取一些相关的内容 */ private OriginDataController originDataController= null; /** * 原始数据性能对象ID */ public int originDataPoId = -1; /** * 原始数据性能对象名称 */ public String originDataPoName = ""; /** * 查询的条件参数 */ private QueryOriginDataPara queryOriginDataPara= null; /** * 主要用来显示日志信息,如是日志的页数 */ private String strDataMessage = null; /** * 国际化方面的消息格式化工具 */ private MessageFormat msgFmt= null; /** * 原始数据查询的WSF接口 */ private OriginDataManageInterface odInterface = null; private Vector remoteServerNodeId = new Vector(); private NeDescription neDescription= null; private FontMetrics fontMetrics= null; // 默认每页最多显示的记录数 // final int countPerPage = 500; private JTabbedPane resultPane = new JTabbedPane(); private JPanel resultPanel = new JPanel(); // private JLabel labelQueryPara = new JLabel(); private JTextArea textAreaQueryPara = new JTextArea(); private JPanel panelQueryParaTip = new JPanel(); /** * 构造器 * @param odController 原始数据查询WSF控制类 */ ShowOriginDataPanel(OriginDataController odController) { try { this.originDataController = odController; jbInit(); } catch(Exception ex) { ex.printStackTrace(); } } /** * 界面初始化 * @throws Exception */ private void jbInit() throws Exception { odInterface = new OriginDataManageInterface(this); odInterface.setOriginDataController(originDataController); msgFmt = new MessageFormat(""); msgFmt.setLocale(originDataController.getCurrentLocale()); msgFmt.applyPattern(CafPmUtility.getClientLocalizedString( "customstat_client_execute_result_current_page_total_page_record")); panelMain.setLayout(new BorderLayout()); /** * 实例化各图标 */ iconFirstPage = new ImageIcon( this.getClass().getResource( "/com/zte/ums/uep/gui/images/bss3g-common-firstpage.gif")); iconPrevPage = new ImageIcon( this.getClass().getResource( "/com/zte/ums/uep/gui/images/bss3g-common-prepage.gif")); iconNextPage = new ImageIcon( this.getClass().getResource( "/com/zte/ums/uep/gui/images/bss3g-common-nextpage.gif")); iconLastPage = new ImageIcon( this.getClass().getResource( "/com/zte/ums/uep/gui/images/bss3g-common-lastpage.gif")); iconJumpTo = new ImageIcon( this.getClass().getResource( "/com/zte/ums/uep/gui/images/bss3g-common-goto.gif")); iconRefreshData = new ImageIcon( this.getClass().getResource("/com/zte/ums/caf/gui/images/pm/refreshdata.gif")); /** * 实例化各工具条按钮 */ jToolBarButtonNextPage = new ZJToolBarButton(iconNextPage); jToolBarButtonNextPage.setEnabled(false); jToolBarButtonLastPage = new ZJToolBarButton(iconLastPage); jToolBarButtonLastPage.setEnabled(false); jToolBarButtonPrevPage = new ZJToolBarButton(iconPrevPage); jToolBarButtonPrevPage.setEnabled(false); jToolBarButtonFirstPage = new ZJToolBarButton(iconFirstPage); jToolBarButtonFirstPage.setEnabled(false); jToolBarButtonRefreshData = new ZJToolBarButton(iconRefreshData); jToolBarButtonRefreshData.setEnabled(true); jToolBarButtonJumpTo = new ZJToolBarButton(iconJumpTo); resultPanel.setLayout(new BorderLayout()); resultPanel.setPreferredSize(new Dimension(600, 400)); /** * 给各工具条按钮添加事件处理 */ jToolBarButtonFirstPage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jToolBarButtonFirstPage_actionPerformed(e); } }); jToolBarButtonPrevPage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jToolBarButtonPrevPage_actionPerformed(e); } }); jToolBarButtonNextPage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jToolBarButtonNextPage_actionPerformed(e); } }); jToolBarButtonLastPage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jToolBarButtonLastPage_actionPerformed(e); } }); jToolBarButtonJumpTo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jToolBarButtonJumpTo_actionPerformed(e); } }); jToolBarButtonRefreshData.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jToolBarButtonRefreshData_actionPerformed(e); } }); /** * 设置各工具条按钮的提示信息 */ jToolBarButtonFirstPage.setToolTipText(CafPmUtility.getClientLocalizedString("origindata_first_page")); jToolBarButtonPrevPage.setToolTipText(CafPmUtility.getClientLocalizedString("origindata_prev_page")); jToolBarButtonNextPage.setToolTipText(CafPmUtility.getClientLocalizedString("origindata_next_page")); jToolBarButtonLastPage.setToolTipText(CafPmUtility.getClientLocalizedString("origindata_last_page")); jToolBarButtonJumpTo.setToolTipText(CafPmUtility.getClientLocalizedString("origindata_jumpto")); jToolBarButtonRefreshData.setToolTipText(CafPmUtility.getClientLocalizedString("customstat_client_refresh_template")); FractionDocument fDoc = new FractionDocument("^//d{0,10}$"); jTextFiledJumpTo.setDocument(fDoc); jTextFiledJumpTo.setMaxValue(999999999); jTextFiledJumpTo.setMinValue(0); jTextFiledJumpTo.setPreferredSize(new Dimension(75,(int)jTextFiledJumpTo.getPreferredSize().getHeight() )); setJumpToFunctionEnable(false); jToolBarMain.setFloatable(false); jToolBarMain.setLayout(new GridBagLayout()); this.setLayout(new BorderLayout()); this.add(panelMain, BorderLayout.CENTER); jToolBarMain.add(jToolBarButtonRefreshData, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 2), 0, 0)); JToolBar.Separator jSepa = new JToolBar.Separator(); jToolBarMain.add(jSepa, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 2), 0, 0)); jToolBarMain.add(jToolBarButtonFirstPage, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0)); jToolBarMain.add(jToolBarButtonPrevPage, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0)); jToolBarMain.add(jToolBarButtonNextPage, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0)); jToolBarMain.add(jToolBarButtonLastPage, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0)); jToolBarMain.add(jTextFiledJumpTo, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 28, 0)); jToolBarMain.add(jToolBarButtonJumpTo, new GridBagConstraints(7, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 2), 0, 0)); // jToolBarMain.add(labelQueryPara, // new GridBagConstraints(6, 0, 1, 1, 1.0, 0.0, // GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0)); panelMain.add(resultPanel, BorderLayout.CENTER); panelMain.add(jToolBarMain, BorderLayout.NORTH); panelMain.add(panelQueryParaTip, BorderLayout.SOUTH); // 增加底部查询条件提示 panelQueryParaTip.setLayout(new BorderLayout()); panelQueryParaTip.add(textAreaQueryPara); textAreaQueryPara.setEditable(false); textAreaQueryPara.setLineWrap(true); textAreaQueryPara.setSelectionColor(textAreaQueryPara.getBackground()); resultPanel.add(resultPane, BorderLayout.CENTER); resultPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { tabbedPane_stateChanged(); } }); this.registerKeyboardAction( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { if(jTextFiledJumpTo.hasFocus()) { jToolBarButtonJumpTo_actionPerformed(null); } } }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); } protected void jToolBarButtonJumpTo_actionPerformed(ActionEvent e) { int totalPage = sAttributes[this.resultPane.getSelectedIndex()].getPageAccount(); String page = jTextFiledJumpTo.getText(); int jumpPage = -1; if (page.length() != 0) { jumpPage = Integer.parseInt(jTextFiledJumpTo.getText()); } if (jumpPage < 1 || jumpPage > totalPage ) { ZJShowMsgPane.showMessageDialog(this, CafPmUtility.getClientLocalizedString("origindata_invalid_page_number"), CafPmUtility.getClientLocalizedString("uep_caf_pm_client_information_message_title"), ZJShowMsgPane.INFORMATION_MESSAGE); return ; } int currentPage = sAttributes[this.resultPane.getSelectedIndex()].getPageNo(); if (currentPage == jumpPage) { return ; } queryOriginDataPara.setPageNo(jumpPage); queryOriginData(queryOriginDataPara, this.resultPane.getSelectedIndex()); } protected void jToolBarButtonRefreshData_actionPerformed(ActionEvent e) { queryOriginDataPara.setPageNo(1); queryOriginData(queryOriginDataPara, this.resultPane.getSelectedIndex()); } /** * OMM子Tab页切换事件 */ private void tabbedPane_stateChanged() { int idx = resultPane.getSelectedIndex(); if (sAttributes[idx] != null && sAttributes[idx].getPageAccount() > 1) { setJumpToFunctionEnable(true); if (sAttributes[idx].getPageNo() > 1) { jToolBarButtonFirstPage.setEnabled(true); jToolBarButtonPrevPage.setEnabled(true); } else { jToolBarButtonFirstPage.setEnabled(false); jToolBarButtonPrevPage.setEnabled(false); } if (sAttributes[idx].getPageNo() < sAttributes[idx].getPageAccount()) { jToolBarButtonNextPage.setEnabled(true); jToolBarButtonLastPage.setEnabled(true); } else { jToolBarButtonNextPage.setEnabled(false); jToolBarButtonLastPage.setEnabled(false); } } else { jToolBarButtonNextPage.setEnabled(false); jToolBarButtonLastPage.setEnabled(false); jToolBarButtonPrevPage.setEnabled(false); jToolBarButtonFirstPage.setEnabled(false); setJumpToFunctionEnable(false); } } /** * 返回该页面对应的查询参数 * @return */ QueryOriginDataPara getQueryOriginDataPara() { return queryOriginDataPara; } /** * 返回各个OMM子Tab页的对应信息 * @return */ SpecificAttribute[] getSAttributes() { return sAttributes; } /** * 查询第一页数据 * @param e 点击事件 */ private void jToolBarButtonFirstPage_actionPerformed(ActionEvent e) { queryFirstPageData(); } /** * 查询前一页数据 * @param e 点击事件 */ private void jToolBarButtonPrevPage_actionPerformed(ActionEvent e) { queryPrevPageData(); } /** * 查询下一页数据 * @param e 点击事件 */ private void jToolBarButtonNextPage_actionPerformed(ActionEvent e) { queryNextPageData(); } /** * 查询最后一页数据 * @param e 点击事件 */ private void jToolBarButtonLastPage_actionPerformed(ActionEvent e) { queryLastPageData(); } /** * 设置POid * @param poid */ void setPoId(int poId){ this.originDataPoId = poId; } /** * 设置PO名称 * @param poName */ void setPoName(String poName){ this.originDataPoName = poName; } /** * 返回PO序号 * @return */ public int getOriginDataPoId() { return originDataPoId; } /** * 返回PO名称 * @return */ public String getOriginDataPoName() { return originDataPoName; } /** * 设置Server别名 added by xiaozhw 11.27 * @param serverAlias Server别名 */ void setServerAlias(String[] serverAlias){ this.serverAlias = serverAlias; } /** * 设置节点号 added by xiaozhw 11.27 * @param serverid 节点号 */ void setServerId(String[] serverid){ this.remoteServerId = serverid; } /** * 初始化表格 * @param resultSet 查询结果集 */ void initTable(Vector odResultSet) { int num = odResultSet.size(); jPanelTable = new JPanel[num]; // 主面板 scrollPane = new JScrollPane[num]; // 滚动面板 tableOriginResult = new Table[num]; // 结果表 jLabelDataMessage = new JLabel[num]; // 顶部标签 sAttributes = new SpecificAttribute[num]; // 每页特定属性 for (int i = 0; i < num; i ++) { OriginDataResultSet odrs = (OriginDataResultSet)odResultSet.get(i); if (odrs == null) { continue; } jPanelTable[i] = new JPanel(); jPanelTable[i].setLayout(new BorderLayout()); sAttributes[i] = new SpecificAttribute(); sAttributes[i].setRs((OriginDataResultSet)odResultSet.get(i)); if (odrs.getObjOriginData() != null && odrs.getObjOriginData().size() > 0) { jLabelDataMessage[i] = new JLabel(); sAttributes[i].setCountPerPage(odrs.getRecordCountPerPage()); // 每页记录数 String[] fieldType = odrs.getObjFieldType(); sAttributes[i].setFieldType(fieldType); SortColumn[] sc = new SortColumn[fieldType.length]; for (int j = 0; j < sc.length; j++) { if ( (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_BYTE)) || (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_DOUBLE)) || (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_FLOAT)) || (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_INTEGER)) || (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_LONG)) || (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_SHORT))) { sc[j] = new SortColumn(j, SortColumn.NUMBER_SORT, SortColumn.NONE); } else { sc[j] = new SortColumn(j, SortColumn.STRING_SORT, SortColumn.NONE); } } sAttributes[i].setOriginDataPoHeader(odrs.getObjHeader()); SortInfo sortInfo = new SortInfo(sc); if (odrs.getTotalPageNo() > 1) { sortInfo.setTrueSort(false); // 自定义排序 } tableOriginResult[i] = new Table(new SortModel(new DefaultTableModel(null, sAttributes[i].getOriginDataPoHeader())), sortInfo, true, SwingConstants.LEFT, SwingConstants.CENTER) { private static final long serialVersionUID = -2250022033504013596L; public void setColumnVisible(String columnName, boolean isVisible) { int j = -1; /*int fixColNum = this.fixedColumn.length; for (int i = fixColNum; i < this.tableColumn.length; i++) { if (this.tableColumn[i].getIdentifier().equals(columnName)) { j = i - fixColNum; break; } }*/ int realJ = 0; for (int i = 0; i < this.tableColumn.length; i++) { try { this.getColumn(this.tableColumn[i].getIdentifier()); realJ ++; } catch (IllegalArgumentException e) { // } if (this.tableColumn[i].getHeaderValue().equals(columnName)) { j = i; break; } } if (j == -1) { throw new RuntimeException("ColumnName is invalid: " + columnName); } if (isVisible) { // 需要显示 try { this.getColumn(columnName); } catch (IllegalArgumentException e) { this.addColumn(this.tableColumn[j]); int numCols = this.getColumnCount(); if (realJ < numCols - 1) { this.moveColumn(numCols - 1, realJ); } } } else { // 需要不显示 TableColumn tc = null; try { tc = this.getColumn(columnName); } catch (IllegalArgumentException e) { return; // do nothing } this.removeColumn(tc); } } }; tableOriginResult[i].setAutoResizeMode(JTable.AUTO_RESIZE_OFF); tableOriginResult[i].getTableHeader().setReorderingAllowed(false); tableOriginResult[i].setAction(new ResultTableAction()); tableOriginResult[i].addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (((Table)e.getComponent()).getSelectedColumn() == 0) { if (e.getKeyCode() == KeyEvent.VK_LEFT) { Table headerTable = ((Table)e.getComponent()).getHeaderTable(); if (headerTable != null && headerTable.getColumnCount() > 0) { headerTable.requestFocus(); headerTable.setColumnSelectionInterval( headerTable.getColumnCount() - 1, headerTable.getColumnCount() - 1); } } } } }); scrollPane[i] = new JScrollPane(); scrollPane[i].getViewport().add(tableOriginResult[i]); jPanelTable[i].add(jLabelDataMessage[i], BorderLayout.NORTH); jPanelTable[i].add(scrollPane[i], BorderLayout.CENTER); } } } /** * 初始化表格信息 */ void setOriginData() throws CafPmException { if (fontMetrics == null) { fontMetrics = originDataController.getQueryOriginDataFrame().getGraphics().getFontMetrics(); } for (int i = 0; i < sAttributes.length; i++) { OriginDataResultSet oSet = null; if (sAttributes[i] != null) { oSet = sAttributes[i].getRs(); } if (oSet == null) { resultPane.add(jPanelTable[i], this.remoteServerId[i] + "[" + this.serverAlias[i] + "](" + CafPmUtility.getClientLocalizedString("query_with_error") + ")" + ""); resultPane.setEnabledAt(i, false); continue; } if ((oSet.getObjOriginData() == null) || (oSet.getObjOriginData().size() <= 0)) { resultPane.add(jPanelTable[i], this.remoteServerId[i] + "[" + this.serverAlias[i] + "](" + CafPmUtility.getClientLocalizedString("query_no_data") + ")" + ""); resultPane.setEnabledAt(i, false); SwingUtilities.invokeLater(new Runnable(){ public void run(){ originDataController.getQueryOriginDataFrame().setExportFunctionEnable(false); } }); continue; } tableOriginResult[i].getSortModel().setNewInitData(null); Vector vctOriginDataList = oSet.getObjOriginData(); sAttributes[i].setCountPerPage(oSet.getRecordCountPerPage()); sAttributes[i].setFieldType(oSet.getObjFieldType()); int exactPageNo = oSet.getExactPageNo(); int totalPageNo = oSet.getTotalPageNo(); int totalNumber = oSet.getTotalNumber(); sAttributes[i].setPageAccount(totalPageNo); sAttributes[i].setPageNo(exactPageNo); sAttributes[i].setRecordNum(totalNumber); Object [] arguments = { new Integer(exactPageNo), new Integer(totalPageNo), new Integer(sAttributes[i].getCountPerPage()), new Integer(totalNumber) }; strDataMessage = msgFmt.format(arguments); jLabelDataMessage[i].setText(strDataMessage); // if isChangeable String[] oneData = (String[])vctOriginDataList.get(0); String[] anotherData = (String[])vctOriginDataList.get(vctOriginDataList.size() - 1); tableOriginResult[i].getColumnModel().getColumn(0). setPreferredWidth(fontMetrics.stringWidth(sAttributes[i].getOriginDataPoHeader()[0].trim()) + 70); tableOriginResult[i].getColumnModel().getColumn(0). setMinWidth(fontMetrics.stringWidth(sAttributes[i].getOriginDataPoHeader()[0].trim()) + 70); // 设置列宽(1024*768大约能显示9列数据,一般默认有两列隐藏Server和BSS) int width1 = 0, width2 = 0, width3 = 0, width = 0; int num = sAttributes[i].getOriginDataPoHeader().length; for (int j = 1; j < num; j++) { if (num > 11) { width1 = fontMetrics.stringWidth(sAttributes[i].getOriginDataPoHeader()[j].trim()) / 2 + 15; } else { width1 = fontMetrics.stringWidth(sAttributes[i].getOriginDataPoHeader()[j].trim()) + 15; } width2 = fontMetrics.stringWidth(oneData[j]) + 10; width3 = fontMetrics.stringWidth(anotherData[j]) + 10; width = (width1 > width2 ? width1 : width2); width = (width > width3 ? width : width3); width = width > 70 ? width : 70; tableOriginResult[i].getColumnModel().getColumn(j).setPreferredWidth(width); tableOriginResult[i].getColumnModel().getColumn(j).setWidth(width); if((tableOriginResult[i].getColumnModel().getColumn(j).getHeaderValue()).equals("Server")){ tableOriginResult[i].getColumnModel().getColumn(j).setMaxWidth(width*2); } if((tableOriginResult[i].getColumnModel().getColumn(j).getHeaderValue()).equals("BSS")){ tableOriginResult[i].getColumnModel().getColumn(j).setMaxWidth(width*2); } } // End if setTableFixColumn(i); if (Arrays.asList(sAttributes[i].getOriginDataPoHeader()).contains("Server")) { tableOriginResult[i].setColumnVisible("Server", false, true); } if (Arrays.asList(sAttributes[i].getOriginDataPoHeader()).contains("BSS")) { tableOriginResult[i].setColumnVisible("BSS", false, true); } addData2Table(i, vctOriginDataList); resultPane.add(jPanelTable[i], this.remoteServerId[i] + "[" + this.serverAlias[i] + "](" + CafPmUtility.getClientLocalizedString("query_all_record_num") + sAttributes[i].getRecordNum() + ")"); // 加入Tab面板 } } /** * 将数据添加到表格中 * @param vctData */ private void addData2Table(int tbIdx, Vector vctData) { if ((vctData != null) && (vctData.size() > 0)) { String[] data= null; for (int i = 0; i < vctData.size(); i++) { data = (String[]) vctData.get(i); tableOriginResult[tbIdx].getSortModel().addRow(data); } } } /** * 设置表格中的固定列 */ private void setTableFixColumn(final int tbIdx) { //关键属性字段的个数 int keywordAttributeNum = 0; int fixNum=0; int fixColumnCount = 0; //性能对象属性 Vector vPoAttributes = null; POAttribute poAttribute = null; int groupByLoc = queryOriginDataPara.getGroupLocId(); //位置分组信息 fixNum =(groupByLoc >0 ? (groupByLoc +1):neDescription.getNeLocParaNum()+1); if(!originDataController.getQueryOriginDataFrame().getAdvanceDialog().isSelectedGroup()){//在不分组的情况下,判断字段是否也要锁定 vPoAttributes = originDataController.getQueryOriginDataFrame().getQueryPoAttributes(); for (int i = 0; i < vPoAttributes.size(); i++) { poAttribute = (POAttribute)vPoAttributes.get(i); if(poAttribute.isKeyword()){ keywordAttributeNum++; }else{//如果碰到第一个不为关键字段的属性,则退出. break; } } } else{//只有选择关键字分组才将关键字加到显示列上 added by xiaozhw 08.07.22 if(null != queryOriginDataPara.getGroupAttrPara() && queryOriginDataPara.getGroupAttrPara().size()>0){ keywordAttributeNum = queryOriginDataPara.getGroupAttrPara().size() ; } // if(originDataController.getQueryOriginDataFrame().getAdvanceDialog().isSelectedGroupOfKeywords()){ // keywordAttributeNum = originDataController.getQueryOriginDataFrame().getAdvanceDialog().getGroupByAttrPara().size(); // // } } if((fixNum + keywordAttributeNum)<=7){ fixNum = fixNum+keywordAttributeNum; } int dialogWidth = 0; int maxColumnNum = fixNum; dialogWidth = originDataController.getQueryOriginDataFrame().getWidth(); int tableColumnWidthValue = 0; //算出时间+网元分组各列的宽度 for (int i = 0; i < maxColumnNum; i++) { tableColumnWidthValue += tableOriginResult[tbIdx].getColumnModel().getColumn(i).getPreferredWidth(); if((tableColumnWidthValue + 100)>dialogWidth){ break; }else{ fixColumnCount++; } } tableOriginResult[tbIdx].setIsRawDataQuerying(true); tableOriginResult[tbIdx].setFixedColumnCount(fixColumnCount); if (tableOriginResult[tbIdx].getHeaderTable() != null) { tableOriginResult[tbIdx].getHeaderTable().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (((Table)e.getComponent()).getSelectedColumn() == ((Table)e.getComponent()).getColumnCount() - 1) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) { if (tableOriginResult[tbIdx].getColumnCount() > 0) { tableOriginResult[tbIdx].requestFocus(); tableOriginResult[tbIdx].setColumnSelectionInterval(0, 0); } } } } }); } } /** * 重载父类的方法 */ public void showOption(){ //通过后调用的方式来使按钮获得焦点 javax.swing.SwingUtilities.invokeLater(new Runnable(){ public void run(){ setDialogShowedFocus(); } }); } /** * 设置焦点的位置 */ private void setDialogShowedFocus(){ //如果多页的情况,设置下一页按钮获取焦点 // if((originDataResultSet != null) && (originDataResultSet.getTotalPageNo() > 1) // && (originDataResultSet.getTotalPageNo() != originDataResultSet.getExactPageNo())){ // jToolBarButtonNextPage.requestFocus(); // } } /** * 设置查询条件参数 * @param para 参数 */ void setQueryOriginDataPara(QueryOriginDataPara para){ this.queryOriginDataPara = para; String str = getQueryParaString(); // labelQueryPara.setText(str); // labelQueryPara.setToolTipText(str); textAreaQueryPara.setText(str); textAreaQueryPara.setToolTipText(str); } /** * 根据查询参数构造查询条件信息 * @return */ private String getQueryParaString() { StringBuffer qps = new StringBuffer(); long timeBegin = queryOriginDataPara.getTimeBegin(); long timeEnd = queryOriginDataPara.getTimeEnd(); int hourBegin = queryOriginDataPara.getHourBegin(); int hourEnd = queryOriginDataPara.getHourEnd(); AttributeFilterEntry entry = queryOriginDataPara.getFilterEntry(); int locGroup = queryOriginDataPara.getGroupLocId(); int timeGroup = queryOriginDataPara.getGroupTimeId(); int queryType = queryOriginDataPara.getQueryType(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String timeBeginStr = dateFormat.format(new Date(timeBegin)); String timeEndStr = dateFormat.format(new Date(timeEnd)); if (queryType == 1) { // 固定小时段 qps.append(CafPmUtility.getClientLocalizedString("query_condition_tip_date_range")) // 日期范围 .append("[") .append(timeBeginStr).append(", ") .append(timeEndStr).append("], ") .append(CafPmUtility.getClientLocalizedString("query_condition_tip_hour_range")) // 小时范围 .append("[") .append(hourBegin).append(", ") .append(hourEnd).append(")"); } else { // 连续小时段 qps.append(CafPmUtility.getClientLocalizedString("query_condition_tip_time_range")); // 时间范围 qps.append("[").append(timeBeginStr + " " + hourBegin).append(":00") .append(", ") .append(timeEndStr + " " + hourEnd).append(":00)"); } if (timeGroup != 0) { qps.append(", "); qps.append(CafPmUtility.getClientLocalizedString("query_condition_tip_time_group")); switch (timeGroup) { case -1 : qps.append(CafPmUtility.getClientLocalizedString("origindata_group_by_begin_time")); break; case 30 : qps.append(CafPmUtility.getClientLocalizedString("origindata_group_by_half_an_hour")); break; case 1 : qps.append(CafPmUtility.getClientLocalizedString("origindata_group_by_hour")); break; case 2 : default : qps.append(CafPmUtility.getClientLocalizedString("origindata_group_by_day")); break; } } if (locGroup > 0 && locGroup < OriginDataConst.MAX_NE_LOCATION_PARA_NUM) { JCheckBox checkBox = originDataController.getQueryOriginDataFrame() .getAdvanceDialog().getJCheckBoxByLoc()[locGroup - 1]; // TODO -1? if (checkBox.getText() != null && !checkBox.getText().equals("")) { qps.append(", "); qps.append(CafPmUtility.getClientLocalizedString("query_condition_tip_location_group")) .append(checkBox.getText()); } } // 属性过滤 if (entry != null) { qps.append(", "); qps.append(CafPmUtility.getClientLocalizedString("query_condition_tip_attribute_filter_item")) .append(entry.getAttrShowName()) .append(entry.getOperator()) .append(entry.getValue()); } return qps.toString(); } /** * 查询第一页的数据 */ private void queryFirstPageData() { queryOriginDataPara.setPageNo(1); queryOriginData(queryOriginDataPara, this.resultPane.getSelectedIndex()); } /** * 查询上一页的数据 */ private void queryPrevPageData() { int page=0; page = sAttributes[this.resultPane.getSelectedIndex()].getPageNo(); if (page == 1) { return; } else { page--; } queryOriginDataPara.setPageNo(page); queryOriginData(queryOriginDataPara, this.resultPane.getSelectedIndex()); } /** * 查询下一页的数据 */ private void queryNextPageData() { int page = 0; page = sAttributes[this.resultPane.getSelectedIndex()].getPageNo(); if (page == QueryOriginDataPara.LAST_PAGE_NO) { return; } else { page++; } queryOriginDataPara.setPageNo(page); queryOriginData(queryOriginDataPara, this.resultPane.getSelectedIndex()); } /** * 查询最后一页的数据 */ private void queryLastPageData() { queryOriginDataPara.setPageNo(QueryOriginDataPara.LAST_PAGE_NO); queryOriginData(queryOriginDataPara, this.resultPane.getSelectedIndex()); } /** * 查询原始数据 * @param para 查询参数 */ private void queryOriginData(QueryOriginDataPara para, int idx){ // int errorCode=0; //错误码 String errorMessage= null; //错误信息 Vector vctOriginData = null; //原始数据列表 Vector vctOriginDataList = null; int exactPageNo = 0; //当前页 int totalPageNo = 0; //总页数 //只查一页的数据 para.setPageAccount(1); try { if (remoteServerNodeId == null) { sAttributes[idx].setRs(odInterface.queryOriginData(para)); } else { sAttributes[idx].setRs(odInterface.queryOriginData(para, remoteServerId[idx])); } } catch (CafPmException cafEx) { sAttributes[idx].setRs(null); // errorCode = cafEx.getErrorCode(); errorMessage = cafEx.getMessage(); ZJShowMsgPane.showMessageDialog(this, errorMessage, CafPmUtility.getClientLocalizedString("uep_caf_pm_client_warning_message_title"), ZJShowMsgPane.WARNING_MESSAGE); return; } vctOriginData = sAttributes[idx].getRs().getObjOriginData(); // init table // jPanelTable[idx] = new JPanel(); if (tableOriginResult[idx] == null && vctOriginData != null && vctOriginData.size() != 0) { jPanelTable[idx].setLayout(new BorderLayout()); OriginDataResultSet odrs = sAttributes[idx].getRs(); if (odrs.getObjOriginData() != null && odrs.getObjOriginData().size() > 0) { jLabelDataMessage[idx] = new JLabel(); sAttributes[idx].setCountPerPage(odrs.getRecordCountPerPage()); // 每页记录数 String[] fieldType = odrs.getObjFieldType(); sAttributes[idx].setFieldType(fieldType); SortColumn[] sc = new SortColumn[fieldType.length]; for (int j = 0; j < sc.length; j++) { if ( (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_BYTE)) || (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_DOUBLE)) || (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_FLOAT)) || (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_INTEGER)) || (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_LONG)) || (fieldType[j].equalsIgnoreCase(CafPmConst.JAVA_LANG_CLASS_SHORT))) { sc[j] = new SortColumn(j, SortColumn.NUMBER_SORT, SortColumn.NONE); } else { sc[j] = new SortColumn(j, SortColumn.STRING_SORT, SortColumn.NONE); } } sAttributes[idx].setOriginDataPoHeader(odrs.getObjHeader()); SortInfo sortInfo = new SortInfo(sc); if (odrs.getTotalPageNo() > 1) { sortInfo.setTrueSort(false); // 自定义排序 } tableOriginResult[idx] = new Table(new SortModel(new DefaultTableModel(null, sAttributes[idx].getOriginDataPoHeader())), sortInfo, true, SwingConstants.LEFT, SwingConstants.CENTER) { private static final long serialVersionUID = -2250022033504013596L; public void setColumnVisible(String columnName, boolean isVisible) { int j = -1; /*int fixColNum = this.fixedColumn.length; for (int i = fixColNum; i < this.tableColumn.length; i++) { if (this.tableColumn[i].getIdentifier().equals(columnName)) { j = i - fixColNum; break; } }*/ int realJ = 0; for (int i = 0; i < this.tableColumn.length; i++) { try { this.getColumn(this.tableColumn[i].getIdentifier()); realJ ++; } catch (IllegalArgumentException e) { // } if (this.tableColumn[i].getHeaderValue().equals(columnName)) { j = i; break; } } if (j == -1) { throw new RuntimeException("ColumnName is invalid: " + columnName); } if (isVisible) { // 需要显示 try { this.getColumn(columnName); } catch (IllegalArgumentException e) { this.addColumn(this.tableColumn[j]); int numCols = this.getColumnCount(); if (realJ < numCols - 1) { this.moveColumn(numCols - 1, realJ); } } } else { // 需要不显示 TableColumn tc = null; try { tc = this.getColumn(columnName); } catch (IllegalArgumentException e) { return; // do nothing } this.removeColumn(tc); } } }; tableOriginResult[idx].setAutoResizeMode(JTable.AUTO_RESIZE_OFF); tableOriginResult[idx].getTableHeader().setReorderingAllowed(false); tableOriginResult[idx].setAction(new ResultTableAction()); tableOriginResult[idx].addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (((Table)e.getComponent()).getSelectedColumn() == 0) { if (e.getKeyCode() == KeyEvent.VK_LEFT) { Table headerTable = ((Table)e.getComponent()).getHeaderTable(); if (headerTable != null && headerTable.getColumnCount() > 0) { headerTable.requestFocus(); headerTable.setColumnSelectionInterval( headerTable.getColumnCount() - 1, headerTable.getColumnCount() - 1); } } } } }); scrollPane[idx] = new JScrollPane(); scrollPane[idx].getViewport().add(tableOriginResult[idx]); jPanelTable[idx].add(jLabelDataMessage[idx], BorderLayout.NORTH); jPanelTable[idx].add(scrollPane[idx], BorderLayout.CENTER); jPanelTable[idx].repaint(); } // setOriginData OriginDataResultSet oSet = null; if (sAttributes[idx] != null) { oSet = sAttributes[idx].getRs(); } tableOriginResult[idx].getSortModel().setNewInitData(null); if(null != oSet){ vctOriginDataList = oSet.getObjOriginData(); sAttributes[idx].setCountPerPage(oSet.getRecordCountPerPage()); sAttributes[idx].setFieldType(oSet.getObjFieldType()); } String[] oneData = null ; String[] anotherData = null ; // if isChangeable if(null != vctOriginDataList){ oneData = (String[])vctOriginDataList.get(0); anotherData = (String[])vctOriginDataList.get(vctOriginDataList.size() - 1); } tableOriginResult[idx].getColumnModel().getColumn(0). setPreferredWidth(fontMetrics.stringWidth(sAttributes[idx].getOriginDataPoHeader()[0].trim()) + 70); tableOriginResult[idx].getColumnModel().getColumn(0). setMinWidth(fontMetrics.stringWidth(sAttributes[idx].getOriginDataPoHeader()[0].trim()) + 70); // 设置列宽(1024*768大约能显示9列数据,一般默认有两列隐藏Server和BSS) int width1 = 0, width2 = 0, width3 = 0, width = 0; int num = sAttributes[idx].getOriginDataPoHeader().length; for (int j = 1; j < num; j++) { if (num > 11) { width1 = fontMetrics.stringWidth(sAttributes[idx].getOriginDataPoHeader()[j].trim()) / 2 + 15; } else { width1 = fontMetrics.stringWidth(sAttributes[idx].getOriginDataPoHeader()[j].trim()) + 15; } width2 = fontMetrics.stringWidth(oneData[j]) + 10; width3 = fontMetrics.stringWidth(anotherData[j]) + 10; width = (width1 > width2 ? width1 : width2); width = (width > width3 ? width : width3); width = width > 70 ? width : 70; tableOriginResult[idx].getColumnModel().getColumn(j).setPreferredWidth(width); tableOriginResult[idx].getColumnModel().getColumn(j).setWidth(width); } // End if setTableFixColumn(idx); if (Arrays.asList(sAttributes[idx].getOriginDataPoHeader()).contains("Server")) { tableOriginResult[idx].setColumnVisible("Server", false, true); } if (Arrays.asList(sAttributes[idx].getOriginDataPoHeader()).contains("BSS")) { tableOriginResult[idx].setColumnVisible("BSS", false, true); } // setOriginData end resultPane.setEnabledAt(idx, true); } // init table end if(vctOriginData == null || vctOriginData.size() == 0) { ZJShowMsgPane.showMessageDialog(ShowOriginDataPanel.this, CafPmUtility.getClientLocalizedString("origindata_query_result_is_empty"), CafPmUtility.getClientLocalizedString("uep_caf_pm_client_information_message_title"), ZJShowMsgPane.INFORMATION_MESSAGE); } if (tableOriginResult[idx] == null) { return ; } tableOriginResult[idx].getSortModel().setNewInitData(null); // TODO exactPageNo = sAttributes[idx].getRs().getExactPageNo(); totalPageNo = sAttributes[idx].getRs().getTotalPageNo(); int totalNumber = sAttributes[idx].getRs().getTotalNumber(); setButtonEnabled(exactPageNo, totalPageNo, totalNumber); sAttributes[idx].setPageNo(exactPageNo); Object [] arguments = { new Integer(exactPageNo), new Integer(totalPageNo), new Integer(sAttributes[idx].getCountPerPage()), new Integer(totalNumber) }; strDataMessage = msgFmt.format(arguments); jLabelDataMessage[idx].setText(strDataMessage); addData2Table(idx, vctOriginData); if (sAttributes[idx].getRecordNum() != totalNumber) { // 其实查询错误也要更新标签信息. sAttributes[idx].setRecordNum(sAttributes[idx].getRs().getTotalNumber()); // 更新Tab页标签信息 resultPane.setTitleAt(idx, this.remoteServerId[idx] + "[" + this.serverAlias[idx] + "](" + CafPmUtility.getClientLocalizedString("query_all_record_num") + sAttributes[idx].getRecordNum() + ")"); } //设置真正当前的页码 queryOriginDataPara.setPageNo(exactPageNo); if(vctOriginData == null || vctOriginData.size() == 0) { ZJShowMsgPane.showMessageDialog(ShowOriginDataPanel.this, CafPmUtility.getClientLocalizedString("origindata_query_result_is_empty"), CafPmUtility.getClientLocalizedString("uep_caf_pm_client_information_message_title"), ZJShowMsgPane.INFORMATION_MESSAGE); } } /** * 设置按钮的使能性 * @param currentPageNo 当前页数 * @param totalPageNo 总页数 */ private void setButtonEnabled(int currentPageNo, int totalPageNo,int total){ if(totalPageNo <= 1){ //总页数是0的情况 jToolBarButtonFirstPage.setEnabled(false); jToolBarButtonPrevPage.setEnabled(false); jToolBarButtonNextPage.setEnabled(false); jToolBarButtonLastPage.setEnabled(false); setJumpToFunctionEnable(false); return; } else { setJumpToFunctionEnable(true); } if(currentPageNo == 1){ //当前是第一页的情况 jToolBarButtonFirstPage.setEnabled(false); jToolBarButtonPrevPage.setEnabled(false); }else{ //不是第一页的情况 jToolBarButtonFirstPage.setEnabled(true); jToolBarButtonPrevPage.setEnabled(true); } if(currentPageNo == totalPageNo){ //当前的页数与总页数相等的情况 jToolBarButtonNextPage.setEnabled(false); jToolBarButtonLastPage.setEnabled(false); }else{ //当前的页数与总页数不相等的情况 jToolBarButtonNextPage.setEnabled(true); jToolBarButtonLastPage.setEnabled(true); } } /** * 设置远程查询原始数据的局结点Id,如是null表示本局 * @param serverId 远程查询原始数据的局结点Id */ void setRemoteServerNodeId(Vector serverId){ this.remoteServerNodeId = serverId; } /** * 设置页面跳转功能使能状态 * @param enabled */ private void setJumpToFunctionEnable(boolean enabled) { jTextFiledJumpTo.setEnabled(enabled); jToolBarButtonJumpTo.setEnabled(enabled); } /** * 设置测量nedescription */ void setNeDescription(NeDescription neDes) { this.neDescription = neDes; } /** * 返回各个OMM的ServerId * @return */ String[] getRemoteServerId() { return remoteServerId; } /** * 返回各个OMM的Server别名 * @return */ String[] getServerAlias() { return serverAlias; } // 表格的action private class ResultTableAction extends TableActionForPm { ResultTableAction() { } public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } public void headerMouseClick(MouseEvent e) { super.headerMouseClick(e); if( e.getModifiers() == MouseEvent.BUTTON3_MASK) { Vector menuItems = tableOriginResult[resultPane.getSelectedIndex()].getHeaderItems(); Vector unselectableItems = new Vector(); unselectableItems.add(sAttributes[resultPane.getSelectedIndex()].getOriginDataPoHeader()[0]); ItemSelector isDlg = new ItemSelector( originDataController.getMainFrame() ,CafPmUtility.getClientLocalizedString("config_column_visible_title") ,menuItems, unselectableItems); Point hp = ((JTableHeader)e.getSource()).getLocationOnScreen(); int x = e.getX() + hp.x; int y = e.getY() + hp.y; int width = isDlg.getWidth(); int height = isDlg.getHeight(); Dimension scrDimension = Toolkit.getDefaultToolkit().getScreenSize(); int scrWidth = (int)scrDimension.getWidth(); int scrHeight = (int)scrDimension.getHeight(); int locX = x + 10, locY = y + 10; if (locX + width > scrWidth - 50) { locX = scrWidth - (scrWidth - x)/2 - width; } if (locY + height > scrHeight - 50) { locY = scrHeight - (scrHeight - y)/2 - height; } isDlg.setLocation(new Point(locX, locY)); isDlg.setVisible(true); } else { getTable().getTableHeader().revalidate();//有些情况,表头没有刷新。 // getTable().getTableHeader().resizeAndRepaint(); /*if (((Table)getTable()).getMainTable() != null) { ((Table)getTable()).getMainTable().getTableHeader().revalidate(); ((Table)getTable()).getMainTable().getTableHeader().resizeAndRepaint(); }*/ } } /** * 重新去服务器端查询数据 */ public void doFakeSort(int sortType, String colName) { // dMsg.error("COLUMN NAME: " + colName); int page = 1; queryOriginDataPara.setPageNo(page); int tbIdx = 0; JCheckBox[] jcbLoc = originDataController.getQueryOriginDataFrame().getAdvanceDialog().getJCheckBoxByLoc(); int timeGroup = queryOriginDataPara.getGroupTimeId(); JCheckBox[] jcbKw = originDataController.getQueryOriginDataFrame().getAdvanceDialog().getJCheckBoxByKw(); int kwLength = 0; int locLength = 0; if (timeGroup == 0) { // 无分组查询 for (int i = 0; i < OriginDataConst.MAX_NE_LOCATION_PARA_NUM; i++) { if (jcbLoc[i].isVisible()) { locLength ++; if (jcbLoc[i].getText().equalsIgnoreCase(colName)) { tbIdx = i + 1; } } } if (tbIdx == 0) { Vector vctAttr = originDataController.getQueryOriginDataFrame().getAdvanceDialog().getVctAttri(); for (int i = 0; i < vctAttr.size(); i++) { POAttribute poAttr = (POAttribute)vctAttr.get(i); if (poAttr.getParaName().equalsIgnoreCase(colName)) { tbIdx = locLength + i + 1; break; } } } } else { // 分组查询 // 位置分组 boolean; for (int i = 0; i < OriginDataConst.MAX_NE_LOCATION_PARA_NUM; i++) { if (jcbLoc[i].isVisible()) { if (jcbLoc[i].isSelected()) { selected = true; } if (selected && !jcbLoc[i].isSelected()) { break; } locLength ++; if (jcbLoc[i].getText().equalsIgnoreCase(colName)) { tbIdx = i + 1; } } } // 未找到匹配,则在属性分组中找 if (tbIdx == 0) { for (int i = 0; i < jcbKw.length; i++) { if (jcbKw[i].isEnabled() && jcbKw[i].isSelected()) { kwLength++; if (jcbKw[i].getText().equalsIgnoreCase(colName)) { tbIdx = locLength + kwLength; } } } } // 是普通属性列 int plainIndex = 0; int unCalculable = 0; if (tbIdx == 0) { Vector vctAttr = originDataController.getQueryOriginDataFrame().getAdvanceDialog().getVctAttri(); for (int i = 0; i < vctAttr.size(); i++) { POAttribute poAttr = (POAttribute)vctAttr.get(i); if (! poAttr.isKeyword() && poAttr.isCalculable()) { plainIndex ++; } else if (!poAttr.isCalculable()) { // 不可计算列 unCalculable ++; if (poAttr.getParaName().equalsIgnoreCase(colName)) { tbIdx = locLength + kwLength + plainIndex + unCalculable; break; } } else { continue; } if (poAttr.getParaName().equalsIgnoreCase(colName)) { tbIdx = locLength + kwLength + plainIndex; break; } } } /*int plainIndex = 0; if (tbIdx == 0) { Vector vctAttr = originDataController.getQueryOriginDataFrame().getAdvanceDialog().getVctAttri(); for (int i = 0; i < vctAttr.size(); i++) { POAttribute poAttr = (POAttribute)vctAttr.get(i); if (! poAttr.isKeyword()) { plainIndex ++; } else { continue; } if (poAttr.getParaName().equalsIgnoreCase(colName)) { tbIdx = locLength + kwLength + plainIndex; break; } } }*/ } tbIdx = tbIdx + 1; // 表格序+1,时间信息 Vector vctTableOrder = new Vector(); TableOrder tableOrder = new TableOrder(); // 实例化一个表格排序信息 if (sortType == TableOrder.ASCEND_ORDER) { tableOrder.setIndex(tbIdx); tableOrder.setOrder(TableOrder.ASCEND_ORDER); } else if (sortType == TableOrder.DESCEND_ORDER) { tableOrder.setIndex(tbIdx); tableOrder.setOrder(TableOrder.DESCEND_ORDER); } else { tableOrder.setTableColumnName(OriginDataConst.ORIGIN_DATA_TABLE_REPORT_TIME_COLUMN_NAME); tableOrder.setIndex(1); tableOrder.setOrder(TableOrder.ASCEND_ORDER); } vctTableOrder.add(tableOrder); queryOriginDataPara.setVctTableOrder(vctTableOrder); queryOriginData(queryOriginDataPara, resultPane.getSelectedIndex()); } } /** * @author Administrator * OMM子Tab页面对应的信息 */ static class SpecificAttribute { private String serverId = ""; // 1 private String alias = ""; // 2 private OriginDataResultSet rs = null; // 3 private int pageNo = 0; // 4 private int pageAccount = 0; // 5 private int recordNum = 0; // 6 public int getRecordNum() { return recordNum; } public void setRecordNum(int recordNum) { this.recordNum = recordNum; } private int countPerPage = 500; // 7 private String[] fieldType = null; private String[] originDataPoHeader = null; public String[] getOriginDataPoHeader() { return originDataPoHeader; } public void setOriginDataPoHeader(String[] originDataPoHeader) { this.originDataPoHeader = originDataPoHeader; } public String[] getFieldType() { return fieldType; } public void setFieldType(String[] fieldType) { this.fieldType = fieldType; } public String getServerId() { return serverId; } public void setServerId(String serverId) { this.serverId = serverId; } public String getAlias() { return alias; } public void setAlias(String alias) { this.alias = alias; } public OriginDataResultSet getRs() { return rs; } public void setRs(OriginDataResultSet rs) { this.rs = rs; } public int getPageNo() { return pageNo; } public void setPageNo(int pageNo) { this.pageNo = pageNo; } public int getPageAccount() { return pageAccount; } public void setPageAccount(int pageAccount) { this.pageAccount = pageAccount; } public int getCountPerPage() { return countPerPage; } public void setCountPerPage(int countPerPage) { this.countPerPage = countPerPage; } public SpecificAttribute() { } } }

你可能感兴趣的:(JAVA,null,string,vector,integer,table,query)