/** Description of the Method */ public void removeAllElements() { for (Enumeration<BPM_Element> e = listModel.elements(); e.hasMoreElements(); ) { BPM_Element elm = e.nextElement(); elm.stopMonitor(); } listModel.removeAllElements(); }
private void register() { if (session != null && session.isConnected()) { onlineUsers.clear(); // get the current list Message msg = session.sendMessage("", "list", ""); System.out.println("LIST: " + msg.getBody()); StringTokenizer st = new StringTokenizer(msg.getBody(), "\n"); while (st.hasMoreTokens()) { onlineUsers.addElement(new HostItem(st.nextToken())); } session.postMessage("", "register", ""); } }
public void receiveMsg(Message msg) { // System.out.println(msg.getSubject() + " : " + msg.getBody()); String subject = msg.getSubject(); if (subject != null) { if (subject.equals("online")) { onlineUsers.addElement(new HostItem(msg.getBody())); displayMessage(msg.getBody() + " : Online", onlineClientAttrSet); } else if (subject.equals("offline")) { onlineUsers.removeElement(new HostItem(msg.getBody())); displayMessage(msg.getBody() + " : Offline", offlineClientAttrSet); } else if (subject.equals("eavesdrop enabled")) { Object[] values = jListOnlineUsers.getSelectedValues(); if (values == null) return; for (int i = 0; i < values.length; i++) { ((HostItem) values[i]).eavesDroppingEnabled = true; } jListOnlineUsers.updateUI(); } else if (subject.equals("eavesdrop disabled")) { Object[] values = jListOnlineUsers.getSelectedValues(); if (values == null) return; for (int i = 0; i < values.length; i++) { ((HostItem) values[i]).eavesDroppingEnabled = false; } jListOnlineUsers.updateUI(); } else if (subject.equals("globaleavesdrop enabled")) { displayMessage("Global Eavesdropping Enabled", onlineClientAttrSet); } else if (subject.equals("globaleavesdrop disabled")) { displayMessage("Global Eavesdropping Disabled", offlineClientAttrSet); } else { String to = msg.getTo(); String from = msg.getFrom() == null ? "server" : msg.getFrom(); String body = msg.getBody() != null ? msg.getBody() : ""; if (jTextFieldUser.getText().equals(to)) { // this message is sent to us displayMessage(subject, from, body, incomingMsgAttrSet); } else { // this is an eavesdrop message displayMessage(subject, to, from, body, eavesdropAttrSet); } } } else { subject = ""; String to = msg.getTo(); String from = msg.getFrom() == null ? "server" : msg.getFrom(); String body = msg.getBody() != null ? msg.getBody() : ""; if (jTextFieldUser.getText().equals(to)) { // this message is sent to us displayMessage(subject, from, body, incomingMsgAttrSet); } else { // this is an eavesdrop message displayMessage(subject, to, from, body, eavesdropAttrSet); } } }
/** * Sets the valueAt attribute of the BPMsList object * * @param aValue The new valueAt value * @param row The new valueAt value * @param column The new valueAt value */ public void setValueAt(Object aValue, int row, int column) { if (column == 1) { BPM_Element elm = listModel.elementAt(row); elm.setActive(!elm.isActive()); fireTableCellUpdated(row, column); } }
/** * Returns the valueAt attribute of the BPMsList object * * @param row The Parameter * @param column The Parameter * @return The valueAt value */ public Object getValueAt(int row, int column) { BPM_Element elm = listModel.elementAt(row); if (column == 0) { return elm.getName(); } return elm.isActiveObj(); }
private void disconnect() { if (session != null && session.isConnected()) { session.disconnect(); } jToggleButtonConnect.setSelected(false); jToggleButtonConnect.setText("Connect"); jToggleButtonRegister.setSelected(false); onlineUsers.clear(); jToggleButtonRegister.setText("Register"); }
public void addElement(Object o) { Comparable a = (Comparable) o; int i = 0; for (i = 0; i < getSize(); i++) { if (a.compareTo(getElementAt(i)) < 0) { break; } } super.add(i, o); }
/** * Returns the bPM attribute of the BPMsTable object * * @param name The Parameter * @return The bPM value */ public BPM_Element getBPM(String name) { BPM_Element bpmElm = null; Enumeration<BPM_Element> bpm_enum = listModel.elements(); while (bpm_enum.hasMoreElements()) { BPM_Element bpmElm1 = bpm_enum.nextElement(); if (bpmElm1.getName().equals(name)) { bpmElm = bpmElm1; } } return bpmElm; }
/** Constructor for the BPMsList object */ public BPMsTable() { listModel.addListDataListener( new ListDataListener() { public void contentsChanged(ListDataEvent e) { fireTableDataChanged(); } public void intervalAdded(ListDataEvent e) { fireTableDataChanged(); } public void intervalRemoved(ListDataEvent e) { fireTableDataChanged(); } }); }
/** Description of the Method */ public void startMonitor() { for (Enumeration<BPM_Element> e = listModel.elements(); e.hasMoreElements(); ) { BPM_Element elm = e.nextElement(); elm.startMonitor(); } }
/** * Returns the rowCount attribute of the BPMsList object * * @return The rowCount value */ public int getRowCount() { return listModel.getSize(); }
public MainCitiesCriteriaPanel() { super(new BorderLayout()); CountryController countryc = Application.getCountryController(); CitiesController citiesc = Application.getCitiesController(); countryName = Application.getCountryName(); label = new JLabel(); labelPanel = new JPanel(); labelPanel.add(label); label.setText("Criteria to select main cities for " + countryName.replaceAll("_", " ")); listModel = new DefaultListModel(); Iterator<HashMap<String, String>> iter = citiesc.getToponymTypesIterator(); while (iter.hasNext()) { String topTypeName = iter.next().get("code"); listModel.addElement(topTypeName); } list = new JList(listModel); list.addListSelectionListener(this); listPanel = new JScrollPane(list); NumberFormat nCitiesFormat = NumberFormat.getInstance(); nCitiesFormat.setMaximumFractionDigits(0); nCitiesFormat.setMaximumIntegerDigits(4); NumberFormat distFormat = NumberFormat.getInstance(); distFormat.setMaximumFractionDigits(0); distFormat.setMaximumIntegerDigits(3); nCitiesField = new JFormattedTextField(nCitiesFormat); distField = new JFormattedTextField(distFormat); nCitiesField.setMaximumSize(new Dimension(50, 1)); distField.setMaximumSize(new Dimension(50, 1)); rb1 = new JRadioButton("Filter by type", true); rb2 = new JRadioButton("Filter by number", false); rb3 = new JRadioButton("Filter by distance to the borders (km)", false); ButtonGroup bgroup = new ButtonGroup(); bgroup.add(rb1); bgroup.add(rb2); bgroup.add(rb3); JPanel radioPanel = new JPanel(); radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS)); radioPanel.add(rb1); radioPanel.add(listPanel); radioPanel.add(rb2); radioPanel.add(nCitiesField); radioPanel.add(rb3); radioPanel.add(distField); submit = new JButton(); back = new JButton(); submit.setText("OK"); back.setText("GO BACK"); submit.addActionListener(this); back.addActionListener(this); buttonPanel = new JPanel(); buttonPanel.add(back); buttonPanel.add(submit); add(labelPanel, BorderLayout.NORTH); add(radioPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); }
private void deregister() { onlineUsers.clear(); if (session != null && session.isConnected()) { session.postMessage("", "deregister", ""); } }
public void setElements(Vector v) { clear(); Object arr[] = v.toArray(); Arrays.sort(arr); for (int i = 0; i < arr.length; i++) super.addElement(arr[i]); }
private void appendFailure(Test test, Throwable t) { fFailures.addElement(new TestFailure(test, t)); if (fFailures.size() == 1) revealFailure(test); }
protected void reset() { fCounterPanel.reset(); fProgressIndicator.reset(); fFailureView.clear(); fFailures.clear(); }