Java Code Examples for org.apache.wicket.AttributeModifier

The following examples show how to use org.apache.wicket.AttributeModifier. 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: SubclassCreationDialog.java    License: Apache License 2.0 6 votes vote down vote up
public ContentPanel(String aId, IModel<KBConcept> newSubclassConceptModel)
{
    super(aId);

    // add components for input form
    RequiredTextField<String> name = new RequiredTextField<>("name");
    name.add(AttributeModifier.append("placeholder",
            new ResourceModel("subclassNamePlaceholder")));

    LambdaAjaxButton<KBConcept> createButton = new LambdaAjaxButton<KBConcept>(
            "createSubclass", SubclassCreationDialog.this::actionCreateSubclass);
    createButton.add(new Label("createLabel", new ResourceModel("create")));

    // initialize input form and add it to the content panel
    Form<KBConcept> form = new Form<KBConcept>("form",
            CompoundPropertyModel.of(newSubclassConceptModel));
    form.add(name);
    form.add(createButton);
    form.setDefaultButton(createButton);
    add(form);
}
 
Example 2
Source Project: sakai   Source File: GradebookPage.java    License: Educational Community License v2.0 6 votes vote down vote up
@Override
public void onBeforeRender() {
	super.onBeforeRender();

	// add simple feedback nofication to sit above the table
	// which is reset every time the page renders
	this.liveGradingFeedback = new Label("liveGradingFeedback", getString("feedback.saved"));
	this.liveGradingFeedback.setVisible(this.hasGradebookItems && this.hasStudents);
	this.liveGradingFeedback.setOutputMarkupId(true);
	this.liveGradingFeedback.add(DISPLAY_NONE);

	// add the 'saving...' message to the DOM as the JavaScript will
	// need to be the one that displays this message (Wicket will handle
	// the 'saved' and 'error' messages when a grade is changed
	this.liveGradingFeedback.add(new AttributeModifier("data-saving-message", getString("feedback.saving")));
	this.tableArea.addOrReplace(this.liveGradingFeedback);
}
 
