org.apache.wicket.model.StringResourceModel Java Examples

The following examples show how to use org.apache.wicket.model.StringResourceModel. 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 File: JobWidget.java    From syncope with 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 #2
Source File: BasePage.java    From Orienteer with 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 File: NotificationDirectoryPanel.java    From syncope with 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 #4
Source File: InstallWizard.java    From openmeetings with 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 #5
Source File: PushPolicyDirectoryPanel.java    From syncope with 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 #6
Source File: TagSetEditorPanel.java    From webanno with 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 #7
Source File: CourseGradeOverridePanel.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * 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 #8
Source File: SakaiInfinitePagingDataTableNavigationToolbar.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
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 #9
Source File: ExportDocumentDialog.java    From webanno with 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 #10
Source File: SchedTasks.java    From syncope with 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 #11
Source File: DocumentListPanel.java    From webanno with 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 #12
Source File: GraphNeighborsWidget.java    From Orienteer with 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 #13
Source File: PushTasks.java    From syncope with 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 #14
Source File: CourseGradeOverrideLogPanel.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * 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 #15
Source File: KnowledgeBaseDetailsPanel.java    From inception with 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 #16
Source File: SakaiNavigatorLabel.java    From sakai with 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 #17
Source File: NotificationTaskDirectoryPanel.java    From syncope with 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 #18
Source File: KudosPanel.java    From sakai with 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 #19
Source File: PasswordsPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	getForm().add(new EqualPasswordInputValidator(password, confirmPassword));
	IModel<String> labelModel = getLabel();
	password.add(new AttributeModifier("placeholder", new StringResourceModel("password.placeholder.enter", labelModel)));
	password.setLabel(labelModel);
	confirmPassword.add(new AttributeModifier("placeholder", new StringResourceModel("password.placeholder.confirm", labelModel)));
	confirmPassword.setLabel(new StringResourceModel("password.confirm.label", labelModel));
}
 
Example #20
Source File: PolicyRuleDirectoryPanel.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
protected List<IColumn<PolicyRuleWrapper, String>> getColumns() {
    final List<IColumn<PolicyRuleWrapper, String>> columns = new ArrayList<>();

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

    columns.add(new AbstractColumn<PolicyRuleWrapper, String>(
            new StringResourceModel("configuration", this)) {

        private static final long serialVersionUID = -4008579357070833846L;

        @Override
        public void populateItem(
                final Item<ICellPopulator<PolicyRuleWrapper>> cellItem,
                final String componentId,
                final IModel<PolicyRuleWrapper> rowModel) {

            if (rowModel.getObject().getConf() == null) {
                cellItem.add(new Label(componentId, ""));
            } else {
                cellItem.add(new Label(componentId, rowModel.getObject().getConf().getClass().getName()));
            }
        }
    });
    return columns;
}
 
Example #21
Source File: AnnotationDetailEditorPanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
public AnnotationDetailEditorPanel(String id, AnnotationPageBase aPage,
        IModel<AnnotatorState> aModel)
{
    super(id, new CompoundPropertyModel<>(aModel));
    
    editorPage = aPage;
    
    setOutputMarkupId(true);
    setOutputMarkupPlaceholderTag(true);
    setMarkupId("annotationDetailEditorPanel");
    
    add(createForwardAnnotationKeySequenceCapturingForm());
    
    add(deleteAnnotationDialog = new ConfirmationDialog("deleteAnnotationDialog",
            new StringResourceModel("DeleteDialog.title", this, null)));
    add(replaceAnnotationDialog = new ConfirmationDialog("replaceAnnotationDialog",
            new StringResourceModel("ReplaceDialog.title", this, null),
            new StringResourceModel("ReplaceDialog.text", this, null)));
    add(layerSelectionPanel = new LayerSelectionPanel("layerContainer", getModel(), this));
    add(selectedAnnotationInfoPanel = new AnnotationInfoPanel("infoContainer", getModel()));
    add(featureEditorListPanel = new FeatureEditorListPanel("featureEditorContainer",
            getModel(), this));
    
    buttonContainer = new WebMarkupContainer("buttonContainer");
    buttonContainer.setOutputMarkupPlaceholderTag(true);
    buttonContainer.add(createDeleteButton());
    buttonContainer.add(createReverseButton());
    buttonContainer.add(createClearButton());
    add(buttonContainer);
}
 
Example #22
Source File: AnnotatorWorkflowActionBarItemGroup.java    From webanno with Apache License 2.0 5 votes vote down vote up
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()));
}
 
Example #23
Source File: MergeLinkedAccountsReviewPanel.java    From syncope with Apache License 2.0 5 votes vote down vote up
public MergeLinkedAccountsReviewPanel(final MergeLinkedAccountsWizardModel wizardModel,
        final PageReference pageReference) {
    super();
    setOutputMarkupId(true);
    setTitleModel(new StringResourceModel("mergeLinkedAccounts.reviewAccounts.title"));
    add(new LinkedAccountsReviewDirectoryPanel("linkedAccounts", pageReference, wizardModel));
}
 
Example #24
Source File: GalleryImageRenderer.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Creates a new instance of <code>GalleryImageRenderer</code>.
 */
