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();
}
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;
}
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());
}
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);
}
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());
}
}
}
Aggregations