Package org.olat.core.gui.components.table

Examples of org.olat.core.gui.components.table.GenericObjectArrayTableDataModel


        tmpThreadList.add(thread);
        threads.add(mesgWrapper);
      }
    }
    // build table model
    attdmodel = new GenericObjectArrayTableDataModel(threads, numTableCols);
    allThreadTableCtr.setTableDataModel(attdmodel);
    allThreadTableCtr.setSortColumn(3, false);
   
    vcListTitles.put("allThreadTable", allThreadTableCtr.getInitialComponent());
    vcListTitles.contextPut("hasThreads", (attdmodel.getRowCount() == 0) ? Boolean.FALSE : Boolean.TRUE);
View Full Code Here


        groupChoiceRowData[0] = new Boolean(true);
        groupChoiceRowData[1] = new ObjectWrapper(area);
        objectArrays.add(groupChoiceRowData);
      }
    }
    GenericObjectArrayTableDataModel tableModel = new GenericObjectArrayTableDataModel(objectArrays, 2);
    return tableModel;
  }
View Full Code Here

  /**
   * Synchronizes the Choice's tableDataModel with its selection/removed status.
   * @param choice
   */
  private void syncTableModelWithSelection(Choice choice) {
    GenericObjectArrayTableDataModel tableDataModel = (GenericObjectArrayTableDataModel)choice.getTableDataModel();
    List removedRowsIndexes = choice.getRemovedRows();
    if(removedRowsIndexes.size()>0) {
      int numRows = choice.getTableDataModel().getRowCount();
      for(int i=0; i<numRows; i++) {
        if(removedRowsIndexes.contains(new Integer(i))) {         
          tableDataModel.setValueAt(new Boolean(false), i, 0);
        }
      }
    }   
  }
