📄 thresholdspanel.java
字号:
{ ex.printStackTrace(); } } return jScrollPane; } public class eventItem { String Name; String Comment; public eventItem(String Name, String Comment) { this.Name=Name; this.Comment=Comment; } public String getName(){return Name;} public void setcheckItem(String _Name){Name=_Name;} public String getComment(){return Comment;} public void setComment(String _Comment){Comment=_Comment;} } /** * This method initializes jTable * * @return javax.swing.JTable */ private JTable getJTable() { if (jTable == null) { jTable = new JTable(dataModel); } return jTable; } /** * internal class * <class or interface desc> */ public class JPropertyTableModel extends AbstractTableModel { public class propertyThresholdItem { public Threshold Threshold; public Property property; public String Name; public String Type; public String Match; public String High; public String Low; public String Rate; public String Offset; public InstanceObject Instance; public propertyThresholdItem() { } } private final String[] names = { "Name", "Type", "Match","High", "Low","Rate","Offset" }; public Vector vectThresholdCollection=new Vector(); JPropertyTableModel() { } // These methods always need to be implemented. //Add Event items to eventlist public void addEventItem(Property property,Threshold threshold,InstanceObject Instance, String Name, String Type, String Match, String High, String Low, int rate, String Offset) throws IntelMobileException { //cache the evet item list propertyThresholdItem thresholdItem=new propertyThresholdItem(); thresholdItem.property=property; thresholdItem.Threshold=threshold; thresholdItem.Instance=Instance; thresholdItem.Type=Type; thresholdItem.Match=Match; thresholdItem.High=High; thresholdItem.Low=Low; thresholdItem.Name=Name; thresholdItem.Offset=Offset; thresholdItem.Rate=String.valueOf(rate); vectThresholdCollection.add(thresholdItem); this.initialize(); } public void removeThreshold(int index) { try { propertyThresholdItem thresholdItem=(propertyThresholdItem)vectThresholdCollection.get(index); if(thresholdItem.Threshold.Stop()) { thresholdItem.Threshold.RemoveObserver(MainFrame.clObserver); } vectThresholdCollection.remove(index); } catch(IntelMobileException e) { } } public void removeALLThreshold() { int count=vectThresholdCollection.size(); for(int i=0;i<count;i++) { removeThreshold(0); } } public int getColumnCount() { return names.length; } public int getRowCount() { return vectThresholdCollection.size();//data.length; } public Object getValueAt(int row, int col) { propertyThresholdItem item=(propertyThresholdItem)vectThresholdCollection.get(row); String strRet=null; switch(col) { case 0: strRet= item.Name; break; case 1: strRet= item.Type; break; case 2: strRet= item.Match; break; case 3: strRet= item.High; break; case 4: strRet= item.Low; break; case 5: strRet= item.Rate; break; case 6: strRet= item.Offset; break; } return strRet; } public void setValueAt(int row, int col, String mValue ) { propertyThresholdItem item=(propertyThresholdItem)vectThresholdCollection.get(row); switch(col) { case 0: item.Name = mValue; break; case 1: item.Type = mValue; break; case 2: item.Match = mValue; break; case 3: item.High = mValue; break; case 4: item.Low = mValue; break; case 5: item.Rate = mValue; break; case 6: item.Offset = mValue; break; } } // The default implementations of these methods in // AbstractTableModel would work, but we can refine them. public String getColumnName(int column) { return names[column]; } public Class getColumnClass(int col) { return String.class; //return getValueAt(0, col).getClass(); } public boolean isCellEditable(int row, int col) { return false; } // ------------- initialize -------------- public void initialize() throws IntelMobileException { } /* (non-Javadoc) * @see javax.swing.table.TableModel#getValueAt(int, int) */ } } class Watcher implements Observer { public void update(Observable obj, Object arg) { /* try { Event myEvent = (Event)arg; if(myEvent != null) { for(int i=0; i<PropertyEventPanel.dataModel.vectThresholdCollection.size(); i++) { if(myEvent.GetObjectKey().toLowerCase().equals(PropertyEventPanel.dataModel.getValueAt(i,0).toString().toLowerCase())) { if(myEvent.GetType()== EventType.eThresholdLow) { String mylowtemp = String.valueOf(PropertyEventPanel.dataModel.getValueAt(i,4)); String myoffsettemp = String.valueOf(PropertyEventPanel.dataModel.getValueAt(i,6)); int mylow = Integer.valueOf(mylowtemp).intValue(); int myoffset = Integer.valueOf(myoffsettemp).intValue(); mylow -= myoffset; PropertyEventPanel.dataModel.setValueAt(i,4,String.valueOf(mylow)); } else if(myEvent.GetType()== EventType.eThresholdHigh) { String mylowtemp = String.valueOf(PropertyEventPanel.dataModel.getValueAt(i,3)); String myoffsettemp = String.valueOf(PropertyEventPanel.dataModel.getValueAt(i,6)); int mylow = Integer.valueOf(mylowtemp).intValue(); int myoffset = Integer.valueOf(myoffsettemp).intValue(); mylow += myoffset; PropertyEventPanel.dataModel.setValueAt(i,3,String.valueOf(mylow)); } else if(myEvent.GetType()== EventType.eThresholdReached) { String mylowtemp = String.valueOf(PropertyEventPanel.dataModel.getValueAt(i,2)); String myoffsettemp = String.valueOf(PropertyEventPanel.dataModel.getValueAt(i,6)); int mylow = Integer.valueOf(mylowtemp).intValue(); int myoffset = Integer.valueOf(myoffsettemp).intValue(); mylow += myoffset; PropertyEventPanel.dataModel.setValueAt(i,2,String.valueOf(mylow)); } refreshUI(); } } } } catch(IntelMobileException ex) { } */ } }} // @jve:decl-index=0:visual-constraint="10,10"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -