Java Code Examples for org.apache.wicket.model.StringResourceModel

The following examples show how to use org.apache.wicket.model.StringResourceModel. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: inception   Source File: KnowledgeBaseDetailsPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void actionDelete(AjaxRequestTarget aTarget)
{
    // delete only if user confirms deletion
    confirmationDialog
        .setTitleModel(new StringResourceModel("kb.details.delete.confirmation.title", this));
    confirmationDialog.setContentModel(
        new StringResourceModel("kb.details.delete.confirmation.content", this,
            kbwModel.bind("kb")));
    confirmationDialog.show(aTarget);
    confirmationDialog.setConfirmAction(_target -> {
        KnowledgeBase kb = kbwModel.getObject().getKb();
        try {
            kbService.removeKnowledgeBase(kb);
            kbwModel.getObject().setKb(null);
            modelChanged();
        }
        catch (RepositoryException | RepositoryConfigException e) {
            error("Unable to remove knowledge base: " + e.getLocalizedMessage());
            log.error("Unable to remove knowledge base.", e);
            _target.addChildren(getPage(), IFeedback.class);

        }
        _target.add(this);
        _target.add(findParentWithAssociatedMarkup());
    });
}
 
Example 2
Source Project: Orienteer   Source File: BasePage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	TransparentWebMarkupContainer body;
	add(body = new TransparentWebMarkupContainer("body"));
	body.add(new AttributeAppender("class", " "+getBodyAppSubClasses()));

	if(get("title")==null) add(new Label("title", getTitleModel()).add(UpdateOnActionPerformedEventBehavior.INSTANCE_ALWAYS_FOR_CHANGING));
	IModel<String> poweredByModel = new StringResourceModel("poweredby").setParameters(
			OrienteerWebApplication.get().getVersion(), OrienteerWebSession.get().isSignedIn() ? OrienteerWebApplication.get().getLoadModeInfo() : "");
	if(get("modulesFailed")==null) add(new OModulesLoadFailedPanel("modulesFailed"));
	if(get("poweredBy")==null) add(new Label("poweredBy", poweredByModel).setEscapeModelStrings(false));
	if(get("footer")==null) add(new Label("footer", new PropertyModel<List<ODocument>>(new PropertyModel<ODocument>(this, "perspective"), "footer"))
								.setEscapeModelStrings(false).setRenderBodyOnly(true));
	if(get("indicator")==null) add(new AjaxIndicator("indicator"));
	//add(new BodyTagAttributeModifier("class", Model.of("sidebar"), this));
}
 
Example 3
Source Project: openmeetings   Source File: InstallWizard.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onSubmit() {
	try {
		ConnectionPropertiesPatcher.patch(getModelObject());
		XmlWebApplicationContext ctx = (XmlWebApplicationContext)getWebApplicationContext(Application.get().getServletContext());
		if (ctx == null) {
			form.error(new StringResourceModel("install.wizard.db.step.error.patch", InstallWizard.this).setParameters("Web context is NULL").getObject());
			log.error("Web context is NULL");
			return;
		}
		LocalEntityManagerFactoryBean emb = ctx.getBeanFactory().getBean(LocalEntityManagerFactoryBean.class);
		emb.afterPropertiesSet();
		dbType = getModelObject().getDbType();
	} catch (Exception e) {
		form.error(new StringResourceModel("install.wizard.db.step.error.patch", InstallWizard.this).setParameters(e.getMessage()).getObject());
		log.error("error while patching", e);
	}
}
 
Example 4
Source Project: webanno   Source File: TagSetEditorPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void actionDelete(AjaxRequestTarget aTarget) {
    confirmationDialog.setContentModel(new StringResourceModel("DeleteDialog.text", this)
            .setParameters(selectedTagSet.getObject().getName()));
    confirmationDialog.show(aTarget);
    
    confirmationDialog.setConfirmAction((_target) -> {
        // If the tagset is used in any features, clear the tagset on these features when
        // the tagset is deleted!
        for (AnnotationFeature ft : annotationSchemaService
                .listAnnotationFeature(selectedProject.getObject())) {
            if (ft.getTagset() != null && ft.getTagset().equals(selectedTagSet.getObject())) {
                ft.setTagset(null);
                annotationSchemaService.createFeature(ft);
            }
        }

        annotationSchemaService.removeTagSet(selectedTagSet.getObject());

        _target.add(getPage());
        actionCancel(_target);
    });
}
 
