Пример #1
0
 /**
  * Instantiates a new write to buddy header button.
  *
  * @param writeToAction the write to action
  * @param entityHeader the entity header
  * @param stateManager the state manager
  * @param session the session
  * @param simpleContactManager the simple contact manager
  */
 @Inject
 public WriteToBuddyHeaderButton(
     final WriteToAction writeToAction,
     final EntityHeader entityHeader,
     final StateManager stateManager,
     final Session session,
     final SimpleContactManager simpleContactManager) {
   final ButtonDescriptor button = new ButtonDescriptor(writeToAction);
   // button.setVisible(false);
   button.withText("Write to your buddy");
   button.setStyles(ActionStyles.BTN_NO_BACK_NO_BORDER);
   writeToAction.addPropertyChangeListener(
       new PropertyChangeListener() {
         @Override
         public void propertyChange(final PropertyChangeEvent event) {
           if (event.getPropertyName().equals(Action.ENABLED)) {
             button.setVisible((Boolean) event.getNewValue());
           }
         }
       });
   writeToAction.setEnabled(false);
   entityHeader.addAction(button);
   stateManager.onStateChanged(
       true,
       new StateChangedHandler() {
         @Override
         public void onStateChanged(final StateChangedEvent event) {
           final StateAbstractDTO state = event.getState();
           final GroupDTO group = state.getGroup();
           final String groupName = group.getShortName();
           final boolean imLogged = session.isLogged();
           final boolean isBuddie = simpleContactManager.isBuddy(groupName);
           if (imLogged
               && group.isPersonal()
               && isBuddie
               && !session.getCurrentUser().getShortName().equals(groupName)) {
             button.setTarget(group);
             writeToAction.setEnabled(true);
           } else {
             writeToAction.setEnabled(false);
           }
         }
       });
 }
Пример #2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.common.client.actions.ActionListener#actionPerformed(cc.kune.
  * common.client.actions.ActionEvent)
  */
 @Override
 public void actionPerformed(final ActionEvent event) {
   stateManager.gotoStateToken(((AbstractContentSimpleDTO) event.getTarget()).getStateToken());
 }