Пример #1
0
 @Override
 protected void updateItem(final Tab tab, boolean empty) {
   super.updateItem(tab, empty);
   if (tab != null) {
     tab.getUnreadProperty()
         .addListener(
             new ChangeListener<Boolean>() {
               @Override
               public void changed(
                   ObservableValue<? extends Boolean> observableValue,
                   Boolean oldValue,
                   Boolean newValue) {
                 if (newValue) {
                   getStyleClass().add("unread");
                 } else {
                   getStyleClass().remove("unread");
                 }
               }
             });
     Entity entity = tab.getEntity();
     setPrefHeight(32);
     if (entity instanceof Server) {
       setPrefHeight(40);
       Label net = new Label("network");
       net.getStyleClass().add("network");
       VBox box = new VBox();
       Label name = new Label(entity.getName());
       name.getStyleClass().add("network-name");
       box.getChildren().addAll(net, name);
       setGraphic(box);
     } else if (entity instanceof Channel) {
       final Label label = new Label(entity.getName().substring(1));
       label.getStyleClass().add("name");
       final HBox box = new HBox();
       box.getChildren().addAll(FontAwesome.createIcon(FontAwesome.COMMENTS), label);
       setGraphic(box);
     } else if (entity instanceof User) {
       final Label label = new Label(entity.getName());
       label.getStyleClass().add("name");
       final HBox box = new HBox();
       box.getChildren().addAll(FontAwesome.createIcon(FontAwesome.USER), label);
       setGraphic(box);
     }
   }
 }
Пример #2
0
 public void addTargetedMessage(Connection connection, Message message, MessageRow.Type type) {
   Entity target = message.getTarget();
   if (target.equals(connection.getLocalUser())) {
     target = message.getSource();
   }
   Tab tab = null;
   for (Tab _tab : getItems()) {
     if (_tab.getEntity().equals(target)) {
       tab = _tab;
       break;
     }
   }
   if (tab == null) {
     if (type == MessageRow.Type.PART && message.getSource().equals(connection.getLocalUser())) {
       return;
     }
     tab = create(connection, target);
   }
   tab.getContentPane().getMessagePane().addRow(new MessageRow(message, type));
 }