Ejemplo n.º 1
0
 /**
  * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
  *     org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
  */
 public void event(UserRequest ureq, Controller source, Event event) {
   if (source == tableCtr) {
     if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
       TableEvent te = (TableEvent) event;
       LockEntry lockToRelease = locksTableModel.getObject(te.getRowId());
       dialogController =
           activateYesNoDialog(ureq, null, translate("lock.release.sure"), dialogController);
       dialogController.setUserObject(lockToRelease);
     }
   } else if (source == dialogController) {
     if (DialogBoxUIFactory.isYesEvent(event)) {
       LockEntry lockToRelease = (LockEntry) dialogController.getUserObject();
       MultiUserEvent mue = new LockRemovedEvent(lockToRelease);
       OLATResourceable lockEntryOres =
           OresHelper.createOLATResourceableInstance(LockEntry.class, 0l);
       CoordinatorManager.getInstance()
           .getCoordinator()
           .getEventBus()
           .fireEventToListenersOf(mue, lockEntryOres);
       CoordinatorManager.getInstance()
           .getCoordinator()
           .getLocker()
           .releaseLockEntry(lockToRelease);
       lockToRelease = null;
       resetTableModel();
     }
   }
 }
Ejemplo n.º 2
0
 public void event(UserRequest ureq, Controller source, Event event) {
   if (source == tableCtr) {
     if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
       TableEvent te = (TableEvent) event;
       if (te.getActionId().equals(ACTION_SINGLESELECT_CHOOSE)) {
         int rowid = te.getRowId();
         Identity foundIdentity = tdm.getObject(rowid);
         UserDeletionManager.getInstance().setIdentityAsActiv(foundIdentity);
         updateUserList();
       }
     } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
       TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
       if (tmse.getAction().equals(ACTION_MULTISELECT_CHOOSE)) {
         handleDeleteButtonEvent(ureq, tmse);
       }
     }
   } else if (source == deleteConfirmController) {
     if (DialogBoxUIFactory.isOkEvent(event)) {
       List<String> errors = new ArrayList<String>();
       deleteIdentities(readyToDeleteIdentities, errors);
       if (errors.isEmpty()) {
         showInfo("deleted.feedback.msg");
       } else {
         StringBuilder sb = new StringBuilder();
         for (String error : errors) {
           if (sb.length() > 0) sb.append(", ");
           sb.append(error);
         }
         showWarning("error.delete", sb.toString());
       }
       initializeContent();
     }
   }
 }
  /**
   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
   *     org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
   */
  @Override
  public void event(UserRequest ureq, Component source, Event event) {
    if (STATISTICS_FULL_RECALCULATION_TRIGGER_BUTTON.equals(event.getCommand())) {
      StatisticUpdateManager statisticUpdateManager = getStatisticUpdateManager();
      if (statisticUpdateManager == null) {
        log_.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
      } else {

        String title = getTranslator().translate("statistics.fullrecalculation.really.title");
        String text = getTranslator().translate("statistics.fullrecalculation.really.text");
        dialogCtr_ = DialogBoxUIFactory.createYesNoDialog(ureq, getWindowControl(), title, text);
        listenTo(dialogCtr_);
        dialogCtr_.activate();
      }
    } else if (STATISTICS_UPDATE_TRIGGER_BUTTON.equals(event.getCommand())) {
      StatisticUpdateManager statisticUpdateManager = getStatisticUpdateManager();
      if (statisticUpdateManager == null) {
        log_.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
      } else {
        statisticUpdateManager.updateStatistics(false, getUpdateFinishedCallback());
        refreshUIState();
        getInitialComponent().setDirty(true);
      }
    }
  }
 public void event(UserRequest ureq, Controller source, Event event) {
   if (source == dialogCtr_) {
     if (DialogBoxUIFactory.isYesEvent(event)) {
       StatisticUpdateManager statisticUpdateManager = getStatisticUpdateManager();
       if (statisticUpdateManager == null) {
         log_.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
       } else {
         statisticUpdateManager.updateStatistics(true, getUpdateFinishedCallback());
         refreshUIState();
         getInitialComponent().setDirty(true);
       }
     }
   }
 }
 /**
  * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
  *     org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
  */
 @Override
 public void event(UserRequest ureq, Controller source, Event event) {
   if (source == dialogCtr) {
     if (DialogBoxUIFactory.isYesEvent(event)) {
       // Yes case, delete now
       for (String deleteLangPack : deleteLangPackSelection.getSelectedKeys()) {
         File file = new File(I18nModule.LANG_PACKS_DIRECTORY, deleteLangPack);
         if (file.exists()) file.delete();
         logAudit("Deleted language pack::" + deleteLangPack, null);
       }
       // Reset i18n system
       I18nModule.reInitializeAndFlushCache();
       // wow, everything worked fine
       showInfo(
           "configuration.management.package.delete.success",
           deleteLangPackSelection.getSelectedKeys().toString());
       fireEvent(ureq, Event.DONE_EVENT);
     } else {
       // No case, do nothing.
     }
   }
 }
  /** Event-handling from components */
  @Override
  protected void event(final UserRequest ureq, final Component source, final Event event) {
    if (source == importLink) {
      uploadCtr = new CPFileImportController(ureq, getWindowControl(), cp, currentPage);
      activateModalDialog(uploadCtr);

    } else if (source == newLink) {
      fireEvent(ureq, new Event("New Page"));

    } else if (source == copyLink) {
      if (currentPage.isOrgaPage()) {
        showInfo("cptreecontroller.orga.cannot.be.copied");
      } else {
        final String newIdentifier = copyPage(currentPage);
        // this.getInitialComponent().setDirty(true);
        contentCtr.displayPage(ureq, newIdentifier);
      }
    } else if (source == deleteLink) {
      if (currentPage.isOrgaPage()) {
        showInfo("cptreecontroller.orga.cannot.be.deleted");
      } else {
        final List<String> buttonLables = new ArrayList<String>();
        buttonLables.add(translate("cptreecontrolller.delete.items.and.files"));
        buttonLables.add(translate("cptreecontrolller.delete.items.only"));
        buttonLables.add(translate("cancel"));

        dialogCtr =
            DialogBoxUIFactory.createGenericDialog(
                ureq,
                getWindowControl(),
                translate("cptreecontroller.q_delete_title"),
                translate("cptreecontroller.q_delete_text", getCurrentPageInfoStringHTML()),
                buttonLables);
        listenTo(dialogCtr);
        dialogCtr.activate();
      }
    }
  }
  /** Event-handling from controllers */
  @Override
  protected void event(final UserRequest ureq, final Controller source, final Event event) {
    if (source == cmc) {
      if (event.equals(CloseableModalController.CLOSE_MODAL_EVENT)) {
        removeAsListenerAndDispose(cmc);
        cmc = null;
        removeAsListenerAndDispose(uploadCtr);
        uploadCtr = null;
      }
    } else if (source == uploadCtr) {
      if (event instanceof NewCPPageEvent) {
        // TODO:GW Is it necessary to set component dirty?
        // getInitialComponent().setDirty(true);
        fireEvent(ureq, event);
      }
      // Dispose the cmc and the podcastFormCtr.
      cmc.deactivate();
      removeAsListenerAndDispose(cmc);
      cmc = null;
      removeAsListenerAndDispose(uploadCtr);
      uploadCtr = null;
    } else if (source == treeCtr) {
      // event from extJSTree (TreeController)
      if (event instanceof MoveTreeNodeEvent) {
        /** move * */
        final MoveTreeNodeEvent moveEvent = (MoveTreeNodeEvent) event;
        final String selectedNodeID = treeModel.getIdentifierForNodeID(moveEvent.getNodeId());

        currentPage = new CPPage(selectedNodeID, cp);

        final MoveTreeNodeEvent newmoveEvent =
            new MoveTreeNodeEvent(
                treeModel.getIdentifierForNodeID(moveEvent.getNodeId()),
                treeModel.getIdentifierForNodeID(moveEvent.getOldParentNodeId()),
                treeModel.getIdentifierForNodeID(moveEvent.getNewParentNodeId()),
                moveEvent.getPosition());

        final boolean success = movePage(newmoveEvent);
        // setResult is important. If sucess is not true, the ajax tree will
        // popup a dialog with error-msg
        moveEvent.setResult(success, "Error", "Error while moving node");

      } else if (event instanceof TreeNodeClickedEvent) {
        /** click * */
        TreeNodeClickedEvent clickedEvent = (TreeNodeClickedEvent) event;
        final String selectedNodeID = treeModel.getIdentifierForNodeID(clickedEvent.getNodeId());

        currentPage = new CPPage(selectedNodeID, cp);

        clickedEvent = new TreeNodeClickedEvent(currentPage.getIdentifier());
        fireEvent(ureq, clickedEvent);
      } else if (event instanceof TreeNodeModifiedEvent) {
        /** a node (name) has been modified * */
        fireEvent(ureq, event);
      }
    } else if (source == dialogCtr) {
      // event from dialog (really-delete-dialog)
      if (event != Event.CANCELLED_EVENT) {
        final int position = DialogBoxUIFactory.getButtonPos(event);

        // 0 = delete with resource
        // 1 = delete without resource
        // 2 = cancel
        if (position == 0 || position == 1) {
          boolean deleteResource = false;
          if (position == 0) {
            // Delete element including files
            deleteResource = true;
          }
          final String parentIdentifier = getParentIdentifier();

          // finally delete the page
          deletePage(currentPage.getIdentifier(), deleteResource);

          if (parentIdentifier != null) {
            contentCtr.displayPage(ureq, parentIdentifier);
          }
        } else {
          // Cancel dialog and close window.
        }
      }
    }
  }