[kune-commits] r1447 - in trunk/src/main/java/cc/kune: chat/client core/client/sitebar/spaces core/client/ws/entheader
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Sun Jul 10 22:58:52 CEST 2011
Author: vjrj_
Date: 2011-07-10 22:58:52 +0200 (Sun, 10 Jul 2011)
New Revision: 1447
Modified:
trunk/src/main/java/cc/kune/chat/client/AvatarDecoratorImpl.java
trunk/src/main/java/cc/kune/chat/client/ChatParts.java
trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java
trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityHeaderPanel.java
trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityHeaderPresenter.java
trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityTextLogo.java
Log:
Some fixes in avatar on/offline status
Modified: trunk/src/main/java/cc/kune/chat/client/AvatarDecoratorImpl.java
===================================================================
--- trunk/src/main/java/cc/kune/chat/client/AvatarDecoratorImpl.java 2011-07-10 18:29:52 UTC (rev 1446)
+++ trunk/src/main/java/cc/kune/chat/client/AvatarDecoratorImpl.java 2011-07-10 20:58:52 UTC (rev 1447)
@@ -6,8 +6,12 @@
import com.calclab.emite.core.client.events.StateChangedEvent;
import com.calclab.emite.core.client.events.StateChangedHandler;
import com.calclab.emite.core.client.xmpp.session.XmppSession;
+import com.calclab.emite.core.client.xmpp.stanzas.Presence;
import com.calclab.emite.core.client.xmpp.stanzas.Presence.Show;
import com.calclab.emite.core.client.xmpp.stanzas.XmppURI;
+import com.calclab.emite.im.client.presence.PresenceManager;
+import com.calclab.emite.im.client.presence.events.OwnPresenceChangedEvent;
+import com.calclab.emite.im.client.presence.events.OwnPresenceChangedHandler;
import com.calclab.emite.im.client.roster.RosterItem;
import com.calclab.emite.im.client.roster.XmppRoster;
import com.calclab.emite.im.client.roster.events.RosterItemChangedEvent;
@@ -29,11 +33,14 @@
private final ImageResource chatDotBusy;
private final ImageResource chatDotExtendedAway;
private final ImageResource chatDotXA;
+ private final HandlerRegistration presenceHandler;
+ private final PresenceManager presenceManager;
private final XmppRoster roster;
private final HandlerRegistration rosterHandler;
private final XmppSession session;
private final HandlerRegistration sessionStateChangedHandler;
private XmppURI uri;
+ private final XmppSession xmppSession;
public AvatarDecoratorImpl(final ChatInstances chatInstances, final ChatClient chatClient,
final ImageResource chatDotBusy, final ImageResource chatDotXA, final ImageResource chatDotAway,
@@ -52,6 +59,8 @@
}
});
roster = chatInstances.roster;
+ xmppSession = chatInstances.xmppSession;
+ presenceManager = chatInstances.presenceManager;
rosterHandler = roster.addRosterItemChangedHandler(new RosterItemChangedHandler() {
@Override
public void onRosterItemChanged(final RosterItemChangedEvent event) {
@@ -61,23 +70,38 @@
}
}
});
-
+ presenceHandler = presenceManager.addOwnPresenceChangedHandler(new OwnPresenceChangedHandler() {
+ @Override
+ public void onOwnPresenceChanged(final OwnPresenceChangedEvent event) {
+ refresh();
+ }
+ });
}
private void clearDecorator() {
AvatarDecoratorImpl.this.clearImage();
}
+ protected boolean isMe() {
+ final XmppURI currentUserURI = xmppSession.getCurrentUserURI();
+ return currentUserURI != null && currentUserURI.getJID().equals(uri);
+ }
+
private void refresh() {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (uri != null) {
- final RosterItem item = roster.getItemByJID(uri);
- if (session.isReady() && item != null) {
- setIcon(item.isAvailable(), item.getShow(), item.getStatus());
+ if (isMe()) {
+ final Presence ownPresence = presenceManager.getOwnPresence();
+ setIcon(xmppSession.isReady(), ownPresence.getShow(), ownPresence.getStatus());
} else {
- clearDecorator();
+ final RosterItem item = roster.getItemByJID(uri.getJID());
+ if (session.isReady() && item != null) {
+ setIcon(item.isAvailable(), item.getShow(), item.getStatus());
+ } else {
+ clearDecorator();
+ }
}
} else {
clearDecorator();
@@ -119,6 +143,7 @@
rosterHandler.removeHandler();
sessionStateChangedHandler.removeHandler();
attachHandler.removeHandler();
+ presenceHandler.removeHandler();
}
}
});
Modified: trunk/src/main/java/cc/kune/chat/client/ChatParts.java
===================================================================
--- trunk/src/main/java/cc/kune/chat/client/ChatParts.java 2011-07-10 18:29:52 UTC (rev 1446)
+++ trunk/src/main/java/cc/kune/chat/client/ChatParts.java 2011-07-10 20:58:52 UTC (rev 1447)
@@ -94,6 +94,7 @@
final MenuItemDescriptor item = new MenuItemDescriptor(startChatWithMemberAction.get());
item.add(isNotMe);
item.add(isPersonCondition);
+ item.add(isNotBuddieCondition);
item.add(isLogged);
return item;
}
@@ -149,6 +150,9 @@
snAdminsRegistry.get().add(startChatWithBuddieItem);
snCollabsItemsRegistry.get().add(startChatWithBuddieItem);
snPendingItemsRegistry.get().add(startChatWithBuddieItem);
+ snAdminsRegistry.get().add(addAsBuddieItem);
+ snCollabsItemsRegistry.get().add(addAsBuddieItem);
+ snPendingItemsRegistry.get().add(addAsBuddieItem);
userItemsRegistry.get().add(startChatWithBuddieItem);
userItemsRegistry.get().add(startChatWithPersonItem);
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java 2011-07-10 18:29:52 UTC (rev 1446)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java 2011-07-10 20:58:52 UTC (rev 1447)
@@ -150,7 +150,7 @@
@ProxyEvent
public void onAppStart(final AppStartEvent event) {
- showTooltipWithDelay();
+ // showTooltipWithDelay();
}
private void onGroupSpaceSelect() {
Modified: trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityHeaderPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityHeaderPanel.java 2011-07-10 18:29:52 UTC (rev 1446)
+++ trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityHeaderPanel.java 2011-07-10 20:58:52 UTC (rev 1447)
@@ -86,14 +86,10 @@
return mainPanel;
}
- private String getAvatarDecoratorParam(final GroupDTO group) {
- return group.isPersonal() ? group.getShortName() : null;
- }
-
@Override
public void reloadImage(final GroupDTO group) {
entityTextLogo.setLogoImage(downloadProvider.get().getLogoImageUrl(group.getStateToken())
- + "&nocache=" + new Date().getTime(), getAvatarDecoratorParam(group));
+ + "&nocache=" + new Date().getTime());
}
@Deprecated
@@ -118,8 +114,7 @@
@Override
public void setLogoImage(final GroupDTO group) {
- entityTextLogo.setLogoImage(downloadProvider.get().getLogoImageUrl(group.getStateToken()),
- getAvatarDecoratorParam(group));
+ entityTextLogo.setLogoImage(downloadProvider.get().getLogoImageUrl(group.getStateToken()));
}
@Override
@@ -137,23 +132,23 @@
entityTextLogo.setMediumFont();
}
- //
- // @Override
- // public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) {
- // if (oldTheme != null) {
- // entityTextLogo.removeStyleDependentName(oldTheme.toString());
- // }
- // entityTextLogo.addStyleDependentName(newTheme.toString());
- // }
+ @Override
+ public void setOnlineStatusGroup(final String group) {
+ entityTextLogo.setOnlineStatusGroup(group);
+ }
+ public void setOnlineStatusVisible(final boolean visible) {
+ entityTextLogo.setOnlineStatusVisible(visible);
+ }
+
@Override
public void setSmallFont() {
entityTextLogo.setSmallFont();
}
@Override
- public void showDefUserLogo(final GroupDTO group) {
- entityTextLogo.setLogoImage(AbstractImagePrototype.create(images.unknown60()),
- getAvatarDecoratorParam(group));
+ public void showDefUserLogo() {
+ entityTextLogo.setLogoImage(AbstractImagePrototype.create(images.unknown60()));
}
+
}
Modified: trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityHeaderPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityHeaderPresenter.java 2011-07-10 18:29:52 UTC (rev 1446)
+++ trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityHeaderPresenter.java 2011-07-10 20:58:52 UTC (rev 1447)
@@ -61,11 +61,13 @@
void setMediumFont();
+ void setOnlineStatusGroup(String group);
+
+ void setOnlineStatusVisible(boolean visible);
+
void setSmallFont();
- // void setTheme(final WsTheme oldTheme, WsTheme newTheme);
-
- void showDefUserLogo(GroupDTO group);
+ void showDefUserLogo();
}
private static final int LARGE_NAME_LIMIT = 17;
@@ -89,12 +91,6 @@
reloadGroupLogoImage();
}
});
- // theme.addOnThemeChanged(new Listener2<WsTheme, WsTheme>() {
- // @Override
- // public void onEvent(final WsTheme oldTheme, final WsTheme newTheme) {
- // // getView().setTheme(oldTheme, newTheme);
- // }
- // });
}
@Override
@@ -123,19 +119,25 @@
}
void setGroupLogo(final GroupDTO group) {
+ setLogoText(group.getLongName());
if (group.hasLogo()) {
- setLogoText(group.getLongName());
getView().setLogoImage(group);
getView().setLogoImageVisible(true);
} else {
- setLogoText(group.getLongName());
if (group.isPersonal()) {
- getView().showDefUserLogo(group);
+ getView().showDefUserLogo();
getView().setLogoImageVisible(true);
} else {
getView().setLogoImageVisible(false);
}
}
+ if (group.isPersonal()) {
+ getView().setOnlineStatusGroup(group.getShortName());
+ getView().setOnlineStatusVisible(true);
+ } else {
+ getView().setOnlineStatusGroup(null);
+ getView().setOnlineStatusVisible(false);
+ }
}
void setLogoText(final String name) {
Modified: trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityTextLogo.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityTextLogo.java 2011-07-10 18:29:52 UTC (rev 1446)
+++ trunk/src/main/java/cc/kune/core/client/ws/entheader/EntityTextLogo.java 2011-07-10 20:58:52 UTC (rev 1447)
@@ -92,16 +92,14 @@
logoLabel.addStyleName(LOGO_LARGE_FONT_STYLE);
}
- public void setLogoImage(final AbstractImagePrototype imageProto, final String groupName) {
+ public void setLogoImage(final AbstractImagePrototype imageProto) {
imageProto.applyTo(logoImage);
- avatarDecorator.setItem(groupName);
}
- public void setLogoImage(final String url, final String groupName) {
+ public void setLogoImage(final String url) {
logoImage.setUrl("images/clear.gif");
Image.prefetch(url);
logoImage.setUrl(url);
- avatarDecorator.setItem(groupName);
}
public void setLogoText(final String text) {
@@ -114,7 +112,6 @@
public void setLogoVisible(final boolean visible) {
logoImage.setVisible(visible);
- avatarDecorator.setDecoratorVisible(visible);
}
public void setMediumFont() {
@@ -122,6 +119,14 @@
logoLabel.addStyleName(LOGO_MEDIUM_FONT_STYLE);
}
+ public void setOnlineStatusGroup(final String group) {
+ avatarDecorator.setItem(group);
+ }
+
+ public void setOnlineStatusVisible(final boolean visible) {
+ avatarDecorator.setDecoratorVisible(visible);
+ }
+
public void setSmallFont() {
resetFontSize();
logoLabel.addStyleName(LOGO_SMALL_FONT_STYLE);
More information about the kune-commits
mailing list