Example 5
Source Project: webanno   Source File: ExportDocumentDialog.java    License: Apache License 2.0 6 votes vote down vote up
public ExportDocumentDialog(String id, final IModel<AnnotatorState> aModel)
{
    super(id);
    
    state = aModel;

    setCookieName("modal-1");
    setInitialWidth(550);
    setInitialHeight(450);
    setResizable(true);
    setWidthUnit("px");
    setHeightUnit("px");
    setCssClassName("w_blue w_flex");
    showUnloadConfirmation(false);
    setTitle(new StringResourceModel("export"));
}
 
Example 6
Source Project: webanno   Source File: DocumentListPanel.java    License: Apache License 2.0 6 votes vote down vote up
public DocumentListPanel(String aId, IModel<Project> aProject)
{
    super(aId);
 
    setOutputMarkupId(true);
    
    project = aProject;
    selectedDocuments = new CollectionModel<>();

    Form<Void> form = new Form<>("form");
    add(form);
    
    overviewList = new ListMultipleChoice<>("documents");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("name"));
    overviewList.setModel(selectedDocuments);
    overviewList.setChoices(LambdaModel.of(this::listSourceDocuments));
    form.add(overviewList);

    confirmationDialog = new ConfirmationDialog("confirmationDialog");
    confirmationDialog.setTitleModel(new StringResourceModel("DeleteDialog.title", this));
    add(confirmationDialog);

    form.add(new LambdaAjaxButton<>("delete", this::actionDelete));
}
 
Example 7
Source Project: Orienteer   Source File: GraphNeighborsWidget.java    License: Apache License 2.0 6 votes vote down vote up
public GraphNeighborsWidget(String id, IModel<ODocument> model, IModel<ODocument> widgetDocumentModel) {
    super(id, model, widgetDocumentModel);

    IModel<DisplayMode> modeModel = DisplayMode.VIEW.asModel();
    OQueryDataProvider<ODocument> provider = new OQueryDataProvider<ODocument>("select expand(both().asSet()) from "+getModelObject().getIdentity());
    OClass commonParent = provider.probeOClass(20);
    if(commonParent==null) commonParent = getSchema().getClass("V");
    List<IColumn<ODocument, String>> columns = oClassIntrospector.getColumnsFor(commonParent, true, modeModel);
    GenericTablePanel<ODocument> tablePanel = new GenericTablePanel<ODocument>("neighbors", columns, provider, 20);
    OrienteerDataTable<ODocument, String> table = tablePanel.getDataTable();
    table.addCommand(new CreateVertexCommand(table, getModel()));
    table.addCommand(new CreateEdgeCommand(table, getModel()));
    table.addCommand(new UnlinkVertexCommand(table, getModel()));
    table.addCommand(new DeleteVertexCommand(table, getModel()));
    table.addCommand(new EditODocumentsCommand(table, modeModel, commonParent));
    table.addCommand(new SaveODocumentsCommand(table, modeModel));
    table.addCommand(new ExportCommand<>(table, new StringResourceModel("export.filename.neighbors", new ODocumentNameModel(model))));
    add(tablePanel);
    add(DisableIfDocumentNotSavedBehavior.INSTANCE,UpdateOnActionPerformedEventBehavior.INSTANCE_ALL_CONTINUE);
}
 