View Full Code Here

        step4VC.contextPut("bulkActionDisplayName", bulkActionDisplayName);
        step4VC.contextPut("currentNodeShortTitle", currentNodeShortTitle);
       
        back4 = LinkFactory.createLinkBack(step4VC, this);
       
        dataModel = new GenericObjectArrayTableDataModel(rows, numOfLines);
        // the data model already contains the column for the feedback,
        // which is used at step 6 and not yet shown to the user
        dataTableCtr.setTableDataModel(dataModel);
        step4VC.put("dataTable", dataTableCtr.getInitialComponent());
       
        olatKeys = new ArrayList();
        // adding order is relevant for the "if-else if"-statement below at events from step 5
        olatKeys.add(translate("username"));
        olatKeys.add(translate("form.name.email"));
       
        removeAsListenerAndDispose(bulkStep4Form);
        bulkStep4Form = new BulkStep4Form(ureq, getWindowControl(), olatKeys,columnNames);
        listenTo(bulkStep4Form);
       
        step4VC.put("step4Form", bulkStep4Form.getInitialComponent());
       
        wc.setWizardTitle(translate("wizard.step4.title"));
        wc.setNextWizardStep(translate("wizard.step4.howto"), step4VC);
     
    }
    // events from step 4, preparing step 5
    else if (source == bulkStep4Form && event == Event.DONE_EVENT) {

        selectedColForOlatKey = Integer.parseInt(bulkStep4Form.getSelectedColumn());
        selectedOlatKey = Integer.parseInt(bulkStep4Form.getSelectedOlatKey());
        selectedValueOfOlatKey = (String) olatKeys.get(selectedOlatKey);
       
        step5VC = createVelocityContainer("bulkstep5");
        step5VC.contextPut("bulkActionDisplayName", bulkActionDisplayName);
        step5VC.contextPut("currentNodeShortTitle", currentNodeShortTitle);
       
        back5 = LinkFactory.createLinkBack(step5VC, this);
       
        dataTableCtr = new TableController(tableConfig, ureq, getWindowControl(), hcTranslator, this);
        columnNames = null;
        columnNames = new ArrayList();
        for(int i = 0;i < numOfValPerLine; i++){
          if (i != selectedColForOlatKey){
            dataTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("ccc"+(i+1), i, null, ureq.getLocale()));
            // add every name of a column to a list deployed as pulldown to the user for matching column with bulk action
            columnNames.add(getTranslator().translate("column", new String[]{""+(i+1)}));
          }else{
            dataTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("hhh" + selectedValueOfOlatKey, i, null, ureq.getLocale()));
          }
        }
       
        dataTableCtr.setTableDataModel(dataModel);
        step5VC.put("dataTable", dataTableCtr.getInitialComponent());
       
        removeAsListenerAndDispose(bulkStep5Form);
        bulkStep5Form = new BulkStep5Form(ureq, getWindowControl(), columnNames, bulkActions);
        listenTo(bulkStep5Form);
       
        step5VC.put("step5Form", bulkStep5Form.getInitialComponent());
       
        wc.setWizardTitle(translate("wizard.step5.title"));
        wc.setNextWizardStep(translate("wizard.step5.howto"), step5VC);
    }
    // events from step 5, preparing step 6
    else if (source == bulkStep5Form && event == Event.DONE_EVENT) { // user clicked 'next'-button !!!!!!!
        List rowsFeedbackStep = new ArrayList(rows.size());
        for (Iterator iter = rows.iterator(); iter.hasNext();) {
          Object[] values = (Object[]) iter.next();
          rowsFeedbackStep.add(values.clone());
        }
        String selectedColForBulk = bulkStep5Form.getSelectedColumn();
        int colForBulk = Integer.parseInt(selectedColForBulk);
        // While the user is matching the olatKey with a table column the relation between
        // table indices and pulldown menu indices is ok, but now while matching the bulkaction
        // with a table column the indices are only ok in certain cases, because the user choosen
        // column for the olatKey is not more shown in the second pulldown menu. It means by example
        // if the user choose pulldown index [1] for the olatKey, it really meets the table index[1],
        // then in the next step the pulldown has not more as many indices as before.
        // If the user is now choosing the pulldown index[1] for the bulkaction he would meet the before selected
        // column for the olatKey, if the system id not adding 1 to the index count.
        if (selectedColForOlatKey <= colForBulk) colForBulk++;

        step6VC = createVelocityContainer("bulkstep6");
        finishedButton = LinkFactory.createButtonSmall("finished", step6VC, this);
        step6VC.put("finishedButton", finishedButton);
       
        step6VC.contextPut("bulkActionDisplayName", bulkActionDisplayName);
        step6VC.contextPut("currentNodeShortTitle", currentNodeShortTitle);
       
        back6 = LinkFactory.createLinkBack(step6VC, this);
       
        GenericObjectArrayTableDataModel feedbackDataModel = new GenericObjectArrayTableDataModel(rowsFeedbackStep, numOfLines);
       
        UserManager um = UserManager.getInstance();
        Manager secMgr = ManagerFactory.getManager();
       
        BulkActionModule bam = new BulkActionModule();
        BulkAction ba = (BulkAction) bulkActions.get(bulkType);

        // TODO: as:b may be add additional class hierarchy (ask pb !!!)
        if ((ba instanceof BulkActionSetNodeScore)){
          ((BulkActionSetNodeScore) ba).setCourseNode((AssessableCourseNode)currentCourseNode);
        }else if ((ba instanceof BulkActionSetNodePassed)){
          ((BulkActionSetNodePassed) ba).setCourseNode((AssessableCourseNode)currentCourseNode);
        }else if ((ba instanceof BulkActionSetNodeUserComment)){
          ((BulkActionSetNodeUserComment) ba).setCourseNode((AssessableCourseNode)currentCourseNode);
        }
       
        List identitiesAndTheirAssessments = new ArrayList(feedbackDataModel.getRowCount());
        // read values from the column which the user has defined as olat key (e.g. username)
        // and add them to a list.
        for(int i = 0; i < feedbackDataModel.getRowCount(); i ++ ){
          String val = (String) feedbackDataModel.getValueAt(i, selectedColForOlatKey);
          val = val.trim();
          String assessment = (String) feedbackDataModel.getValueAt(i, colForBulk);
          Identity identity = null;

          if (selectedOlatKey == 0){ // username
              identity = secMgr.findIdentityByName(val);
          }else if (selectedOlatKey == 1) { // email
            identity = um.findIdentityByEmail(val);
          }
          identitiesAndTheirAssessments.add(new Object[]{identity,assessment});
        }
        List bulkResults = bam.apply(identitiesAndTheirAssessments, ba);
       
        // add the bulk results to the data model
        for(int i = 0; i < feedbackDataModel.getRowCount(); i++ ){           
          Object[] feedback = (Object[]) bulkResults.get(i);
          feedbackDataModel.setValueAt(feedback[2],i, numOfValPerLine);
        }
       
        tableConfig.setDownloadOffered(true);
       
        feedbackDataTableCtr = new TableController(tableConfig, ureq, getWindowControl(), hcTranslator, this);
View Full Code Here

        for(int i = 0;i < numOfValuesPerLine+1; i++){ // lenght+1 since adding the delimiter above
          sepValTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("ccc"+(i+1), i, null, ureq.getLocale()));
          // add every name of a column to a list deployed as pulldown to the user for matching column with olat key
          columnNames.add(trans.translate("column", new String[]{""+(i+1)}));
        }
        sepValModel = new GenericObjectArrayTableDataModel(rows, numOfLines);
        sepValTableCtr.setTableDataModel(sepValModel);
        keywithcolVC.put("sepValTable", sepValTableCtr.getInitialComponent());
       
        PackageTranslator userTrans = new PackageTranslator("org.olat.user", ureq.getLocale());
        PackageTranslator properyHandlersTrans = new PackageTranslator("org.olat.user.propertyhandlers", ureq.getLocale());
        olatKeys = new ArrayList();
        // adding order is relevant for the "if-else if"-statement below at events from step 3
        olatKeys.add(properyHandlersTrans.translate("form.name.institutionalUserIdentifier"));
        olatKeys.add(userTrans.translate("form.username"));
        olatKeys.add(userTrans.translate("form.email"));
       
        // add olatKeys and columnsNames to the form which displays it as pulldown menus
        kwcForm = new KeyWithColumnForm("keywithcolform", trans, olatKeys, columnNames);
        kwcForm.addListener(this);
        keywithcolVC.put("kwcForm", kwcForm);
       
        wc.setWizardTitle(trans.translate("wizard.step2.title"));
        wc.setNextWizardStep(trans.translate("wizard.step2.howto"), keywithcolVC);
      }
    // events from step 2
    // preparing step 3
    }else if (source == kwcForm){
      if (event == Form.EVNT_VALIDATION_OK) { // user clicked 'next'-button !!!!!!!
        selectedColForOlatKey = Integer.parseInt(kwcForm.getSelectedColumn());
        selectedOlatKey = Integer.parseInt(kwcForm.getSelectedOlatKey());
        selectedValueOfOlatKey = (String) olatKeys.get(selectedOlatKey);
        colwithbulkactionVC = new VelocityContainer("colwithbulkaction", VELOCITY_ROOT + "/colwithbulkaction.html", trans, this);
        backLinkCol = LinkFactory.createLinkBack(colwithbulkactionVC, this);
       
        sepValTableCtr = new TableController(tableConfig, ureq, getWindowControl(), hcTranslator, this);
        columnNames = null;
        columnNames = new ArrayList();
        for(int i = 0;i < numOfValuesPerLine+1; i++){ // lenght+1 since adding the delimiter above
          if (i != selectedColForOlatKey){
            sepValTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("ccc"+(i+1), i, null, ureq.getLocale()));
            // add every name of a column to a list deployed as pulldown to the user for matching column with olat key
            columnNames.add(trans.translate("column", new String[]{""+(i+1)}));
          }else{
            sepValTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("hhh" + selectedValueOfOlatKey, i, null, ureq.getLocale()));
          }
        }
        sepValTableCtr.setTableDataModel(sepValModel);
        colwithbulkactionVC.put("sepValTable", sepValTableCtr.getInitialComponent());
       
        cwbForm = new ColWithBulkActionForm("colwithbulkactionform", trans, columnNames, bulkActions);
        cwbForm.addListener(this);
        colwithbulkactionVC.put("cwbForm", cwbForm);
       
        wc.setWizardTitle(trans.translate("wizard.step3.title"));
        wc.setNextWizardStep(trans.translate("wizard.step3.howto"), colwithbulkactionVC);
      }
    }else if (source == backLinkKey){
      wc.setWizardTitle(trans.translate("wizard.step1.title"));
      wc.setBackWizardStep(trans.translate("wizard.step1.howto"), sepValInForm);
    // events from step 3
    // preparing step 4
    }else if (source == cwbForm){
      if (event == Form.EVNT_VALIDATION_OK) { // user clicked 'next'-button !!!!!!!
        List rowsFourthStep = new ArrayList(rows.size());
        for (Iterator iter = rows.iterator(); iter.hasNext();) {
          Object[] values = (Object[]) iter.next();
          rowsFourthStep.add(values.clone());
        }
        String selectedColForBulk = cwbForm.getSelectedColumn();
        int colForBulk = Integer.parseInt(selectedColForBulk);
        // the selected column for the OLAT key was not more shown in the pulldownmenu for
        // for choosing the bulkaction, but it is not removed, therefore we have to increment
        // the colForBulk in certain cases
        if (selectedColForOlatKey <= colForBulk) colForBulk++;
        String selectedBulk = cwbForm.getSelectedBulkAction();
        int bulk = Integer.parseInt(selectedBulk);
        finishedVC = new VelocityContainer("finished", VELOCITY_ROOT + "/finished.html", trans, this);
        backLinkFin = LinkFactory.createLinkBack(finishedVC, this);
       
        GenericObjectArrayTableDataModel sepValFinModel = new GenericObjectArrayTableDataModel(rowsFourthStep, numOfLines);
         
        UserManager um = UserManager.getInstance();
        Manager secMgr = ManagerFactory.getManager();
       
        BulkActionModule bam = new BulkActionModule();
        BulkAction ba = (BulkAction) bulkActions.get(bulk);
        List identities = new ArrayList(sepValFinModel.getRowCount());
       
        // read values from the column which the user has defined as olat key (e.g. username)
        // and add them to a list.
        for(int i = 0; i < sepValFinModel.getRowCount(); i ++ ){
          String val = (String) sepValFinModel.getValueAt(i, selectedColForOlatKey);
          val = val.trim();
          Identity identity = null;

          if (selectedOlatKey == 0) { // matrikelnumber
            Map<String, String> searchValue = new HashMap<String, String>();
            searchValue.put(UserConstants.INSTITUTIONALUSERIDENTIFIER, val);
            List identitiesFoundByInst = ManagerFactory.getManager().getIdentitiesByPowerSearch(null, searchValue, true, null, null, null, null, null, null);
            //FIXME:as:b error handling if there is more than one identity found by institutionalUserIdentifier
            // see also in BulkAssessmentWizardController
            if (identitiesFoundByInst.size() == 1){
              identity = (Identity) identitiesFoundByInst.get(0);
            }
          }else if (selectedOlatKey == 1){ // username
              identity = secMgr.findIdentityByName(val);
          }else if (selectedOlatKey == 2) { // email
            identity = um.findIdentityByEmail(val);
          }
          identities.add(identity);
        }
        // get results from the user chosen bulk action for every identity
        List bulkResults = bam.apply(identities, ba);
        // add the bulk results to the data model
        for(int i = 0; i < sepValFinModel.getRowCount(); i++ ){
          String result = (String) bulkResults.get(i);
          sepValFinModel.setValueAt(result,i,colForBulk);
        }
       
        tableConfig.setDownloadOffered(true);
        TableController sepValFinTableCtr = new TableController(tableConfig, ureq, getWindowControl(), hcTranslator, this);
        columnNames = null;
View Full Code Here

TOP

Related Classes of org.olat.core.gui.components.table.GenericObjectArrayTableDataModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.