|
@@ -9,10 +9,15 @@ import com.its.vds.global.AppRepository;
|
|
|
import com.its.vds.service.VdsCtlrService;
|
|
|
import com.sun.management.OperatingSystemMXBean;
|
|
|
import lombok.Getter;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
|
+import javax.swing.Timer;
|
|
|
import javax.swing.*;
|
|
|
import javax.swing.plaf.FontUIResource;
|
|
|
+import javax.swing.table.DefaultTableCellRenderer;
|
|
|
+import javax.swing.table.TableCellRenderer;
|
|
|
+import javax.swing.table.TableColumnModel;
|
|
|
import javax.swing.text.StyleContext;
|
|
|
import java.awt.*;
|
|
|
import java.awt.datatransfer.Clipboard;
|
|
@@ -21,11 +26,10 @@ import java.awt.event.ActionEvent;
|
|
|
import java.awt.event.ActionListener;
|
|
|
import java.io.IOException;
|
|
|
import java.lang.management.ManagementFactory;
|
|
|
-import java.util.Locale;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.SortedMap;
|
|
|
-import java.util.TreeMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Getter
|
|
|
public class MainUI {
|
|
|
private static MainUI _instance = null;
|
|
@@ -34,7 +38,8 @@ public class MainUI {
|
|
|
private Timer timer;
|
|
|
private Long tick = Long.valueOf(0);
|
|
|
|
|
|
- private CtlrSttsTableModel ctlrSttsTableModel = new CtlrSttsTableModel();
|
|
|
+ private CtlrSttsTableModel ctlrSttsTableModel;
|
|
|
+ private TableCellRenderer cellRenderer = new CtlrSttsTableCellRenderer();
|
|
|
|
|
|
private JPanel rootPanel;
|
|
|
private JPanel pnlCtlr;
|
|
@@ -46,7 +51,7 @@ public class MainUI {
|
|
|
private JCheckBox chkLogPause;
|
|
|
private JLabel lblSystime;
|
|
|
private JPanel pnlStatusBar;
|
|
|
- private JTable tblCtlr;
|
|
|
+ private JTable tblCtlrList;
|
|
|
private JTextArea taLog;
|
|
|
private JButton btnLogCopy;
|
|
|
private JLabel lblTotal;
|
|
@@ -60,6 +65,7 @@ public class MainUI {
|
|
|
|
|
|
public void displaySystime() {
|
|
|
lblSystime.setText(" " + SysUtils.getSysTimeStr() + " ");
|
|
|
+ updateCommSttsTotal();
|
|
|
}
|
|
|
|
|
|
public void displayResource() {
|
|
@@ -94,7 +100,7 @@ public class MainUI {
|
|
|
btnLogDirOpen.setFocusable(false);
|
|
|
btnLogCopy.setFocusable(false);
|
|
|
|
|
|
- initTblListHeader();
|
|
|
+ //initTblListUI();
|
|
|
|
|
|
btnLogPause.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
@@ -132,30 +138,53 @@ public class MainUI {
|
|
|
/**
|
|
|
* 목록 헤더 생성
|
|
|
*/
|
|
|
- private void initTblListHeader() {
|
|
|
+ private void initTblListUI(List<TbVdsCtlr> ctlrList) {
|
|
|
|
|
|
- tblCtlr.setModel(ctlrSttsTableModel);
|
|
|
- tblCtlr.setBackground(Color.WHITE);
|
|
|
- tblCtlr.setSelectionMode(1);
|
|
|
- //tblCtlr.addMouseListener(new ListMouseListener(null));
|
|
|
- tblCtlr.getColumnModel().getColumn(0).setPreferredWidth(50);
|
|
|
- tblCtlr.getColumnModel().getColumn(1).setPreferredWidth(100);
|
|
|
- tblCtlr.getColumnModel().getColumn(2).setPreferredWidth(100);
|
|
|
- tblCtlr.getColumnModel().getColumn(3).setPreferredWidth(210);
|
|
|
- tblCtlr.getColumnModel().getColumn(4).setPreferredWidth(50);
|
|
|
-//
|
|
|
-// this.defaultTableCellRenderer = new DefaultTableCellRenderer();
|
|
|
-// this.defaultTableCellRenderer.setHorizontalAlignment(0);
|
|
|
-// this.defaultTableCellRenderer.setBackground(new Color(255, 220, 220));
|
|
|
-// this.tableColumnModel = tblCtlr.getColumnModel();
|
|
|
-// for (int i = 0; i < this.tableColumnModel.getColumnCount(); i++)
|
|
|
-// this.tableColumnModel.getColumn(i).setCellRenderer(this.defaultTableCellRenderer);
|
|
|
-// this.tableCellRenderer = new CommTableCellRenderer();
|
|
|
-// try {
|
|
|
-// tblCtlr.setDefaultRenderer(Class.forName("java.lang.String"), this.tableCellRenderer);
|
|
|
-// } catch (ClassNotFoundException ex) {
|
|
|
-// System.exit(0);
|
|
|
-// }
|
|
|
+ ctlrSttsTableModel = new CtlrSttsTableModel(ctlrList);
|
|
|
+ tblCtlrList.setModel(ctlrSttsTableModel);
|
|
|
+ tblCtlrList.setBackground(Color.WHITE);
|
|
|
+ tblCtlrList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
|
|
+ //tblCtlrList.setAutoCreateRowSorter(true); // sorting
|
|
|
+
|
|
|
+ //tblCtlrList.addMouseListener(new ListMouseListener(null));
|
|
|
+
|
|
|
+ TableColumnModel getColumnModel = tblCtlrList.getColumnModel();
|
|
|
+ getColumnModel.getColumn(0).setPreferredWidth(30); // "S",
|
|
|
+ getColumnModel.getColumn(1).setPreferredWidth(75); // "번호",
|
|
|
+ getColumnModel.getColumn(2).setPreferredWidth(75); // "시설물ID",
|
|
|
+ getColumnModel.getColumn(3).setPreferredWidth(260); // "명칭",
|
|
|
+ getColumnModel.getColumn(4).setPreferredWidth(120); // "IP",
|
|
|
+ getColumnModel.getColumn(5).setPreferredWidth(55); // "PORT",
|
|
|
+ getColumnModel.getColumn(6).setPreferredWidth(70); // "연결상태",
|
|
|
+ getColumnModel.getColumn(7).setPreferredWidth(50); // "도어",
|
|
|
+ getColumnModel.getColumn(8).setPreferredWidth(50); // "팬",
|
|
|
+ getColumnModel.getColumn(9).setPreferredWidth(50); // "히터",
|
|
|
+ getColumnModel.getColumn(10).setPreferredWidth(50); // "온도",
|
|
|
+ getColumnModel.getColumn(11).setPreferredWidth(50); // "Video",
|
|
|
+ getColumnModel.getColumn(12).setPreferredWidth(120);
|
|
|
+ getColumnModel.getColumn(13).setPreferredWidth(120);
|
|
|
+
|
|
|
+ DefaultTableCellRenderer centerAlign = new DefaultTableCellRenderer();
|
|
|
+ centerAlign.setHorizontalAlignment(JLabel.CENTER);
|
|
|
+ for (int ii = 0; ii < getColumnModel.getColumnCount(); ii++) {
|
|
|
+ getColumnModel.getColumn(ii).setCellRenderer(cellRenderer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateCommSttsTotal() {
|
|
|
+ int ctlrTotal = 0;
|
|
|
+ int ctlrError = 0;
|
|
|
+ for (Map.Entry<String, TbVdsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ TbVdsCtlr obj = e.getValue();
|
|
|
+ if (StringUtils.equals("N", obj.getDEL_YN()) && StringUtils.equals("Y", obj.getVALD_YN())) {
|
|
|
+ ctlrTotal++;
|
|
|
+ if (!"CMS0".equals(obj.getStts().getCMNC_STTS_CD())) {
|
|
|
+ ctlrError++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lblTotal.setText(" " + ctlrTotal + " ");
|
|
|
+ lblError.setText(" " + ctlrError + " ");
|
|
|
}
|
|
|
|
|
|
public void LoadControllerInfo(VdsCtlrService vdsCtlrService) {
|
|
@@ -168,18 +197,29 @@ public class MainUI {
|
|
|
ctlrMap.put(Integer.valueOf(obj.getVDS_CTLR_NMBR()), obj);
|
|
|
}
|
|
|
}
|
|
|
+ List<TbVdsCtlr> ctlrList = new ArrayList<TbVdsCtlr>(ctlrMap.values());
|
|
|
+ initTblListUI(ctlrList);
|
|
|
+// for (Map.Entry<Integer, TbVdsCtlr> e : ctlrMap.entrySet()) {
|
|
|
+// TbVdsCtlr obj = e.getValue();
|
|
|
+// ctlrSttsTableModel.Add(obj);
|
|
|
+// }
|
|
|
+ updateCommSttsTotal();
|
|
|
+ }
|
|
|
|
|
|
- int ctlrTotal = ctlrMap.size();
|
|
|
- int ctlrError = 0;
|
|
|
- for (Map.Entry<Integer, TbVdsCtlr> e : ctlrMap.entrySet()) {
|
|
|
- TbVdsCtlr obj = e.getValue();
|
|
|
- ctlrSttsTableModel.Add(obj);
|
|
|
- if (!"CMS0".equals(obj.getStts().getCMNC_STTS_CD())) {
|
|
|
- ctlrError++;
|
|
|
+ public void updateCtlrStts(TbVdsCtlr obj) {
|
|
|
+
|
|
|
+ //CtlrSttsTableModel ctlrSttsTableModel = (CtlrSttsTableModel)tblCtlrList.getModel();
|
|
|
+ for (int ii = 0; ii < ctlrSttsTableModel.getRowCount(); ii++) {
|
|
|
+ if (obj.getVDS_CTLR_ID().equals(ctlrSttsTableModel.getValueAt(ii, 2).toString())) {
|
|
|
+ int modelRow = tblCtlrList.convertRowIndexToModel(ii);
|
|
|
+// //int viewColumn = tblCtlrList.getSelectedColumn();
|
|
|
+// int modelColumn = tblCtlrList.convertColumnIndexToModel(4);
|
|
|
+// Object cell = tblCtlrList.getValueAt(modelRow, modelColumn);
|
|
|
+// log.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: {}", cell);
|
|
|
+ ctlrSttsTableModel.setValue(obj, ii, modelRow);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
- lblTotal.setText(" " + ctlrTotal + " ");
|
|
|
- lblError.setText(" " + ctlrError + " ");
|
|
|
}
|
|
|
|
|
|
{
|
|
@@ -242,10 +282,10 @@ public class MainUI {
|
|
|
pnlCtlrTitle.add(lblError, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
|
|
final JScrollPane scrollPane1 = new JScrollPane();
|
|
|
pnlCtlr.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
|
|
- tblCtlr = new JTable();
|
|
|
- Font tblCtlrFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, tblCtlr.getFont());
|
|
|
- if (tblCtlrFont != null) tblCtlr.setFont(tblCtlrFont);
|
|
|
- scrollPane1.setViewportView(tblCtlr);
|
|
|
+ tblCtlrList = new JTable();
|
|
|
+ Font tblCtlrListFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, tblCtlrList.getFont());
|
|
|
+ if (tblCtlrListFont != null) tblCtlrList.setFont(tblCtlrListFont);
|
|
|
+ scrollPane1.setViewportView(tblCtlrList);
|
|
|
pnlLog = new JPanel();
|
|
|
pnlLog.setLayout(new GridLayoutManager(2, 1, new Insets(0, 4, 0, 4), -1, -1));
|
|
|
rootPanel.add(pnlLog, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, new Dimension(-1, 250), new Dimension(-1, 250), new Dimension(-1, 250), 0, false));
|