Example 3
Source Project: onedev   Source File: DatePropertyEditor.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	DateTextFieldConfig config = new DateTextFieldConfig();
	config.autoClose(true).withFormat(DateEditSupport.DATE_INPUT_FORMAT)
			.highlightToday(true).showTodayButton(TodayButton.TRUE);
	input = new DateTextField("input", Model.of(getModelObject()), config);
	input.setType(getDescriptor().getPropertyClass());
	Method propertyGetter = getDescriptor().getPropertyGetter();
	if (propertyGetter.getAnnotation(OmitName.class) != null)
		input.add(AttributeModifier.replace("placeholder", EditableUtils.getDisplayName(propertyGetter)));

	input.setLabel(Model.of(getDescriptor().getDisplayName()));
	add(input);
	
	input.add(new OnTypingDoneBehavior() {

		@Override
		protected void onTypingDone(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
}
 
Example 4
Source Project: onedev   Source File: Tabbable.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	add(new ListView<Tab>("tabs", new LoadableDetachableModel<List<Tab>>() {

		@Override
		protected List<Tab> load() {
			return getTabs().stream().collect(Collectors.toList());
		}
		
	}) {

		@Override
		protected void populateItem(ListItem<Tab> item) {
			Tab tab = item.getModelObject();
			if (tab.isSelected())
				item.add(AttributeModifier.append("class", "active"));

			item.add(tab.render("tab"));
		}
		
	});
}
 
Example 5
Source Project: the-app   Source File: ProductItemPanel.java    License: Apache License 2.0 6 votes vote down vote up
private Component productDetailImageLink() {
    Link<Void> detailPageLink = new Link<Void>("productDetailLink") {
        @Override
        public void onClick() {
            PageParameters pageParameters = new PageParameters();
            pageParameters.set("urlname", productUrlModel.getObject());
            setResponsePage(new ProductDetailPage(pageParameters));
        }
    };
    WebMarkupContainer image = new WebMarkupContainer("image");
    image.add(new AttributeModifier("src", new ImageLinkModel(productInfoModel, this)));
    image.add(new AttributeModifier("title", new PropertyModel<String>(productInfoModel, "description")));
    image.add(new AttributeModifier("alt", new PropertyModel<String>(productInfoModel, "name")));
    image.setOutputMarkupId(true);

    detailPageLink.add(image);
    return detailPageLink;
}
 
Example 6
Source Project: yes-cart   Source File: SecureStringEditor.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Construct simple text editor.
 *
 * @param id         editor id.
 * @param markupProvider markup object.
 * @param model      model.
 * @param labelModel label model
 * @param errorLabelModel error label model
 * @param attrValue  {@link org.yes.cart.domain.entity.AttrValue}
 * @param readOnly  if true this component is read only
 */
public SecureStringEditor(final String id,
                          final MarkupContainer markupProvider,
                          final IModel<String> model,
                          final IModel<String> labelModel,
                          final IModel<String> errorLabelModel,
                          final AttrValueWithAttribute attrValue,
                          final boolean readOnly) {

    super(id, "secureStringEditor", markupProvider);

    final PasswordTextField textField = new PasswordTextField(EDIT, model);

    textField.setLabel(labelModel);
    textField.setRequired(attrValue.getAttribute().isMandatory());
    textField.setEnabled(!readOnly);

    if (StringUtils.isNotBlank(attrValue.getAttribute().getRegexp())) {
        textField.add(new CustomPatternValidator(attrValue.getAttribute().getRegexp(), errorLabelModel));
    }
    textField.add(new AttributeModifier("placeholder", labelModel));
    add(textField);
}
 
Example 7
Source Project: yes-cart   Source File: URLPagingNavigator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected AbstractLink newPagingNavigationLink(final String id, final IPageable pageable, int pageNumber) {

    final LinksSupport links = ((AbstractWebPage) getPage()).getWicketSupportFacade().links();
    final PageParameters params = links.getFilteredCurrentParameters(pageParameters);

    final long pNum;

    if ("last".equals(id)) {
        pNum = getPageable().getPageCount() - 1;
    } else {
        pNum = pageNumber;
    }

    params.set(WebParametersKeys.PAGE, pNum);

    return (AbstractLink) links.newLink(id, params).add(new AttributeModifier("class", "nav-page-control " + id));

}
 
Example 8
Source Project: yes-cart   Source File: ProductPerPageListView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void populateItem(ListItem<String> stringListItem) {

    final String pageSize = stringListItem.getModelObject();
    final Label label = new Label(WebParametersKeys.QUANTITY, pageSize);

    final AbstractWebPage page = ((AbstractWebPage) getPage());
    final PageParameters pageParameters = page.getPageParameters();
    final LinksSupport links = page.getWicketSupportFacade().links();
    final PaginationSupport pagination = page.getWicketSupportFacade().pagination();

    final PageParameters params = links.getFilteredCurrentParameters(pageParameters);
    params.set(WebParametersKeys.QUANTITY, pageSize);

    final Link pageSizeLink = links.newLink(ITEMS_PER_PAGE, params);
    pageSizeLink.add(label);
    stringListItem.add(pageSizeLink);

    if (pagination.markSelectedPageSizeLink(pageSizeLink, pageParameters, getModelObject(), NumberUtils.toInt(pageSize))) {
        stringListItem.add(new AttributeModifier("class", "active"));
    }

}
 
Example 9
Source Project: openmeetings   Source File: StartWidgetView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
	add(new WebMarkupContainer("step1").add(new PublicRoomsEventBehavior()));
	add(new WebMarkupContainer("step2").add(new PublicRoomsEventBehavior()));
	add(new WebMarkupContainer("step3").add(new WebMarkupContainer("avTest").add(AttributeModifier.append("href"
			, RequestCycle.get().urlFor(HashPage.class, new PageParameters().add(APP, APP_TYPE_SETTINGS)).toString()))));

	add(new WebMarkupContainer("step4").add(new PublicRoomsEventBehavior()));
	add(new Label("123msg", Application.getString("widget.start.desc")) //Application here is used to substitute {0}
			.setEscapeModelStrings(false));
	add(new BootstrapButton("start", new ResourceModel("788"), Buttons.Type.Outline_Primary).add(new PublicRoomsEventBehavior()));
	add(new BootstrapButton("calendar", new ResourceModel("291"), Buttons.Type.Outline_Primary).add(new AjaxEventBehavior(EVT_CLICK) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onEvent(AjaxRequestTarget target) {
			((MainPage)getPage()).updateContents(CALENDAR, target);
		}
	}));
	super.onInitialize();
}
 