Example 8
Source Project: syncope   Source File: NotificationTaskDirectoryPanel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected List<IColumn<NotificationTaskTO, String>> getColumns() {
    final List<IColumn<NotificationTaskTO, String>> columns = new ArrayList<>();

    columns.add(new KeyPropertyColumn<>(
            new StringResourceModel(Constants.KEY_FIELD_NAME, this), Constants.KEY_FIELD_NAME));

    columns.add(new PropertyColumn<>(
            new StringResourceModel("sender", this), "sender", "sender"));

    columns.add(new PropertyColumn<>(
            new StringResourceModel("subject", this), "subject", "subject"));

    columns.add(new CollectionPropertyColumn<>(
            new StringResourceModel("recipients", this), "recipients"));

    columns.add(new DatePropertyColumn<>(
            new StringResourceModel("start", this), "start", "start"));

    columns.add(new DatePropertyColumn<>(
            new StringResourceModel("end", this), "end", "end"));

    columns.add(new PropertyColumn<>(
            new StringResourceModel("latestExecStatus", this), "latestExecStatus", "latestExecStatus"));
    return columns;
}
 
Example 9
Source Project: sakai   Source File: SakaiNavigatorLabel.java    License: Educational Community License v2.0 6 votes vote down vote up
private SakaiNavigatorLabel(final String id, final PageableComponent table) {
	super(id);
	Model model = new Model(new LabelModelObject(table)); 
	setDefaultModel(
			new StringResourceModel(
					"pager_textStatus", 
					this, 
					model,
					"Viewing {0} - {1} of {2} {3}",
					new Object[] {
						new PropertyModel(model, "from"),
						new PropertyModel(model, "to"),
						new PropertyModel(model, "of"),
						new ResourceModel("pager_textItem"),
					})
	);
}
 
Example 10
Source Project: sakai   Source File: KudosPanel.java    License: Educational Community License v2.0 6 votes vote down vote up
public KudosPanel(String id, final String ownerUserId, final String viewingUserId, final int score) {
	super(id);
	
	log.debug("KudosPanel()");
	
	//heading	
	Label heading = new Label("heading");
	
	if(viewingUserId.equals(ownerUserId)) {
		heading.setDefaultModel(new ResourceModel("heading.widget.my.kudos"));
	} else {
		String displayName = sakaiProxy.getUserDisplayName(ownerUserId);
		heading.setDefaultModel(new StringResourceModel("heading.widget.view.kudos", null, new Object[]{ displayName } ));
	}
	add(heading);
	
	//score
	add(new Label("kudosRating", String.valueOf(score)));
	
	String img = getImage(score);
	
	//images
	add(new ContextImage("kudosImgLeft", img));
	add(new ContextImage("kudosImgRight", img));

}
 
Example 11
/**
 * Helper to format the points display
 *
 * @param courseGrade the {@link CourseGrade}
 * @param gradebook the {@link Gradebook} which has the settings
 * @return fully formatted string ready for display
 */
private String formatPoints(final CourseGrade courseGrade, final Gradebook gradebook) {

	String rval;

	// only display points if not weighted category type
	final GbCategoryType categoryType = GbCategoryType.valueOf(gradebook.getCategory_type());
	if (categoryType != GbCategoryType.WEIGHTED_CATEGORY) {

		final Double pointsEarned = courseGrade.getPointsEarned();
		final Double totalPointsPossible = courseGrade.getTotalPointsPossible();

		if (pointsEarned != null && totalPointsPossible != null) {
			rval = new StringResourceModel("coursegrade.display.points-first", null,
					new Object[] { pointsEarned, totalPointsPossible }).getString();
		} else {
			rval = getString("coursegrade.display.points-none");
		}
	} else {
		rval = getString("coursegrade.display.points-none");
	}

	return rval;

}
 
Example 12
Source Project: syncope   Source File: PushPolicyDirectoryPanel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void addCustomActions(final ActionsPanel<PushPolicyTO> panel, final IModel<PushPolicyTO> model) {
    panel.add(new ActionLink<PushPolicyTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final PushPolicyTO ignore) {
            target.add(policySpecModal.setContent(
                    new ProvisioningPolicyModalPanel(model.getObject(), policySpecModal, pageRef)));

            policySpecModal.header(new StringResourceModel(
                    "policy.rules", PushPolicyDirectoryPanel.this, Model.of(model.getObject())));

            MetaDataRoleAuthorizationStrategy.authorize(
                    policySpecModal.getForm(), ENABLE, IdRepoEntitlement.POLICY_UPDATE);

            policySpecModal.show(true);
        }
    }, ActionLink.ActionType.COMPOSE, IdRepoEntitlement.POLICY_UPDATE);
}
 
