@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); IndexNode node = comm.getRegisteredIndexNodes().get(nodesTable.convertRowIndexToModel(row)); switch (node.getNodeStatus()) { case ACTIVE: if (node.isSecure()) { setIcon(frame.getGui().getUtil().getImage("secure")); } else { setIcon(frame.getGui().getUtil().getImage("connect")); } break; case AUTHREQUIRED: setIcon(frame.getGui().getUtil().getImage("secure")); break; case UNCONTACTABLE: setIcon(frame.getGui().getUtil().getImage("disconnect")); break; case INCOMPATIBLE: setIcon(frame.getGui().getUtil().getImage("error")); break; case FIREWALLED: setIcon(frame.getGui().getUtil().getImage("failure")); break; default: setIcon(frame.getGui().getUtil().getImage("disconnect")); break; } return this; }
@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); IndexNode node = comm.getRegisteredIndexNodes().get(nodesTable.convertRowIndexToModel(row)); if (node.wasAdvertised()) setIcon(frame.getGui().getUtil().getImage("autodetect")); else setIcon(null); return this; }
@Override public void newMessages(LinkedList<ChatMessage> messages) { ChatDocument doc = (ChatDocument) chatLog.getDocument(); for (ChatMessage m : messages) { if (m.id != -1) { // Only print non-commands try { doc.insertChatMessage( doc.getLength(), m.message + "\n", indexNode.getStats().getPeers().values()); if (!owner.isActiveTab()) { missedMessageCount++; } else { missedMessageCount = 0; } if (owner.displayChatNotifications()) { // Only show messages if we're not focused on the tab // Currently pops up messages intended for the user only // If we don't trim the username out of the string then it will pop up every time the // user sends a message // if (m.message.replaceFirst(".*:", // "").contains(frame.getGui().getShareServer().getAlias())){ toaster.showToaster( frame.getGui().getUtil().getImageFullname("chat.png"), indexNode.getName(), m.message); // "There are "+missedMessageCount+" unread chat messages."); // } // toaster.showToaster(m.message); } chatLogScrollPane .getVerticalScrollBar() .setValue(chatLogScrollPane.getVerticalScrollBar().getMaximum()); } catch (BadLocationException e) { Logger.log(e); } } } }
/** Send the message to the index node */ @Override public void actionPerformed(ActionEvent e) { String messageToSend = message.getText(); messageToSend = messageToSend.replace("\n", ""); // send the message indexNode.sendMessage(messageToSend); // Clear the message from the textbox message.setText(""); message.requestFocus(); }
public void deactivate() { indexNode.deregisterChatListenter(this); message.setEnabled(false); message.setText("You are no longer connected to this index node. No chats for you."); sendMessage.setEnabled(false); avatarTable.setEnabled(false); chatLog.setBackground(Color.lightGray); // Set status active = false; }
public void reactivate() { // Need to re-register incase the index node has been rebooted indexNode.registerChatListener(this); message.setEnabled(true); message.setText(""); message.requestFocus(); sendMessage.setEnabled(true); avatarTable.setEnabled(true); chatLog.setBackground(Color.white); // Set status active = true; }