diff options
author | hristoterezov <hristo@jitsi.org> | 2013-11-18 19:59:02 +0200 |
---|---|---|
committer | hristoterezov <hristo@jitsi.org> | 2013-11-18 19:59:02 +0200 |
commit | 275cbb770c8eaf6e1e300fca7d594effe43a61be (patch) | |
tree | 0d768d57a3b4b975a5b43b6aa9555d4a345935dd | |
parent | eb2079f63a597829cabe4f86e22193225c93bf6e (diff) | |
download | jitsi-275cbb770c8eaf6e1e300fca7d594effe43a61be.zip jitsi-275cbb770c8eaf6e1e300fca7d594effe43a61be.tar.gz jitsi-275cbb770c8eaf6e1e300fca7d594effe43a61be.tar.bz2 |
Implements the right button menu for chat room contacts. Fixes the issue
with the dialog for chat room password.
29 files changed, 1199 insertions, 311 deletions
diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index b51ab19..b175b5e 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -307,6 +307,7 @@ service.gui.JOIN_CHAT_ROOM=&Join chat room... service.gui.JOIN_CHAT_ROOM_TITLE=Join chat room service.gui.JOIN_CHAT_ROOM_NAME=Please enter the name of the chat room you would like to join. service.gui.JOIN_CHAT_ROOM_WIZARD=Join chat room wizard +service.gui.JOIN_AUTOMATICALLY=Join automatically service.gui.KICK=&Kick service.gui.KICK_FAILED=Kick failed service.gui.KICK_FAILED_GENERAL_ERROR=Failed to kick {0}. A general server error occurred. diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index a4eec98..d9bac36 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -34,6 +34,7 @@ import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; +import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.shutdown.*; import net.java.sip.communicator.util.*; @@ -55,6 +56,7 @@ import com.sun.jna.platform.WindowUtils; * @author Lyubomir Marinov * @author Dmitri Melnikov * @author Adam Netocny + * @author Hristo Terezov */ public class UIServiceImpl implements UIService, @@ -1542,6 +1544,38 @@ public class UIServiceImpl else throw new IllegalArgumentException("participants"); } + + /** + * Opens a chat room window for the given <tt>ChatRoomWrapper</tt> instance. + * + * @param chatRoom the chat room associated with the chat room window + */ + public void openChatRoomWindow(ChatRoomWrapper chatRoom) + { + ChatWindowManager chatWindowManager + = getChatWindowManager(); + ChatPanel chatPanel + = chatWindowManager.getMultiChat(chatRoom, true); + + chatWindowManager.openChat(chatPanel, true); + } + + /** + * Closes the chat room window for the given <tt>ChatRoomWrapper</tt> + * instance. + * + * @param chatRoom the chat room associated with the chat room window. + */ + public void closeChatRoomWindow(ChatRoomWrapper chatRoom) + { + ChatWindowManager chatWindowManager + = getChatWindowManager(); + ChatPanel chatPanel + = chatWindowManager.getMultiChat(chatRoom, false); + + if (chatPanel != null) + chatWindowManager.closeChat(chatPanel); + } /** * Creates a contact list component. diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactRightButtonMenu.java index 52b6c6f..fbd03d8 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactRightButtonMenu.java @@ -12,9 +12,9 @@ import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; +import net.java.sip.communicator.plugin.desktoputil.chat.*; import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java index 847f0e3..9733e60 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java @@ -6,18 +6,15 @@ */ package net.java.sip.communicator.impl.gui.main.chat.conference; -import java.awt.*; -import java.awt.event.*; import java.util.*; import java.util.concurrent.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.main.chat.history.*; import net.java.sip.communicator.impl.gui.main.chatroomslist.*; -import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; +import net.java.sip.communicator.plugin.desktoputil.chat.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; @@ -29,8 +26,6 @@ import org.jdesktop.swingworker.SwingWorker; import org.osgi.framework.*; import javax.swing.*; -// Java 1.6 has javax.swing.SwingWorker so we have to disambiguate. -import javax.swing.border.*; /** * The <tt>ConferenceChatManager</tt> is the one that manages both chat room and @@ -535,7 +530,8 @@ public class ConferenceChatManager { if(chatRoomWrapper != null) { - this.closeChatRoom(chatRoomWrapper); + GuiActivator.getUIService() + .closeChatRoomWindow(chatRoomWrapper); // Need to refresh the chat room's list in order to change // the state of the chat room to offline. @@ -701,7 +697,7 @@ public class ConferenceChatManager if (chatRoom != null) leaveChatRoom(chatRoomWrapper); - this.closeChatRoom(chatRoomWrapper); + GuiActivator.getUIService().closeChatRoomWindow(chatRoomWrapper); GuiActivator.getMUCService().removeChatRoom(chatRoomWrapper); @@ -755,7 +751,7 @@ public class ConferenceChatManager ChatRoomWrapper leavedRoomWrapped = GuiActivator.getMUCService().leaveChatRoom(chatRoomWrapper); if(leavedRoomWrapped != null) - this.closeChatRoom(leavedRoomWrapped); + GuiActivator.getUIService().closeChatRoomWindow(leavedRoomWrapped); } /** @@ -879,23 +875,6 @@ public class ConferenceChatManager } } - /** - * Closes the chat corresponding to the given chat room wrapper, if such - * exists. - * - * @param chatRoomWrapper the chat room wrapper for which we search a chat - * to close. - */ - public void closeChatRoom(ChatRoomWrapper chatRoomWrapper) - { - ChatWindowManager chatWindowManager - = GuiActivator.getUIService().getChatWindowManager(); - ChatPanel chatPanel - = chatWindowManager.getMultiChat(chatRoomWrapper, false); - - if (chatPanel != null) - chatWindowManager.closeChat(chatPanel); - } /** * Closes the chat corresponding to the given ad-hoc chat room wrapper, if @@ -1316,7 +1295,7 @@ public class ConferenceChatManager if (savedNick == null) { - String[] joinOptions = getJoinOptions( + String[] joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( room.getParentProvider().getProtocolProvider(), room.getChatRoomID()); String nickName = joinOptions[0]; @@ -1336,186 +1315,9 @@ public class ConferenceChatManager GuiActivator.getMUCService().joinChatRoom(room, savedNick, null); } - ChatWindowManager chatWindowManager - = GuiActivator.getUIService().getChatWindowManager(); - ChatPanel chatPanel - = chatWindowManager.getMultiChat(room, true); - - chatWindowManager.openChat(chatPanel, true); + GuiActivator.getUIService().openChatRoomWindow(room); } - /** - * Opens a dialog with a fields for the nickname and the subject of the room - * and returns them. - * - * @param pps the protocol provider associated with the chat room. - * @param chatRoomId the id of the chat room. - * @return array with the nickname and subject values. - */ - public String[] getJoinOptions(ProtocolProviderService pps, - String chatRoomId) - { - return getJoinOptions(false, pps, chatRoomId); - } - - /** - * Opens a dialog with a fields for the nickname and the subject of the room - * and returns them. - * - * @param dontDisplaySubjectFields if true the subject fields will be hidden - * @return array with the nickname and subject values. - */ - public String[] getJoinOptions(boolean dontDisplaySubjectFields, - ProtocolProviderService pps, String chatRoomId) - { - String nickName = null; - ChatRoomJoinOptionsDialog reasonDialog = - new ChatRoomJoinOptionsDialog(GuiActivator.getResources() - .getI18NString("service.gui.CHANGE_NICKNAME"), GuiActivator - .getResources().getI18NString( - "service.gui.CHANGE_NICKNAME_LABEL"), false, true, - dontDisplaySubjectFields); - reasonDialog.setIcon(ImageLoader.getImage( - ImageLoader.CHANGE_NICKNAME_ICON)); - - final OperationSetServerStoredAccountInfo accountInfoOpSet - = pps.getOperationSet( - OperationSetServerStoredAccountInfo.class); - - String displayName = ""; - if (accountInfoOpSet != null) - { - displayName = AccountInfoUtils.getDisplayName(accountInfoOpSet); - } - - if(displayName == null || displayName.length() == 0) - { - displayName = GuiActivator.getGlobalDisplayDetailsService() - .getGlobalDisplayName(); - if(displayName == null || displayName.length() == 0) - { - displayName = pps.getAccountID().getUserID(); - if(displayName != null) - { - int atIndex = displayName.lastIndexOf("@"); - if (atIndex > 0) - displayName = displayName.substring(0, atIndex); - } - } - } - reasonDialog.setReasonFieldText(displayName); - - int result = reasonDialog.showDialog(); - - if (result == MessageDialog.OK_RETURN_CODE) - { - nickName = reasonDialog.getReason().trim(); - ConfigurationUtils.updateChatRoomProperty( - pps, - chatRoomId, "userNickName", nickName); - - } - String[] joinOptions = {nickName, reasonDialog.getSubject()}; - return joinOptions; - } - - /** - * Dialog with fields for nickname and subject. - */ - private class ChatRoomJoinOptionsDialog extends ChatOperationReasonDialog - { - /** - * Text field for the subject. - */ - private SIPCommTextField subject = new SIPCommTextField(GuiActivator - .getResources().getI18NString("service.gui.SUBJECT")); - - /** - * Label that hides and shows the subject fields panel on click. - */ - private JLabel cmdExpandSubjectFields; - - /** - * Panel that holds the subject fields. - */ - private JPanel subjectFieldsPannel = new JPanel(new BorderLayout()); - - /** - * Adds the subject fields to dialog. Sets action listeners. - * - * @param title the title of the dialog - * @param message the message shown in this dialog - * @param disableOKIfReasonIsEmpty if true the OK button will be - * disabled if the reason text is empty. - * @param showReasonLabel specify if we want the "Reason:" label - * @param dontDisplaySubjectFields if true the sibject fields will be - * hidden. - */ - public ChatRoomJoinOptionsDialog(String title, String message, - boolean showReasonLabel, - boolean disableOKIfReasonIsEmpty, - boolean dontDisplaySubjectFields) - { - super(title, - message, - showReasonLabel, - disableOKIfReasonIsEmpty); - - if(dontDisplaySubjectFields) - return; - - JPanel subjectPanel = new JPanel(new BorderLayout()); - subjectPanel.setOpaque(false); - subjectPanel.setBorder( - BorderFactory.createEmptyBorder(10, 0, 0, 0)); - - subjectFieldsPannel.setBorder( - BorderFactory.createEmptyBorder(10, 30, 0, 0)); - subjectFieldsPannel.setOpaque(false); - subjectFieldsPannel.add(subject, BorderLayout.CENTER); - subjectFieldsPannel.setVisible(false); - subject.setFont(getFont().deriveFont(12f)); - - cmdExpandSubjectFields = new JLabel(); - cmdExpandSubjectFields.setBorder(new EmptyBorder(0, 5, 0, 0)); - cmdExpandSubjectFields.setIcon(GuiActivator.getResources() - .getImage("service.gui.icons.RIGHT_ARROW_ICON")); - cmdExpandSubjectFields.setText(GuiActivator - .getResources().getI18NString("service.gui.SET_SUBJECT")); - cmdExpandSubjectFields.addMouseListener(new MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent e) - { - cmdExpandSubjectFields.setIcon( - UtilActivator.getResources().getImage( - subjectFieldsPannel.isVisible() - ? "service.gui.icons.RIGHT_ARROW_ICON" - : "service.gui.icons.DOWN_ARROW_ICON")); - - subjectFieldsPannel.setVisible( - !subjectFieldsPannel.isVisible()); - - pack(); - } - }); - subjectPanel.add(cmdExpandSubjectFields,BorderLayout.NORTH); - subjectPanel.add(subjectFieldsPannel,BorderLayout.CENTER); - addToReasonFieldPannel(subjectPanel); - this.pack(); - } - - /** - * Returns the text entered in the subject field. - * - * @return the text from the subject field. - */ - public String getSubject() - { - return subject.getText(); - } - } - @Override public void chatRoomProviderWrapperAdded(ChatRoomProviderWrapper provider) {} @@ -1524,6 +1326,6 @@ public class ConferenceChatManager public void chatRoomProviderWrapperRemoved(ChatRoomProviderWrapper provider) { for(int i = 0; i < provider.countChatRooms(); i++) - closeChatRoom(provider.getChatRoom(i)); + GuiActivator.getUIService().closeChatRoomWindow(provider.getChatRoom(i)); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java index 7d0d5eb..31f53f7 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java @@ -488,10 +488,14 @@ public class MainToolBar } else if (buttonText.equals("leave")) { - ConferenceChatManager conferenceManager - = GuiActivator.getUIService().getConferenceChatManager(); - conferenceManager.leaveChatRoom( - (ChatRoomWrapper)chatPanel.getChatSession().getDescriptor()); + ChatRoomWrapper chatRoomWrapper + = (ChatRoomWrapper)chatPanel.getChatSession().getDescriptor(); + ChatRoomWrapper leavedRoomWrapped + = GuiActivator.getMUCService().leaveChatRoom( + chatRoomWrapper); + if(leavedRoomWrapped != null) + GuiActivator.getUIService().closeChatRoomWindow( + leavedRoomWrapped); } else if (buttonText.equals("call")) { diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java index fa59379..a1ca465 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java @@ -16,6 +16,7 @@ import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.main.chat.conference.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; +import net.java.sip.communicator.plugin.desktoputil.chat.*; import net.java.sip.communicator.service.muc.ChatRoomWrapper; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; @@ -125,7 +126,7 @@ public class ChatRoomRightButtonMenu .getChatRoomID(), "userNickName"); if(nickName == null) { - joinOptions = conferenceManager.getJoinOptions( + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); nickName = joinOptions[0]; @@ -165,7 +166,7 @@ public class ChatRoomRightButtonMenu .getChatRoomID(), "userNickName"); if(nickName == null) { - joinOptions = conferenceManager.getJoinOptions( + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( chatRoomWrapper.getParentProvider() .getProtocolProvider(), chatRoomWrapper.getChatRoomID()); @@ -189,7 +190,7 @@ public class ChatRoomRightButtonMenu } else if(itemName.equals("joinAsChatRoom")) { - joinOptions = conferenceManager.getJoinOptions( + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); if(joinOptions[0] == null) @@ -200,7 +201,7 @@ public class ChatRoomRightButtonMenu } else if(itemName.equals("nickNameChatRoom")) { - conferenceManager.getJoinOptions(true, + ChatRoomJoinOptionsDialog.getJoinOptions(true, chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); } diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableDialog.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableDialog.java index 66197e3..95259bd 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableDialog.java @@ -17,9 +17,9 @@ import javax.swing.event.*; import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.chat.*; -import net.java.sip.communicator.impl.gui.main.chat.conference.*; import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.plugin.desktoputil.SwingWorker; +import net.java.sip.communicator.plugin.desktoputil.chat.*; import net.java.sip.communicator.service.muc.ChatRoomList; import net.java.sip.communicator.service.muc.ChatRoomProviderWrapper; import net.java.sip.communicator.service.muc.ChatRoomWrapper; @@ -351,8 +351,6 @@ public class ChatRoomTableDialog String[] joinOptions; String subject = null; JButton sourceButton = (JButton) e.getSource(); - ConferenceChatManager conferenceManager - = GuiActivator.getUIService().getConferenceChatManager(); if(sourceButton.equals(addButton)) { String chatRoomName = editor.getText(); @@ -365,7 +363,7 @@ public class ChatRoomTableDialog getSelectedProvider().getProtocolProvider(), new ArrayList<String>(), "", false, true, true); - conferenceManager.getJoinOptions(true, + ChatRoomJoinOptionsDialog.getJoinOptions(true, chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); @@ -393,7 +391,7 @@ public class ChatRoomTableDialog false, false); - joinOptions = conferenceManager.getJoinOptions( + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); String nickName = joinOptions[0]; @@ -427,10 +425,11 @@ public class ChatRoomTableDialog { - joinOptions = conferenceManager.getJoinOptions( - selectedRoom.getParentProvider() - .getProtocolProvider(), - selectedRoom.getChatRoomID()); + joinOptions = ChatRoomJoinOptionsDialog + .getJoinOptions( + selectedRoom.getParentProvider() + .getProtocolProvider(), + selectedRoom.getChatRoomID()); savedNick = joinOptions[0]; subject = joinOptions[1]; if(savedNick == null) @@ -464,7 +463,7 @@ public class ChatRoomTableDialog if (savedNick == null) { - joinOptions = conferenceManager.getJoinOptions( + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( selectedRoom.getParentProvider() .getProtocolProvider(), selectedRoom.getChatRoomID()); diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableUI.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableUI.java index 43c5901..b5cb1ca 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableUI.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableUI.java @@ -19,6 +19,7 @@ import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.main.chat.conference.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; +import net.java.sip.communicator.plugin.desktoputil.chat.*; import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -176,9 +177,7 @@ public class ChatRoomTableUI if (savedNick == null) { - ConferenceChatManager conferenceManager - = GuiActivator.getUIService().getConferenceChatManager(); - String[] joinOptions = conferenceManager.getJoinOptions( + String[] joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); String nickName = joinOptions[0]; diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java index ad940dc..81f7fb8 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java @@ -93,7 +93,9 @@ public class SourceContactRightButtonMenu add(initCallMenu()); // Only create the menu if the add contact functionality is enabled. - if (!ConfigurationUtils.isAddContactDisabled()) + if ((sourceContact.getPreferredContactDetail( + OperationSetMultiUserChat.class) == null) + && !ConfigurationUtils.isAddContactDisabled()) { addContactComponent = TreeContactList.createAddContactMenu(sourceContact); @@ -101,6 +103,12 @@ public class SourceContactRightButtonMenu if (addContactComponent != null) add(addContactComponent); + + for(JMenuItem item : + sourceUIContact.getContactCustomActionMenuItems(true)) + { + add(item); + } } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ExternalContactSource.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ExternalContactSource.java index 74a272b..d20d2a5 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ExternalContactSource.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ExternalContactSource.java @@ -28,6 +28,7 @@ import java.util.List; * <tt>ContactSourceService</tt>. * * @author Yana Stamcheva + * @author Hristo Terezov */ public class ExternalContactSource implements UIContactSource @@ -59,6 +60,12 @@ public class ExternalContactSource */ private static Map<ContactAction<SourceContact>, SIPCommButton> customContactActionButtons; + + /** + * The list of right menu action items for this source contact. + */ + private static Map<ContactActionMenuItem<SourceContact>, JMenuItem> + customContactActionMenuItems; /** * The list of action buttons for this source service. @@ -174,8 +181,7 @@ public class ExternalContactSource SIPCommButton actionButton = customContactActionButtons.get(contactAction); - if (isContactActionVisible( contactAction, - sourceContact)) + if (isContactActionVisible( contactAction, sourceContact)) { availableCustomActionButtons.add(actionButton); } @@ -183,6 +189,44 @@ public class ExternalContactSource return availableCustomActionButtons; } + + /** + * Returns all custom action menu items for this contact. + * + * @param initActions if <tt>true</tt> the actions will be reloaded. + * @param sourceContact the contact. + * @return a list of all custom action menu items for this contact. + */ + public Collection<JMenuItem> getContactCustomActionMenuItems( + final SourceContact sourceContact, boolean initActions) + { + customActionContact = sourceContact; + + if (initActions || (customContactActionMenuItems == null)) + initCustomContactActionMenuItems(); + + Iterator<ContactActionMenuItem<SourceContact>> customActionsIter + = customContactActionMenuItems.keySet().iterator(); + + Collection<JMenuItem> availableCustomActionMenuItems + = new LinkedList<JMenuItem>(); + + while (customActionsIter.hasNext()) + { + ContactActionMenuItem<SourceContact> contactAction + = customActionsIter.next(); + + JMenuItem actionMenuItem = + customContactActionMenuItems.get(contactAction); + + if (isContactActionVisible( contactAction, sourceContact)) + { + availableCustomActionMenuItems.add(actionMenuItem); + } + } + + return availableCustomActionMenuItems; + } /** * Indicates if the given <tt>ContactAction</tt> should be visible for the @@ -202,6 +246,25 @@ public class ExternalContactSource return false; } + + /** + * Indicates if the given <tt>ContactActionMenuItem</tt> should be visible + * for the given <tt>SourceContact</tt>. + * + * @param contactAction the <tt>ContactActionMenuItem</tt> to verify + * if the given action should be visible + * @return <tt>true</tt> if the given <tt>ContactActionMenuItem</tt> is + * visible for the given <tt>SourceContact</tt>, <tt>false</tt> - otherwise + */ + private static boolean isContactActionVisible( + ContactActionMenuItem<SourceContact> contactAction, + SourceContact contact) + { + if (contactAction.isVisible(contact)) + return true; + + return false; + } /** * Initializes custom action buttons for this contact source. @@ -222,12 +285,36 @@ public class ExternalContactSource { final ContactAction<SourceContact> ca = actionIterator.next(); - initActionButton(ca, SourceContact.class); } } } } + + /** + * Initializes custom action menu items for this contact source. + */ + private void initCustomContactActionMenuItems() + { + customContactActionMenuItems + = new LinkedHashMap<ContactActionMenuItem<SourceContact>, JMenuItem>(); + for (CustomContactActionsService<SourceContact> ccas + : getContactActionsServices()) + { + Iterator<ContactActionMenuItem<SourceContact>> actionIterator + = ccas.getCustomContactActionsMenuItems(); + + if (actionIterator!= null) + { + while (actionIterator.hasNext()) + { + final ContactActionMenuItem<SourceContact> ca + = actionIterator.next(); + initActionMenuItem(ca); + } + } + } + } /** * Initializes custom action buttons for this source service. @@ -247,7 +334,6 @@ public class ExternalContactSource while (actionIterator!= null && actionIterator.hasNext()) { final ContactAction<ContactSourceService> ca = actionIterator.next(); - initActionButton(ca, ContactSourceService.class); } } @@ -352,6 +438,63 @@ public class ExternalContactSource } } } + + /** + * Initializes an action menu item. + * + * @param ca the <tt>ContactActionMenuItem</tt> corresponding to the item. + */ + private void initActionMenuItem( + final ContactActionMenuItem<SourceContact> ca) + { + JMenuItem actionMenuItem; + + actionMenuItem = customContactActionMenuItems.get(ca); + + if (actionMenuItem == null) + { + if(ca.isCheckBox()) + { + actionMenuItem = new JCheckBoxMenuItem(); + } + else + { + actionMenuItem = new JMenuItem(); + } + + actionMenuItem.setText(ca.getText()); + + actionMenuItem.setMnemonic(ca.getMnemonics()); + + byte[] icon = ca.getIcon(); + if(icon != null) + actionMenuItem.setIcon( + new ImageIcon(icon)); + + actionMenuItem.setSelected(ca.isSelected(customActionContact)); + actionMenuItem.setEnabled(ca.isEnabled(customActionContact)); + + actionMenuItem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent event) + { + try + { + ca.actionPerformed(customActionContact); + } + catch (OperationFailedException e) + { + new ErrorDialog(null, + GuiActivator.getResources() + .getI18NString("service.gui.ERROR"), + e.getMessage()); + } + } + }); + + customContactActionMenuItems.put(ca, actionMenuItem); + } + } /** * Returns a list of all custom contact action services. diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java index 3cddd53..517f790 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java @@ -16,11 +16,9 @@ import org.jitsi.service.resources.*; import org.jitsi.util.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.main.chatroomslist.*; import net.java.sip.communicator.impl.gui.main.contactlist.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; -import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; @@ -32,6 +30,7 @@ import net.java.sip.communicator.util.*; * <tt>ExternalContactSource</tt>. * * @author Yana Stamcheva + * @author Hristo Terezov */ public class SourceUIContact extends UIContactImpl @@ -413,19 +412,7 @@ public class SourceUIContact @Override public JPopupMenu getRightButtonMenu() { - if(!(sourceContact instanceof MetaContact) && - (sourceContact.getPreferredContactDetail( - OperationSetMultiUserChat.class) - != null)) - { - return new ChatRoomRightButtonMenu( - GuiActivator.getMUCService() - .findChatRoomWrapperFromSourceContact(sourceContact)); - } - else - { - return new SourceContactRightButtonMenu(this); - } + return new SourceContactRightButtonMenu(this); } /** @@ -708,4 +695,21 @@ public class SourceUIContact return null; } + + /** + * Returns all custom action menu items for this contact. + * + * @param initActions if <tt>true</tt> the actions will be reloaded. + * @return a list of all custom action menu items for this contact. + */ + @Override + public Collection<JMenuItem> getContactCustomActionMenuItems( + boolean initActions) + { + if (sourceContact != null) + return uiGroup.getParentUISource() + .getContactCustomActionMenuItems(sourceContact, initActions); + + return null; + } } diff --git a/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java b/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java index df798c0..288cab6 100644 --- a/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java +++ b/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java @@ -9,7 +9,6 @@ package net.java.sip.communicator.impl.gui.main.login; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.service.protocol.*; @@ -71,7 +70,7 @@ public class DefaultSecurityAuthority String userName = userCredentials.getUserName(); char[] password = userCredentials.getPassword(); ImageIcon icon - = ImageLoader.getAuthenticationWindowIcon(protocolProvider); + = AuthenticationWindow.getAuthenticationWindowIcon(protocolProvider); if (errorMessage == null) loginWindow = new AuthenticationWindow( diff --git a/src/net/java/sip/communicator/impl/gui/main/login/LoginRendererSwingImpl.java b/src/net/java/sip/communicator/impl/gui/main/login/LoginRendererSwingImpl.java index 56f84e7..00d5dea 100644 --- a/src/net/java/sip/communicator/impl/gui/main/login/LoginRendererSwingImpl.java +++ b/src/net/java/sip/communicator/impl/gui/main/login/LoginRendererSwingImpl.java @@ -7,9 +7,9 @@ package net.java.sip.communicator.impl.gui.main.login; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.authorization.*; +import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.account.*; diff --git a/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf b/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf index 607dffc..38041b9 100644 --- a/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf +++ b/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf @@ -80,4 +80,5 @@ Import-Package: com.apple.eawt, org.osgi.framework, say.swing, net.java.sip.communicator.service.credentialsstorage, - net.java.sip.communicator.service.muc + net.java.sip.communicator.service.muc, + net.java.sip.communicator.plugin.desktoputil.chat diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java index c2dba57..51af8c6 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -1718,34 +1718,4 @@ public class ImageLoader { getImageLoaderService().clearCache(); } - - /** - * Returns the icon corresponding to the given <tt>protocolProvider</tt>. - * - * @param protocolProvider the <tt>ProtocolProviderService</tt>, which icon - * we're looking for - * @return the icon to show on the authentication window - */ - public static ImageIcon getAuthenticationWindowIcon( - ProtocolProviderService protocolProvider) - { - Image image = null; - - if(protocolProvider != null) - { - ProtocolIcon protocolIcon = protocolProvider.getProtocolIcon(); - - if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_64x64)) - image = ImageUtils.getBytesInImage( - protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_64x64)); - else if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_48x48)) - image = ImageUtils.getBytesInImage( - protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_48x48)); - } - - if (image != null) - return new ImageIcon(image); - - return null; - } } diff --git a/src/net/java/sip/communicator/impl/muc/MUCActivator.java b/src/net/java/sip/communicator/impl/muc/MUCActivator.java index 5e6d086..37a943b 100644 --- a/src/net/java/sip/communicator/impl/muc/MUCActivator.java +++ b/src/net/java/sip/communicator/impl/muc/MUCActivator.java @@ -10,6 +10,7 @@ import java.util.*; import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.credentialsstorage.*; +import net.java.sip.communicator.service.customcontactactions.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; @@ -79,6 +80,16 @@ public class MUCActivator * The credential storage service. */ private static CredentialsStorageService credentialsService; + + /** + * The custom actions service. + */ + private static MUCCustomContactActionService mucCustomActionService; + + /** + * The UI service. + */ + private static UIService uiService = null; /** * Starts this bundle. @@ -98,6 +109,11 @@ public class MUCActivator MUCService.class.getName(), mucService, null); + mucCustomActionService = new MUCCustomContactActionService(); + bundleContext.registerService( + CustomContactActionsService.class.getName(), + mucCustomActionService, + null); } public void stop(BundleContext context) throws Exception @@ -343,4 +359,22 @@ public class MUCActivator if (chatRoomProviders.contains(protocolProvider)) chatRoomProviders.remove(protocolProvider); } + + /** + * Returns the <tt>UIService</tt> obtained from the bundle + * context. + * @return the <tt>UIService</tt> obtained from the bundle + * context + */ + public static UIService getUIService() + { + if(uiService == null) + { + uiService + = ServiceUtils.getService( + bundleContext, + UIService.class); + } + return uiService; + } } diff --git a/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java b/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java new file mode 100644 index 0000000..2d3884e --- /dev/null +++ b/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java @@ -0,0 +1,503 @@ +/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.impl.muc;
+
+import java.util.*;
+
+import org.jitsi.service.resources.*;
+
+import net.java.sip.communicator.plugin.desktoputil.chat.*;
+import net.java.sip.communicator.service.contactsource.*;
+import net.java.sip.communicator.service.customcontactactions.*;
+import net.java.sip.communicator.service.muc.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+
+/**
+ * Implements <tt>CustomContactActionsService</tt> for MUC contact source.
+ *
+ * @author Hristo Terezov
+ */
+public class MUCCustomContactActionService
+ implements CustomContactActionsService<SourceContact>
+{
+ /**
+ * List of custom menu items.
+ */
+ private final List<ContactActionMenuItem<SourceContact>> MUCActionMenuItems
+ = new LinkedList<ContactActionMenuItem<SourceContact>>();
+
+ /**
+ * Array of labels for the custom menu items.
+ */
+ private String[] actionsLabels = {
+ "service.gui.OPEN", "service.gui.JOIN",
+ "service.gui.JOIN_AS", "service.gui.LEAVE",
+ "service.gui.REMOVE", "service.gui.CHANGE_NICK",
+ "service.gui.JOIN_AUTOMATICALLY"
+ };
+
+ /**
+ * Array of icons for the custom menu items.
+ */
+ private String[] actionsIcons = {
+ "service.gui.icons.CHAT_ROOM_16x16_ICON", "service.gui.icons.JOIN_ICON",
+ "service.gui.icons.JOIN_AS_ICON", "service.gui.icons.LEAVE_ICON",
+ "service.gui.icons.REMOVE_CHAT_ICON",
+ "service.gui.icons.RENAME_16x16_ICON",
+ null
+ };
+
+ /**
+ * Array of <tt>MUCCustomActionRunnable</tt> objects for the custom menu
+ * items. They will be executed when the item is pressed.
+ */
+ private MUCCustomActionRunnable[] actionsRunnable = {
+ new MUCCustomActionRunnable()
+ {
+ @Override
+ public void run()
+ {
+ String[] joinOptions;
+ String subject = null;
+ if(chatRoomWrapper.getChatRoom() == null)
+ {
+ // this is not a server persistent room we must create it
+ // and join
+ chatRoomWrapper =
+ MUCActivator.getMUCService().createChatRoom(
+ chatRoomWrapper.getChatRoomName(),
+ chatRoomWrapper.getParentProvider()
+ .getProtocolProvider(),
+ new ArrayList<String>(),
+ "",
+ false,
+ false,
+ true);
+ }
+
+ if(!chatRoomWrapper.getChatRoom().isJoined())
+ {
+ String nickName = null;
+
+ nickName =
+ ConfigurationUtils.getChatRoomProperty(
+ chatRoomWrapper.getParentProvider()
+ .getProtocolProvider(), chatRoomWrapper
+ .getChatRoomID(), "userNickName");
+ if(nickName == null)
+ {
+ joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions(
+ chatRoomWrapper.getParentProvider()
+ .getProtocolProvider(),
+ chatRoomWrapper.getChatRoomID());
+ nickName = joinOptions[0];
+ subject = joinOptions[1];
+ }
+
+ if (nickName != null)
+ MUCActivator.getMUCService().joinChatRoom(chatRoomWrapper,
+ nickName, null, subject);
+ else
+ return;
+ }
+
+ MUCActivator.getUIService().openChatRoomWindow(chatRoomWrapper);
+ }
+ },
+ new MUCCustomActionRunnable()
+ {
+
+ @Override
+ public void run()
+ {
+ String[] joinOptions;
+ String subject = null;
+ String nickName = null;
+
+ nickName =
+ ConfigurationUtils.getChatRoomProperty(
+ chatRoomWrapper.getParentProvider()
+ .getProtocolProvider(), chatRoomWrapper
+ .getChatRoomID(), "userNickName");
+ if(nickName == null)
+ {
+ joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions(
+ chatRoomWrapper.getParentProvider()
+ .getProtocolProvider(),
+ chatRoomWrapper.getChatRoomID());
+ nickName = joinOptions[0];
+ subject = joinOptions[1];
+ }
+
+ if (nickName != null)
+ MUCActivator.getMUCService().joinChatRoom(chatRoomWrapper,
+ nickName, null, subject);
+ }
+ },
+ new MUCCustomActionRunnable()
+ {
+
+ @Override
+ public void run()
+ {
+ String[] joinOptions;
+ joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions(
+ chatRoomWrapper.getParentProvider().getProtocolProvider(),
+ chatRoomWrapper.getChatRoomID());
+ if(joinOptions[0] == null)
+ return;
+ MUCActivator.getMUCService()
+ .joinChatRoom(chatRoomWrapper, joinOptions[0], null,
+ joinOptions[1]);
+ }
+ },
+ new MUCCustomActionRunnable()
+ {
+
+ @Override
+ public void run()
+ {
+ ChatRoomWrapper leavedRoomWrapped
+ = MUCActivator.getMUCService().leaveChatRoom(
+ chatRoomWrapper);
+ if(leavedRoomWrapped != null)
+ MUCActivator.getUIService().closeChatRoomWindow(
+ leavedRoomWrapped);
+ }
+ },
+ new MUCCustomActionRunnable()
+ {
+
+ @Override
+ public void run()
+ {
+ ChatRoom chatRoom = chatRoomWrapper.getChatRoom();
+
+ if (chatRoom != null)
+ {
+ ChatRoomWrapper leavedRoomWrapped
+ = MUCActivator.getMUCService().leaveChatRoom(
+ chatRoomWrapper);
+ if(leavedRoomWrapped != null)
+ MUCActivator.getUIService().closeChatRoomWindow(
+ leavedRoomWrapped);
+ }
+
+ MUCActivator.getUIService().closeChatRoomWindow(chatRoomWrapper);
+
+ MUCActivator.getMUCService().removeChatRoom(chatRoomWrapper);
+ }
+ },
+ new MUCCustomActionRunnable()
+ {
+
+ @Override
+ public void run()
+ {
+ ChatRoomJoinOptionsDialog.getJoinOptions(true,
+ chatRoomWrapper.getParentProvider().getProtocolProvider(),
+ chatRoomWrapper.getChatRoomID());
+ }
+ },
+ new MUCCustomActionRunnable()
+ {
+
+ @Override
+ public void run()
+ {
+ chatRoomWrapper.setAutoJoin(!chatRoomWrapper.isAutojoin());
+ }
+ }
+ };
+
+ /**
+ * Array of <tt>EnableChecker</tt> objects for the custom menu items. They
+ * are used to check if the item is enabled or disabled.
+ */
+ private EnableChecker[] actionsEnabledCheckers = {
+ null,
+ new JoinEnableChecker(),
+ new JoinEnableChecker(),
+ new LeaveEnableChecker(),
+ null,
+ null,
+ null
+ };
+
+ /**
+ * Array for the custom menu items that describes the type of the menu item.
+ * If <tt>true</tt> - the item is check box.
+ */
+ private boolean[] actionsIsCheckBox = {
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ true
+ };
+
+ /**
+ * The resource management service instance.
+ */
+ ResourceManagementService resources = MUCActivator.getResources();
+
+ /**
+ * Constructs the custom actions.
+ */
+ public MUCCustomContactActionService()
+ {
+ for(int i = 0; i < actionsLabels.length; i++)
+ {
+ MUCActionMenuItems item = new MUCActionMenuItems(actionsLabels[i],
+ actionsIcons[i], actionsRunnable[i], actionsIsCheckBox[i]);
+ MUCActionMenuItems.add(item);
+ if(actionsEnabledCheckers[i] != null)
+ item.setEnabled(actionsEnabledCheckers[i]);
+ }
+
+ }
+
+ /**
+ * Returns the template class that this service has been initialized with
+ *
+ * @return the template class
+ */
+ public Class<SourceContact> getContactSourceClass()
+ {
+ return SourceContact.class;
+ }
+
+ @Override
+ public Iterator<ContactActionMenuItem<SourceContact>>
+ getCustomContactActionsMenuItems()
+ {
+ return MUCActionMenuItems.iterator();
+ }
+
+
+ @Override
+ public Iterator<ContactAction<SourceContact>> getCustomContactActions()
+ {
+ return null;
+ }
+
+ /**
+ * Implements the MUC custom menu items.
+ */
+ private class MUCActionMenuItems
+ implements ContactActionMenuItem<SourceContact>
+ {
+ /**
+ * The key used to retrieve the label for the menu item.
+ */
+ private String textKey;
+
+ /**
+ * The key used to retrieve the icon for the menu item.
+ */
+ private String imageKey;
+
+ /**
+ * The action executed when the menu item is pressed.
+ */
+ private MUCCustomActionRunnable actionPerformed;
+
+ /**
+ * Object that is used to check if the item is enabled or disabled.
+ */
+ private EnableChecker enabled;
+
+ /**
+ * if <tt>true</tt> the item should be check box and if <tt>false</tt>
+ * it is standard menu item.
+ */
+ private boolean isCheckBox;
+
+ /**
+ * Constructs <tt>MUCActionMenuItems</tt> instance.
+ *
+ * @param textKey the key used to retrieve the label for the menu item.
+ * @param imageKey the key used to retrieve the icon for the menu item.
+ * @param actionPerformed the action executed when the menu item is
+ * pressed.
+ * @param isCheckBox if <tt>true</tt> the item should be check box.
+ */
+ public MUCActionMenuItems(String textKey, String imageKey,
+ MUCCustomActionRunnable actionPerformed, boolean isCheckBox)
+ {
+ this.textKey = textKey;
+ this.imageKey = imageKey;
+ this.actionPerformed = actionPerformed;
+ this.enabled = new EnableChecker();
+ this.isCheckBox = isCheckBox;
+ }
+
+ @Override
+ public void actionPerformed(SourceContact actionSource)
+ throws OperationFailedException
+ {
+ if(!(actionSource instanceof ChatRoomSourceContact))
+ return;
+ actionPerformed.setContact(actionSource);
+ new Thread(actionPerformed).start();
+ }
+
+ @Override
+ public byte[] getIcon()
+ {
+ return (imageKey == null)? null :
+ resources.getImageInBytes(imageKey);
+ }
+
+
+ @Override
+ public String getText()
+ {
+ return resources.getI18NString(textKey);
+ }
+
+ @Override
+ public boolean isVisible(SourceContact actionSource)
+ {
+ return (actionSource instanceof ChatRoomSourceContact);
+ }
+
+ @Override
+ public char getMnemonics()
+ {
+ return resources.getI18nMnemonic(textKey);
+ }
+
+ @Override
+ public boolean isEnabled(SourceContact actionSource)
+ {
+ return enabled.check(actionSource);
+ }
+
+ /**
+ * Sets <tt>EnabledChecker</tt> instance that will be used to check if
+ * the item should be enabled or disabled.
+ *
+ * @param enabled the <tt>EnabledChecker</tt> instance.
+ */
+ public void setEnabled(EnableChecker enabled)
+ {
+ this.enabled = enabled;
+ }
+
+ @Override
+ public boolean isCheckBox()
+ {
+ return isCheckBox;
+ }
+
+ @Override
+ public boolean isSelected(SourceContact contact)
+ {
+ ChatRoomWrapper chatRoomWrapper = MUCActivator.getMUCService()
+ .findChatRoomWrapperFromSourceContact(contact);
+ return chatRoomWrapper.isAutojoin();
+ }
+
+ }
+
+ /**
+ * Checks if the menu item should be enabled or disabled. This is default
+ * implementation. Always returns that the item should be enabled.
+ */
+ private class EnableChecker
+ {
+ /**
+ * Checks if the menu item should be enabled or disabled.
+ *
+ * @param contact the contact associated with the menu item.
+ * @return always <tt>true</tt>
+ */
+ public boolean check(SourceContact contact)
+ {
+ return true;
+ }
+ }
+
+ /**
+ * Implements <tt>EnableChecker</tt> for the join menu items.
+ */
+ private class JoinEnableChecker extends EnableChecker
+ {
+ /**
+ * Checks if the menu item should be enabled or disabled.
+ *
+ * @param contact the contact associated with the menu item.
+ * @return <tt>true</tt> if the item should be enabled and
+ * <tt>false</tt> if not.
+ */
+ public boolean check(SourceContact contact)
+ {
+ ChatRoomWrapper chatRoomWrapper = MUCActivator.getMUCService()
+ .findChatRoomWrapperFromSourceContact(contact);
+ ChatRoom chatRoom = null;
+ if(chatRoomWrapper != null)
+ {
+ chatRoom = chatRoomWrapper.getChatRoom();
+ }
+
+ if((chatRoom != null) && chatRoom.isJoined())
+ return false;
+ return true;
+ }
+ }
+
+ /**
+ * Implements <tt>EnableChecker</tt> for the leave menu item.
+ */
+ private class LeaveEnableChecker extends JoinEnableChecker
+ {
+ /**
+ * Checks if the menu item should be enabled or disabled.
+ *
+ * @param contact the contact associated with the menu item.
+ * @return <tt>true</tt> if the item should be enabled and
+ * <tt>false</tt> if not.
+ */
+ public boolean check(SourceContact contact)
+ {
+ return !super.check(contact);
+ }
+ }
+
+ /**
+ * Implements base properties for the MUC menu items.These properties are
+ * used when the menu item is pressed.
+ */
+ private abstract class MUCCustomActionRunnable implements Runnable
+ {
+ /**
+ * The contact associated with the menu item.
+ */
+ protected SourceContact contact;
+
+ /**
+ * The contact associated with the menu item.
+ */
+ protected ChatRoomWrapper chatRoomWrapper;
+
+ /**
+ * Sets the source contact.
+ * @param contact the contact to set
+ */
+ public void setContact(SourceContact contact)
+ {
+ this.contact = contact;
+ chatRoomWrapper = MUCActivator.getMUCService()
+ .findChatRoomWrapperFromSourceContact(contact);
+ }
+
+ }
+}
diff --git a/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java b/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java index 0fa21b3..5a62c80 100644 --- a/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java +++ b/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java @@ -11,7 +11,7 @@ import java.util.*; import org.jitsi.service.resources.*;
-import net.java.sip.communicator.impl.gui.utils.*;
+import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.contactsource.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.muc.*;
@@ -737,7 +737,7 @@ public class MUCServiceImpl authWindowsService.create(
null, null, null, false,
chatRoomWrapper.isPersistent(),
- ImageLoader.getAuthenticationWindowIcon(
+ AuthenticationWindow.getAuthenticationWindowIcon(
chatRoomWrapper.getParentProvider()
.getProtocolProvider()),
resources.getI18NString(
diff --git a/src/net/java/sip/communicator/impl/muc/muc.manifest.mf b/src/net/java/sip/communicator/impl/muc/muc.manifest.mf index 6427cbf..21c5d9a 100644 --- a/src/net/java/sip/communicator/impl/muc/muc.manifest.mf +++ b/src/net/java/sip/communicator/impl/muc/muc.manifest.mf @@ -13,5 +13,8 @@ Import-Package: org.osgi.framework, org.jitsi.service.configuration, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.credentialsstorage, - net.java.sip.communicator.service.gui + net.java.sip.communicator.service.gui, + net.java.sip.communicator.service.customcontactactions, + net.java.sip.communicator.plugin.desktoputil, + net.java.sip.communicator.plugin.desktoputil.chat Export-Package: net.java.sip.communicator.service.muc diff --git a/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java b/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java index 265c44d..a989eec 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java @@ -12,6 +12,7 @@ import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.Logger; import org.jitsi.util.*; @@ -757,5 +758,36 @@ public class AuthenticationWindow }); return subscribeLabel; } + + + /** + * Returns the icon corresponding to the given <tt>protocolProvider</tt>. + * + * @param protocolProvider the <tt>ProtocolProviderService</tt>, which icon + * we're looking for + * @return the icon to show on the authentication window + */ + public static ImageIcon getAuthenticationWindowIcon( + ProtocolProviderService protocolProvider) + { + Image image = null; + + if(protocolProvider != null) + { + ProtocolIcon protocolIcon = protocolProvider.getProtocolIcon(); + + if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_64x64)) + image = ImageUtils.getBytesInImage( + protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_64x64)); + else if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_48x48)) + image = ImageUtils.getBytesInImage( + protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_48x48)); + } + + if (image != null) + return new ImageIcon(image); + + return null; + } } diff --git a/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java b/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java index 23bb10d..2be0ca1 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java @@ -10,6 +10,7 @@ import javax.swing.*; import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.certificate.*; import net.java.sip.communicator.service.credentialsstorage.*; +import net.java.sip.communicator.service.globaldisplaydetails.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.keybindings.*; import net.java.sip.communicator.service.protocol.*; @@ -52,6 +53,8 @@ public class DesktopUtilActivator private static AudioNotifierService audioNotifierService; + private static GlobalDisplayDetailsService globalDisplayDetailsService; + static BundleContext bundleContext; /** @@ -324,4 +327,23 @@ public class DesktopUtilActivator } return audioNotifierService; } + + /** + * Returns the <tt>GlobalDisplayDetailsService</tt> obtained from the bundle + * context. + * + * @return the <tt>GlobalDisplayDetailsService</tt> obtained from the bundle + * context + */ + public static GlobalDisplayDetailsService getGlobalDisplayDetailsService() + { + if (globalDisplayDetailsService == null) + { + globalDisplayDetailsService + = ServiceUtils.getService( + bundleContext, + GlobalDisplayDetailsService.class); + } + return globalDisplayDetailsService; + } }
\ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/MessageDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/MessageDialog.java index 2832a34..1b4ec68 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/MessageDialog.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/MessageDialog.java @@ -4,7 +4,7 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package net.java.sip.communicator.impl.gui.customcontrols; +package net.java.sip.communicator.plugin.desktoputil; import java.awt.*; import java.awt.event.*; @@ -12,9 +12,6 @@ import java.lang.reflect.*; import javax.swing.*; -import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.util.skin.*; /** @@ -35,17 +32,17 @@ public class MessageDialog private static final long serialVersionUID = 1L; private JButton cancelButton = new JButton( - GuiActivator.getResources().getI18NString("service.gui.CANCEL")); + DesktopUtilActivator.getResources().getI18NString("service.gui.CANCEL")); protected JButton okButton = new JButton( - GuiActivator.getResources().getI18NString("service.gui.OK")); + DesktopUtilActivator.getResources().getI18NString("service.gui.OK")); private JCheckBox doNotAskAgain = new SIPCommCheckBox( - GuiActivator.getResources() + DesktopUtilActivator.getResources() .getI18NString("service.gui.DO_NOT_ASK_AGAIN")); - private JLabel iconLabel = new JLabel(new ImageIcon(ImageLoader - .getImage(ImageLoader.WARNING_ICON))); + private JLabel iconLabel = new JLabel(new ImageIcon( + DesktopUtilActivator.getImage("service.gui.icons.WARNING_ICON"))); private StyledHTMLEditorPane messageArea = new StyledHTMLEditorPane(); @@ -166,7 +163,7 @@ public class MessageDialog if(!isCancelButtonEnabled) { - doNotAskAgain.setText(GuiActivator.getResources() + doNotAskAgain.setText(DesktopUtilActivator.getResources() .getI18NString("service.gui.DO_NOT_SHOW_AGAIN")); buttonsPanel.remove(cancelButton); @@ -322,8 +319,8 @@ public class MessageDialog */ public void loadSkin() { - iconLabel.setIcon(new ImageIcon(ImageLoader - .getImage(ImageLoader.WARNING_ICON))); + iconLabel.setIcon(new ImageIcon( + DesktopUtilActivator.getImage("service.gui.icons.WARNING_ICON"))); } /** @@ -334,4 +331,13 @@ public class MessageDialog { iconLabel.setIcon(new ImageIcon(image)); } + + /** + * Changes the icon in the dialog. + * @param image + */ + public void setIcon(ImageIcon image) + { + iconLabel.setIcon(image); + } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatOperationReasonDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatOperationReasonDialog.java index b8f518e..ae59707 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatOperationReasonDialog.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatOperationReasonDialog.java @@ -4,15 +4,15 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package net.java.sip.communicator.impl.gui.main.chat; +package net.java.sip.communicator.plugin.desktoputil.chat; import java.awt.*; import javax.swing.*; import javax.swing.event.*; -import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.plugin.desktoputil.DesktopUtilActivator; +import net.java.sip.communicator.plugin.desktoputil.MessageDialog; /** * @@ -34,11 +34,11 @@ public class ChatOperationReasonDialog extends MessageDialog public ChatOperationReasonDialog() { this(null, - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.REASON"), - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.SPECIFY_REASON"), - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.OK"), true, false); @@ -54,11 +54,11 @@ public class ChatOperationReasonDialog extends MessageDialog public ChatOperationReasonDialog(boolean disableOKIfReasonIsEmpty) { this(null, - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.REASON"), - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.SPECIFY_REASON"), - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.OK"), true, disableOKIfReasonIsEmpty); @@ -75,7 +75,7 @@ public class ChatOperationReasonDialog extends MessageDialog this(null, title, message, - GuiActivator.getResources().getI18NString("service.gui.OK"), + DesktopUtilActivator.getResources().getI18NString("service.gui.OK"), true, false); @@ -97,7 +97,7 @@ public class ChatOperationReasonDialog extends MessageDialog this(null, title, message, - GuiActivator.getResources().getI18NString("service.gui.OK"), + DesktopUtilActivator.getResources().getI18NString("service.gui.OK"), showReasonLabel, disableOKIfReasonIsEmpty); } @@ -144,7 +144,7 @@ public class ChatOperationReasonDialog extends MessageDialog JLabel reasonLabel = new JLabel( showReasonLabel - ? (GuiActivator.getResources().getI18NString( + ? (DesktopUtilActivator.getResources().getI18NString( "service.gui.REASON") + ":") : ""); diff --git a/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java new file mode 100644 index 0000000..cd7ed11 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java @@ -0,0 +1,196 @@ +/**
+ *
+ */
+package net.java.sip.communicator.plugin.desktoputil.chat;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+import javax.swing.border.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+
+/**
+ * @author Ico
+ *
+ */
+/**
+ * Dialog with fields for nickname and subject.
+ */
+public class ChatRoomJoinOptionsDialog extends ChatOperationReasonDialog
+{
+ /**
+ * Serial id.
+ */
+ private static final long serialVersionUID = -916498752420264164L;
+
+ /**
+ * Text field for the subject.
+ */
+ private SIPCommTextField subject = new SIPCommTextField(DesktopUtilActivator
+ .getResources().getI18NString("service.gui.SUBJECT"));
+
+ /**
+ * Label that hides and shows the subject fields panel on click.
+ */
+ private JLabel cmdExpandSubjectFields;
+
+ /**
+ * Panel that holds the subject fields.
+ */
+ private JPanel subjectFieldsPannel = new JPanel(new BorderLayout());
+
+ /**
+ * Adds the subject fields to dialog. Sets action listeners.
+ *
+ * @param title the title of the dialog
+ * @param message the message shown in this dialog
+ * @param disableOKIfReasonIsEmpty if true the OK button will be
+ * disabled if the reason text is empty.
+ * @param showReasonLabel specify if we want the "Reason:" label
+ * @param dontDisplaySubjectFields if true the sibject fields will be
+ * hidden.
+ */
+ public ChatRoomJoinOptionsDialog(String title, String message,
+ boolean showReasonLabel,
+ boolean disableOKIfReasonIsEmpty,
+ boolean dontDisplaySubjectFields)
+ {
+ super(title,
+ message,
+ showReasonLabel,
+ disableOKIfReasonIsEmpty);
+
+ if(dontDisplaySubjectFields)
+ return;
+
+ JPanel subjectPanel = new JPanel(new BorderLayout());
+ subjectPanel.setOpaque(false);
+ subjectPanel.setBorder(
+ BorderFactory.createEmptyBorder(10, 0, 0, 0));
+
+ subjectFieldsPannel.setBorder(
+ BorderFactory.createEmptyBorder(10, 30, 0, 0));
+ subjectFieldsPannel.setOpaque(false);
+ subjectFieldsPannel.add(subject, BorderLayout.CENTER);
+ subjectFieldsPannel.setVisible(false);
+ subject.setFont(getFont().deriveFont(12f));
+
+ cmdExpandSubjectFields = new JLabel();
+ cmdExpandSubjectFields.setBorder(new EmptyBorder(0, 5, 0, 0));
+ cmdExpandSubjectFields.setIcon(DesktopUtilActivator.getResources()
+ .getImage("service.gui.icons.RIGHT_ARROW_ICON"));
+ cmdExpandSubjectFields.setText(DesktopUtilActivator
+ .getResources().getI18NString("service.gui.SET_SUBJECT"));
+ cmdExpandSubjectFields.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mouseClicked(MouseEvent e)
+ {
+ cmdExpandSubjectFields.setIcon(
+ UtilActivator.getResources().getImage(
+ subjectFieldsPannel.isVisible()
+ ? "service.gui.icons.RIGHT_ARROW_ICON"
+ : "service.gui.icons.DOWN_ARROW_ICON"));
+
+ subjectFieldsPannel.setVisible(
+ !subjectFieldsPannel.isVisible());
+
+ pack();
+ }
+ });
+ subjectPanel.add(cmdExpandSubjectFields,BorderLayout.NORTH);
+ subjectPanel.add(subjectFieldsPannel,BorderLayout.CENTER);
+ addToReasonFieldPannel(subjectPanel);
+ this.pack();
+ }
+
+ /**
+ * Returns the text entered in the subject field.
+ *
+ * @return the text from the subject field.
+ */
+ public String getSubject()
+ {
+ return subject.getText();
+ }
+
+ /**
+ * Opens a dialog with a fields for the nickname and the subject of the room
+ * and returns them.
+ *
+ * @param pps the protocol provider associated with the chat room.
+ * @param chatRoomId the id of the chat room.
+ * @return array with the nickname and subject values.
+ */
+ public static String[] getJoinOptions(ProtocolProviderService pps,
+ String chatRoomId)
+ {
+ return getJoinOptions(false, pps, chatRoomId);
+ }
+
+ /**
+ * Opens a dialog with a fields for the nickname and the subject of the room
+ * and returns them.
+ *
+ * @param dontDisplaySubjectFields if true the subject fields will be hidden
+ * @return array with the nickname and subject values.
+ */
+ public static String[] getJoinOptions(boolean dontDisplaySubjectFields,
+ ProtocolProviderService pps, String chatRoomId)
+ {
+ String nickName = null;
+ ChatRoomJoinOptionsDialog reasonDialog =
+ new ChatRoomJoinOptionsDialog(DesktopUtilActivator.getResources()
+ .getI18NString("service.gui.CHANGE_NICKNAME"),
+ DesktopUtilActivator.getResources().getI18NString(
+ "service.gui.CHANGE_NICKNAME_LABEL"), false, true,
+ dontDisplaySubjectFields);
+ reasonDialog.setIcon(new ImageIcon(DesktopUtilActivator.getImage(
+ "service.gui.icons.CHANGE_NICKNAME_16x16")));
+
+ final OperationSetServerStoredAccountInfo accountInfoOpSet
+ = pps.getOperationSet(
+ OperationSetServerStoredAccountInfo.class);
+
+ String displayName = "";
+ if (accountInfoOpSet != null)
+ {
+ displayName = AccountInfoUtils.getDisplayName(accountInfoOpSet);
+ }
+
+ if(displayName == null || displayName.length() == 0)
+ {
+ displayName = DesktopUtilActivator.getGlobalDisplayDetailsService()
+ .getGlobalDisplayName();
+ if(displayName == null || displayName.length() == 0)
+ {
+ displayName = pps.getAccountID().getUserID();
+ if(displayName != null)
+ {
+ int atIndex = displayName.lastIndexOf("@");
+ if (atIndex > 0)
+ displayName = displayName.substring(0, atIndex);
+ }
+ }
+ }
+ reasonDialog.setReasonFieldText(displayName);
+
+ int result = reasonDialog.showDialog();
+
+ if (result == MessageDialog.OK_RETURN_CODE)
+ {
+ nickName = reasonDialog.getReason().trim();
+ ConfigurationUtils.updateChatRoomProperty(
+ pps,
+ chatRoomId, "userNickName", nickName);
+
+ }
+ String[] joinOptions = {nickName, reasonDialog.getSubject()};
+ return joinOptions;
+ }
+
+}
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/desktoputil.manifest.mf b/src/net/java/sip/communicator/plugin/desktoputil/desktoputil.manifest.mf index 4b91013..91f2af6 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/desktoputil.manifest.mf +++ b/src/net/java/sip/communicator/plugin/desktoputil/desktoputil.manifest.mf @@ -59,7 +59,8 @@ Import-Package: com.sun.awt, org.xml.sax, sun.awt.shell, sun.net.dns, - sun.net.util + sun.net.util, + net.java.sip.communicator.service.globaldisplaydetails Export-Package: net.java.sip.communicator.plugin.desktoputil, net.java.sip.communicator.plugin.desktoputil.border, net.java.sip.communicator.plugin.desktoputil.event, @@ -67,4 +68,5 @@ Export-Package: net.java.sip.communicator.plugin.desktoputil, net.java.sip.communicator.plugin.desktoputil.presence, net.java.sip.communicator.plugin.desktoputil.presence.avatar, net.java.sip.communicator.plugin.desktoputil.transparent, - net.java.sip.communicator.plugin.desktoputil.wizard + net.java.sip.communicator.plugin.desktoputil.wizard, + net.java.sip.communicator.plugin.desktoputil.chat diff --git a/src/net/java/sip/communicator/service/customcontactactions/ContactActionMenuItem.java b/src/net/java/sip/communicator/service/customcontactactions/ContactActionMenuItem.java new file mode 100644 index 0000000..1c97623 --- /dev/null +++ b/src/net/java/sip/communicator/service/customcontactactions/ContactActionMenuItem.java @@ -0,0 +1,87 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.customcontactactions; + +import net.java.sip.communicator.service.contactsource.SourceContact; +import net.java.sip.communicator.service.protocol.*; + +/** + * A custom contact action menu item, used to define an action that can be + * represented in the contact list entry in the user interface. + * + * @author Hristo Terezov + */ +public interface ContactActionMenuItem<T> +{ + /** + * Invoked when an action occurs. + * + * @param actionSource the source of the action + */ + public void actionPerformed(T actionSource) + throws OperationFailedException; + + /** + * The icon used by the UI to visualize this action. + * @return the button icon. + */ + public byte[] getIcon(); + + /** + * Returns the text of the component to create for this contact + * action. + * + * @return the tool tip text of the component to create for this contact + * action + */ + public String getText(); + + /** + * Indicates if this action is visible for the given <tt>actionSource</tt>. + * + * @param actionSource the action source for which we're verifying the + * action. + * @return <tt>true</tt> if the action should be visible for the given + * <tt>actionSource</tt>, <tt>false</tt> - otherwise + */ + public boolean isVisible(T actionSource); + + /** + * + * @return + */ + public char getMnemonics(); + + /** + * Returns <tt>true</tt> if the item should be enabled and <tt>false</tt> + * - not. + * + * @param actionSource the action source for which we're verifying the + * action. + * @return <tt>true</tt> if the item should be enabled and <tt>false</tt> + * - not. + */ + public boolean isEnabled(T actionSource); + + /** + * Returns <tt>true</tt> if the item should be a check box and + * <tt>false</tt> if not + * + * @return <tt>true</tt> if the item should be a check box and + * <tt>false</tt> if not + */ + public boolean isCheckBox(); + + /** + * Returns the state of the item if the item is check box. + * + * @param actionSource the action source for which we're verifying the + * action. + * @return the state of the item. + */ + public boolean isSelected(T actionSource); +}
\ No newline at end of file diff --git a/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java b/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java index 3aaf0ba..52c4b4d 100644 --- a/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java +++ b/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java @@ -29,4 +29,11 @@ public interface CustomContactActionsService<T> * @return an iterator over a list of <tt>ContactAction</tt>s */ public Iterator<ContactAction<T>> getCustomContactActions(); + + /** + * Returns all custom actions menu items defined by this service. + * + * @return an iterator over a list of <tt>ContactActionMenuItem</tt>s + */ + public Iterator<ContactActionMenuItem<T>> getCustomContactActionsMenuItems(); } diff --git a/src/net/java/sip/communicator/service/gui/UIContact.java b/src/net/java/sip/communicator/service/gui/UIContact.java index e842cbb..0c3b343 100644 --- a/src/net/java/sip/communicator/service/gui/UIContact.java +++ b/src/net/java/sip/communicator/service/gui/UIContact.java @@ -10,6 +10,8 @@ import java.awt.*; import java.util.*; import java.util.List; +import javax.swing.*; + import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.service.protocol.*; @@ -136,4 +138,16 @@ public abstract class UIContact { return -1; } + + /** + * Returns all custom action menu items for this contact. + * + * @param initActions if <tt>true</tt> the actions will be reloaded. + * @return a list of all custom action menu items for this contact. + */ + public Collection<JMenuItem> getContactCustomActionMenuItems( + boolean initActions) + { + return null; + } } diff --git a/src/net/java/sip/communicator/service/gui/UIService.java b/src/net/java/sip/communicator/service/gui/UIService.java index 68ab907..ffdd052 100644 --- a/src/net/java/sip/communicator/service/gui/UIService.java +++ b/src/net/java/sip/communicator/service/gui/UIService.java @@ -13,6 +13,7 @@ import java.util.List; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.event.*; +import net.java.sip.communicator.service.muc.ChatRoomWrapper; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.account.*; @@ -49,6 +50,7 @@ import net.java.sip.communicator.util.account.*; * @author Dmitri Melnikov * @author Adam Netocny * @author Lyubomir Marinov + * @author Hristo Terezov */ public interface UIService { @@ -473,4 +475,19 @@ public interface UIService * @return the login manager used by the current UI implementation */ public LoginManager getLoginManager(); + + /** + * Opens a chat room window for the given <tt>ChatRoomWrapper</tt> instance. + * + * @param chatRoom the chat room associated with the chat room window + */ + public void openChatRoomWindow(ChatRoomWrapper chatRoom); + + /** + * Closes the chat room window for the given <tt>ChatRoomWrapper</tt> + * instance. + * + * @param chatRoom the chat room associated with the chat room window + */ + public void closeChatRoomWindow(ChatRoomWrapper chatRoom); } |