Example 13
Source Project: syncope   Source File: NotificationDirectoryPanel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected List<IColumn<NotificationTO, String>> getColumns() {
    List<IColumn<NotificationTO, String>> columns = new ArrayList<>();
    columns.add(new KeyPropertyColumn<>(
            new StringResourceModel(Constants.KEY_FIELD_NAME, this), Constants.KEY_FIELD_NAME));
    columns.add(new PropertyColumn<>(
            new StringResourceModel("sender", this), "sender", "sender"));
    columns.add(new PropertyColumn<>(
            new StringResourceModel("subject", this), "subject", "subject"));
    columns.add(new PropertyColumn<>(
            new StringResourceModel("template", this), "template", "template"));
    columns.add(new CollectionPropertyColumn<>(
            new StringResourceModel("events", this), "events"));
    columns.add(new BooleanPropertyColumn<>(
            new StringResourceModel("active", this), "active", "active"));
    return columns;
}
 
Example 14
protected Label newNavigatorLabel(final String id, final InfinitePagingDataTable<?, ?> table)
{
	return new Label(id, "")
	{

		@Override
		public void onConfigure()
		{
			long startRecord = table.getOffset();
			long rowCount = table.getRowCount();
			long endRecord = startRecord + rowCount;
			if (rowCount > 0)
			{
				++startRecord;
			}

			setDefaultModel(new StringResourceModel("paging_nav_label", table, new Model<>(), new ResourceModel("pager_textItem"), startRecord, endRecord));
		}
	};
}
 
Example 15
Source Project: syncope   Source File: SchedTasks.java    License: Apache License 2.0 6 votes vote down vote up
public <T extends AnyTO> SchedTasks(final BaseModal<?> baseModal, final PageReference pageReference) {
    super(BaseModal.CONTENT_ID);

    final MultilevelPanel mlp = new MultilevelPanel("tasks");
    add(mlp);

    mlp.setFirstLevel(new SchedTaskDirectoryPanel<SchedTaskTO>(
            baseModal, mlp, TaskType.SCHEDULED, SchedTaskTO.class, pageReference) {

        private static final long serialVersionUID = -2195387360323687302L;

        @Override
        protected void viewTask(final SchedTaskTO taskTO, final AjaxRequestTarget target) {
            mlp.next(
                    new StringResourceModel("task.view", this, new Model<>(Pair.of(null, taskTO))).getObject(),
                    new TaskExecutionDetails<>(baseModal, taskTO, pageReference), target);
        }
    });
}
 
Example 16
Source Project: syncope   Source File: PushTasks.java    License: Apache License 2.0 6 votes vote down vote up
public <T extends AnyTO> PushTasks(
        final BaseModal<?> baseModal, final PageReference pageReference, final String resource) {
    super(BaseModal.CONTENT_ID);

    final MultilevelPanel mlp = new MultilevelPanel("tasks");
    add(mlp);

    mlp.setFirstLevel(new PushTaskDirectoryPanel(baseModal, mlp, resource, pageReference) {

        private static final long serialVersionUID = -2195387360323687302L;

        @Override
        protected void viewTask(final PushTaskTO taskTO, final AjaxRequestTarget target) {
            mlp.next(
                    new StringResourceModel("task.view", this, new Model<>(Pair.of(null, taskTO))).getObject(),
                    new TaskExecutionDetails<>(baseModal, taskTO, pageReference), target);
        }
    });
}
 
Example 17
/**
 * Helper to format a grade log entry
 *
 * @param gradeLog
 * @return
 */
