Esempio n. 1
0
 public void addUserStatusMessage(
     User source, Message message, MessageRow.Type type, TabAction action) {
   for (Tab tab : getItems()) {
     if (tab.getEntity().equals(source)
         || (tab.getEntity() instanceof Channel
             && ((Channel) tab.getEntity()).getUsers().contains(source))) {
       tab.getContentPane().getMessagePane().addRow(new MessageRow(message, type));
       if (action != null) {
         action.process(tab);
       }
     }
   }
 }
Esempio n. 2
0
 public Tab get(Connection connection, Entity entity) {
   for (Tab t : tabList.getItems()) {
     if (t.getConnection().equals(connection) && t.getEntity().equals(entity)) {
       return t;
     }
   }
   return create(connection, entity);
 }
Esempio n. 3
0
 public void close(Tab tab, boolean action) {
   if (getSelected().equals(tab)) {
     if (selectionModel.getSelectedIndex() == tabList.getItems().size()) {
       selectPrevious();
     } else {
       selectNext();
     }
   }
   {
     Iterator<Tab> it = tabList.getItems().iterator();
     while (it.hasNext()) {
       Tab _tab = it.next();
       if (_tab.equals(tab)) {
         it.remove();
         if (action) {
           if (tab.getEntity() instanceof Channel) {
             appPane.getContentPane().getConnection().part((Channel) tab.getEntity());
           } else if (tab.getEntity() instanceof Server) {
             appPane.getContentPane().getConnection().quit("");
           }
         }
         break;
       }
     }
   }
   if (tab.getEntity() instanceof Server) {
     Iterator<Tab> it = tabList.getItems().iterator();
     while (it.hasNext()) {
       Tab _tab = it.next();
       if (_tab.getConnection().equals(tab.getConnection())) {
         close(_tab);
       }
     }
   }
   Mercury.saveConnections();
 }
Esempio n. 4
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);
     }
   }
 }
Esempio n. 5
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));
 }