public GalleryImageRenderer(String id, String imageResourceId) {
	super(id);
	
	if (imageResourceId == null) {
		add(new ContextImage("img",new Model(ProfileConstants.UNAVAILABLE_IMAGE)));
		return;
	}
	else if (sakaiProxy.getResource(imageResourceId) == null) {
		// may have been deleted in CHS
		add(new ContextImage("img",new Model(ProfileConstants.UNAVAILABLE_IMAGE)));
		return;
	}

	final byte[] imageBytes = sakaiProxy.getResource(imageResourceId).getBytes();
	
	if (imageBytes != null && imageBytes.length > 0) {

		BufferedDynamicImageResource imageResource = new BufferedDynamicImageResource() {

			private static final long serialVersionUID = 1L;
			@Override
			protected byte[] getImageData(IResource.Attributes ignored) {
				return imageBytes;
			}
		};

		Image myPic = new Image("img", new Model(imageResource));
		myPic.add(new AttributeModifier("alt", new StringResourceModel("profile.gallery.image.alt",this,null).getString()));
		add(myPic);

	} else {
		add(new ContextImage("img",new Model(ProfileConstants.UNAVAILABLE_IMAGE)));
	}
}
 
Example #25
Source File: ViewFriends.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public ViewFriends(final String userUuid) {

        log.debug("ViewFriends()");

        //get user viewing this page
        final String currentUserUuid = sakaiProxy.getCurrentUserId();

        //check person viewing this page (currentuserId) is allowed to view userId's friends - unless admin
        boolean isFriendsListVisible = sakaiProxy.isSuperUser()
                    || privacyLogic.isActionAllowed(userUuid, currentUserUuid, PrivacyType.PRIVACY_OPTION_MYFRIENDS);

        if (isFriendsListVisible) {
            //show confirmed friends panel for the given user
            Panel confirmedFriends = new ConfirmedFriends("confirmedFriends", userUuid);
            confirmedFriends.setOutputMarkupId(true);
            add(confirmedFriends);

            //post view event
            sakaiProxy.postEvent(ProfileConstants.EVENT_FRIENDS_VIEW_OTHER, "/profile/"+userUuid, false);
        } else {
            log.debug("User: {} is not allowed to view the friends list for: {} ", currentUserUuid, userUuid);
            String displayName = sakaiProxy.getUserDisplayName(userUuid);
            Label notPermitted = new Label("confirmedFriends"
                        , new StringResourceModel("error.friend.view.disallowed", null, new Object[] {displayName}));
            add(notPermitted);
        }
	}
 
Example #26
Source File: BaseTreePage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected AjaxLink getExpandCollapseLink(){
	//Expand Collapse Link:
	final Label expandCollapse = new Label("expandCollapse", new StringResourceModel("exapndNodes", null));
	expandCollapse.setOutputMarkupId(true);
	AjaxLink expandLink  = new AjaxLink("expandAll")
	{
		boolean expand = true;
		@Override
		public void onClick(AjaxRequestTarget target)
		{
			if(expand){
				getTree().getTreeState().expandAll();
				expandCollapse.setDefaultModel(new StringResourceModel("collapseNodes", null));
				collapseEmptyFolders();
			}else{
				getTree().getTreeState().collapseAll();
				expandCollapse.setDefaultModel(new StringResourceModel("exapndNodes", null));
			}
			target.add(expandCollapse);
			getTree().updateTree(target);
			expand = !expand;

		}
		@Override
		public boolean isVisible() {
			return getTree().getDefaultModelObject() != null;
		}
	};
	expandLink.add(expandCollapse);
	return expandLink;
}
 
Example #27
Source File: ProductSorter.java    From yes-cart with 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 #28
Source File: NotFoundWidget.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public NotFoundWidget(String id, IModel<T> model,
		IModel<ODocument> widgetDocumentModel) {
	super(id, model, widgetDocumentModel);
	ODocument widgetDoc = widgetDocumentModel.getObject();
	add(new Label("error", new StringResourceModel("widget.error.notfound", widgetDocumentModel)
									.setParameters(widgetDoc!=null?widgetDoc.field(OWidgetsModule.OPROPERTY_TYPE_ID):"null")));
}
 
Example #29
Source File: SearchAnnotationSidebar.java    From inception with 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 #30
Source File: InfinitePagingNavigator.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected SakaiSpinnerDropDownChoice<String> newPageSizeSelector(final InfinitePagingDataTable table)
{
	final List<String> choices = new ArrayList<>();
	choices.add("5");
	choices.add("10");
	choices.add("20");
	choices.add("50");
	choices.add("100");
	choices.add("200");

	IModel<String> choiceModel = new PropertyModel<>(this, "pageSizeSelection");
	IModel<String> labelModel = new StringResourceModel("pager_select_label", this, null);
	SakaiSpinnerDropDownChoice<String> ddc = new SakaiSpinnerDropDownChoice<>("pageSize", choiceModel, choices,
			new SakaiStringResourceChoiceRenderer("pager_textPageSize", this), labelModel,
			new SakaiSpinningSelectOnChangeBehavior()
			{
				@Override
				protected void onUpdate(AjaxRequestTarget target)
				{
					int pageSize = Integer.parseInt(pageSizeSelection);
					table.setItemsPerPage(pageSize);
					if (target != null)
					{
						target.add(table);
					}
				}
			});

	return ddc;
}