private String formatLogEntry(final GbGradeLog gradeLog) {

	final String logDate = FormatHelper.formatDateTime(gradeLog.getDateGraded());
	final String grade = gradeLog.getGrade();

	final GbUser grader = CourseGradeOverrideLogPanel.this.businessService.getUser(gradeLog.getGraderUuid());
	final String graderDisplayId = (grader != null) ? grader.getDisplayName() + " (" +  grader.getDisplayId() + ")" : getString("unknown.user.id");

	String rval;

	// if no grade, it is a reset
	if (StringUtils.isNotBlank(grade)) {
		rval = new StringResourceModel("coursegrade.log.entry.set", null, new Object[] { logDate, grade, graderDisplayId }).getString();
	} else {
		rval = new StringResourceModel("coursegrade.log.entry.unset", null, new Object[] { logDate, graderDisplayId }).getString();
	}

	return rval;

}
 
Example 18
Source Project: syncope   Source File: JobWidget.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ActionsPanel<ExecTO> getActions(final IModel<ExecTO> model) {
    final ActionsPanel<ExecTO> panel = super.getActions(model);

    panel.add(new ActionLink<ExecTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final ExecTO ignore) {
            detailModal.header(new StringResourceModel("execution.view", JobWidget.this, model));
            detailModal.setContent(new ExecMessageModal(model.getObject().getMessage()));
            detailModal.show(true);
            target.add(detailModal);
        }
    }, ActionLink.ActionType.VIEW, IdRepoEntitlement.TASK_READ);
    return panel;
}
 
Example 19
Source Project: inception   Source File: KnowledgeBaseCreationDialog.java    License: Apache License 2.0 5 votes vote down vote up
public KnowledgeBaseCreationDialog(String aId, IModel<Project> aProjectModel) {
    super(aId, aProjectModel);
    
    setOutputMarkupPlaceholderTag(true);
    
    projectModel = aProjectModel;

    setInitialWidth(675);
    setInitialHeight(450);
    setResizable(false);
    setWidthUnit("px");
    setHeightUnit("px");
    setTitle(new StringResourceModel("kb.wizard.title", this));
    setCssClassName("w_blue w_flex");
}
 
Example 20
Source Project: syncope   Source File: NetworkServiceDirectoryPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected List<IColumn<NetworkService, String>> getColumns() {
    List<IColumn<NetworkService, String>> columns = new ArrayList<>();

    columns.add(new PropertyColumn<>(new StringResourceModel("address", this), "address", "address"));

    return columns;
}
 
Example 21
Source Project: syncope   Source File: SAML2IdPWizardBuilder.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Serializable onApplyInternal(final SAML2IdPTO modelObject) {
    long connObjectKeyCount = modelObject.getItems().stream().filter(ItemTO::isConnObjectKey).count();
    if (connObjectKeyCount != 1) {
        throw new IllegalArgumentException(
                new StringResourceModel("connObjectKeyValidation", directoryPanel).getString());
    }

    SAML2IdPsRestClient.update(modelObject);
    return modelObject;
}
 
Example 22
Source Project: syncope   Source File: ReportTemplateDirectoryPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected List<IColumn<ReportTemplateTO, String>> getColumns() {
    List<IColumn<ReportTemplateTO, String>> columns = new ArrayList<>();
    columns.add(new PropertyColumn<>(
            new StringResourceModel(Constants.KEY_FIELD_NAME, this),
            Constants.KEY_FIELD_NAME, Constants.KEY_FIELD_NAME));
    return columns;
}
 
Example 23
Source Project: inception   Source File: ProjectsOverviewPage.java    License: Apache License 2.0 5 votes vote down vote up
public ProjectsOverviewPage()
{
    add(projectListContainer = createProjectList());
    add(createNewProjectLink());
    add(createStartTutorialLink());
    add(createImportProjectForm());
    add(roleFilters = createRoleFilters());
    add(confirmLeaveDialog = new ConfirmationDialog(MID_CONFIRM_LEAVE,
            new StringResourceModel("leaveDialog.title", this),
            new StringResourceModel("leaveDialog.text", this)));
    activeRoleFilters = Model.ofSet(new HashSet<>());
    
    emptyListLabel = new Label(MID_EMPTY_LIST_LABEL, new ResourceModel("noProjects"));
    projectListContainer.add(emptyListLabel);
}
 
