private void addSuperSections( ISIXmlSection currentSection, ISIXmlSection rootSection, RepeatingView superSectionRepeater, SectionIconFactory iconFactory) { // We do have supersections for (XmlSection ss : rootSection.getChildren()) { ISIXmlSection superSection = (ISIXmlSection) ss; WebMarkupContainer superSectionContainer = new WebMarkupContainer(superSectionRepeater.newChildId()); superSectionRepeater.add(superSectionContainer); superSectionContainer.add(new Label("superSectionTitle", superSection.getTitle())); List<XmlSection> sections; // Use Supersection children, or supersection itself if there are no children. if (!superSection.hasChildren()) { sections = new ArrayList<XmlSection>(); sections.add(superSection); } else { sections = superSection.getChildren(); } superSectionContainer.add( new SectionRepeater("sectionRepeater", sections, currentSection, iconFactory)); } }
@Test public void selectNewClassInDropDown_shouldRenderNewEditorPanelThroughAjax() { selectEventType(1); fieldList = (RepeatingView) tester.getComponentFromLastRenderedPage("form:fieldContainer:fields"); assertThat(fieldList.size(), is(2)); Component attributeName = fieldList.get("1:row:name"); assertThat(attributeName.getDefaultModelObjectAsString(), is("name")); }
/** * Return a component with a list of steps. * * @param model wizard model * @return a RepeatingView with step list */ private RepeatingView getStepList(IWizardModel model) { Iterator<IWizardStep> it = model.stepIterator(); RepeatingView view = new RepeatingView("repeater"); while (it.hasNext()) { IWizardStep step = it.next(); Label label = new Label(view.newChildId(), new PropertyModel<WizardStep>(step, "title")); if (step.equals(model.getActiveStep())) { label.add(new AttributeModifier("class", new Model<String>("selectedStep"))); } view.add(label); } return view; }
private void addSimpleSections( ISIXmlSection currentSection, ISIXmlSection rootSection, RepeatingView superSectionRepeater, SectionIconFactory iconFactory) { // Simple case - no supersection. Create a single container and put sections into it. WebMarkupContainer container = new WebMarkupContainer(superSectionRepeater.newChildId()); superSectionRepeater.add(container); container.add(new EmptyPanel("superSectionTitle")); container.add( new SectionRepeater( "sectionRepeater", rootSection.getChildren(), currentSection, iconFactory)); }
private void initialize() { // FeedbackPanel // final FeedbackPanel feedback = new JQueryFeedbackPanel("feedback"); this.add(feedback.setOutputMarkupId(true)); // EventObjects // RepeatingView view = new RepeatingView("object"); this.add(view); for (MyEvent event : this.objects) { view.add( new EventObject(view.newChildId(), event.toString()) { private static final long serialVersionUID = 1L; @Override public void onConfigure(JQueryBehavior behavior) { super.onConfigure(behavior); // draggable options // behavior.setOption("revert", true); behavior.setOption("revertDuration", 0); } }); } // Calendar // this.add( new Calendar("calendar", this.newCalendarModel(), new Options("theme", true)) { private static final long serialVersionUID = 1L; @Override public boolean isObjectDropEnabled() { return true; } @Override public void onObjectDrop( AjaxRequestTarget target, String title, LocalDateTime date, boolean allDay) { CalendarEvent event = new CalendarEvent(0, title, date); event.setAllDay(allDay); events.add(event); // adds to DAO this.refresh(target); this.info(String.format("Added %s on %s", event.getTitle(), event.getStart())); target.add(feedback); } }); }
@Override protected void onInitialize() { super.onInitialize(); RepeatingView rw = new RepeatingView("buttons"); int idx = 0; for (String linkKey : linkKeys) { if (idx == 0) { add(createLink("leftButton", linkKey, idx++)); } else { rw.add(createLink(rw.newChildId(), linkKey, idx++)); } } add(rw); }
/** @see org.apache.wicket.Component#onInitialize() */ @Override protected void onInitialize() { super.onInitialize(); if (socialMediaValues == null) { socialMediaValues = new ArrayList<SocialMediaValue>(); } newSocialMediaValue = new LabelValueBean<InstantMessagingType, String>( InstantMessagingType.AIM, DEFAULT_IM_VALUE); socialMediaChoiceRenderer = new LabelValueChoiceRenderer<InstantMessagingType>(); final InstantMessagingType[] ims = InstantMessagingType.values(); for (final InstantMessagingType im : ims) { socialMediaChoiceRenderer.addValue(im, im.toString()); } mainContainer = new WebMarkupContainer("main"); add(mainContainer.setOutputMarkupId(true)); socialMediaRepeater = new RepeatingView("liRepeater"); mainContainer.add(socialMediaRepeater); rebuildSocialMedias(); addNewSocialMediaContainer = new WebMarkupContainer("liAddNewIm"); mainContainer.add(addNewSocialMediaContainer.setOutputMarkupId(true)); init(addNewSocialMediaContainer); socialMediaRepeater.setVisible(true); }
private Component getSingleLanguagePathLabel(LanguagePath[] paths) throws InvalidLanguageTagException { WebMarkupContainer container = new WebMarkupContainer("singleContainer"); RepeatingView rv = new RepeatingView("singles"); if (paths != null) { WebMarkupContainer wmc = new WebMarkupContainer(rv.newChildId()); rv.add( wmc.add( new Label( "singleLanguages", LanguagePathUtil.makeLanguagePathString( paths, MetaAttribute.SUPPORTEDLANGUAGES, getLocale())) .setRenderBodyOnly(true))); } container.add(rv); container.setVisible(rv.size() != 0); addCount += rv.size(); return container; }
/** @see org.projectforge.web.wicket.AbstractSelectPanel#onBeforeRender() */ @SuppressWarnings("serial") @Override protected void onBeforeRender() { super.onBeforeRender(); final TaskDO task = getModelObject(); final Integer taskId = task != null ? task.getId() : null; if (currentTaskId == taskId) { return; } currentTaskId = taskId; if (showPath == true && task != null) { ancestorRepeater.removeAll(); final TaskNode taskNode = taskTree.getTaskNodeById(task.getId()); final List<Integer> ancestorIds = taskNode.getAncestorIds(); final ListIterator<Integer> it = ancestorIds.listIterator(ancestorIds.size()); while (it.hasPrevious() == true) { final Integer ancestorId = it.previous(); final TaskDO ancestorTask = taskTree.getTaskById(ancestorId); if (ancestorTask.getParentTask() == null) { // Don't show root node: continue; } final WebMarkupContainer cont = new WebMarkupContainer(ancestorRepeater.newChildId()); ancestorRepeater.add(cont); final SubmitLink selectTaskLink = new SubmitLink("ancestorTaskLink") { @Override public void onSubmit() { caller.select(selectProperty, ancestorTask.getId()); } }; selectTaskLink.setDefaultFormProcessing(false); cont.add(selectTaskLink); WicketUtils.addTooltip( selectTaskLink, getString("task.selectPanel.selectAncestorTask.tooltip")); selectTaskLink.add(new Label("name", ancestorTask.getTitle())); } ancestorRepeater.setVisible(true); } else { ancestorRepeater.setVisible(false); } }
public LeftNavigationPanel(String id) { super(id); RepeatingView rv = new RepeatingView("menu"); add(rv); List<MenuItem> menuItems = new ArrayList<MenuItem>(); menuItems.add(new MenuItem("PlayerProfile", PlayerProfile.class)); menuItems.add(new MenuItem("PlayerProfile", PlayerProfile.class)); menuItems.add(new MenuItem("PlayerProfile", PlayerProfile.class)); menuItems.add(new MenuItem("PlayerProfile", PlayerProfile.class)); menuItems.add(new MenuItem("ListPlayersOfMyClub", ListPlayersOfMyClub.class)); menuItems.add(new MenuItem("CreateClubPanel", CreateClubPanel.class)); BBTSession session = (BBTSession) Session.get(); for (MenuItem i : menuItems) { if (checkVisibility(session, i)) { WebMarkupContainer parent = new WebMarkupContainer(rv.newChildId()); rv.add(parent); Link lk = new Link("link", new Model(i.getDestination())) { @Override public void onClick() { try { Class classe = (Class) getModelObject(); Class[] types = {String.class}; Constructor constructeur = classe.getConstructor(types); Object[] params = {"businessPanel"}; LeftNavigationPanel.this .getParent() .addOrReplace((Component) constructeur.newInstance(params)); } catch (Exception ex) { Logger.getLogger(LeftNavigationPanel.class.getName()).log(Level.SEVERE, null, ex); } } }; lk.add(new Label("linkName", i.getCaption())); parent.add(lk); } } }
private Component getMultidirectionalPathViewComponent(Collection<LanguagePath[]> pathList) throws InvalidLanguageTagException { WebMarkupContainer container = new WebMarkupContainer("multidirectionalContainer"); RepeatingView rv = new RepeatingView("multidirectionals"); if (pathList != null) { for (LanguagePath[] paths : pathList) { WebMarkupContainer wmc = new WebMarkupContainer(rv.newChildId()); rv.add( wmc.add( new Label( "multidirectionalPairs", LanguagePathUtil.makeLanguagePathString( paths, MetaAttribute.SUPPORTEDLANGUAGEPAIRS_PAIRLIST, getLocale())) .setRenderBodyOnly(true))); } } container.add(rv); container.setVisible(rv.size() != 0); addCount += rv.size(); return container; }
@Override protected void onBeforeRender() { if (!hasBeenRendered()) { items = new ArrayList<T>(getModelObject()); for (int i = 0; i < items.size(); i++) { EditableListItem<T> li = new EditableListItem<T>(newChildId(), i); add(li); onPopulateItem(li); } } super.onBeforeRender(); }
@Override protected void onBeforeRender() { // if (!hasBeenRendered()) { this.removeAll(); items = new ArrayList<T>(getModelObject()); for (int i = 0; i < items.size(); i++) { ListItem<T> li = new ListItem<T>(newChildId(), i); add(li); onPopulateItem(li); } // } super.onBeforeRender(); }
public Menu(String id) { super(id); BookmarkablePageLink home = new BookmarkablePageLink("home", HomePage.class); BookmarkablePageLink chisiamo = new BookmarkablePageLink("chisiamo", ChiSiamo.class); add(home); add(chisiamo); String[] riga = {"riga1", "riga2", "riga3", "riga4", "riga5"}; RepeatingView tab = new RepeatingView("riga"); /*tab.add(new Label(tab.newChildId(),"riga1")); tab.add(new Label(tab.newChildId(),"riga2")); tab.add(new Label(tab.newChildId(),"riga3")); tab.add(new Label(tab.newChildId(),"riga4")); tab.add(new Label(tab.newChildId(),"riga5")); tab.add(new Label(tab.newChildId(),"chi ama (|) metta una riga"));*/ for (String r : riga) { tab.add(new Label(tab.newChildId(), r)); } add(tab); }
private Component getCombinationPathViewComponent(LanguagePath[] paths) throws InvalidLanguageTagException { WebMarkupContainer container = new WebMarkupContainer("combinationContainer"); RepeatingView rv = new RepeatingView("combinations"); if (paths != null) { for (LanguagePath path : paths) { WebMarkupContainer wmc = new WebMarkupContainer(rv.newChildId()); rv.add( wmc.add( new Label( "combinationPairs", LanguagePathUtil.makeLanguagePathString( new LanguagePath[] {path}, MetaAttribute.SUPPORTEDLANGUAGEPAIRS_ANYCOMBINATION, getLocale())) .setRenderBodyOnly(true))); } } container.add(rv); container.setVisible(rv.size() != 0); addCount += rv.size(); return container; }
/** * @see * org.apache.wicket.markup.repeater.RefreshingView#populateItem(org.apache.wicket.markup.repeater.Item) */ @Override protected final void populateItem(final Item<T> item) { RepeatingView cells = new RepeatingView(CELL_REPEATER_ID); item.add(cells); int populatorsNumber = populators.size(); for (int i = 0; i < populatorsNumber; i++) { ICellPopulator<T> populator = populators.get(i); IModel<ICellPopulator<T>> populatorModel = new Model<>(populator); Item<ICellPopulator<T>> cellItem = newCellItem(cells.newChildId(), i, populatorModel); cells.add(cellItem); populator.populateItem(cellItem, CELL_ITEM_ID, item.getModel()); if (cellItem.get("cell") == null) { throw new WicketRuntimeException( populator.getClass().getName() + ".populateItem() failed to add a component with id [" + CELL_ITEM_ID + "] to the provided [cellItem] object. Make sure you call add() on cellItem and make sure you gave the added component passed in 'componentId' id. ( *cellItem*.add(new MyComponent(*componentId*, rowModel) )"); } } }
private void initLayout() { itemsCount = getModel() != null ? (getModel().getObject() != null ? getModel().getObject().size() : 0) : 0; RepeatingView rows = new RepeatingView(ID_ROW); rows.setOutputMarkupId(true); if (itemsCount > 0 && itemsPerRow > 0) { int index = 0; List<AssignmentEditorDto> assignmentsList = getModelObject(); long rowCount = itemsCount % itemsPerRow == 0 ? (itemsCount / itemsPerRow) : (itemsCount / itemsPerRow + 1); for (int rowNumber = 0; rowNumber < rowCount; rowNumber++) { WebMarkupContainer rowContainer = new WebMarkupContainer(rows.newChildId()); rows.add(rowContainer); RepeatingView columns = new RepeatingView(ID_CELL); columns.setOutputMarkupId(true); rowContainer.add(columns); for (int colNumber = 0; colNumber < itemsPerRow; colNumber++) { WebMarkupContainer colContainer = new WebMarkupContainer(columns.newChildId()); columns.add(colContainer); WebMarkupContainer itemButtonContainer = new WebMarkupContainer(ID_ITEM_BUTTON_CONTAINER); itemButtonContainer.setOutputMarkupId(true); itemButtonContainer.add( new AttributeAppender( "class", getBackgroundClass(assignmentsList.get(index).getType()))); colContainer.add(itemButtonContainer); populateCell(itemButtonContainer, assignmentsList.get(index)); index++; if (index >= assignmentsList.size()) { break; } } } } add(rows); }
@Test public void firstClassIsDefault_shouldCreateEditorFieldsBasedOnDefault() { assertThat(fieldList.size(), is(3)); Component attributeName = fieldList.get("3:row:name"); assertThat(attributeName.getDefaultModelObjectAsString(), is("testProperty")); }
/** @see org.apache.wicket.Component#onBeforeRender() */ @SuppressWarnings("serial") protected void redraw( final TemplateEntry activeTemplateEntry, final List<TeamCalDO> selectedCalendars) { columnRepeater.removeAll(); final int counter = selectedCalendars.size(); int rowsPerColumn = counter / 3; if (counter % 3 > 0) { ++rowsPerColumn; // Need one more row. } int rowCounter = 0; WebMarkupContainer columnContainer; RepeatingView rowRepeater = null; for (final TeamCalDO calendar : selectedCalendars) { if (rowCounter++ % rowsPerColumn == 0) { // Start new column: columnContainer = new WebMarkupContainer(columnRepeater.newChildId()); columnContainer.add(AttributeModifier.append("class", GridSize.COL33.getClassAttrValue())); columnRepeater.add(columnContainer); rowRepeater = new RepeatingView("rowRepeater"); columnContainer.add(rowRepeater); } final WebMarkupContainer container = new WebMarkupContainer(rowRepeater.newChildId()); rowRepeater.add(container); final IModel<Boolean> model = Model.of(activeTemplateEntry.isVisible(calendar.getId()) == true); final CheckBoxPanel checkBoxPanel = new CheckBoxPanel("isVisible", model, ""); checkBoxPanel .getCheckBox() .add( new AjaxFormComponentUpdatingBehavior("onChange") { private static final long serialVersionUID = 3523446385818267608L; @Override protected void onUpdate(final AjaxRequestTarget target) { final Boolean newSelection = checkBoxPanel.getCheckBox().getConvertedInput(); final TemplateCalendarProperties properties = activeTemplateEntry.getCalendarProperties(calendar.getId()); if (newSelection != properties.isVisible()) { properties.setVisible(newSelection); activeTemplateEntry.setDirty(); } } }); container.add(checkBoxPanel); WicketUtils.addTooltip( checkBoxPanel.getCheckBox(), getString("plugins.teamcal.filterDialog.calendarIsVisible.tooltip")); container.add(new Label("name", calendar.getTitle())); final ColorPickerPanel picker = new ColorPickerPanel("colorPicker", activeTemplateEntry.getColorCode(calendar.getId())) { @Override protected void onColorUpdate(final String selectedColor) { final TemplateCalendarProperties props = activeTemplateEntry.getCalendarProperties(calendar.getId()); if (props != null) { props.setColorCode(selectedColor); } else { log.warn( "TeamCalendarProperties not found: calendar.id='" + calendar.getId() + "' + for active template '" + activeTemplateEntry.getName() + "'."); } } }; container.add(picker); } }
@Override protected void initLayout() { final List<RichHyperlinkType> linksList = getModel().getObject(); RepeatingView rowView = new RepeatingView(ID_LINKS_ROW); int linksListSize = linksList == null ? 0 : linksList.size(); if (linksListSize > 0) { int currentColumn = 0; RepeatingView columnView = null; WebMarkupContainer row = null; boolean isRowAdded = false; for (int i = 0; i < linksListSize; i++) { final RichHyperlinkType link = linksList.get(i); if (WebMiscUtil.isAuthorized(link.getAuthorization())) { if (currentColumn == 0) { row = new WebMarkupContainer(rowView.newChildId()); isRowAdded = false; columnView = new RepeatingView(ID_LINKS_COLUMN); } WebMarkupContainer column = new WebMarkupContainer(columnView.newChildId()); Link linkItem = new Link(ID_LINK) { @Override public void onClick() {} @Override protected void onComponentTag(final ComponentTag tag) { super.onComponentTag(tag); String rootContext = ""; if (link.getTargetUrl() != null && !link.getTargetUrl().startsWith("http://") && !link.getTargetUrl().startsWith("https://") && !link.getTargetUrl().startsWith("www://") && !link.getTargetUrl().startsWith("//")) { WebApplication webApplication = WebApplication.get(); if (webApplication != null) { ServletContext servletContext = webApplication.getServletContext(); if (servletContext != null) { rootContext = servletContext.getContextPath(); } } } tag.put("href", rootContext + link.getTargetUrl()); } }; linkItem.add( new Label(ID_IMAGE) { @Override protected void onComponentTag(final ComponentTag tag) { super.onComponentTag(tag); String cssClass = ICON_DEFAULT_CSS_CLASS; if (link.getIcon() != null) { cssClass = link.getIcon().getCssClass(); } tag.put( "class", "info-box-icon " + (link.getColor() != null ? (link.getColor().startsWith("bg-") ? link.getColor() : "bg-" + link.getColor()) : "") + " " + cssClass); } }); linkItem.add( new Label( ID_LABEL, new Model<String>() { public String getObject() { return link.getLabel(); } })); Label description = new Label( ID_DESCRIPTION, new Model<String>() { public String getObject() { return link.getDescription(); } }); description.setEnabled(false); linkItem.add(description); column.add(linkItem); columnView.add(column); if (currentColumn == 1 || (linksList.indexOf(link) == linksListSize - 1)) { row.add(columnView); rowView.add(row); currentColumn = 0; isRowAdded = true; } else { currentColumn++; } } else { LOGGER.trace("Link {} not authorized, skipping", link); } } if (row != null && columnView != null && !isRowAdded) { row.add(columnView); rowView.add(row); } } add(rowView); }
@SuppressWarnings("serial") private void rebuildSocialMedias() { socialMediaRepeater.removeAll(); if (model.getObject().getSocialMedia() != null) { for (final LabelValueBean<InstantMessagingType, String> socialMediaValue : model.getObject().getSocialMedia()) { final WebMarkupContainer item = new WebMarkupContainer(socialMediaRepeater.newChildId()); socialMediaRepeater.add(item); final DropDownChoice<InstantMessagingType> socialMediaChoice = new DropDownChoice<InstantMessagingType>( "socialMediaChoice", new PropertyModel<InstantMessagingType>(socialMediaValue, "label"), socialMediaChoiceRenderer.getValues(), socialMediaChoiceRenderer); item.add(socialMediaChoice); socialMediaChoice.add( new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(final AjaxRequestTarget target) { // socialMediaValue.setSocialMediaType(socialMediaChoice.getModelObject()); // // model.getObject().setSocialMediaValues(contactDao.getSocialMediaValuesAsXml(socialMediaValues)); // target.add(mainContainer); } }); item.add( new AjaxMaxLengthEditableLabel( "editableLabel", new PropertyModel<String>(socialMediaValue, "value")) { @Override protected void onSubmit(final AjaxRequestTarget target) { super.onSubmit(target); model .getObject() .setSocialMedia(socialMediaValue.getLabel(), socialMediaValue.getValue()); rebuildSocialMedias(); target.add(mainContainer); } }); final WebMarkupContainer deleteDiv = new WebMarkupContainer("deleteDiv"); deleteDiv.setOutputMarkupId(true); deleteDiv.add( new AjaxIconLinkPanel( "delete", IconType.REMOVE, new PropertyModel<String>(socialMediaValue, "value")) { /** * @see * org.projectforge.web.wicket.flowlayout.AjaxIconLinkPanel#onClick(org.apache.wicket.ajax.AjaxRequestTarget) */ @Override protected void onClick(final AjaxRequestTarget target) { // super.onClick(target); // final Iterator<SocialMediaValue> it = socialMediaValues.iterator(); // while (it.hasNext() == true) { // if (it.next() == socialMediaValue) { // it.remove(); // } // } // rebuildSocialMedias(); // // model.getObject().setSocialMediaValues(contactDao.getSocialMediaValuesAsXml(socialMediaValues)); // target.add(mainContainer); } }); item.add(deleteDiv); } } }