use of org.jivesoftware.spark.component.RolloverButton in project Spark by igniterealtime.
the class BroadcastPlugin method initialize.
@Override
public void initialize() {
// See if we should disable all "Broadcast" menu items
if (Default.getBoolean(Default.DISABLE_BROADCAST_MENU_ITEM) || !Enterprise.containsFeature(Enterprise.BROADCAST_FEATURE)) {
return;
}
// Add as ContainerDecoratr
SparkManager.getChatManager().addSparkTabHandler(this);
StanzaFilter serverFilter = new StanzaTypeFilter(Message.class);
SparkManager.getConnection().addAsyncStanzaListener(this, serverFilter);
// Register with action menu
final JMenu actionsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.actions"));
JMenuItem broadcastHistoryMenu = new JMenuItem(Res.getString("title.broadcast.history"), SparkRes.getImageIcon(SparkRes.HISTORY_16x16));
JMenuItem broadcastMenu = new JMenuItem(Res.getString("title.broadcast.message"), SparkRes.getImageIcon(SparkRes.MEGAPHONE_16x16));
ResourceUtils.resButton(broadcastMenu, Res.getString("title.broadcast.message"));
actionsMenu.add(broadcastHistoryMenu);
actionsMenu.add(broadcastMenu);
broadcastMenu.addActionListener(e -> broadcastToRoster());
broadcastHistoryMenu.addActionListener(e -> new BroadcastHistoryFrame().run());
// Register with action menu
JMenuItem startConversationtMenu = new JMenuItem("", SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE));
ResourceUtils.resButton(startConversationtMenu, Res.getString("menuitem.start.a.chat"));
if (!Default.getBoolean(Default.HIDE_START_A_CHAT) && Enterprise.containsFeature(Enterprise.START_A_CHAT_FEATURE)) {
actionsMenu.add(startConversationtMenu, 0);
}
startConversationtMenu.addActionListener(e -> {
ContactList contactList = SparkManager.getWorkspace().getContactList();
Collection<ContactItem> selectedUsers = contactList.getSelectedUsers();
String selectedUser = "";
Iterator<ContactItem> selectedUsersIterator = selectedUsers.iterator();
if (selectedUsersIterator.hasNext()) {
ContactItem contactItem = selectedUsersIterator.next();
selectedUser = contactItem.getJid().toString();
}
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
UIManager.put("OptionPane.cancelButtonText", Res.getString("cancel"));
String jid = (String) JOptionPane.showInputDialog(SparkManager.getMainWindow(), Res.getString("label.enter.address"), Res.getString("title.start.chat"), JOptionPane.QUESTION_MESSAGE, null, null, selectedUser);
if (ModelUtil.hasLength(jid) && ModelUtil.hasLength(XmppStringUtils.parseDomain(jid))) {
if (ModelUtil.hasLength(jid) && jid.indexOf('@') == -1) {
// Append server address
jid = jid + "@" + SparkManager.getConnection().getXMPPServiceDomain();
}
EntityBareJid entityBareJid = JidCreate.entityBareFromUnescapedOrThrowUnchecked(jid);
String nickname = SparkManager.getUserManager().getUserNicknameFromJID(entityBareJid);
ChatRoom chatRoom = SparkManager.getChatManager().createChatRoom(entityBareJid, nickname, nickname);
SparkManager.getChatManager().getChatContainer().activateChatRoom(chatRoom);
}
});
// Add send to selected users.
final ContactList contactList = SparkManager.getWorkspace().getContactList();
contactList.addContextMenuListener(new ContextMenuListener() {
@Override
public void poppingUp(Object component, JPopupMenu popup) {
if (component instanceof ContactGroup) {
final ContactGroup group = (ContactGroup) component;
Action broadcastMessageAction = new AbstractAction() {
private static final long serialVersionUID = -6411248110270296726L;
@Override
public void actionPerformed(ActionEvent e) {
broadcastToGroup(group);
}
};
broadcastMessageAction.putValue(Action.NAME, Res.getString("menuitem.broadcast.to.group"));
broadcastMessageAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.MEGAPHONE_16x16));
popup.add(broadcastMessageAction);
}
}
@Override
public void poppingDown(JPopupMenu popup) {
}
@Override
public boolean handleDefaultAction(MouseEvent e) {
return false;
}
});
// Add Broadcast to roster
StatusBar statusBar = SparkManager.getWorkspace().getStatusBar();
RolloverButton broadcastToRosterButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.MEGAPHONE_16x16));
broadcastToRosterButton.setToolTipText(Res.getString("message.send.a.broadcast"));
statusBar.invalidate();
statusBar.validate();
statusBar.repaint();
broadcastToRosterButton.addActionListener(e -> broadcastToRoster());
}
use of org.jivesoftware.spark.component.RolloverButton in project Spark by igniterealtime.
the class EmoticonPlugin method chatRoomOpened.
@Override
public void chatRoomOpened(final ChatRoom room) {
// Check to see if emoticons are enabled.
if (!SettingsManager.getLocalPreferences().areEmoticonsEnabled()) {
return;
}
// final String activeEmoticonSetName =
// emoticonManager.getActiveEmoticonSetName();
emoticonManager = EmoticonManager.getInstance();
Collection<String> emoticonPacks;
emoticonPacks = emoticonManager.getEmoticonPacks();
if (emoticonPacks != null) {
// Add Emoticon button
final RolloverButton emoticonPicker = UIComponentRegistry.getButtonFactory().createEmoticonButton();
room.addEditorComponent(emoticonPicker);
emoticonPicker.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
// Show popup
final JPopupMenu popup = new JPopupMenu();
EmoticonUI emoticonUI = new EmoticonUI();
emoticonUI.setEmoticonPickListener(emoticon -> {
try {
popup.setVisible(false);
final ChatInputEditor editor = room.getChatInputEditor();
String currentText = editor.getText();
if (currentText.length() == 0 || currentText.endsWith(" ")) {
room.getChatInputEditor().insertText(emoticon + " ");
} else {
room.getChatInputEditor().insertText(" " + emoticon + " ");
}
room.getChatInputEditor().requestFocus();
} catch (BadLocationException e1) {
Log.error(e1);
}
});
popup.add(emoticonUI);
popup.show(emoticonPicker, e.getX(), e.getY());
}
});
room.addClosingListener(() -> room.removeEditorComponent(emoticonPicker));
}
}
use of org.jivesoftware.spark.component.RolloverButton in project Spark by igniterealtime.
the class CoBrowser method tabSelected.
public void tabSelected() {
goButton = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.PUSH_URL_16x16));
pushCurrentPageButton = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.DOWNLOAD_16x16));
followMeButton = new JCheckBox(FpRes.getString("checkbox.allow.user.to.follow"), false);
followMeButton.setToolTipText(GraphicUtils.createToolTip(PUBLIC_TOOLTIP));
followMeButton.addActionListener(this);
final JPanel mainPanel = new JPanel();
browser = BrowserFactory.getBrowser();
browser.addBrowserListener(this);
mainPanel.setLayout(new BorderLayout());
mainPanel.add(browser, BorderLayout.CENTER);
urlField = new JTextField();
setLayout(new GridBagLayout());
backButton = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.SMALL_PIN_BLUE));
backButton.setText(FpRes.getString("back"));
backButton.setToolTipText(GraphicUtils.createToolTip(FpRes.getString("tooltip.back.one.page")));
goButton.setToolTipText(GraphicUtils.createToolTip(FpRes.getString("tooltip.push.url")));
goButton.setText(FpRes.getString("go"));
pushCurrentPageButton.setToolTipText(GraphicUtils.createToolTip(FpRes.getString("tooltip.push.current.page")));
pushCurrentPageButton.setText(FpRes.getString("button.start.cobrowsing.session"));
load(getStartLocation());
buildUI();
add(mainPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
urlField.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
showSpecifiedPage();
}
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
});
followMeButton.setOpaque(false);
}
use of org.jivesoftware.spark.component.RolloverButton in project Spark by igniterealtime.
the class ButtonFactory method createTemaButton.
public RolloverButton createTemaButton() {
RolloverButton thema = new RolloverButton(SparkRes.getImageIcon(SparkRes.TYPING_TRAY));
thema.setToolTipText(Res.getString("menuitem.change.subject"));
return thema;
}
use of org.jivesoftware.spark.component.RolloverButton in project Spark by igniterealtime.
the class ButtonFactory method createEmoticonButton.
public RolloverButton createEmoticonButton() {
final EmoticonManager emoticonManager = EmoticonManager.getInstance();
final String activeEmoticonSetName = emoticonManager.getActiveEmoticonSetName();
final Emoticon smileEmoticon = emoticonManager.getEmoticon(activeEmoticonSetName, ":)");
Emoticon firstEmoticon = (smileEmoticon == null) ? emoticonManager.getFirstEmotion(activeEmoticonSetName) : smileEmoticon;
URL emotionURL = emoticonManager.getEmoticonURL(firstEmoticon);
ImageIcon icon = new ImageIcon(emotionURL);
return new RolloverButton(icon);
}
Aggregations