[kune-commits] r1694 - in trunk/src/main/java/cc/kune: core/client/actions events/client/actions events/client/viewer
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Wed Feb 22 15:33:29 CET 2012
Author: vjrj_
Date: 2012-02-22 15:33:28 +0100 (Wed, 22 Feb 2012)
New Revision: 1694
Added:
trunk/src/main/java/cc/kune/events/client/actions/CalendarRolAction.java
Modified:
trunk/src/main/java/cc/kune/core/client/actions/RolActionAutoUpdated.java
trunk/src/main/java/cc/kune/events/client/actions/CalendarOnOverMenu.java
trunk/src/main/java/cc/kune/events/client/actions/EventAddMenuItem.java
trunk/src/main/java/cc/kune/events/client/actions/EventEditMenuItem.java
trunk/src/main/java/cc/kune/events/client/actions/EventRemoveMenuItem.java
trunk/src/main/java/cc/kune/events/client/actions/EventsClientActions.java
trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java
Log:
NEW - # 158: Add a Calendar view to event tool
http://kune.ourproject.org/issues/ticket/158
Modified: trunk/src/main/java/cc/kune/core/client/actions/RolActionAutoUpdated.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/actions/RolActionAutoUpdated.java 2012-02-22 10:54:28 UTC (rev 1693)
+++ trunk/src/main/java/cc/kune/core/client/actions/RolActionAutoUpdated.java 2012-02-22 14:33:28 UTC (rev 1694)
@@ -59,25 +59,23 @@
public void refreshStatus(final AccessRolDTO rolRequired, final boolean authNeed,
final boolean isLogged, final boolean visibleForMembers, final boolean visibleForNonMemb,
final AccessRights newRights) {
- boolean newVisibility = false;
boolean newEnabled = false;
if (authNeed && !isLogged) {
- newVisibility = newEnabled = false;
+ newEnabled = false;
} else {
// Auth ok
newEnabled = RolComparator.isEnabled(rolRequired, newRights);
if (newEnabled) {
final boolean isMember = RolComparator.isMember(newRights);
- newEnabled = newVisibility = isMember && visibleForMembers || !isMember && visibleForNonMemb;
- } else {
- newVisibility = false;
+ newEnabled = isMember && visibleForMembers || !isMember && visibleForNonMemb;
}
}
setEnabled(!newEnabled);
setEnabled(newEnabled);
+
// Workaround to force change ...
- putValue(GuiActionDescrip.VISIBLE, !newVisibility);
- putValue(GuiActionDescrip.VISIBLE, newVisibility);
+ putValue(GuiActionDescrip.VISIBLE, !newEnabled);
+ putValue(GuiActionDescrip.VISIBLE, newEnabled);
// NotifyUser.info("Set '" + getValue(Action.NAME) + "' visible: " +
// newVisibility, true);
}
Modified: trunk/src/main/java/cc/kune/events/client/actions/CalendarOnOverMenu.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/actions/CalendarOnOverMenu.java 2012-02-22 10:54:28 UTC (rev 1693)
+++ trunk/src/main/java/cc/kune/events/client/actions/CalendarOnOverMenu.java 2012-02-22 14:33:28 UTC (rev 1694)
@@ -4,7 +4,9 @@
import cc.kune.gspace.client.actions.StandaloneMenuProvider;
import com.google.inject.Inject;
+import com.google.inject.Singleton;
+ at Singleton
public class CalendarOnOverMenu extends StandaloneMenuProvider {
@Inject
Added: trunk/src/main/java/cc/kune/events/client/actions/CalendarRolAction.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/actions/CalendarRolAction.java (rev 0)
+++ trunk/src/main/java/cc/kune/events/client/actions/CalendarRolAction.java 2012-02-22 14:33:28 UTC (rev 1694)
@@ -0,0 +1,36 @@
+package cc.kune.events.client.actions;
+
+import cc.kune.core.client.actions.RolAction;
+import cc.kune.core.client.actions.RolComparator;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.domain.utils.AccessRights;
+import cc.kune.core.shared.dto.AccessRolDTO;
+import cc.kune.events.client.viewer.CalendarStateChangeEvent;
+import cc.kune.events.client.viewer.CalendarViewer;
+
+import com.google.gwt.event.shared.EventBus;
+import com.google.inject.Provider;
+
+public abstract class CalendarRolAction extends RolAction {
+
+ public CalendarRolAction(final EventBus eventBus, final Session session,
+ final Provider<CalendarViewer> calendar, final AccessRolDTO rolRequired, final boolean authNeed,
+ final boolean onlyOnApp) {
+ super(rolRequired, authNeed);
+ eventBus.addHandler(CalendarStateChangeEvent.getType(),
+ new CalendarStateChangeEvent.CalendarStateChangeHandler() {
+ @Override
+ public void onCalendarStateChange(final CalendarStateChangeEvent event) {
+ // if the calendar is not selecting a appointment don't show this
+ final AccessRights rights = session.getContainerState().getContainerRights();
+ final boolean isEnabled = RolComparator.isEnabled(AccessRolDTO.Editor, rights);
+ final boolean isMember = RolComparator.isMember(rights);
+ final boolean isOnApp = !calendar.get().getAppToEdit().equals(CalendarViewer.NO_APPOINT);
+ final boolean newEnabled = isMember && isEnabled && (!onlyOnApp || isOnApp);
+ setEnabled(!newEnabled);
+ setEnabled(newEnabled);
+ }
+ });
+ }
+
+}
Modified: trunk/src/main/java/cc/kune/events/client/actions/EventAddMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/actions/EventAddMenuItem.java 2012-02-22 10:54:28 UTC (rev 1693)
+++ trunk/src/main/java/cc/kune/events/client/actions/EventAddMenuItem.java 2012-02-22 14:33:28 UTC (rev 1694)
@@ -7,11 +7,11 @@
import cc.kune.common.client.ui.dialogs.PromptTopDialog;
import cc.kune.common.client.ui.dialogs.PromptTopDialog.Builder;
import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.client.actions.RolAction;
import cc.kune.core.client.resources.nav.NavResources;
import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
import cc.kune.core.client.rpcservices.ContentServiceAsync;
import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.SessionConstants;
import cc.kune.core.shared.dto.AccessRolDTO;
import cc.kune.core.shared.dto.StateContentDTO;
@@ -23,13 +23,14 @@
import com.bradrydzewski.gwt.calendar.client.AppointmentStyle;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@Singleton
public class EventAddMenuItem extends MenuItemDescriptor {
- public static class EventAddAction extends RolAction {
+ public static class EventAddAction extends CalendarRolAction {
private final Provider<CalendarViewer> calendar;
private final Provider<ContentServiceAsync> contService;
private PromptTopDialog dialog;
@@ -39,8 +40,8 @@
@Inject
public EventAddAction(final NavResources res, final I18nTranslationService i18n,
final Provider<CalendarViewer> calendar, final Provider<ContentServiceAsync> contService,
- final Session session) {
- super(AccessRolDTO.Editor, true);
+ final Session session, final StateManager stateManager, final EventBus eventBus) {
+ super(eventBus, session, calendar, AccessRolDTO.Editor, true, false);
this.i18n = i18n;
this.calendar = calendar;
this.contService = contService;
Modified: trunk/src/main/java/cc/kune/events/client/actions/EventEditMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/actions/EventEditMenuItem.java 2012-02-22 10:54:28 UTC (rev 1693)
+++ trunk/src/main/java/cc/kune/events/client/actions/EventEditMenuItem.java 2012-02-22 14:33:28 UTC (rev 1694)
@@ -2,13 +2,12 @@
import cc.kune.common.client.actions.ActionEvent;
import cc.kune.common.client.actions.ui.descrip.MenuItemDescriptor;
-import cc.kune.common.client.ui.dialogs.PromptTopDialog;
import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.client.actions.RolAction;
import cc.kune.core.client.resources.nav.NavResources;
+import cc.kune.core.client.state.AccessRightsClientManager;
+import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.dto.AccessRolDTO;
-import cc.kune.events.client.viewer.CalendarStateChangeEvent;
import cc.kune.events.client.viewer.CalendarViewer;
import com.google.gwt.event.shared.EventBus;
@@ -18,28 +17,18 @@
@Singleton
public class EventEditMenuItem extends MenuItemDescriptor {
- public static class EventEditAction extends RolAction {
+ public static class EventEditAction extends CalendarRolAction {
private final Provider<CalendarViewer> calendar;
- private PromptTopDialog dialog;
- private final I18nTranslationService i18n;
private final StateManager stateManager;
@Inject
public EventEditAction(final NavResources res, final I18nTranslationService i18n,
- final Provider<CalendarViewer> calendar, final EventBus eventBus, final StateManager stateManager) {
- super(AccessRolDTO.Administrator, true);
- this.i18n = i18n;
+ final Provider<CalendarViewer> calendar, final EventBus eventBus,
+ final StateManager stateManager, final Session session, final AccessRightsClientManager rightsMan) {
+ super(eventBus, session, calendar, AccessRolDTO.Editor, true, true);
this.calendar = calendar;
this.stateManager = stateManager;
withText(i18n.t("Edit the appointment")).withIcon(res.go());
- eventBus.addHandler(CalendarStateChangeEvent.getType(),
- new CalendarStateChangeEvent.CalendarStateChangeHandler() {
- @Override
- public void onCalendarStateChange(final CalendarStateChangeEvent event) {
- // if the calendar is not selecting a appointment don't show this
- setEnabled(!calendar.get().getAppToEdit().equals(CalendarViewer.NO_APPOINT));
- }
- });
}
@Override
Modified: trunk/src/main/java/cc/kune/events/client/actions/EventRemoveMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/actions/EventRemoveMenuItem.java 2012-02-22 10:54:28 UTC (rev 1693)
+++ trunk/src/main/java/cc/kune/events/client/actions/EventRemoveMenuItem.java 2012-02-22 14:33:28 UTC (rev 1694)
@@ -6,10 +6,11 @@
import cc.kune.common.client.ui.dialogs.PromptTopDialog;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.common.shared.utils.TextUtils;
-import cc.kune.core.client.actions.RolAction;
import cc.kune.core.client.resources.CoreResources;
+import cc.kune.core.client.state.AccessRightsClientManager;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.dto.AccessRolDTO;
-import cc.kune.events.client.viewer.CalendarStateChangeEvent;
import cc.kune.events.client.viewer.CalendarViewer;
import com.google.gwt.event.shared.EventBus;
@@ -19,25 +20,19 @@
@Singleton
public class EventRemoveMenuItem extends MenuItemDescriptor {
- public static class EventEditAction extends RolAction {
+ public static class EventEditAction extends CalendarRolAction {
private final Provider<CalendarViewer> calendar;
private PromptTopDialog dialog;
private final I18nTranslationService i18n;
@Inject
public EventEditAction(final CoreResources res, final I18nTranslationService i18n,
- final Provider<CalendarViewer> calendar, final EventBus eventBus) {
- super(AccessRolDTO.Editor, true);
+ final Provider<CalendarViewer> calendar, final EventBus eventBus, final Session session,
+ final StateManager stateManager, final AccessRightsClientManager rightsMan) {
+ super(eventBus, session, calendar, AccessRolDTO.Administrator, true, true);
this.i18n = i18n;
this.calendar = calendar;
withText(i18n.t("Remove this appointment")).withIcon(res.cancel());
- eventBus.addHandler(CalendarStateChangeEvent.getType(),
- new CalendarStateChangeEvent.CalendarStateChangeHandler() {
- @Override
- public void onCalendarStateChange(final CalendarStateChangeEvent event) {
- setEnabled(!calendar.get().getAppToEdit().equals(CalendarViewer.NO_APPOINT));
- }
- });
}
@Override
Modified: trunk/src/main/java/cc/kune/events/client/actions/EventsClientActions.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/actions/EventsClientActions.java 2012-02-22 10:54:28 UTC (rev 1693)
+++ trunk/src/main/java/cc/kune/events/client/actions/EventsClientActions.java 2012-02-22 14:33:28 UTC (rev 1694)
@@ -73,6 +73,14 @@
// On over calendar menu
actionsRegistry.addAction(ActionGroups.TOOLBAR, onOverMenu, containers);
+
+ // actionsRegistry.addAction(ActionGroups.TOOLBAR, eventAddMenuItem,
+ // containers);
+ // actionsRegistry.addAction(ActionGroups.TOOLBAR, eventEditMenuItem,
+ // containers);
+ // actionsRegistry.addAction(ActionGroups.TOOLBAR, eventRemoveMenuItem,
+ // containers);
+
eventAddMenuItem.get();
eventEditMenuItem.get();
eventRemoveMenuItem.get();
Modified: trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java 2012-02-22 10:54:28 UTC (rev 1693)
+++ trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java 2012-02-22 14:33:28 UTC (rev 1694)
@@ -150,6 +150,8 @@
@Override
public void onOpen(final OpenEvent<Appointment> event) {
// NotifyUser.info("open handler");
+ updateMenuItems();
+ showMenu();
}
});
getView().addSelectionHandler(new SelectionHandler<Appointment>() {
@@ -158,8 +160,10 @@
appToEdit = event.getSelectedItem();
onOverDate = event.getSelectedItem().getStart();
// NotifyUser.info("on selection");
- updateMenuItems();
- showMenu();
+
+ // This is not very usable:
+ // updateMenuItems();
+ // showMenu();
}
});
}
@@ -235,6 +239,7 @@
@Override
public void setContent(@Nonnull final HasContent state) {
folderViewerUtils.setContent(getView(), state);
+ updateMenuItems();
}
@Override
More information about the kune-commits
mailing list