Search in sources :

Example 1 with PatternDateConverter

use of org.apache.wicket.datetime.PatternDateConverter in project midpoint by Evolveum.

the class TaskSummaryPanel method getTitle3Model.

@Override
protected IModel<String> getTitle3Model() {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (parentPage.getTaskDto().isWorkflow()) {
                String stageInfo = getStageInfo();
                if (stageInfo != null) {
                    return getString("TaskSummaryPanel.stage", stageInfo);
                } else {
                    return null;
                }
            }
            TaskType taskType = getModel().getObject();
            if (taskType == null) {
                return null;
            }
            long started = XmlTypeConverter.toMillis(taskType.getLastRunStartTimestamp());
            long finished = XmlTypeConverter.toMillis(taskType.getLastRunFinishTimestamp());
            if (started == 0) {
                return null;
            }
            if ((TaskExecutionStatus.RUNNABLE.equals(taskType.getExecutionStatus()) && taskType.getNodeAsObserved() != null) || finished == 0 || finished < started) {
                PatternDateConverter pdc = new PatternDateConverter(WebComponentUtil.getLocalizedDatePattern(DateLabelComponent.SHORT_MEDIUM_STYLE), true);
                String date = pdc.convertToString(new Date(started), WebComponentUtil.getCurrentLocale());
                return getString("TaskStatePanel.message.executionTime.notFinished", date, DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - started));
            } else {
                PatternDateConverter pdc = new PatternDateConverter(WebComponentUtil.getLocalizedDatePattern(DateLabelComponent.SHORT_MEDIUM_STYLE), true);
                String startedDate = pdc.convertToString(new Date(started), WebComponentUtil.getCurrentLocale());
                String finishedDate = pdc.convertToString(new Date(finished), WebComponentUtil.getCurrentLocale());
                return getString("TaskStatePanel.message.executionTime.finished", startedDate, finishedDate, DurationFormatUtils.formatDurationHMS(finished - started));
            }
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) PatternDateConverter(org.apache.wicket.datetime.PatternDateConverter) Date(java.util.Date)

Example 2 with PatternDateConverter

use of org.apache.wicket.datetime.PatternDateConverter in project qi4j-sdk by Qi4j.

the class DCISampleApplication_a method wicketInit.

public void wicketInit() {
    // Tabs and SEO urls
    mountPages();
    // Show/hide Ajax debugging
    getDebugSettings().setDevelopmentUtilitiesEnabled(true);
    // Check that components are stateless when required
    getComponentPostOnBeforeRenderListeners().add(new StatelessChecker());
    // Show/hide wicket tags in html code
    getMarkupSettings().setStripWicketTags(true);
    // Default date format (we don't care for now about the hour of the day)
    ((ConverterLocator) getConverterLocator()).set(Date.class, new PatternDateConverter("yyyy-MM-dd", true));
}
Also used : ConverterLocator(org.apache.wicket.ConverterLocator) PatternDateConverter(org.apache.wicket.datetime.PatternDateConverter) StatelessChecker(org.apache.wicket.devutils.stateless.StatelessChecker)

Example 3 with PatternDateConverter

use of org.apache.wicket.datetime.PatternDateConverter in project qi4j-sdk by Qi4j.

the class DCISampleApplication_b method wicketInit.

public void wicketInit() {
    // Tabs and SEO urls
    mountPages();
    // Show/hide Ajax debugging
    getDebugSettings().setDevelopmentUtilitiesEnabled(true);
    // Check that components are stateless when required
    getComponentPostOnBeforeRenderListeners().add(new StatelessChecker());
    // Show/hide wicket tags in html code
    getMarkupSettings().setStripWicketTags(true);
    // Default date format (we don't care for now about the hour of the day)
    ((ConverterLocator) getConverterLocator()).set(Date.class, new PatternDateConverter("yyyy-MM-dd", true));
}
Also used : ConverterLocator(org.apache.wicket.ConverterLocator) PatternDateConverter(org.apache.wicket.datetime.PatternDateConverter) StatelessChecker(org.apache.wicket.devutils.stateless.StatelessChecker)

Example 4 with PatternDateConverter

use of org.apache.wicket.datetime.PatternDateConverter in project midpoint by Evolveum.

the class DateInput method newDateTextField.

@Override
protected DateTextField newDateTextField(String id, PropertyModel dateFieldModel) {
    String localizedDatePattern = WebComponentUtil.getLocalizedDatePattern(DateLabelComponent.SHORT_NOTIME_STYLE);
    if (localizedDatePattern != null && !localizedDatePattern.contains("yyyy")) {
        localizedDatePattern = localizedDatePattern.replaceAll("yy", "yyyy");
    }
    DateTextField dateField = DateTextField.withConverter(id, dateFieldModel, new PatternDateConverter(localizedDatePattern, false));
    dateField.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            DateInput.this.setModelObject(computeDateTime());
            target.add(DateInput.this);
        }
    });
    return dateField;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) DateTextField(org.apache.wicket.datetime.markup.html.form.DateTextField) PatternDateConverter(org.apache.wicket.datetime.PatternDateConverter)

Aggregations

PatternDateConverter (org.apache.wicket.datetime.PatternDateConverter)4 ConverterLocator (org.apache.wicket.ConverterLocator)2 StatelessChecker (org.apache.wicket.devutils.stateless.StatelessChecker)2 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)1 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)1 Date (java.util.Date)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 DateTextField (org.apache.wicket.datetime.markup.html.form.DateTextField)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1