[kune-commits] r1046 - in trunk/src/main/java/org/ourproject/kune:
chat/client platf/client/services
workspace/client/entityheader workspace/client/options
workspace/client/socialnet workspace/client/socialnet/other
vjrj
vjrj at ourproject.org
Tue Feb 3 11:53:24 CET 2009
Author: vjrj
Date: 2009-02-03 11:53:22 +0100 (Tue, 03 Feb 2009)
New Revision: 1046
Added:
trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/EntityHeaderButton.java
trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/
trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddie.java
trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddiePanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddiePresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddieView.java
Modified:
trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngine.java
trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java
Log:
"Add as buddie" options checking roster
Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngine.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngine.java 2009-02-03 10:15:36 UTC (rev 1045)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngine.java 2009-02-03 10:53:22 UTC (rev 1046)
@@ -20,11 +20,14 @@
package org.ourproject.kune.chat.client;
import com.calclab.emite.core.client.xmpp.stanzas.XmppURI;
+import com.calclab.suco.client.events.Listener0;
public interface ChatEngine {
void addNewBuddie(String shortName);
+ void addOnRosterChanged(Listener0 slot);
+
void chat(XmppURI jid);
ChatConnectionOptions getChatOptions();
Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java 2009-02-03 10:15:36 UTC (rev 1045)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java 2009-02-03 10:53:22 UTC (rev 1046)
@@ -40,6 +40,7 @@
import com.calclab.emiteuimodule.client.UserChatOptions;
import com.calclab.emiteuimodule.client.params.AvatarProvider;
import com.calclab.emiteuimodule.client.status.OwnPresence.OwnStatus;
+import com.calclab.suco.client.events.Event0;
import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
import com.calclab.suco.client.ioc.Provider;
@@ -57,6 +58,7 @@
private final Provider<EmiteUIDialog> emiteUIProvider;
private final Provider<FileDownloadUtils> downloadUtils;
private Collection<RosterItem> roster;
+ private final Event0 onRosterChanged;
public ChatEngineDefault(final I18nTranslationService i18n, final WorkspaceSkeleton ws, Application application,
Session session, final Provider<EmiteUIDialog> emiteUIProvider,
@@ -65,6 +67,7 @@
this.ws = ws;
this.emiteUIProvider = emiteUIProvider;
this.downloadUtils = downloadUtils;
+ this.onRosterChanged = new Event0("onRosterChanged");
session.onInitDataReceived(new Listener<InitDataDTO>() {
public void onEvent(final InitDataDTO initData) {
checkChatDomain(initData.getChatDomain());
@@ -102,6 +105,10 @@
emiteUIProvider.get().addBuddie(getLocalUserJid(shortName), shortName, "");
}
+ public void addOnRosterChanged(final Listener0 slot) {
+ onRosterChanged.add(slot);
+ }
+
public void chat(XmppURI jid) {
emiteUIProvider.get().chat(jid);
}
@@ -158,6 +165,7 @@
emiteUIProvider.get().onRosterChanged(new Listener<Collection<RosterItem>>() {
public void onEvent(Collection<RosterItem> rosterChanged) {
roster = rosterChanged;
+ onRosterChanged.fire();
}
});
emiteUIProvider.get().start(userChatOptions, chatOptions.httpBase, chatOptions.domain,
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java 2009-02-03 10:15:36 UTC (rev 1045)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java 2009-02-03 10:53:22 UTC (rev 1046)
@@ -126,6 +126,9 @@
import org.ourproject.kune.workspace.client.socialnet.ParticipationSummaryPanel;
import org.ourproject.kune.workspace.client.socialnet.ParticipationSummaryPresenter;
import org.ourproject.kune.workspace.client.socialnet.ParticipationSummaryView;
+import org.ourproject.kune.workspace.client.socialnet.other.AddAsBuddie;
+import org.ourproject.kune.workspace.client.socialnet.other.AddAsBuddiePanel;
+import org.ourproject.kune.workspace.client.socialnet.other.AddAsBuddiePresenter;
import org.ourproject.kune.workspace.client.summary.GroupSummary;
import org.ourproject.kune.workspace.client.summary.GroupSummaryPanel;
import org.ourproject.kune.workspace.client.summary.GroupSummaryPresenter;
@@ -387,6 +390,18 @@
}
});
+ register(ApplicationComponentGroup.class, new Factory<AddAsBuddie>(AddAsBuddie.class) {
+ @Override
+ public AddAsBuddie create() {
+ final AddAsBuddiePresenter presenter = new AddAsBuddiePresenter($$(ChatEngine.class),
+ $(StateManager.class), $(Session.class));
+ final AddAsBuddiePanel panel = new AddAsBuddiePanel(presenter, $(EntityHeader.class), $(Images.class),
+ $(I18nTranslationService.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
register(ApplicationComponentGroup.class, new Factory<BuddiesSummary>(BuddiesSummary.class) {
@Override
public BuddiesSummary create() {
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/EntityHeaderButton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/EntityHeaderButton.java 2009-02-03 10:15:36 UTC (rev 1045)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/EntityHeaderButton.java 2009-02-03 10:53:22 UTC (rev 1046)
@@ -0,0 +1,16 @@
+package org.ourproject.kune.workspace.client.entityheader;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.ui.IconLabel;
+
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+
+public class EntityHeaderButton extends IconLabel implements View {
+ public EntityHeaderButton(AbstractImagePrototype icon, String text) {
+ super(icon, text, false);
+ }
+
+ public EntityHeaderButton(String text, AbstractImagePrototype icon) {
+ super(text, icon, false);
+ }
+}
\ No newline at end of file
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java 2009-02-03 10:15:36 UTC (rev 1045)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java 2009-02-03 10:53:22 UTC (rev 1046)
@@ -20,30 +20,23 @@
package org.ourproject.kune.workspace.client.options;
import org.ourproject.kune.platf.client.PlatfMessages;
-import org.ourproject.kune.platf.client.View;
import org.ourproject.kune.platf.client.app.EntityOptionsGroup;
import org.ourproject.kune.platf.client.services.I18nTranslationService;
import org.ourproject.kune.platf.client.services.Images;
-import org.ourproject.kune.platf.client.ui.IconLabel;
import org.ourproject.kune.workspace.client.entityheader.EntityHeader;
+import org.ourproject.kune.workspace.client.entityheader.EntityHeaderButton;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;
public class EntityOptionsPanel extends AbstractOptionsPanel implements EntityOptionsView {
- class EntityOptionPushButton extends IconLabel implements View {
- public EntityOptionPushButton(String text, AbstractImagePrototype icon) {
- super(text, icon, false);
- }
- }
public static final String ENTITY_OP_PANEL_ID = "k-eop-diag";
public static final String GROUP_OPTIONS_ERROR_ID = "k-eop-err-mess";
public static final String GROUP_OPTIONS_ICON = "k-eop-icon";
private final I18nTranslationService i18n;
private final EntityHeader entityHeader;
- private EntityOptionPushButton optionsButton;
+ private EntityHeaderButton optionsButton;
private final Images images;
private final EntityOptionsGroup entityPreferencesGroup;
@@ -81,7 +74,7 @@
}
private void createOptionsButton() {
- optionsButton = new EntityOptionPushButton("", images.emblemSystem());
+ optionsButton = new EntityHeaderButton("", images.emblemSystem());
optionsButton.addClickListener(new ClickListener() {
public void onClick(Widget arg0) {
createAndShow();
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddie.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddie.java 2009-02-03 10:15:36 UTC (rev 1045)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddie.java 2009-02-03 10:53:22 UTC (rev 1046)
@@ -0,0 +1,5 @@
+package org.ourproject.kune.workspace.client.socialnet.other;
+
+public interface AddAsBuddie {
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddiePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddiePanel.java 2009-02-03 10:15:36 UTC (rev 1045)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddiePanel.java 2009-02-03 10:53:22 UTC (rev 1046)
@@ -0,0 +1,33 @@
+package org.ourproject.kune.workspace.client.socialnet.other;
+
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.platf.client.services.Images;
+import org.ourproject.kune.workspace.client.entityheader.EntityHeader;
+import org.ourproject.kune.workspace.client.entityheader.EntityHeaderButton;
+
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Widget;
+
+public class AddAsBuddiePanel implements AddAsBuddieView {
+
+ public static final String ADD_BUDDIE_BUTTON = "k-aabp-bt";
+ private final EntityHeaderButton button;
+
+ public AddAsBuddiePanel(final AddAsBuddiePresenter presenter, final EntityHeader entityHeader, Images images,
+ I18nTranslationService i18n) {
+ button = new EntityHeaderButton(images.addGreen(), i18n.t("Add as a buddie"));
+ button.addClickListener(new ClickListener() {
+ public void onClick(Widget arg0) {
+ presenter.onAdd();
+ }
+ });
+ button.ensureDebugId(ADD_BUDDIE_BUTTON);
+ button.addStyleName("kune-Margin-Medium-t");
+ button.addStyleName("kune-pointer");
+ entityHeader.addWidget(button);
+ }
+
+ public void setVisible(boolean visible) {
+ button.setVisible(visible);
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddiePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddiePresenter.java 2009-02-03 10:15:36 UTC (rev 1045)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddiePresenter.java 2009-02-03 10:53:22 UTC (rev 1046)
@@ -0,0 +1,60 @@
+package org.ourproject.kune.workspace.client.socialnet.other;
+
+import org.ourproject.kune.chat.client.ChatEngine;
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.dto.StateAbstractDTO;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.workspace.client.site.Site;
+
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.client.ioc.Provider;
+
+public class AddAsBuddiePresenter implements AddAsBuddie {
+
+ private AddAsBuddieView view;
+ private final Session session;
+ private final Provider<ChatEngine> chatEngine;
+
+ public AddAsBuddiePresenter(Provider<ChatEngine> chatEngine, StateManager stateManager, final Session session) {
+ this.chatEngine = chatEngine;
+ this.session = session;
+ stateManager.onStateChanged(new Listener<StateAbstractDTO>() {
+ public void onEvent(StateAbstractDTO state) {
+ setState(state);
+ }
+ });
+ chatEngine.get().addOnRosterChanged(new Listener0() {
+ public void onEvent() {
+ setState(session.getCurrentState());
+ }
+ });
+ }
+
+ public View getView() {
+ return view;
+ }
+
+ public void init(AddAsBuddieView view) {
+ this.view = view;
+ }
+
+ public void onAdd() {
+ chatEngine.get().addNewBuddie(session.getCurrentState().getGroup().getShortName());
+ Site.info("Added as buddie. Waiting buddie response");
+ view.setVisible(false);
+ }
+
+ private void setState(StateAbstractDTO state) {
+ String groupName = state.getGroup().getShortName();
+ boolean isPersonal = state.getGroup().isPersonal();
+ boolean isLogged = session.isLogged();
+ if (isLogged && isPersonal && (!chatEngine.get().isBuddie(groupName))
+ && (!session.getCurrentUser().getShortName().equals(groupName))) {
+ view.setVisible(true);
+ } else {
+ view.setVisible(false);
+ }
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddieView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddieView.java 2009-02-03 10:15:36 UTC (rev 1045)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/other/AddAsBuddieView.java 2009-02-03 10:53:22 UTC (rev 1046)
@@ -0,0 +1,8 @@
+package org.ourproject.kune.workspace.client.socialnet.other;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface AddAsBuddieView extends View {
+
+ void setVisible(boolean visible);
+}
More information about the kune-commits
mailing list