Example 24
Source Project: inception   Source File: SearchAnnotationSidebar.java    License: Apache License 2.0 5 votes vote down vote up
private CheckBox createLowLevelPagingCheckBox()
{
    CheckBox checkbox = new CheckBox("lowLevelPaging");
    checkbox.setOutputMarkupId(true);
    checkbox.add(enabledWhen(() -> searchOptions.getObject().getGroupingLayer() == null
            && searchOptions.getObject().getGroupingFeature() == null));
    checkbox.add(AttributeModifier.append("title",
        new StringResourceModel("lowLevelPagingMouseover", this)));
    return checkbox;
}
 
Example 25
Source Project: yes-cart   Source File: WicketUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create parametrized string resource model for wicket. (i.e. "The ${animal} jumped over the ${target}.")
 *
 * @param component component to provide resources
 * @param resourceKey key
 * @param parameters parameters which are specified by ${name} placeholders in the resource key
 *
 * @return parametrized label
 */
public static StringResourceModel createStringResourceModel(final Component component,
                                                            final String resourceKey,
                                                            final Map<String, Object> parameters) {
    if (parameters != null) {
        final ValueMap params = new ValueMap(parameters);
        return new StringResourceModel(resourceKey, component, new Model<>(params));
    }
    return new StringResourceModel(resourceKey, component, null);
}
 
Example 26
Source Project: sakai   Source File: LastJobRun.java    License: Educational Community License v2.0 5 votes vote down vote up
private void renderBody() {
	StatsManager statsManager = Locator.getFacade().getStatsManager();
	StatsUpdateManager statsUpdateManager = Locator.getFacade().getStatsUpdateManager();
	
	setRenderBodyOnly(true);
	
	final WebMarkupContainer lastJobRun = new WebMarkupContainer("lastJobRun");
	boolean lastJobRunVisible = !statsUpdateManager.isCollectThreadEnabled() && statsManager.isLastJobRunDateVisible(); 
	lastJobRun.setVisible(lastJobRunVisible);
	add(lastJobRun);
	final Label lastJobRunDate = new Label("lastJobRunDate");
	final Label lastJobRunServerDate = new Label("lastJobRunServerDate");
	if(lastJobRunVisible) {
		try{
			Date d = statsUpdateManager.getEventDateFromLatestJobRun();
			UserTimeService timeServ = Locator.getFacade().getUserTimeService();
			String dStr = timeServ.shortLocalizedTimestamp(d.toInstant(), getSession().getLocale());
			String serverDateStr = timeServ.shortLocalizedTimestamp(d.toInstant(), TimeZone.getDefault(), getSession().getLocale());
			lastJobRunDate.setDefaultModel(new Model(dStr));
			String localSakaiName = Locator.getFacade().getStatsManager().getLocalSakaiName();
			StringResourceModel model = new StringResourceModel("lastJobRun_server_time", getPage(), null,
					new Object[] {localSakaiName, serverDateStr});
			lastJobRunServerDate.setDefaultModel(model);
		}catch(Exception e){
			lastJobRunDate.setDefaultModel(new Model());
			lastJobRunServerDate.setDefaultModel(new Model());
		}
	}
	lastJobRun.add(lastJobRunDate);
	lastJobRun.add(lastJobRunServerDate);
}
 
Example 27
Source Project: yes-cart   Source File: WishListView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onBeforeRender() {

    boolean oldOwnerViewing = ownerViewing;
    ownerViewing = !getPage().getPageParameters().getNamedKeys().contains("token") && customerEmail.getObject() != null && customerEmail.getObject().equals(getCurrentCart().getCustomerEmail());
    if (ownerViewing != oldOwnerViewing) {
        products = null; // reset products just in case
    }
    addOrReplace(new Label("noProducts", new StringResourceModel("wishlistNoItems", this, null)).setVisible(getProductListToShow().isEmpty()));
    super.onBeforeRender();
}
 
