/// <summary> /// Add an annotation to the list. /// </summary> public virtual void addAnnotation(StateMod_Network_AnnotationData annotationData) { // For now just add at the end... if (annotationData != null) { __annotationJListModel.addElement(annotationData.getLabel()); } checkVisibility(); }
/// <summary> /// Set the annotation data and repopulate the list. /// </summary> public virtual void setAnnotationData(IList <StateMod_Network_AnnotationData> annotationDataList) { __annotationDataList = annotationDataList; IList <string> annotationLabelList = new List <string>(annotationDataList.Count); foreach (StateMod_Network_AnnotationData annotationData in annotationDataList) { annotationLabelList.Add(annotationData.getLabel()); } // Sort the array before adding annotationLabelList.Sort(); __annotationJListModel = new DefaultListModel(); foreach (string annotationLabel in annotationLabelList) { __annotationJListModel.addElement(annotationLabel); } __annotationJList.setModel(__annotationJListModel); checkVisibility(); }
//-------- //-------- Constructors //-------- /// <summary> /// Constructor a frame to contain the device data. Provide /// the device and the log file name /// </summary> public TagMainFrame() : base("1-Wire Tag Viewer") { // construct the frame //set the look and feel to the system look and feel try { UIManager.LookAndFeel = UIManager.SystemLookAndFeelClassName; } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } // add an event listener to end the aplication when the frame is closed addWindowListener(new WindowAdapterAnonymousInnerClassHelper(this, e)); // create the main panel mainPanel = new JPanel(new BorderLayout(10, 10)); // create the sub-pannels northPanel = new JPanel(); northPanel.Border = BorderFactory.createLoweredBevelBorder(); centerPanel = new JPanel(); centerPanel.Layout = new BoxLayout(centerPanel, BoxLayout.Y_AXIS); southPanel = new JPanel(); southPanel.Layout = new BoxLayout(southPanel, BoxLayout.Y_AXIS); southPanel.Border = BorderFactory.createLoweredBevelBorder(); westPanel = new JPanel(); westPanel.Border = BorderFactory.createRaisedBevelBorder(); westPanel.Border = BorderFactory.createEmptyBorder(10, 10, 10, 10); eastPanel = new JPanel(); eastPanel.Border = BorderFactory.createEmptyBorder(10, 10, 10, 10); // fill the panels // north logLabel = new JLabel("Log Filename: "); northPanel.add(logLabel); logField = new JTextField("log.txt", 20); logField.addActionListener(this); northPanel.add(logField); // center listData = new DefaultListModel(); listData.addElement(" "); listData.addElement(" "); listData.addElement(" "); listData.addElement(" "); pathList = new JList(listData); pathList.VisibleRowCount = 5; scrollPanel = new JScrollPane(pathList); scrollPanel.Border = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "1-Wire Paths to Search"); centerPanel.add(scrollPanel); // west scanCheck = new JCheckBox("Scan 1-Wire Paths for XML Tags", false); scanCheck.addActionListener(this); westPanel.add(scanCheck); // south portLabel = new JLabel("Adapter:"); southPanel.add(portLabel); statusLabel = new JLabel("Status:"); southPanel.add(statusLabel); // add to main mainPanel.add(northPanel, BorderLayout.NORTH); mainPanel.add(centerPanel, BorderLayout.CENTER); mainPanel.add(southPanel, BorderLayout.SOUTH); mainPanel.add(eastPanel, BorderLayout.EAST); mainPanel.add(westPanel, BorderLayout.WEST); // add to frame ContentPane.add(mainPanel); // pack the frame pack(); // resize the window and put in random location Dimension current_sz = Size; Size = new Dimension(current_sz.width * 5 / 4, current_sz.height); Toolkit tool = Toolkit.DefaultToolkit; Dimension mx = tool.ScreenSize; Dimension sz = Size; Random rand = new Random(); setLocation((mx.width - sz.width) / 2, (mx.height - sz.height) / 2); // clear out the listbox data listData.removeAllElements(); // make visible Visible = true; }
/// <summary> /// Add an element to the path list /// </summary> public virtual void addToPathList(string newPath) { listData.addElement(newPath); }