Example 10
Source Project: webanno   Source File: TextAreaFeatureEditor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected AbstractTextComponent createInputField()
{
    TextArea<String> textarea = new TextArea<>("value");
    textarea.add(new AjaxPreventSubmitBehavior());
    try {
        String traitsString = getModelObject().feature.getTraits();
        StringFeatureTraits traits = 
                JSONUtil.fromJsonString(StringFeatureTraits.class, traitsString);
        textarea.add(new AttributeModifier("rows", traits.getCollapsedRows()));
        textarea.add(new AttributeAppender("onfocus",
                "this.rows=" + traits.getExpandedRows() + ";"));
        textarea.add(new AttributeAppender("onblur",
                "this.rows=" + traits.getCollapsedRows() + ";"));
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    return textarea;
}
 
Example 11
Source Project: webanno   Source File: ChainLayerTraitsEditor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeForm(Form<ChainLayerTraits> aForm)
{
    aForm.add(new ValidationModeSelect("validationMode", getLayerModel()));
    
    aForm.add(new AnchoringModeSelect("anchoringMode", getLayerModel()));
    
    aForm.add(new OverlapModeSelect("overlapMode", getLayerModel()));
    
    CheckBox linkedListBehavior = new CheckBox("linkedListBehavior");
    linkedListBehavior.setModel(PropertyModel.of(getLayerModel(), "linkedListBehavior"));
    aForm.add(linkedListBehavior);
    
    CheckBox crossSentence = new CheckBox("crossSentence");
    crossSentence.setOutputMarkupPlaceholderTag(true);
    crossSentence.setModel(PropertyModel.of(getLayerModel(), "crossSentence"));
    crossSentence.add(visibleWhen(() -> !isBlank(getLayerModelObject().getType())));
    aForm.add(crossSentence);
    
    TextArea<String> onClickJavascriptAction = new TextArea<String>("onClickJavascriptAction");
    onClickJavascriptAction.setModel(PropertyModel.of(getLayerModel(), "onClickJavascriptAction"));
    onClickJavascriptAction.add(new AttributeModifier("placeholder",
            "alert($PARAM.PID + ' ' + $PARAM.PNAME + ' ' + $PARAM.DOCID + ' ' + "
                    + "$PARAM.DOCNAME + ' ' + $PARAM.fieldname);"));
    aForm.add(onClickJavascriptAction);
}
 
Example 12
Source Project: sakai   Source File: AjaxLazyLoadImage.java    License: Educational Community License v2.0 6 votes vote down vote up
public Image renderImage(AjaxRequestTarget target, boolean fullRender) {
	if(returnPage != null || returnClass != null) {
		link.add(new AttributeModifier("title", new ResourceModel("click_to_max")));
		link.setEnabled(true);
	}
	link.removeAll();
	Image img = null;
	if(!autoDetermineChartSizeByAjax) {
		img = createImage("content", getImageData());
	}else{
		img = createImage("content", getImageData(selectedWidth, selectedHeight));
	}
	img.add(AttributeModifier.replace("style", "display: none; margin: 0 auto;"));
	link.add(img);
	setState((byte) 1);
	if(fullRender) {
		if(target != null) {
			target.add(link);	
			target.appendJavaScript("jQuery('#"+img.getMarkupId()+"').fadeIn();");
		}		
		setState((byte) 2);
	}
	return img;
}
 
Example 13
Source Project: ontopia   Source File: FieldInstanceImageField.java    License: Apache License 2.0 6 votes vote down vote up
public FieldInstanceImageField(String id, FieldValueModel _fieldValueModel, boolean readonly) {
  super(id);
  this.fieldValueModel = _fieldValueModel;
  
  image = new Image("image");
  image.add(new AttributeModifier("src", true, new AbstractReadOnlyModel<String>() {
    @Override
    public final String getObject() {
      TopicMap topicMap = fieldValueModel.getFieldInstanceModel().getFieldInstance().getInstance().getTopicMap();        
      Object o = fieldValueModel.getFieldValue();
      return getRequest().getRelativePathPrefixToContextRoot() + "occurrenceImages?topicMapId=" + topicMap.getId() + 
      "&occurrenceId=" + ((o instanceof OccurrenceIF ? ((OccurrenceIF)o).getObjectId(): "unknown"));
    }
  }));
  upload = new UploadPanel("upload", this);
  add(image);
  add(upload);
  if (fieldValueModel.isExistingValue()) {
    upload.setVisible(false);
  } else {
    image.setVisible(false);
    if (readonly)
      upload.setVisible(false);
  }
}
 
Example 14
Source Project: sakai   Source File: BasePage.java    License: Educational Community License v2.0 6 votes vote down vote up
/**
 * Helper to build a notification flag with a Bootstrap popover
 */
public WebMarkupContainer buildFlagWithPopover(final String componentId, final String message) {
	final WebMarkupContainer flagWithPopover = new WebMarkupContainer(componentId);

	flagWithPopover.add(new AttributeModifier("title", message));
	flagWithPopover.add(new AttributeModifier("aria-label", message));
	flagWithPopover.add(new AttributeModifier("data-toggle", "popover"));
	flagWithPopover.add(new AttributeModifier("data-trigger", "manual"));
	flagWithPopover.add(new AttributeModifier("data-placement", "bottom"));
	flagWithPopover.add(new AttributeModifier("data-html", "true"));
	flagWithPopover.add(new AttributeModifier("data-container", "#gradebookGrades"));
	flagWithPopover.add(new AttributeModifier("data-template",
			"<div class=\"gb-popover popover\" role=\"tooltip\"><div class=\"arrow\"></div><div class=\"popover-content\"></div></div>"));
	flagWithPopover.add(new AttributeModifier("data-content", generatePopoverContent(message)));
	flagWithPopover.add(new AttributeModifier("tabindex", "0"));

	return flagWithPopover;
}
 
Example 15
@Override
public void onInitialize() {
	super.onInitialize();

	final List<Assignment> assignments = this.businessService.getGradebookAssignments(SortType.SORT_BY_SORTING);

	add(new ListView<Assignment>("gradeItemList", assignments) {
		@Override
		protected void populateItem(final ListItem<Assignment> assignmentItem) {
			final Assignment assignment = assignmentItem.getModelObject();
			assignmentItem.add(new Label("name", assignment.getName()));
			assignmentItem.add(new HiddenField<Long>("id",
					Model.of(assignment.getId())).add(
							new AttributeModifier("name",
									String.format("id", assignment.getId()))));
			assignmentItem.add(new HiddenField<Integer>("order",
					Model.of(assignment.getSortOrder())).add(
							new AttributeModifier("name",
									String.format("item_%s[order]", assignment.getId()))));
			assignmentItem.add(new HiddenField<Integer>("current_order",
					Model.of(assignment.getSortOrder())).add(
							new AttributeModifier("name",
									String.format("item_%s[current_order]", assignment.getId()))));
		}
	});
}
 
Example 16
private void addNameRecord() {
    WebMarkupContainer nameRecordingContainer = new WebMarkupContainer("nameRecordingContainer");

    nameRecordingContainer.add(new Label("nameRecordingLabel", new ResourceModel("profile.name.recording")));
    WebMarkupContainer audioPlayer = new WebMarkupContainer("audioPlayer");

    final String slash = Entity.SEPARATOR;
    final StringBuilder path = new StringBuilder();
    path.append(slash);
    path.append("direct");
    path.append(slash);
    path.append("profile");
    path.append(slash);
    path.append(userProfile.getUserUuid());
    path.append(slash);
    path.append("pronunciation");
    path.append("?v=");
    path.append(RandomStringUtils.random(8, true, true));

    audioPlayer.add(new AttributeModifier("src", path.toString()));
    nameRecordingContainer.add(audioPlayer);
    add(nameRecordingContainer);

    if (profileLogic.getUserNamePronunciation(userProfile.getUserUuid()) == null) nameRecordingContainer.setVisible(false);
    else visibleFieldCount++;
}
 
Example 17
Source Project: sakai   Source File: FeedbackLabel.java    License: Educational Community License v2.0 6 votes vote down vote up
/**
 * Set the content of this FeedbackLabel, depending on if the component has a FeedbackMessage.
 *
 * The HTML class attribute will be filled with the error level of the feedback message. That way, you can easily
 * style different messages differently. Examples:
 *
 * class = "feedbacklabel INFO"
 * class = "feedbacklabel ERROR"
 * class = "feedbacklabel DEBUG"
 * class = "feedbacklabel FATAL"
 *
 *
 * @see Component
 */
@Override
protected void onBeforeRender() {
    super.onBeforeRender();
    this.setDefaultModel(null);

    if(component.hasFeedbackMessage()){
        if(this.text!=null){
            this.setDefaultModel(text);
        } else {
            this.setDefaultModel(new Model(component.getFeedbackMessages().first()));
        }

        this.add(new AttributeModifier("class", true, new Model("feedbackLabel " + component.getFeedbackMessages().first().getLevelAsString())));
    } else {
        this.setDefaultModel(null);
    }
  
}
 
Example 18
Source Project: sakai   Source File: IconWithClueTip.java    License: Educational Community License v2.0 6 votes vote down vote up
public IconWithClueTip(String id, String iconUrl, IModel textModel) {
	super(id);
		
	//link
	AjaxFallbackLink link = new AjaxFallbackLink("link") {
		public void onClick(AjaxRequestTarget target) {
			//nothing
		}
	};
	link.add(new AttributeModifier("title", true, textModel));
	
	//image
	ContextImage image = new ContextImage("icon",new Model(iconUrl));
	image.add(new AttributeModifier("alt", true, new ResourceModel("accessibility.tooltip")));
	link.add(image);
	
	add(link);

}
 
Example 19
Source Project: JPPF   Source File: StatisticsTablePanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(final Item<ICellPopulator<Fields>> cellItem, final String componentId, final IModel<Fields> rowModel) {
  final Fields field = rowModel.getObject();
  final Locale locale = JPPFWebSession.get().getLocale();
  String value = null;
  if (index == 0) {
    //value = LocalizationUtils.getLocalized(FIELDS_BASE, field.getName(), locale);
    value = field.getLocalizedName();
  } else {
    final StatsUpdater updater = JPPFWebConsoleApplication.get().getStatsUpdater();
    value = updater.formatLatestValue(locale, JPPFWebSession.get().getCurrentDriver(), field);
  }
  cellItem.add(new Label(componentId, value));
  cellItem.add(new AttributeModifier("class", index == 0 ? "stats_label" : "stats_number"));
}
 
Example 20
Source Project: JPPF   Source File: JobsPage.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(final Item<ICellPopulator<DefaultMutableTreeNode>> cellItem, final String componentId, final IModel<DefaultMutableTreeNode> rowModel) {
  final NodeModel<DefaultMutableTreeNode> nodeModel = (NodeModel<DefaultMutableTreeNode>) rowModel;
  final DefaultMutableTreeNode treeNode = nodeModel.getObject();
  final AbstractJobComponent comp = (AbstractJobComponent) treeNode.getUserObject();
  final String value = (String) treeModel.getValueAt(treeNode, index);
  cellItem.add(new Label(componentId, value));
  if (traceEnabled) log.trace(String.format("index %d populating value=%s, treeNode=%s", index, value, treeNode));
  String cssClass = "default_cursor ";
  final boolean selected = selectionHandler.isSelected(comp.getUuid());
  if ((comp instanceof Job) || (comp instanceof JobDispatch)) cssClass += "node_up " + getCssClass();
  else if (!selected) cssClass += "empty";
  if (selected) cssClass += "tree_selected";
  cellItem.add(new AttributeModifier("class", cssClass));
}
 
Example 21
private void addInstructorAttributeOrHide(WebMarkupContainer sakaiRubricButton, Assignment assignment, String studentId, boolean showingStudentView) {

		if (!showingStudentView && (GradeSummaryTablePanel.this.getUserRole() == GbRole.INSTRUCTOR
					|| GradeSummaryTablePanel.this.getUserRole() == GbRole.TA)) {
			sakaiRubricButton.add(AttributeModifier.append("instructor", true));
		} else {
			GradeDefinition gradeDefinition = businessService.getGradeForStudentForItem(studentId, assignment.getId());
			if (assignment.isExternallyMaintained() && gradeDefinition.getGrade() == null) {
				sakaiRubricButton.add(AttributeModifier.replace("force-preview", true));
			}
		}
	}
 
Example 22
Source Project: sakai   Source File: Menus.java    License: Educational Community License v2.0 5 votes vote down vote up
/** Render Sakai Menu. */
@SuppressWarnings("unchecked")
private void renderBody() {
	setRenderBodyOnly(true);
	
	boolean isSiteStatsAdminPage = Locator.getFacade().getStatsAuthz().isSiteStatsAdminPage();
	boolean isSiteStatsView = Locator.getFacade().getStatsAuthz().isUserAbleToViewSiteStats(siteId);
	boolean isBrowsingThisSite = siteId.equals(realSiteId);
	
	// admin menu
	AdminMenu adminMenu = new AdminMenu("adminMenu");
	add(adminMenu);
	
	// standard menu
	WebMarkupContainer standardMenuContainer = new WebMarkupContainer("standardMenuContainer");
	// menu
	Menu standardMenu = new Menu("standardMenu", siteId);
	standardMenuContainer.add(standardMenu);
	add(standardMenuContainer);
	
	// menus rendering
	if(isSiteStatsAdminPage) {
		adminMenu.setVisible(true);
		if(!isBrowsingThisSite) {
			standardMenuContainer.setVisible(true);
			standardMenuContainer.add(new AttributeModifier("style", new Model("margin: 10px 5px 5px 5px;")));
		}else{
			standardMenuContainer.setVisible(false);
		}
	}else if(isSiteStatsView){
		adminMenu.setVisible(false);
		standardMenuContainer.setVisible(true);
	}else{
		adminMenu.setVisible(false);
		standardMenuContainer.setVisible(false);
	}
}
 
Example 23
Source Project: JPPF   Source File: NodeFilterPage.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onConfigure() {
  super.onConfigure();
  final UserSettings settings = JPPFWebSession.get().getUserSettings();
  final boolean active = settings.getProperties().getBoolean(JPPFWebSession.NODE_FILTER_ACTIVE_PROP, false);
  JPPFWebSession.get().getNodeFilter().setActive(active);
  nodeFilterLink.add(new AttributeModifier("style", "color: " + (active ? "green" : "red")));
}
 
Example 24
@Override
public void onInitialize()
{
	super.onInitialize();
	WebMarkupContainer span = new WebMarkupContainer("span");
	add(span);
	span.add(AttributeModifier.replace("colspan", new AbstractReadOnlyModel<String>()
	{
		@Override
		public String getObject()
		{
			return String.valueOf(table.getColumns().size());
		}
	}));
	final Form<?> form = new Form<>("navForm");
	form.add(newPagingNavigator("navigator", table, form).setRenderBodyOnly(true));
	form.add(newNavigatorLabel("navigatorLabel", table).setRenderBodyOnly(true));
	span.add(form);
}
 
Example 25
Source Project: inception   Source File: KnowledgeBasePanel.java    License: Apache License 2.0 5 votes vote down vote up
private KnowledgeBaseItemAutoCompleteField createSearchField(String aId,
    IModel<KBHandle> aHandleModel, IModel<Project> aProjectModel)
{
    KnowledgeBaseItemAutoCompleteField field = new KnowledgeBaseItemAutoCompleteField(
            aId, aHandleModel, _query -> 
                    listSearchResults(aProjectModel.getObject(), _query)) {
        private static final long serialVersionUID = 3188821013226116770L;

        @Override
        protected void onSelected(AjaxRequestTarget aTarget)
        {
            KBHandle selectedResource = this.getModelObject();
            Optional<KBObject> optKbObject = kbService
                .readItem(kbModel.getObject(), selectedResource.getIdentifier());

            if (optKbObject.isPresent()) {
                KBObject kbObject = optKbObject.get();
                sendSelectionChangedEvents(aTarget, kbObject);
            }
        }
    };
    
    field.add(AttributeModifier.append("placeholder",
            new ResourceModel("page.search.placeholder")));
    
    return field;
}
 
Example 26
Source Project: onedev   Source File: NavigationToolbar.java    License: MIT License 5 votes vote down vote up
/**
 * Constructor
 * 
 * @param table
 *            data table this toolbar will be attached to
 */
public NavigationToolbar(final DataTable<?, ?> table)
{
	super(table);

	WebMarkupContainer span = new WebMarkupContainer("span") {

		private static final long serialVersionUID = 1L;

		@Override
		protected void onBeforeRender() {
			addOrReplace(newPagingNavigator("navigator", table));
			addOrReplace(newNavigatorLabel("navigatorLabel", table));
			super.onBeforeRender();
		}
		
	};
	add(span);
	span.add(AttributeModifier.replace("colspan", new AbstractReadOnlyModel<String>()
	{
		private static final long serialVersionUID = 1L;

		@Override
		public String getObject()
		{
			return String.valueOf(table.getColumns().size()).intern();
		}
	}));

}
 
Example 27
Source Project: onedev   Source File: NumericPropertyEditor.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new TextField<Number>("input", Model.of(getModelObject()));
	input.setType(getDescriptor().getPropertyClass());
	add(input);
	input.setLabel(Model.of(getDescriptor().getDisplayName()));
	
	input.add(new OnTypingDoneBehavior() {

		@Override
		protected void onTypingDone(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
	
	Method getter = getDescriptor().getPropertyGetter();
	if (getter.getAnnotation(OmitName.class) != null) {
		input.add(AttributeModifier.replace("placeholder", EditableUtils.getDisplayName(getter)));
	} else {
		NameOfEmptyValue nameOfEmptyValue = getter.getAnnotation(NameOfEmptyValue.class);
		if (nameOfEmptyValue != null)
			input.add(AttributeModifier.replace("placeholder", nameOfEmptyValue.value()));
	}
}
 
Example 28
Source Project: onedev   Source File: CommentableOperationConfirmPanel.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	getForm().add(new CommentInput("comment", new PropertyModel<String>(this, "comment"), false) {

		@Override
		protected Project getProject() {
			return getLatestUpdate().getRequest().getTargetProject();
		}
		
		@Override
		protected AttachmentSupport getAttachmentSupport() {
			return new ProjectAttachmentSupport(getProject(), getLatestUpdate().getRequest().getUUID()) {

				@Override
				public boolean canDeleteAttachment() {
					return SecurityUtils.canManagePullRequests(getProject());
				}
				
			};
		}

		@Override
		protected List<User> getMentionables() {
			return OneDev.getInstance(UserManager.class)
					.queryAndSort(getLatestUpdate().getRequest().getParticipants());
		}
		
		@Override
		protected List<AttributeModifier> getInputModifiers() {
			return Lists.newArrayList(AttributeModifier.replace("placeholder", "Leave a note"));
		}
		
	});
}
 
Example 29
Source Project: yes-cart   Source File: PaginationSupportImpl.java    License: Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean markSelectedSortLink(final Link link,
                                    final PageParameters pageParameters, final String sortOrder, final String sortField) {
    if (isSortSelected(pageParameters, sortOrder, sortField)) {
        link.add(new AttributeModifier("class", "sort-order-active sort-order active"));
        return true;
    } else {
        link.add(new AttributeModifier("class", "sort-order"));
        return false;
    }
}
 
Example 30
Source Project: sakai   Source File: MenuItem.java    License: Educational Community License v2.0 5 votes vote down vote up
public MenuItem(String id, IModel itemText, Class itemPageClass, PageParameters pageParameters, boolean first, Class menusCurrentPageClass) {
	super(id);

	boolean currentPage = itemPageClass.equals(menusCurrentPageClass);

	// link version
	menuItemLinkHolder = new WebMarkupContainer("menuItemLinkHolder");
	menuItemLink = new BookmarkablePageLink("menuItemLink", itemPageClass, pageParameters);
	menuLinkText = new Label("menuLinkText", itemText);
	menuLinkText.setRenderBodyOnly(true);
	menuItemLink.add(menuLinkText);
	menuItemLinkHolder.add(menuItemLink);
	menuItemLinkHolder.setVisible(!currentPage);
	add(menuItemLinkHolder);

	// span version
	menuItemLabel = new Label("menuItemLabel", itemText);
	menuItemLabel.setVisible(currentPage);
	add(menuItemLabel);
	
	//add current page styling
	AttributeModifier currentPageStyling = new AttributeModifier("class", new Model("current"));
	if(currentPage) {
		menuItemLabel.add(currentPageStyling);
	}

	if(first) {
		add(new AttributeModifier("class", new Model("firstToolBarItem")));
	}
}