Example 28
Source Project: yes-cart   Source File: ShippingView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Add shipping price view to given form if shipping method is selected.
 *
 * @param form given form.
 */
private void addPriceView(final Form form) {

    final ShoppingCart cart = getCurrentCart();
    final Total total = cart.getTotal();
    final Long slaId = cart.getCarrierSlaId().get(this.supplier);

    if (slaId == null) {
        form.addOrReplace(new Label(PRICE_LABEL));
        form.addOrReplace(new Label(PRICE_VIEW));
    } else {
        final PriceModel model = shippingServiceFacade.getCartShippingSupplierTotal(cart, this.supplier);

        form.addOrReplace(new Label(PRICE_LABEL, new StringResourceModel(PRICE_LABEL, this)));
        form.addOrReplace(
                new PriceView(
                        PRICE_VIEW,
                        model,
                        total.getAppliedDeliveryPromo(), true, true,
                        model.isTaxInfoEnabled(), model.isTaxInfoShowAmount(),
                        true
                )
        );

    }

}
 
Example 29
Source Project: yes-cart   Source File: ProductSorter.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Construct product sorter.
 * @param id component id.
 * @param items sort options.
 */
public ProductSorter(final String id,
                     final List<String> items) {
    super(id);

    add(new ListView<String>(PAGE_SORT, items) {
        /**
         * {@inheritDoc}
         */
        @Override
        protected void populateItem(final ListItem<String> stringSortOption) {

            final ShoppingCart cart = getCurrentCart();

            ProductSortingUtils.SupportedSorting sort = ProductSortingUtils.getConfiguration(stringSortOption.getModelObject());
            final boolean supported = sort != null;
            if (!supported) {
                sort = ProductSortingUtils.NULL_SORT;
            }

            stringSortOption.setVisible(supported);

            final String labelKey = sort.resolveLabelKey(cart.getShoppingContext().getShopId(), cart.getCurrentLocale(), cart.getCurrencyCode());
            stringSortOption.add(new Label(SORT_LABEL, new StringResourceModel(labelKey, this, null)));

            final String sortField = sort.resolveSortField(cart.getShoppingContext().getShopId(), cart.getCurrentLocale(), cart.getCurrencyCode());

            stringSortOption.add(getSortLink(SORT_A, WebParametersKeys.SORT, sortField));
            stringSortOption.add(getSortLink(SORT_D, WebParametersKeys.SORT_REVERSE, sortField));

        }
    });

}
 
Example 30
public AnnotatorWorkflowActionBarItemGroup(String aId, AnnotationPageBase aPage)
{
    super(aId);

    page = aPage;

    add(finishDocumentDialog = new ConfirmationDialog("finishDocumentDialog",
            new StringResourceModel("FinishDocumentDialog.title", this, null),
            new StringResourceModel("FinishDocumentDialog.text", this, null)));
    
    add(finishDocumentLink = new LambdaAjaxLink("showFinishDocumentDialog",
            this::actionFinishDocument));
    finishDocumentLink.setOutputMarkupId(true);
    finishDocumentLink.add(enabledWhen(() -> page.isEditable()));
    finishDocumentLink.add(new Label("state")
            .add(new CssClassNameModifier(LambdaModel.of(this::getStateClass))));

    IModel<String> documentNameModel = PropertyModel.of(page.getModel(), "document.name");
    add(resetDocumentDialog = new ChallengeResponseDialog("resetDocumentDialog",
            new StringResourceModel("ResetDocumentDialog.title", this),
            new StringResourceModel("ResetDocumentDialog.text", this)
                    .setModel(page.getModel()).setParameters(documentNameModel),
            documentNameModel));
    resetDocumentDialog.setConfirmAction(this::actionResetDocument);

    add(resetDocumentLink = new LambdaAjaxLink("showResetDocumentDialog",
            resetDocumentDialog::show));
    resetDocumentLink.add(enabledWhen(() -> page.isEditable()));
}