Search in sources :

Example 1 with User

use of chatty.User in project chatty by chatty.

the class ChannelTextPane method printUserMessage.

/**
 * Output a regular message from a user.
 *
 * @param message The object contain all the data
 */
private void printUserMessage(UserMessage message) {
    User user = message.user;
    boolean ignored = message.ignored_compact;
    if (ignored) {
        printCompact("IGNORED", user);
        return;
    }
    Color color = message.color;
    boolean action = message.action;
    String text = message.text;
    TagEmotes emotes = message.emotes;
    boolean highlighted = message.highlighted;
    if (message.whisper && message.action) {
        color = StyleConstants.getForeground(styles.info());
        highlighted = true;
    }
    closeCompactMode();
    MutableAttributeSet style;
    if (highlighted) {
        style = styles.highlight(color);
    } else {
        style = styles.standard(color);
    }
    print(getTimePrefix(), style);
    printUser(user, action, message.whisper, message.id);
    // Change style for text if /me and no highlight (if enabled)
    if (!highlighted && color == null && action && styles.actionColored()) {
        style = styles.standard(user.getDisplayColor());
    }
    printSpecials(text, user, style, emotes, false, message.bits > 0);
    printNewline();
}
Also used : EmoticonUser(chatty.util.api.Emoticon.EmoticonUser) User(chatty.User) TagEmotes(chatty.util.api.Emoticons.TagEmotes)

Example 2 with User

use of chatty.User in project chatty by chatty.

the class ChannelTextPane method getUserFromElement.

/**
 * Gets the User-object from an element. If there is none, it returns null.
 *
 * @param element
 * @return The User object or null if none was found
 */
private User getUserFromElement(Element element) {
    if (element != null) {
        User elementUser = (User) element.getAttributes().getAttribute(Attribute.USER);
        Boolean isMessage = (Boolean) element.getAttributes().getAttribute(Attribute.IS_USER_MESSAGE);
        if (isMessage != null && isMessage == true) {
            return elementUser;
        }
    }
    return null;
}
Also used : EmoticonUser(chatty.util.api.Emoticon.EmoticonUser) User(chatty.User)

Example 3 with User

use of chatty.User in project chatty by chatty.

the class LinkController method openContextMenu.

private void openContextMenu(MouseEvent e) {
    // the click)
    if (!e.getComponent().isShowing()) {
        return;
    }
    User user = getUser(e);
    String url = getUrl(e);
    EmoticonImage emote = getEmoticon(e);
    Usericon usericon = getUsericon(e);
    JPopupMenu m;
    if (user != null) {
        m = new UserContextMenu(user, getAutoModMsgId(e), contextMenuListener);
    } else if (url != null) {
        m = new UrlContextMenu(url, isUrlDeleted(e), contextMenuListener);
    } else if (emote != null) {
        m = new EmoteContextMenu(emote, contextMenuListener);
    } else if (usericon != null) {
        m = new UsericonContextMenu(usericon, contextMenuListener);
    } else {
        if (defaultContextMenu == null) {
            m = new ChannelContextMenu(contextMenuListener);
        } else {
            m = defaultContextMenu;
        }
    }
    m.show(e.getComponent(), e.getX(), e.getY());
}
Also used : User(chatty.User) Usericon(chatty.util.api.usericons.Usericon) EmoteContextMenu(chatty.gui.components.menus.EmoteContextMenu) ChannelContextMenu(chatty.gui.components.menus.ChannelContextMenu) UsericonContextMenu(chatty.gui.components.menus.UsericonContextMenu) UrlContextMenu(chatty.gui.components.menus.UrlContextMenu) UserContextMenu(chatty.gui.components.menus.UserContextMenu) EmoticonImage(chatty.util.api.Emoticon.EmoticonImage) JPopupMenu(javax.swing.JPopupMenu)

Example 4 with User

use of chatty.User in project chatty by chatty.

the class MainGui method hotkeyCommand.

/**
 * Perform a command executed by a hotkey. This means that the channel
 * context is the currently active channel and the selected user name is
 * added as command parameter if present.
 *
 * @param command The name of the command, leading / is removed if necessary
 * @param parameter2 Additional parameter after the username
 * @param selectedUserRequired Whether the command should only be executed
 * if a user is currently selected
 */
private void hotkeyCommand(String command, String parameter2, boolean selectedUserRequired) {
    Channel channel = channels.getLastActiveChannel();
    User selectedUser = channel.getSelectedUser();
    if (selectedUserRequired && selectedUser == null) {
        return;
    }
    String selectedUserName = selectedUser != null ? selectedUser.getName() : "";
    if (command.startsWith("/")) {
        command = command.substring(1);
    }
    String parameter = null;
    if (!selectedUserName.isEmpty() || parameter2 != null) {
        parameter = selectedUserName + (parameter2 != null ? " " + parameter2 : "");
    }
    client.command(channels.getLastActiveChannel().getRoom(), command, parameter);
}
Also used : User(chatty.User) Channel(chatty.gui.components.Channel)

Example 5 with User

use of chatty.User in project chatty by chatty.

the class UserList method openContextMenu.

/**
 * Open context menu for this user, if the event points at one.
 *
 * @param e
 */
private void openContextMenu(MouseEvent e) {
    if (e.isPopupTrigger()) {
        User user = getUser(e);
        if (user != null) {
            UserContextMenu m = new UserContextMenu(user, null, contextMenuListener);
            m.show(this, e.getX(), e.getY());
        }
    }
}
Also used : User(chatty.User) UserContextMenu(chatty.gui.components.menus.UserContextMenu)

Aggregations

User (chatty.User)11 EmoticonUser (chatty.util.api.Emoticon.EmoticonUser)4 UserContextMenu (chatty.gui.components.menus.UserContextMenu)2 EmoticonImage (chatty.util.api.Emoticon.EmoticonImage)2 Usericon (chatty.util.api.usericons.Usericon)2 UserListener (chatty.gui.UserListener)1 Channel (chatty.gui.components.Channel)1 ChannelContextMenu (chatty.gui.components.menus.ChannelContextMenu)1 EmoteContextMenu (chatty.gui.components.menus.EmoteContextMenu)1 UrlContextMenu (chatty.gui.components.menus.UrlContextMenu)1 UsericonContextMenu (chatty.gui.components.menus.UsericonContextMenu)1 UserMessage (chatty.gui.components.textpane.UserMessage)1 TagEmotes (chatty.util.api.Emoticons.TagEmotes)1 JPopupMenu (javax.swing.JPopupMenu)1 Test (org.junit.Test)1