From a4e09b9f3c55c195a3fa078f02ccff137cebc447 Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Fri, 22 Nov 2013 12:30:20 +0200 Subject: [PATCH] Implements chat room contacts action buttons and right menu actions. --- resources/images/images.properties | 7 + .../images/impl/gui/buttons/autoJoin.png | Bin 0 -> 1200 bytes .../images/impl/gui/buttons/autoJoinOver.png | Bin 0 -> 1307 bytes .../impl/gui/buttons/autoJoinPressed.png | Bin 0 -> 1394 bytes .../images/impl/gui/buttons/leaveRoom.png | Bin 0 -> 1298 bytes .../images/impl/gui/buttons/leaveRoomOver.png | Bin 0 -> 1471 bytes .../impl/gui/buttons/leaveRoomOverPressed.png | Bin 0 -> 1558 bytes .../impl/gui/common/autoJoinRightMenu.png | Bin 0 -> 1179 bytes resources/languages/resources.properties | 1 + .../communicator/impl/muc/ChatRoomQuery.java | 47 ++- .../impl/muc/ChatRoomSourceContact.java | 46 ++- .../impl/muc/ChatRoomWrapperImpl.java | 2 + .../muc/MUCCustomContactActionService.java | 355 ++++++++++++++---- 13 files changed, 370 insertions(+), 88 deletions(-) create mode 100644 resources/images/impl/gui/buttons/autoJoin.png create mode 100644 resources/images/impl/gui/buttons/autoJoinOver.png create mode 100644 resources/images/impl/gui/buttons/autoJoinPressed.png create mode 100644 resources/images/impl/gui/buttons/leaveRoom.png create mode 100644 resources/images/impl/gui/buttons/leaveRoomOver.png create mode 100644 resources/images/impl/gui/buttons/leaveRoomOverPressed.png create mode 100644 resources/images/impl/gui/common/autoJoinRightMenu.png diff --git a/resources/images/images.properties b/resources/images/images.properties index c02cec9f1..525cd0c70 100644 --- a/resources/images/images.properties +++ b/resources/images/images.properties @@ -15,6 +15,7 @@ service.gui.DEFAULT_USER_PHOTO_SMALL=resources/images/impl/gui/common/personPhot # service gui icons service.gui.icons.ACCOUNT_ICON=resources/images/impl/gui/buttons/addAccount.png service.gui.icons.ADD_ACCOUNT_MENU_ICON=resources/images/impl/gui/buttons/addAccountMenu.png +service.gui.icons.AUTOJOIN=resources/images/impl/gui/common/autoJoinRightMenu.png service.gui.icons.CONFIGURE_ICON=resources/images/impl/gui/common/configureIcon.png service.gui.icons.SHOW_HIDE_OFFLINE_ICON=resources/images/impl/gui/common/showHideOffline.png service.gui.icons.NO_SOUND_ICON=resources/images/impl/gui/common/noSound.png @@ -260,6 +261,12 @@ service.gui.buttons.CONTACT_LIST_DIAL_BUTTON=resources/images/impl/gui/buttons/c service.gui.buttons.DIAL_PAD_CALL_BUTTON_BG=resources/images/impl/gui/buttons/dialPadCallButtonBg.png service.gui.buttons.CALL_INFO=resources/images/impl/gui/buttons/callInfo.png service.gui.buttons.ZRTP_ID_BUTTON=resources/images/impl/gui/buttons/zrtpEditId.png +service.gui.icons.LEAVE_ICON_BUTTON=resources/images/impl/gui/buttons/leaveRoom.png +service.gui.icons.LEAVE_ICON_ROLLOVER_BUTTON=resources/images/impl/gui/buttons/leaveRoomOver.png +service.gui.icons.LEAVE_ICON_PRESSED_BUTTON=resources/images/impl/gui/buttons/leaveRoomOverPressed.png +service.gui.icons.AUTOJOIN_ICON_BUTTON=resources/images/impl/gui/buttons/autoJoin.png +service.gui.icons.AUTOJOIN_ICON_ROLLOVER_BUTTON=resources/images/impl/gui/buttons/autoJoinOver.png +service.gui.icons.AUTOJOIN_ICON_PRESSED_BUTTON=resources/images/impl/gui/buttons/autoJoinPressed.png # Sound level icons service.gui.soundlevel.SOUND_LEVEL_ACTIVE_LEFT=resources/images/impl/gui/common/soundlevel/soundActiveLeft.png diff --git a/resources/images/impl/gui/buttons/autoJoin.png b/resources/images/impl/gui/buttons/autoJoin.png new file mode 100644 index 0000000000000000000000000000000000000000..611f1281355c629f339e802debcbbb18f72f92db GIT binary patch literal 1200 zcmbVMZD`zN9M5@ht49Y)hitXjkn?4myGx$jC3lHU%iSee&+Te=J?MQjmptu-YhFyA zdTHl$t$wH|bHWh6$QX#6h<@0H3S&Cu1pPL_4>E8%n4m*9M3{qC&nIoK^F!GOLz3rt z{`voY|M$E)IdO1jd@xQB#Lm*VT*2!geje_N;dlL^(@nhWK}roxIWwrGd638(P92gZ zOPhris2K~-eFH}bBHA#kHB>7f7Inu;X`xOkuw0BLh>@|t)$}GrWF5|$wnW{!@Hs`A zhD1$sWv1*FVZ$6>^x)LuL{(pG>ViRyjgljQhzTr+G%~Q}Y+no{YMoca`%p|%h-7{TeIyMUBLvGWm$!&*e=|`yWptpqG)OVDWrcCAYx}4I@4B(AwqIRvAzgvKGwf7Yc%`6y;nIC{!i9u>JRCP( zUhCq)x>}O+)!<5ft=k=oO2k0)ol9+{7D*%$yQ7i4Uv?9J{CX>)4!wWk)Vp7=9F!72 z9P1Rw-+u4gL&P6^TO?N>I6Hd%GPMi6-g!LM{-S&41r@zkYY$!v3di@44zBdC4o}C2 zlFN;mZ(lla?PjF261>EH3=XUC4-_g($aE06RaKCiqnJa#pDzH@5m(8|ZZ{Jr|u^wL|6lg<14&i(Y{ wqi2X+!>5<-#1=m+Jv{_Y@SnskDnukkeEKJI<@WbSTj4*Xq)f;k6`o!G7oY`<0RR91 literal 0 HcmV?d00001 diff --git a/resources/images/impl/gui/buttons/autoJoinOver.png b/resources/images/impl/gui/buttons/autoJoinOver.png new file mode 100644 index 0000000000000000000000000000000000000000..3da139d50da47e6a4bc6454a0382acc85d21f331 GIT binary patch literal 1307 zcmeAS@N?(olHy`uVBq!ia0vp^Qa~)t!3HFg#O7xMDajJoh?3y^w370~qErUQl>DSr z1<%~X^wgl##FWaylc_cg49ppsArU1JzCKpT`MG+DAT@dwxdlMo3=B5*6$OdO*{LN8 zNvY|XdA3ULckfqH$V{%1*XSQL?vFu&J;D8jzb> zlBiITo0C^;Rbi_HHrEQs1_|pcDS(xfWZNo192Makpx~Tel&WB=XRMoSU}&gdW~OIo zVrph)sH0$HU}&Uo07PcGh9*{~W>!Y#3Q(W~w5=#5%__*n4QdyVXRDM^Qc_^0uU}qX zu2*iXmtT~wZ)j<02{OaTNEfI=x41H|B(Xv_uUHvof=g;~a#3bMNoIbY0?5R~r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d0hG_np+{nPp!qCvt+`_`i(bC1z$jQyX(#;WO1~$DG1}@Id2BwB4j?RvThOWj=PL?jN z&Mp?thOSPg#-^4qy`Fi+C5d^-sW5vpf%Zc68sODy)eNyv)d8P=MIXa6H zl^7Tp7kIijhE&|T6Smi{#X;a+>@)%C;)fNCwM;8>)@`zhfB25`jsC_@oLe?8+4X(H zrmY4cYHI&P(tY&O);n^(d1%fl;j|-J|A469Cqu?*Khx6E+nz>FGd#U1=GYC%0v3xk z(w&Xs5B#$K9&HtHzT?Bls50ksskjbD!<(B7H)ngtxEcIoUb|rbLer9KlUUStu+}!* zX8hvu=%Bz4mN17&)fc=H+NUry@&<6(c4?gQd~|KL(DCm}WRFWuJiPO)=m{Cem#36p zx}Go-2z1#sYuzDZVa4~WUuP>_Ui9|Z?5;b%f=+d-F~2ytzch2!y=nUwm%F({{K$Be zTN-<}eADGGS6nV}U);viq1UwvRORcM;~4N{#Sa!p07crOaFGzopr0O(Zr AlK=n! literal 0 HcmV?d00001 diff --git a/resources/images/impl/gui/buttons/leaveRoom.png b/resources/images/impl/gui/buttons/leaveRoom.png new file mode 100644 index 0000000000000000000000000000000000000000..8e1cdd519cee9367e8ca2b3ccfe522365f0f126d GIT binary patch literal 1298 zcmbVMZD<>19KSYQ+XaTM!?JcAJ1%Z+uF1XS?T%(?E_c}?O&gPlQTxHm-P7hsbC=#- zo3wMb6GRJDiVhKr>*jEqh+@DO#^%~WofIeAJ_ss0-%y4)HksmZYJ8F=ogd0Rc--Cd zJpcRue*gEIiuUf^U~RV|2(lr(kB`B%9X?x{8{s?EI+uYTJMy$c(+6>qVVE)pMcJW--566%v0zsXTaAGShNLSwQ_)nk z%qXU`5z~i3Pgg?7<|2_*V%4Z73Z@J%h&h~e5O_9Qj;o?=m@#nMjWxB6#8?jCF<@vT zx&-SnV5@;)?(S@;tO&hf`*Z~sMI7QaX(S6&GtB!i_{AYBG8^JOA(Hes2@gfMy(Gza zyk0KA@C?O;2qqM$ajb<63M9k{PG=yS+tU2 zR$0RXg7L!sxgEKeq5?r)a8fRsCS4?jRk8B_$r=uw!OQLOpLVHxy&!iNnth?Rcn@ayp%LkB)BLF?#*m#r56dgEIZd z^{1O`wqsk#??(UpO=&wKzDAra7K_%I3!HgzF;OGZM5xD zI+lm0k8QUc=;SWE93}5U_e}1-@%{N1Z?;(4FRnZO+;0AOXnJXZJIN!j>~H43Ic4nK zJh1*~i{;J7-ucnizu0vCYTqRHK7X&#Lr=YT<<}oR-apwN$8KyIYyEJd^w0e>Zv?n= wA1!n?NcXgCn>%>3ar^S@@Vlp6SM2r81j0PuP(St7>y_VBSm@>7<{p3QUnm*2L;wH) literal 0 HcmV?d00001 diff --git a/resources/images/impl/gui/buttons/leaveRoomOver.png b/resources/images/impl/gui/buttons/leaveRoomOver.png new file mode 100644 index 0000000000000000000000000000000000000000..2ff653b365622163e2bbdc7a88bdb1d018ba155e GIT binary patch literal 1471 zcmeAS@N?(olHy`uVBq!ia0vp^Qa~)t!3HFg#O7xMDajJoh?3y^w370~qErUQl>DSr z1<%~X^wgl##FWaylc_cg49ppsArU1JzCKpT`MG+DAT@dwxdlMo3=B5*6$OdO*{LN8 zNvY|XdA3ULckfqH$V{%1*XSQL?vFu&J;D8jzb> zlBiITo0C^;Rbi_HHrEQs1_|pcDS(xfWZNo192Makpx~Tel&WB=XRMoSU}&gdW~OIo zVrph)sH0$HU}&Uo07PcGh9*{~W>!Y#3Q(W~w5=#5%__*n4QdyVXRDM^Qc_^0uU}qX zu2*iXmtT~wZ)j<02{OaTNEfI=x41H|B(Xv_uUHvof=g;~a#3bMNoIbY0?5R~r2Ntn zTP2`NAzsKW@b!fooL3ADC}5E3S0onb8|oS8=jMX^1y)^L5|oN?23FO@A(aKG`a!A1 z`K3k4!1zd0hG_np+{nPp!qCvt+`_`i(bC1z$jQyX(#;WO1~$DG1}@Id2BxMaj?RvThOWj=PL?jN z&Mp?thOSPg#-^4qy`Fi+C5d^-sW5vpf%Zc6n&8!I)eNyv)d8P=MI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Y~ww>r5eSXf_U4DFcY#=s%rgr_=zHdH1 zRex{t>b9jnTmGJV)WC3X0DQTe`{b<_<$d<@pVezaqWJW9y`1J>JnHQq)X(hd+8VGE`t;iBlZU^ tmpContactResults; @@ -291,6 +302,24 @@ public void contentChanged(ChatRoomListChangeEvent evt) } } break; + case ChatRoomListChangeEvent.CHAT_ROOM_CHANGED: + synchronized (contactResults) + { + for(ChatRoomSourceContact contact : contactResults) + { + if(contact.getContactAddress().equals( + chatRoom.getChatRoomName())) + { + if(chatRoom.isAutojoin() != contact.isAutoJoin()) + { + contact.setAutoJoin(chatRoom.isAutojoin()); + fireContactChanged(contact); + } + break; + } + } + } + break; default: break; } diff --git a/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java b/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java index e4f8f2404..f2791eeaa 100644 --- a/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java +++ b/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java @@ -39,14 +39,21 @@ public class ChatRoomSourceContact private ProtocolProviderService provider; /** - * - * @param chatRoomName - * @param chatRoomID - * @param query - * @param pps + * The protocol provider of the chat room associated with the contact. + */ + private boolean isAutoJoin; + + /** + * Contsructs new chat room source contact. + * @param chatRoomName the name of the chat room associated with the room. + * @param chatRoomID the id of the chat room associated with the room. + * @param query the query associated with the contact. + * @param pps the protocol provider of the contact. + * @param isAutoJoin the auto join state. */ public ChatRoomSourceContact(String chatRoomName, - String chatRoomID, ChatRoomQuery query, ProtocolProviderService pps) + String chatRoomID, ChatRoomQuery query, ProtocolProviderService pps, + boolean isAutoJoin) { super(query, query.getContactSource(), chatRoomName, generateDefaultContactDetails(chatRoomName)); @@ -55,17 +62,21 @@ public ChatRoomSourceContact(String chatRoomName, this.chatRoomID = chatRoomID; this.provider = pps; this.parentQuery = query; + this.isAutoJoin = isAutoJoin; initContactProperties(getChatRoomStateByName()); } /** + * Constructs new chat room source contact. * - * @param chatRoom - * @param query + * @param chatRoom the chat room associated with the contact. + * @param query the query associated with the contact. + * @param isAutoJoin the auto join state */ - public ChatRoomSourceContact(ChatRoom chatRoom, ChatRoomQuery query) + public ChatRoomSourceContact(ChatRoom chatRoom, ChatRoomQuery query, + boolean isAutoJoin) { super(query, query.getContactSource(), chatRoom.getName(), generateDefaultContactDetails(chatRoom.getName())); @@ -74,6 +85,7 @@ public ChatRoomSourceContact(ChatRoom chatRoom, ChatRoomQuery query) this.chatRoomID = chatRoom.getIdentifier(); this.provider = chatRoom.getParentProvider(); this.parentQuery = query; + this.isAutoJoin = isAutoJoin; initContactProperties( (chatRoom.isJoined()? @@ -179,5 +191,21 @@ public int getIndex() return parentQuery.indexOf(this); } + /** + * Returns the auto join state of the contact. + * @return the auto join state of the contact. + */ + public boolean isAutoJoin() + { + return isAutoJoin; + } + /** + * Sets the auto join state of the contact. + * @param isAutoJoin the auto join state to be set. + */ + public void setAutoJoin(boolean isAutoJoin) + { + this.isAutoJoin = isAutoJoin; + } } diff --git a/src/net/java/sip/communicator/impl/muc/ChatRoomWrapperImpl.java b/src/net/java/sip/communicator/impl/muc/ChatRoomWrapperImpl.java index a6e4a5e1e..a22a1ed15 100644 --- a/src/net/java/sip/communicator/impl/muc/ChatRoomWrapperImpl.java +++ b/src/net/java/sip/communicator/impl/muc/ChatRoomWrapperImpl.java @@ -271,6 +271,8 @@ public void setAutoJoin(boolean value) getParentProvider().getProtocolProvider(), chatRoomID, AUTOJOIN_PROPERTY_NAME, null); } + MUCActivator.getMUCService().fireChatRoomListChangedEvent(this, + ChatRoomListChangeEvent.CHAT_ROOM_CHANGED); } diff --git a/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java b/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java index 2d3884e07..b0fa9427b 100644 --- a/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java +++ b/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java @@ -32,31 +32,131 @@ public class MUCCustomContactActionService = new LinkedList>(); /** - * Array of labels for the custom menu items. + * List of custom actions. + */ + private final List> MUCActions + = new LinkedList>(); + + /** + * Array of names for the custom actions. + */ + private String[] actionsNames = { + "leave", "autojoin", "autojoin_pressed" + }; + + /** + * Array of labels for the custom actions. */ private String[] actionsLabels = { + "service.gui.LEAVE", + "service.gui.JOIN_AUTOMATICALLY", + "service.gui.JOIN_AUTOMATICALLY" + }; + + /** + * Array of icons for the custom actions. + */ + private String[] actionsIcons = { + "service.gui.icons.LEAVE_ICON_BUTTON", + "service.gui.icons.AUTOJOIN_ICON_BUTTON", + "service.gui.icons.AUTOJOIN_ICON_PRESSED_BUTTON" + }; + + /** + * Array of rollover icons for the custom actions. + */ + private String[] actionsIconsRollover = { + "service.gui.icons.LEAVE_ICON_ROLLOVER_BUTTON", + "service.gui.icons.AUTOJOIN_ICON_ROLLOVER_BUTTON", + "service.gui.icons.AUTOJOIN_ICON_ROLLOVER_BUTTON" + }; + + /** + * Array of pressed icons for the custom actions. + */ + private String[] actionsIconsPressed = { + "service.gui.icons.LEAVE_ICON_PRESSED_BUTTON", + "service.gui.icons.AUTOJOIN_ICON_PRESSED_BUTTON", + "service.gui.icons.AUTOJOIN_ICON_BUTTON", + }; + + /** + * Array of names for the custom menu items. + */ + private String[] menuActionsNames = { + "open", "join", "join_as", "leave", "remove", "change_nick", "autojoin", + "autojoin_pressed" + }; + + /** + * Array of labels for the custom menu items. + */ + private String[] menuActionsLabels = { "service.gui.OPEN", "service.gui.JOIN", "service.gui.JOIN_AS", "service.gui.LEAVE", "service.gui.REMOVE", "service.gui.CHANGE_NICK", - "service.gui.JOIN_AUTOMATICALLY" + "service.gui.JOIN_AUTOMATICALLY", + "service.gui.DONT_JOIN_AUTOMATICALLY" }; /** * Array of icons for the custom menu items. */ - private String[] actionsIcons = { + private String[] menuActionsIcons = { "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 + "service.gui.icons.AUTOJOIN", "service.gui.icons.AUTOJOIN" }; + + /** + * A runnable that leaves the chat room. + */ + private MUCCustomActionRunnable leaveRunnable + = new MUCCustomActionRunnable() + { + + @Override + public void run() + { + ChatRoomWrapper leavedRoomWrapped + = MUCActivator.getMUCService().leaveChatRoom( + chatRoomWrapper); + if(leavedRoomWrapped != null) + MUCActivator.getUIService().closeChatRoomWindow( + leavedRoomWrapped); + } + }; + + /** + * A runnable that sets / unsets auto join setting of the chat room. + */ + private MUCCustomActionRunnable autoJoinRunnable + = new MUCCustomActionRunnable() + { + + @Override + public void run() + { + chatRoomWrapper.setAutoJoin(!chatRoomWrapper.isAutojoin()); + + } + }; /** * Array of MUCCustomActionRunnable objects for the custom menu * items. They will be executed when the item is pressed. */ private MUCCustomActionRunnable[] actionsRunnable = { + leaveRunnable, autoJoinRunnable, autoJoinRunnable + }; + + /** + * Array of MUCCustomActionRunnable objects for the custom menu + * items. They will be executed when the item is pressed. + */ + private MUCCustomActionRunnable[] menuActionsRunnable = { new MUCCustomActionRunnable() { @Override @@ -100,8 +200,8 @@ public void run() } if (nickName != null) - MUCActivator.getMUCService().joinChatRoom(chatRoomWrapper, - nickName, null, subject); + MUCActivator.getMUCService().joinChatRoom( + chatRoomWrapper,nickName, null, subject); else return; } @@ -156,20 +256,7 @@ public void run() joinOptions[1]); } }, - new MUCCustomActionRunnable() - { - - @Override - public void run() - { - ChatRoomWrapper leavedRoomWrapped - = MUCActivator.getMUCService().leaveChatRoom( - chatRoomWrapper); - if(leavedRoomWrapped != null) - MUCActivator.getUIService().closeChatRoomWindow( - leavedRoomWrapped); - } - }, + leaveRunnable, new MUCCustomActionRunnable() { @@ -204,15 +291,8 @@ public void run() chatRoomWrapper.getChatRoomID()); } }, - new MUCCustomActionRunnable() - { - - @Override - public void run() - { - chatRoomWrapper.setAutoJoin(!chatRoomWrapper.isAutojoin()); - } - } + autoJoinRunnable, + autoJoinRunnable }; /** @@ -226,42 +306,38 @@ public void run() new LeaveEnableChecker(), null, null, + null, null }; - /** - * Array for the custom menu items that describes the type of the menu item. - * If true - 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++) + for(int i = 0; i < menuActionsLabels.length; i++) { - MUCActionMenuItems item = new MUCActionMenuItems(actionsLabels[i], - actionsIcons[i], actionsRunnable[i], actionsIsCheckBox[i]); + MUCActionMenuItems item + = new MUCActionMenuItems(menuActionsNames[i], menuActionsLabels[i], + menuActionsIcons[i], menuActionsRunnable[i]); MUCActionMenuItems.add(item); if(actionsEnabledCheckers[i] != null) item.setEnabled(actionsEnabledCheckers[i]); } + for(int i = 0; i < actionsLabels.length; i++) + { + MUCAction item = new MUCAction(actionsNames[i], actionsLabels[i], + actionsIcons[i], actionsIconsRollover[i], actionsIconsPressed[i], + actionsRunnable[i]); + MUCActions.add(item); + } + } /** @@ -285,7 +361,128 @@ public Class getContactSourceClass() @Override public Iterator> getCustomContactActions() { - return null; + return MUCActions.iterator(); + } + + /** + * Implements the MUC custom action. + */ + private class MUCAction + implements ContactAction + { + /** + * The text of the action. + */ + private String text; + + /** + * The icon of the action + */ + private byte[] icon; + + /** + * The icon that is shown when the action is pressed. + */ + private byte[] iconPressed; + + /** + * The runnable that is executed when the action is pressed. + */ + private MUCCustomActionRunnable actionPerformed; + + /** + * The icon that is shown when the mouse is over the action. + */ + private byte[] iconRollover; + + /** + * The name of the action. + */ + private String name; + + /** + * Constructs MUCAction instance. + * + * @param textKey the key used to retrieve the label for the action. + * @param iconKey the key used to retrieve the icon for the action. + * @param actionPerformed the action executed when the action is + * pressed. + * @param iconRolloverKey the key used to retrieve the rollover icon for + * the action. + * @param iconPressedKey the key used to retrieve the pressed icon for + * the action. + */ + public MUCAction(String name, String textKey, String iconKey, + String iconRolloverKey, String iconPressedKey, + MUCCustomActionRunnable actionPerformed) + { + this.name = name; + this.text = resources.getI18NString(textKey); + this.icon = resources.getImageInBytes(iconKey); + this.iconRollover = resources.getImageInBytes(iconRolloverKey); + this.iconPressed = resources.getImageInBytes(iconPressedKey); + this.actionPerformed = actionPerformed; + } + + @Override + public void actionPerformed(SourceContact actionSource, int x, int y) + throws OperationFailedException + { + if(!(actionSource instanceof ChatRoomSourceContact)) + return; + actionPerformed.setContact(actionSource); + new Thread(actionPerformed).start(); + } + + @Override + public byte[] getIcon() + { + return icon; + } + + @Override + public byte[] getRolloverIcon() + { + return iconRollover; + } + + @Override + public byte[] getPressedIcon() + { + return iconPressed; + } + + @Override + public String getToolTipText() + { + return text; + } + + @Override + public boolean isVisible(SourceContact actionSource) + { + if(actionSource instanceof ChatRoomSourceContact) + { + if(name.equals("leave")) + { + return true; + } + else + { + ChatRoomSourceContact contact + = (ChatRoomSourceContact) actionSource; + ChatRoomWrapper room = MUCActivator.getMUCService() + .findChatRoomWrapperFromSourceContact(contact); + if(name.equals("autojoin")) + return !room.isAutojoin(); + + if(name.equals("autojoin_pressed")) + return room.isAutojoin(); + } + } + return false; + } + } /** @@ -295,14 +492,14 @@ private class MUCActionMenuItems implements ContactActionMenuItem { /** - * The key used to retrieve the label for the menu item. + * The label for the menu item. */ - private String textKey; + private String text; /** - * The key used to retrieve the icon for the menu item. + * The the icon for the menu item. */ - private String imageKey; + private byte[] image; /** * The action executed when the menu item is pressed. @@ -313,13 +510,17 @@ private class MUCActionMenuItems * Object that is used to check if the item is enabled or disabled. */ private EnableChecker enabled; - + /** - * if true the item should be check box and if false - * it is standard menu item. + * The name of the custom action menu item. */ - private boolean isCheckBox; + private String name; + /** + * The mnemonic for the action. + */ + private char mnemonics; + /** * Constructs MUCActionMenuItems instance. * @@ -327,16 +528,17 @@ private class MUCActionMenuItems * @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 true the item should be check box. */ - public MUCActionMenuItems(String textKey, String imageKey, - MUCCustomActionRunnable actionPerformed, boolean isCheckBox) + public MUCActionMenuItems(String name, String textKey, String imageKey, + MUCCustomActionRunnable actionPerformed) { - this.textKey = textKey; - this.imageKey = imageKey; + this.text = resources.getI18NString(textKey); + this.image = (imageKey == null)? null : + resources.getImageInBytes(imageKey); this.actionPerformed = actionPerformed; this.enabled = new EnableChecker(); - this.isCheckBox = isCheckBox; + this.name = name; + this.mnemonics = resources.getI18nMnemonic(text); } @Override @@ -352,27 +554,41 @@ public void actionPerformed(SourceContact actionSource) @Override public byte[] getIcon() { - return (imageKey == null)? null : - resources.getImageInBytes(imageKey); + return image; } @Override public String getText() { - return resources.getI18NString(textKey); + return text; } @Override public boolean isVisible(SourceContact actionSource) { - return (actionSource instanceof ChatRoomSourceContact); + if(!(actionSource instanceof ChatRoomSourceContact)) + return false; + + if(name.equals("autojoin") || name.equals("autojoin_pressed")) + { + ChatRoomSourceContact contact + = (ChatRoomSourceContact) actionSource; + ChatRoomWrapper room = MUCActivator.getMUCService() + .findChatRoomWrapperFromSourceContact(contact); + if(name.equals("autojoin")) + return !room.isAutojoin(); + + if(name.equals("autojoin_pressed")) + return room.isAutojoin(); + } + return true; } @Override public char getMnemonics() { - return resources.getI18nMnemonic(textKey); + return mnemonics; } @Override @@ -395,7 +611,7 @@ public void setEnabled(EnableChecker enabled) @Override public boolean isCheckBox() { - return isCheckBox; + return false; } @Override @@ -487,7 +703,7 @@ private abstract class MUCCustomActionRunnable implements Runnable * The contact associated with the menu item. */ protected ChatRoomWrapper chatRoomWrapper; - + /** * Sets the source contact. * @param contact the contact to set @@ -498,6 +714,5 @@ public void setContact(SourceContact contact) chatRoomWrapper = MUCActivator.getMUCService() .findChatRoomWrapperFromSourceContact(contact); } - } }