List of usage examples for java.text DateFormat SHORT
int SHORT
To view the source code for java.text DateFormat SHORT.
Click Source Link
From source file:qtiscoringengine.QTIUtility.java
public static String getUniqueFileName(String fileNamePrefix, String fileExtension) { Date d = Calendar.getInstance().getTime(); long now = System.currentTimeMillis(); return "QTIScoringEngine_" + fileNamePrefix + "_" + DateFormat.getDateInstance(DateFormat.SHORT).format(d).replace("/", "-") + "_" + DateFormat.getTimeInstance(DateFormat.LONG).format(d).replace(" ", "").replace(":", "_") + fileExtension;//from w w w . j av a 2 s. co m }
From source file:org.kalypso.model.wspm.tuhh.core.wspwin.WspWinExporter.java
private static void write1DTuhhSteuerparameter(final TuhhCalculation calculation, final File batFile, final File zustFile, final File qwtFile, final File psiFile, final TuhhStationRange stationRange) throws IOException { final MODE calcMode = calculation.getCalcMode(); Formatter pw = null;// w w w.j a va2s .c o m try { batFile.getParentFile().mkdirs(); pw = new Formatter(batFile); pw.format("# %s%n", calculation.getName()); //$NON-NLS-1$ pw.format("# %s%n", //$NON-NLS-1$ DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date())); pw.format("%n"); //$NON-NLS-1$ pw.format("PROJEKTPFAD=%s%n", "."); //$NON-NLS-1$ //$NON-NLS-2$ pw.format("STRANGDATEI=%s%n", zustFile.getName()); //$NON-NLS-1$ pw.format("%n"); //$NON-NLS-1$ pw.format("# mgliche Werte:%n"); //$NON-NLS-1$ pw.format("# WATERLEVEL%n"); //$NON-NLS-1$ pw.format("# BF_UNIFORM%n"); //$NON-NLS-1$ pw.format("# BF_NON_UNIFORM%n"); //$NON-NLS-1$ pw.format("# REIB_KONST%n"); //$NON-NLS-1$ pw.format("BERECHNUNGSMODUS=%s%n", calcMode.name()); //$NON-NLS-1$ pw.format("%n"); //$NON-NLS-1$ pw.format("# mgliche Werte:%n"); //$NON-NLS-1$ pw.format("# DARCY_WEISBACH_OHNE_FORMEINFLUSS%n"); //$NON-NLS-1$ pw.format("# DARCY_WEISBACH_MIT_FORMEINFLUSS%n"); //$NON-NLS-1$ pw.format("# MANNING_STRICKLER%n"); //$NON-NLS-1$ pw.format("FLIESSGESETZ=%s%n", calculation.getFliessgesetz().name()); //$NON-NLS-1$ pw.format("%n"); //$NON-NLS-1$ pw.format(Locale.US, "ANFANGSSTATION=%s%n", stationRange.getExportFrom()); //$NON-NLS-1$ pw.format(Locale.US, "ENDSTATION=%s%n", stationRange.getExportTo()); //$NON-NLS-1$ pw.format("%n"); //$NON-NLS-1$ pw.format("# mgliche Werte%n"); //$NON-NLS-1$ pw.format("# CRITICAL_WATER_DEPTH%n"); //$NON-NLS-1$ pw.format("# UNIFORM_BOTTOM_SLOPE%n"); //$NON-NLS-1$ pw.format("# WATERLEVEL%n"); //$NON-NLS-1$ pw.format("ART_RANDBEDINGUNG=%s%n", calculation.getStartKind().name()); //$NON-NLS-1$ final Double startWaterlevel = calculation.getStartWaterlevel(); if (startWaterlevel != null) { pw.format(Locale.US, "ANFANGSWASSERSPIEGEL=%s%n", startWaterlevel); //$NON-NLS-1$ } final BigDecimal startSlope = calculation.getStartSlope(); if (startSlope != null) { pw.format("GEFAELLE=%s%n", startSlope); //$NON-NLS-1$ } pw.format("%n"); //$NON-NLS-1$ pw.format("# mgliche Werte%n"); //$NON-NLS-1$ pw.format("# NON%n"); //$NON-NLS-1$ pw.format("# DVWK%n"); //$NON-NLS-1$ pw.format("# BJOERNSEN%n"); //$NON-NLS-1$ pw.format("# DFG%n"); //$NON-NLS-1$ pw.format("VERZOEGERUNGSVERLUST=%s%n", calculation.getVerzoegerungsverlust().name()); //$NON-NLS-1$ pw.format("%n"); //$NON-NLS-1$ pw.format("# mgliche Werte%n"); //$NON-NLS-1$ pw.format("# SIMPLE%n"); //$NON-NLS-1$ pw.format("# EXACT%n"); //$NON-NLS-1$ pw.format("ITERATIONSART=%s%n", calculation.getIterationType().name()); //$NON-NLS-1$ pw.format("%n"); //$NON-NLS-1$ pw.format("# mgliche Werte%n"); //$NON-NLS-1$ pw.format("# TRAPEZ_FORMULA%n"); //$NON-NLS-1$ pw.format("# GEOMETRIC_FORMULA%n"); //$NON-NLS-1$ pw.format("REIBUNGSVERLUST=%s%n", calculation.getReibungsverlust().name()); //$NON-NLS-1$ pw.format("%n"); //$NON-NLS-1$ pw.format("# mgliche Werte: true / false%n"); //$NON-NLS-1$ pw.format("MIT_BRUECKEN=%b%n", calculation.isCalcBridges()); //$NON-NLS-1$ pw.format("MIT_WEHREN=%b%n", calculation.isCalcBarrages()); //$NON-NLS-1$ pw.format("USE_EXTREM_ROUGH=%b%n", calculation.isUseExtremeRoughness()); //$NON-NLS-1$ pw.format("%n"); //$NON-NLS-1$ pw.format("ABFLUSSEREIGNIS=%s%n", qwtFile.getName()); //$NON-NLS-1$ pw.format("%n"); //$NON-NLS-1$ pw.format("EINZELVERLUSTE=%s%n", psiFile.getName()); //$NON-NLS-1$ //$NON-NLS-2$ pw.format("%n"); //$NON-NLS-1$ final Double minQ = calculation.getMinQ(); if (minQ != null) { pw.format(Locale.US, "MIN_Q=%s%n", minQ); //$NON-NLS-1$ } final Double maxQ = calculation.getMaxQ(); if (maxQ != null) { pw.format(Locale.US, "MAX_Q=%s%n", maxQ); //$NON-NLS-1$ } final Double qstep = calculation.getQStep(); if (qstep != null) { pw.format(Locale.US, "DELTA_Q=%s%n", qstep); //$NON-NLS-1$ } pw.format("%n"); //$NON-NLS-1$ // Einheit des Durchflusses wird standardmig festgelegt pw.format("# mgliche Werte%n"); //$NON-NLS-1$ pw.format("# QM_S%n"); //$NON-NLS-1$ pw.format("# L_S%n"); //$NON-NLS-1$ pw.format("DURCHFLUSS_EINHEIT=QM_S%n"); //$NON-NLS-1$ FormatterUtils.checkIoException(pw); } finally { if (pw != null) { pw.close(); } } }
From source file:org.jdal.vaadin.ui.FormUtils.java
/** * Create a new DateField with format for current locale and {@link DateFormat#SHORT} style * @return a new DateField// w ww. j a v a 2 s.c o m */ public static DateField newDateField() { return newDateField(DateFormat.SHORT); }
From source file:org.sakaiproject.evaluation.tool.producers.EvaluationAssignProducer.java
public void fill(UIContainer tofill, ViewParameters viewparams, ComponentChecker checker) { // local variables used in the render logic String currentUserId = commonLogic.getCurrentUserId(); DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); DateFormat dtf = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale); navBarRenderer.makeNavBar(tofill, NavBarRenderer.NAV_ELEMENT, this.getViewID()); EvalViewParameters evalViewParams = (EvalViewParameters) viewparams; if (evalViewParams.evaluationId == null) { throw new IllegalArgumentException("Cannot access this view unless the evaluationId is set"); }// w ww.ja v a 2s.c o m /** * This is the evaluation we are working with on this page, * this should ONLY be read from, do not change any of these fields */ EvalEvaluation evaluation = evaluationService.getEvaluationById(evalViewParams.evaluationId); //Are we using the selection options (UCT)? YES boolean useSelectionOptions = ((Boolean) settings.get(EvalSettings.ENABLE_INSTRUCTOR_ASSISTANT_SELECTION)); //find out is this evaluation will contain any Instructor/TA questions based in it's template List<String> validItemCategories; boolean hasInstructorQuestions = true; boolean hasAssistantQuestions = true; if (useSelectionOptions) { validItemCategories = renderingUtils.extractCategoriesInTemplate(evaluation.getTemplate().getId()); hasInstructorQuestions = validItemCategories.contains(EvalConstants.ITEM_CATEGORY_INSTRUCTOR); hasAssistantQuestions = validItemCategories.contains(EvalConstants.ITEM_CATEGORY_ASSISTANT); } LOG.debug("Template id: " + evaluation.getTemplate().getId() + " useSelectionOptions: " + useSelectionOptions + " hasInstructorQuestions: " + hasInstructorQuestions + " hasAssistantQuestions: " + hasAssistantQuestions); String actionBean = "setupEvalBean."; Boolean newEval = false; UIInternalLink.make(tofill, "eval-settings-link", UIMessage.make("evalsettings.page.title"), new EvalViewParameters(EvaluationSettingsProducer.VIEW_ID, evalViewParams.evaluationId)); if (EvalConstants.EVALUATION_STATE_PARTIAL.equals(evaluation.getState())) { // creating a new eval UIMessage.make(tofill, "eval-start-text", "starteval.page.title"); newEval = true; } UIMessage.make(tofill, "assign-eval-edit-page-title", "assigneval.assign.page.title", new Object[] { evaluation.getTitle() }); UIMessage.make(tofill, "assign-eval-instructions", "assigneval.assign.instructions", new Object[] { evaluation.getTitle() }); UIMessage.make(tofill, "evalAssignInstructions", "evaluationassignconfirm.eval.assign.instructions", new Object[] { df.format(evaluation.getStartDate()) }); // display info about the evaluation (dates and what not) UIOutput.make(tofill, "startDate", dtf.format(evaluation.getStartDate())); if (evaluation.getDueDate() != null) { UIBranchContainer branch = UIBranchContainer.make(tofill, "showDueDate:"); UIOutput.make(branch, "dueDate", dtf.format(evaluation.getDueDate())); } if (evaluation.getStopDate() != null) { UIBranchContainer branch = UIBranchContainer.make(tofill, "showStopDate:"); UIOutput.make(branch, "stopDate", dtf.format(evaluation.getStopDate())); } if (evaluation.getViewDate() != null) { UIBranchContainer branch = UIBranchContainer.make(tofill, "showViewDate:"); UIOutput.make(branch, "viewDate", dtf.format(evaluation.getViewDate())); } /* * About this form. * * This is a GET form that has 2 UISelects, one for Hierarchy Nodes, and * one for Eval Groups (which includes adhoc groups). They are interspered * and mixed together. In order to do this easily we pass in empty String * arrays for the option values and labels in the UISelects. This is partially * because rendering each individual checkbox requires and integer indicating * it's position, and this view is too complicated to generate these arrays * ahead of time. So we generate the String Arrays on the fly, using the list.size()-1 * at each point to get this index. Then at the very end we update the UISelect's * with the appropriate optionlist and optionnames. This actually works * really good and the wizard feels much smoother than it did with the * old session bean. * * Also see the comments on HierarchyTreeNodeSelectRenderer. * */ UIForm form = UIForm.make(tofill, "eval-assign-form"); // Things for building the UISelect of Hierarchy Node Checkboxes List<String> hierNodesLabels = new ArrayList<>(); List<String> hierNodesValues = new ArrayList<>(); UISelect hierarchyNodesSelect = UISelect.makeMultiple(form, "hierarchyNodeSelectHolder", new String[] {}, new String[] {}, (useSelectionOptions ? actionBean : "") + "selectedHierarchyNodeIDs", evalViewParams.selectedHierarchyNodeIDs); String hierNodesSelectID = hierarchyNodesSelect.getFullID(); // Things for building the UISelect of Eval Group Checkboxes List<String> evalGroupsLabels = new ArrayList<>(); List<String> evalGroupsValues = new ArrayList<>(); UISelect evalGroupsSelect = UISelect.makeMultiple(form, "evalGroupSelectHolder", new String[] {}, new String[] {}, (useSelectionOptions ? actionBean : "") + "selectedGroupIDs", evalViewParams.selectedGroupIDs == null ? new String[] {} : evalViewParams.selectedGroupIDs); String evalGroupsSelectID = evalGroupsSelect.getFullID(); /* * About the 4 collapsable areas. * * What's happening here is that we have 4 areas: hierarchy, groups, * new adhoc groups, and existing adhoc groups that can be hidden and selected * which a checkbox for each one. * */ Boolean useAdHocGroups = (Boolean) settings.get(EvalSettings.ENABLE_ADHOC_GROUPS); Boolean showHierarchy = (Boolean) settings.get(EvalSettings.DISPLAY_HIERARCHY_OPTIONS); // NOTE: this is the one place where the perms should be used instead of user assignments (there are no assignments yet) -AZ // get the current eval group id (ie: reference site id) that the user is in now String currentEvalGroupId = commonLogic.getCurrentEvalGroup(); // get the current eval group id (ie: site id) that the user is in now String currentSiteId = EntityReference.getIdFromRef(currentEvalGroupId); // get the groups that this user is allowed to assign evals to List<EvalGroup> assignEvalGroups; // for backwards compatibility we will pull the list of groups the user is being evaluated in as well and merge it in List<EvalGroup> beEvalGroups; Boolean isGroupFilterEnabled = (Boolean) settings.get(EvalSettings.ENABLE_FILTER_ASSIGNABLE_GROUPS); if (isGroupFilterEnabled) { assignEvalGroups = commonLogic.getFilteredEvalGroupsForUser(currentUserId, EvalConstants.PERM_ASSIGN_EVALUATION, currentSiteId); beEvalGroups = commonLogic.getFilteredEvalGroupsForUser(currentUserId, EvalConstants.PERM_BE_EVALUATED, currentSiteId); } else { assignEvalGroups = commonLogic.getEvalGroupsForUser(currentUserId, EvalConstants.PERM_ASSIGN_EVALUATION); beEvalGroups = commonLogic.getEvalGroupsForUser(currentUserId, EvalConstants.PERM_BE_EVALUATED); } /* * EVALSYS-987- Side effect * remove ad hoc groups from view as they are handled already in another * section in the same view. */ List<EvalGroup> evalGroups = new ArrayList<>(); for (EvalGroup evalGroup : assignEvalGroups) { if (!evalGroups.contains(evalGroup) && !EvalConstants.GROUP_TYPE_ADHOC.equals(evalGroup.type)) { evalGroups.add(evalGroup); } } for (EvalGroup evalGroup : beEvalGroups) { if (!evalGroups.contains(evalGroup) && !EvalConstants.GROUP_TYPE_ADHOC.equals(evalGroup.type)) { evalGroups.add(evalGroup); } } if (evalGroups.size() > 0) { Map<String, EvalGroup> groupsMap = new HashMap<>(); for (int i = 0; i < evalGroups.size(); i++) { EvalGroup c = (EvalGroup) evalGroups.get(i); groupsMap.put(c.evalGroupId, c); } /* * Area 1. Selection GUI for Hierarchy Nodes and Evaluation Groups */ if (showHierarchy) { //need to determine who can see what nodes in the hierarchy: //null means the user is an admin, empty means the user has no access Set<String> parentNodes = null; Set<String> accessNodes = null; if (!commonLogic.isUserAdmin(currentUserId)) { parentNodes = new HashSet<>(); accessNodes = new HashSet<>(); Set<EvalHierarchyNode> nodes = hierarchyLogic.getNodesForUserPerm(currentUserId, EvalConstants.HIERARCHY_PERM_ASSIGN_EVALUATION); for (EvalHierarchyNode node : nodes) { accessNodes.add(node.id); accessNodes.addAll(node.childNodeIds); parentNodes.add(node.id); parentNodes.addAll(node.parentNodeIds); } } UIBranchContainer hierarchyArea = UIBranchContainer.make(form, "hierarchy-node-area:"); hierUtil.renderSelectHierarchyNodesTree(hierarchyArea, "hierarchy-tree-select:", evalGroupsSelectID, hierNodesSelectID, evalGroupsLabels, evalGroupsValues, hierNodesLabels, hierNodesValues, evalViewParams, accessNodes, parentNodes, evaluation.getSectionAwareness()); addCollapseControl(tofill, hierarchyArea, "initJSHierarchyToggle", "hierarchy-assignment-area", "hide-button", "show-button", evalViewParams.expanded == null); form.parameters.add(new UIELBinding(actionBean + "expanded", evalViewParams.expanded)); } /* * Area 2. display checkboxes for selecting the non-hierarchy groups */ UIBranchContainer evalgroupArea = UIBranchContainer.make(form, "evalgroups-area:"); // If both the hierarchy and adhoc groups are disabled, don't hide the // selection area and don't make it collapsable, since it will be the // only thing on the screen. if (!showHierarchy && !useAdHocGroups) { UIOutput.make(evalgroupArea, "evalgroups-assignment-area"); } else { addCollapseControl(tofill, evalgroupArea, "initJSGroupsToggle", "evalgroups-assignment-area", "hide-button", "show-button", true); } String[] nonAssignedEvalGroupIDs = getEvalGroupIDsNotAssignedInHierarchy(evalGroups) .toArray(new String[] {}); List<EvalGroup> unassignedEvalGroups = new ArrayList<>(); for (String nonAssignedEvalGroupID : nonAssignedEvalGroupIDs) { unassignedEvalGroups.add(groupsMap.get(nonAssignedEvalGroupID)); } if (!unassignedEvalGroups.isEmpty()) { // sort the list by title Collections.sort(unassignedEvalGroups, new ComparatorsUtils.GroupComparatorByTitle()); //Move current site to top of this list EVALSYS-762. int count2 = 0; for (EvalGroup group : unassignedEvalGroups) { if (group.evalGroupId.equals(currentEvalGroupId)) { unassignedEvalGroups.remove(count2); unassignedEvalGroups.add(0, group); break; } count2++; } List<String> assignGroupsIds = new ArrayList<>(); String groupSelectionOTP = "assignGroupSelectionSettings."; if (!newEval) { Map<Long, List<EvalAssignGroup>> selectedGroupsMap = evaluationService .getAssignGroupsForEvals(new Long[] { evalViewParams.evaluationId }, true, null); List<EvalAssignGroup> assignGroups = selectedGroupsMap.get(evalViewParams.evaluationId); for (EvalAssignGroup assGroup : assignGroups) { assignGroupsIds.add(assGroup.getEvalGroupId()); //Add group selection settings to form to support EVALSYS-778 if (useSelectionOptions) { Map<String, String> selectionOptions = assGroup.getSelectionOptions(); form.parameters.add(new UIELBinding( groupSelectionOTP + assGroup.getEvalGroupId() .replaceAll(EvalConstants.GROUP_ID_SITE_PREFIX, "") + ".instructor", selectionOptions.get(EvalAssignGroup.SELECTION_TYPE_INSTRUCTOR))); form.parameters.add(new UIELBinding( groupSelectionOTP + assGroup.getEvalGroupId() .replaceAll(EvalConstants.GROUP_ID_SITE_PREFIX, "") + ".assistant", selectionOptions.get(EvalAssignGroup.SELECTION_TYPE_ASSISTANT))); } } } int count = 0; int countUnpublishedGroups = 0; for (EvalGroup evalGroup : unassignedEvalGroups) { if (evalGroup != null) { String evalGroupId = evalGroup.evalGroupId; boolean hasEvaluators = true; if (!EvalConstants.EVALUATION_AUTHCONTROL_NONE.equals(evaluation.getAuthControl())) { int numEvaluatorsInSite = commonLogic.countUserIdsForEvalGroup(evalGroupId, EvalConstants.PERM_TAKE_EVALUATION, evaluation.getSectionAwareness()); hasEvaluators = numEvaluatorsInSite > 0; } boolean isPublished = commonLogic.isEvalGroupPublished(evalGroupId); UIBranchContainer checkboxRow = UIBranchContainer.make(evalgroupArea, "groups:", count + ""); if (count % 2 == 0) { checkboxRow.decorate(new UIStyleDecorator("itemsListOddLine")); // must match the existing CSS class } checkboxRow.decorate(new UIFreeAttributeDecorator("rel", count + "")); // table row counter for JS use in EVALSYS-618 //keep deselected user info as a result of changes in EVALSYS-660 Set<String> deselectedInsructorIds = new HashSet<>(); Set<String> deselectedAssistantIds = new HashSet<>(); //Assign attribute to row to help JS set checkbox selection to true if (assignGroupsIds.contains(evalGroupId)) { checkboxRow.decorate(new UIStyleDecorator("selectedGroup")); } if (useSelectionOptions) { if (!newEval) { //Get saved selection settings for this eval List<EvalAssignUser> deselectedInsructors = evaluationService .getParticipantsForEval(evalViewParams.evaluationId, null, new String[] { evalGroupId }, EvalAssignUser.TYPE_EVALUATEE, EvalAssignUser.STATUS_REMOVED, null, null); List<EvalAssignUser> deselectedAssistants = evaluationService .getParticipantsForEval(evalViewParams.evaluationId, null, new String[] { evalGroupId }, EvalAssignUser.TYPE_ASSISTANT, EvalAssignUser.STATUS_REMOVED, null, null); //check for already deselected users that match this groupId for (EvalAssignUser deselectedUser : deselectedInsructors) { deselectedInsructorIds.add(deselectedUser.getUserId()); } for (EvalAssignUser deselectedUser : deselectedAssistants) { deselectedAssistantIds.add(deselectedUser.getUserId()); } } else { //add blank selection options for this group for use by evalAssign.js form.parameters .add(new UIELBinding( groupSelectionOTP + evalGroupId.replaceAll( EvalConstants.GROUP_ID_SITE_PREFIX, "") + ".instructor", "")); form.parameters .add(new UIELBinding( groupSelectionOTP + evalGroupId.replaceAll( EvalConstants.GROUP_ID_SITE_PREFIX, "") + ".assistant", "")); } } evalGroupsLabels.add(evalGroup.title); evalGroupsValues.add(evalGroupId); String evalUsersLocator = "selectedEvaluationUsersLocator."; UISelectChoice choice = UISelectChoice.make(checkboxRow, "evalGroupId", evalGroupsSelectID, evalGroupsLabels.size() - 1); if (!hasEvaluators) { choice.decorate(new UIDisabledDecorator()); } if (useSelectionOptions) { form.parameters.add(new UIELBinding( evalUsersLocator + evalGroupId.replaceAll(EvalConstants.GROUP_ID_SITE_PREFIX, "") + ".deselectedInstructors", deselectedInsructorIds.toArray(new String[deselectedInsructorIds.size()]))); form.parameters.add(new UIELBinding( evalUsersLocator + evalGroupId.replaceAll(EvalConstants.GROUP_ID_SITE_PREFIX, "") + ".deselectedAssistants", deselectedAssistantIds.toArray(new String[deselectedAssistantIds.size()]))); //add ordering bindings form.parameters.add(new UIELBinding(evalUsersLocator + evalGroupId.replaceAll(EvalConstants.GROUP_ID_SITE_PREFIX, "") + ".orderingInstructors", new String[] {})); form.parameters.add(new UIELBinding(evalUsersLocator + evalGroupId.replaceAll(EvalConstants.GROUP_ID_SITE_PREFIX, "") + ".orderingAssistants", new String[] {})); } // get title from the map since it is faster UIOutput title = UIOutput.make(checkboxRow, "groupTitle", evalGroup.title); if (!isPublished) { title.decorate(new UIStyleDecorator("elementAlertBack")); countUnpublishedGroups++; } if (useSelectionOptions) { if (hasEvaluators) { int totalUsers = commonLogic.countUserIdsForEvalGroup(evalGroupId, EvalConstants.PERM_BE_EVALUATED, evaluation.getSectionAwareness()); if (totalUsers > 0 && hasInstructorQuestions) { int currentUsers = deselectedInsructorIds.size() >= 0 ? (totalUsers - deselectedInsructorIds.size()) : totalUsers; UIInternalLink link = UIInternalLink.make(checkboxRow, "select-instructors", UIMessage.make("assignselect.instructors.select", new Object[] { currentUsers, totalUsers }), new EvalViewParameters(EvaluationAssignSelectProducer.VIEW_ID, evaluation.getId(), evalGroupId, EvalAssignGroup.SELECTION_TYPE_INSTRUCTOR)); link.decorate(new UIStyleDecorator("addItem total:" + totalUsers)); link.decorate(new UITooltipDecorator( messageLocator.getMessage("assignselect.instructors.page.title"))); } totalUsers = commonLogic.countUserIdsForEvalGroup(evalGroup.evalGroupId, EvalConstants.PERM_ASSISTANT_ROLE, evaluation.getSectionAwareness()); if (totalUsers > 0 && hasAssistantQuestions) { int currentUsers = deselectedAssistantIds.size() >= 0 ? (totalUsers - deselectedAssistantIds.size()) : totalUsers; UIInternalLink link = UIInternalLink.make(checkboxRow, "select-tas", UIMessage.make("assignselect.tas.select", new Object[] { currentUsers, totalUsers }), new EvalViewParameters(EvaluationAssignSelectProducer.VIEW_ID, evaluation.getId(), evalGroup.evalGroupId, EvalAssignGroup.SELECTION_TYPE_ASSISTANT)); link.decorate(new UIStyleDecorator("addItem total:" + totalUsers)); link.decorate(new UITooltipDecorator( messageLocator.getMessage("assignselect.tas.page.title"))); } } else { title.decorate(new UIStyleDecorator("instruction")); UIMessage.make(checkboxRow, "select-no", "assigneval.cannot.assign"); } } UILabelTargetDecorator.targetLabel(title, choice); // make title a label for checkbox count++; } } if (countUnpublishedGroups > 0) { UIMessage.make(tofill, "assign-eval-instructions-group-notpublished", "assigneval.assign.instructions.notpublished"); } } } else { // TODO tell user there are no groups to assign to } /* * Area 3: Selection GUI for Adhoc Groups */ String[] adhocGroupRowIds = new String[] {}; if (useAdHocGroups) { UIBranchContainer adhocGroupsArea = UIBranchContainer.make(form, "use-adhoc-groups-area:"); UIMessage.make(adhocGroupsArea, "adhoc-groups-deleted", "modifyadhocgroup.group.deleted"); addCollapseControl(tofill, adhocGroupsArea, "initJSAdhocToggle", "adhocgroups-assignment-area", "hide-button", "show-button", false); // Table of Existing adhoc groups for selection List<EvalAdhocGroup> myAdhocGroups = commonLogic.getAdhocGroupsForOwner(currentUserId); if (myAdhocGroups.size() > 0) { UIOutput.make(adhocGroupsArea, "adhoc-groups-table"); ArrayList<String> adhocGroupRowIdsArray = new ArrayList<>(myAdhocGroups.size()); int count = 0; for (EvalAdhocGroup adhocGroup : myAdhocGroups) { UIBranchContainer tableRow = UIBranchContainer.make(adhocGroupsArea, "groups:"); adhocGroupRowIdsArray.add(tableRow.getFullID()); if (count % 2 == 0) { tableRow.decorate(new UIStyleDecorator("itemsListOddLine")); // must match the existing CSS class } evalGroupsLabels.add(adhocGroup.getTitle()); evalGroupsValues.add(adhocGroup.getEvalGroupId()); UISelectChoice choice = UISelectChoice.make(tableRow, "evalGroupId", evalGroupsSelectID, evalGroupsLabels.size() - 1); // get title from the map since it is faster UIOutput title = UIOutput.make(tableRow, "groupTitle", adhocGroup.getTitle()); UILabelTargetDecorator.targetLabel(title, choice); // make title a label for checkbox // Link to allow editing an existing group UIInternalLink.make(tableRow, "editGroupLink", UIMessage.make("assigneval.page.adhocgroups.editgrouplink"), new AdhocGroupParams(ModifyAdhocGroupProducer.VIEW_ID, adhocGroup.getId(), vsh.getFullURL(evalViewParams))); // add delete option - https://bugs.caret.cam.ac.uk/browse/CTL-1310 if (currentUserId.equals(adhocGroup.getOwner()) || commonLogic.isUserAdmin(currentUserId)) { String deleteLink = commonLogic.getEntityURL(AdhocGroupEntityProvider.ENTITY_PREFIX, adhocGroup.getId().toString()); UILink.make(tableRow, "deleteGroupLink", UIMessage.make("general.command.delete"), deleteLink); } count++; } adhocGroupRowIds = adhocGroupRowIdsArray.toArray(new String[adhocGroupRowIdsArray.size()]); } UIInternalLink.make(adhocGroupsArea, "new-adhocgroup-link", UIMessage.make("assigneval.page.adhocgroups.newgrouplink"), new AdhocGroupParams(ModifyAdhocGroupProducer.VIEW_ID, null, vsh.getFullURL(evalViewParams))); } // Add all the groups and hierarchy nodes back to the UISelect Many's. see // the large comment further up. evalGroupsSelect.optionlist = UIOutputMany.make(evalGroupsValues.toArray(new String[] {})); evalGroupsSelect.optionnames = UIOutputMany.make(evalGroupsLabels.toArray(new String[] {})); hierarchyNodesSelect.optionlist = UIOutputMany.make(hierNodesValues.toArray(new String[] {})); hierarchyNodesSelect.optionnames = UIOutputMany.make(hierNodesLabels.toArray(new String[] {})); form.parameters.add(new UIELBinding(actionBean + "evaluationId", evalViewParams.evaluationId)); UIMessage.make(form, "back-button", "general.back.button"); if (useSelectionOptions) { UIOutput.make(tofill, "JS-facebox"); UIOutput.make(tofill, "JS-facebox-assign"); UIOutput.make(tofill, "JS-assign"); UIMessage.make(form, "select-column-title", "assignselect.page.column.title"); form.type = EarlyRequestParser.ACTION_REQUEST; UICommand.make(form, "confirmAssignCourses", UIMessage.make("evaluationassignconfirm.done.button"), actionBean + "completeConfirmAction"); } else { // this is a get form which does not submit to a backing bean EvalViewParameters formViewParams = (EvalViewParameters) evalViewParams.copyBase(); formViewParams.viewID = EvaluationAssignConfirmProducer.VIEW_ID; form.viewparams = formViewParams; form.type = EarlyRequestParser.RENDER_REQUEST; // all command buttons are just HTML now so no more bindings UIMessage assignButton = UIMessage.make(form, "confirmAssignCourses", "assigneval.save.assigned.button"); // activate the adhoc groups deletion javascript if (useAdHocGroups) { UIInitBlock.make(tofill, "initJavaScriptAdhoc", "EvalSystem.initEvalAssignAdhocDelete", new Object[] { adhocGroupRowIds }); } // Error message to be triggered by javascript if users doesn't select anything // There is a 'evalgroupselect' class on each input checkbox that the JS // can check for now. UIMessage assignErrorDiv = UIMessage.make(tofill, "nogroups-error", "assigneval.invalid.selection"); boolean anonymousAllowed = false; if (EvalConstants.EVALUATION_AUTHCONTROL_NONE.equals(evaluation.getAuthControl())) { anonymousAllowed = true; } UIInitBlock.make(tofill, "initJavaScript", "EvalSystem.initEvalAssignValidation", new Object[] { form.getFullID(), assignErrorDiv.getFullID(), assignButton.getFullID(), anonymousAllowed }); } }
From source file:org.mifos.framework.util.helpers.DateUtils.java
public static String getCurrentDate() throws InvalidDateException { Calendar currentCalendar = getCurrentDateCalendar(); java.sql.Date currentDate = new java.sql.Date(currentCalendar.getTimeInMillis()); SimpleDateFormat format = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, internalLocale); String userfmt = convertToCurrentDateFormat(format.toPattern()); return convertDbToUserFmt(currentDate.toString(), userfmt); }
From source file:org.olat.core.util.Formatter.java
License:asdf
/** * formats the given time period so it is friendly to read * /* w w w .java 2 s.co m*/ * @param d the date * @return a String with the formatted time */ public String formatTimeShort(Date d) { DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, locale); df.setLenient(false); String da = df.format(d); return da; }
From source file:org.exoplatform.platform.portlet.juzu.calendar.CalendarPortletController.java
private String formatDate(Locale locale) { String datePattern = ""; DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.SHORT, locale); // convert to unique pattern datePattern = ((SimpleDateFormat) dateFormat).toPattern(); if (!datePattern.contains("yy")) { datePattern = datePattern.replaceAll("y", "yy"); }/* ww w .j a v a 2s . c o m*/ if (!datePattern.contains("yyyy")) { datePattern = datePattern.replaceAll("yy", "yyyy"); } if (!datePattern.contains("dd")) { datePattern = datePattern.replaceAll("d", "dd"); } if (!datePattern.contains("MM")) { datePattern = datePattern.replaceAll("M", "MM"); } return datePattern; }
From source file:useraccess.ejb.RegistrationBean.java
/** * Notifies by email to the validator users the new registration. * /*from w ww.ja v a 2 s . c om*/ */ public void notifyNewValidationNeeded() { //Gets the email addresses for admin users String emailList = getAdminsEmails(); if (emailList != null) { String subject = "Nuevos registros en ECUSA"; DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); Date timeStamp = new Date(); String messageBody = "Se han producido nuevos registros en ECUSA el " + dateFormatter.format(timeStamp) + ".\n" + "Dichos registros estn disponibles para su validacin.\n" + "\n Saludos."; this.mailSender.sendMail(emailList, subject, messageBody); } }
From source file:org.helianto.core.domain.IdentitySecurity.java
public String getLastModifiedDateAsString() { if (getLastModified() == null) { return ""; }//w w w . j a v a2 s . c om DateFormat formatter = SimpleDateFormat.getDateInstance(DateFormat.SHORT); return formatter.format(getLastModified()); }
From source file:org.sakaiproject.poll.tool.producers.PollToolProducer.java
public void fillComponents(UIContainer tofill, ViewParameters viewparams, ComponentChecker checker) { voteBean.setPoll(null);// www . j ava 2 s.co m voteBean.voteCollection = null; String locale = localegetter.get().toString(); Map<String, String> langMap = new HashMap<String, String>(); langMap.put("lang", locale); langMap.put("xml:lang", locale); UIOutput.make(tofill, "polls-html", null).decorate(new UIFreeAttributeDecorator(langMap)); UIOutput.make(tofill, "poll-list-title", messageLocator.getMessage("poll_list_title")); boolean renderDelete = false; //populate the action links if (this.isAllowedPollAdd() || this.isSiteOwner()) { UIBranchContainer actions = UIBranchContainer.make(tofill, "actions:", Integer.toString(0)); LOG.debug("this user has some admin functions"); if (this.isAllowedPollAdd()) { LOG.debug("User can add polls"); //UIOutput.make(tofill, "poll-add", messageLocator // .getMessage("action_add_poll")); UIInternalLink.make(actions, NAVIGATE_ADD, UIMessage.make("action_add_poll"), new PollViewParameters(AddPollProducer.VIEW_ID, "New 0")); } if (this.isSiteOwner()) { UIInternalLink.make(actions, NAVIGATE_PERMISSIONS, UIMessage.make("action_set_permissions"), new SimpleViewParameters(PermissionsProducer.VIEW_ID)); } } List<Poll> polls = new ArrayList<Poll>(); String siteId = externalLogic.getCurrentLocationId(); if (siteId != null) { polls = pollListManager.findAllPolls(siteId); } else { LOG.warn("Unable to get siteid!"); } if (polls.isEmpty()) { UIOutput.make(tofill, "no-polls", messageLocator.getMessage("poll_list_empty")); UIOutput.make(tofill, "add-poll-icon"); if (this.isAllowedPollAdd()) { UIInternalLink.make(tofill, "add-poll", UIMessage.make("new_poll_title"), new PollViewParameters(AddPollProducer.VIEW_ID, "New 0")); } } else { // fix for broken en_ZA locale in JRE http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6488119 Locale M_locale = null; String langLoc[] = localegetter.get().toString().split("_"); if (langLoc.length >= 2) { if ("en".equals(langLoc[0]) && "ZA".equals(langLoc[1])) M_locale = new Locale("en", "GB"); else M_locale = new Locale(langLoc[0], langLoc[1]); } else { M_locale = new Locale(langLoc[0]); } DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, M_locale); TimeZone tz = externalLogic.getLocalTimeZone(); df.setTimeZone(tz); //m_log.debug("got timezone: " + tz.getDisplayName()); UIOutput.make(tofill, "poll_list_remove_confirm", messageLocator.getMessage("poll_list_remove_confirm")); UIOutput.make(tofill, "poll_list_reset_confirm", messageLocator.getMessage("poll_list_reset_confirm")); UIForm deleteForm = UIForm.make(tofill, "delete-poll-form"); // Create a multiple selection control for the tasks to be deleted. // We will fill in the options at the loop end once we have collected them. UISelect deleteselect = UISelect.makeMultiple(deleteForm, "delete-poll", null, "#{pollToolBean.deleteids}", new String[] {}); //get the headers for the table /*UIMessage.make(deleteForm, "poll-question-title","poll_question_title"); UIMessage.make(deleteForm, "poll-open-title", "poll_open_title"); UIMessage.make(deleteForm, "poll-close-title", "poll_close_title");*/ UIMessage.make(deleteForm, "poll-result-title", "poll_result_title"); UIMessage.make(deleteForm, "poll-remove-title", "poll_remove_title"); UILink question = UILink.make(tofill, "poll-question-title", messageLocator.getMessage("poll_question_title"), "#"); question.decorators = new DecoratorList( new UITooltipDecorator(messageLocator.getMessage("poll_question_title_tooltip"))); UILink open = UILink.make(tofill, "poll-open-title", messageLocator.getMessage("poll_open_title"), "#"); open.decorators = new DecoratorList( new UITooltipDecorator(messageLocator.getMessage("poll_open_title_tooltip"))); UILink close = UILink.make(tofill, "poll-close-title", messageLocator.getMessage("poll_close_title"), "#"); close.decorators = new DecoratorList( new UITooltipDecorator(messageLocator.getMessage("poll_close_title_tooltip"))); StringList deletable = new StringList(); for (int i = 0; i < polls.size(); i++) { Poll poll = (Poll) polls.get(i); boolean canVote = pollVoteManager.pollIsVotable(poll); UIBranchContainer pollrow = UIBranchContainer.make(deleteForm, canVote ? "poll-row:votable" : "poll-row:nonvotable", poll.getPollId().toString()); LOG.debug("adding poll row for " + poll.getText()); if (canVote) { UIInternalLink voteLink = UIInternalLink.make(pollrow, NAVIGATE_VOTE, poll.getText(), new PollViewParameters(PollVoteProducer.VIEW_ID, poll.getPollId().toString())); //we need to add a decorator for the alt text voteLink.decorators = new DecoratorList(new UITooltipDecorator( messageLocator.getMessage("poll_vote_title") + ":" + poll.getText())); } else { //the poll is lazily loaded so get the options poll.setOptions(pollListManager.getOptionsForPoll(poll.getPollId())); //is this not votable because of no options? if (poll.getPollOptions().size() == 0) UIOutput.make(pollrow, "poll-text", poll.getText() + " (" + messageLocator.getMessage("poll_no_options") + ")"); else UIOutput.make(pollrow, "poll-text", poll.getText()); } if (pollListManager.isAllowedViewResults(poll, externalLogic.getCurrentUserId())) { UIInternalLink resultsLink = UIInternalLink.make(pollrow, "poll-results", messageLocator.getMessage("action_view_results"), new PollViewParameters(ResultsProducer.VIEW_ID, poll.getPollId().toString())); resultsLink.decorators = new DecoratorList(new UITooltipDecorator( messageLocator.getMessage("action_view_results") + ":" + poll.getText())); } if (poll.getVoteOpen() != null) UIOutput.make(pollrow, "poll-open-date", df.format(poll.getVoteOpen())).decorators = new DecoratorList( new UIFreeAttributeDecorator("name", "realDate:" + poll.getVoteOpen().toString())); else UIVerbatim.make(pollrow, "poll-open-date", " "); if (poll.getVoteClose() != null) UIOutput.make(pollrow, "poll-close-date", df.format(poll.getVoteClose())).decorators = new DecoratorList( new UIFreeAttributeDecorator("name", "realDate:" + poll.getVoteClose().toString())); else UIVerbatim.make(pollrow, "poll-close-date", " "); if (pollCanEdit(poll)) { UIInternalLink editLink = UIInternalLink.make(pollrow, "poll-revise", messageLocator.getMessage("action_revise_poll"), new PollViewParameters(AddPollProducer.VIEW_ID, poll.getPollId().toString())); editLink.decorators = new DecoratorList(new UITooltipDecorator( messageLocator.getMessage("action_revise_poll") + ":" + poll.getText())); } if (pollCanDelete(poll)) { deletable.add(poll.getPollId().toString()); UISelectChoice delete = UISelectChoice.make(pollrow, "poll-select", deleteselect.getFullID(), (deletable.size() - 1)); delete.decorators = new DecoratorList(new UITooltipDecorator( UIMessage.make("delete_poll_tooltip", new String[] { poll.getText() }))); UIMessage message = UIMessage.make(pollrow, "delete-label", "delete_poll_tooltip", new String[] { poll.getText() }); UILabelTargetDecorator.targetLabel(message, delete); LOG.debug("this poll can be deleted"); renderDelete = true; } } deleteselect.optionlist.setValue(deletable.toStringArray()); deleteForm.parameters.add(new UIELBinding("#{pollToolBean.siteID}", siteId)); if (renderDelete) UICommand.make(deleteForm, "delete-polls", UIMessage.make("poll_list_delete"), "#{pollToolBean.processActionDelete}").decorators = new DecoratorList( new UITooltipDecorator(messageLocator.getMessage("poll_list_delete_tooltip"))); UICommand.make(deleteForm, "reset-polls-votes", UIMessage.make("poll_list_reset"), "#{pollToolBean.processActionResetVotes}").decorators = new DecoratorList( new UITooltipDecorator(messageLocator.getMessage("poll_list_reset_tooltip"))); } }