org.apache.wicket.Component Java Examples
The following examples show how to use
org.apache.wicket.Component.
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: ProjectSelectionPanel.java From webanno with Apache License 2.0 | 7 votes |
public ProjectSelectionPanel(String id, IModel<Project> aModel) { super(id); overviewList = new OverviewListChoice<>("project"); overviewList.setChoiceRenderer(new ChoiceRenderer<>("name")); overviewList.setModel(aModel); overviewList.setChoices(LambdaModel.of(this::listProjects)); overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange)); add(overviewList); add(createLink = new LambdaAjaxLink("create", this::actionCreate)); MetaDataRoleAuthorizationStrategy.authorize(createLink, Component.RENDER, StringUtils.join( new String[] { Role.ROLE_ADMIN.name(), Role.ROLE_PROJECT_CREATOR.name() }, ",")); importProjectPanel = new ProjectImportPanel("importPanel", aModel); add(importProjectPanel); authorize(importProjectPanel, Component.RENDER, String.join(",", ROLE_ADMIN.name(), ROLE_PROJECT_CREATOR.name())); }
Example #2
Source File: URIValidator.java From ontopia with Apache License 2.0 | 6 votes |
@Override protected void onValidate(IValidatable<String> validatable) { final String value = validatable.getValue(); if (value == null) return; try { new URILocator(value); } catch (Exception e) { String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey(), (Component)null, new Model<Serializable>(new Serializable() { @SuppressWarnings("unused") public String getValue() { return value; } })); component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message))); } }
Example #3
Source File: RelationshipTypesITCase.java From syncope with Apache License 2.0 | 6 votes |
@Test public void read() { browsingToRelationshipType(); Component result = findComponentByProp(KEY, DATATABLE_PATH, "inclusion"); TESTER.assertComponent( result.getPageRelativePath() + ":cells:1:cell", Label.class); TESTER.executeAjaxEvent(result.getPageRelativePath(), Constants.ON_CLICK); TESTER.clickLink( "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:" + "togglePanelContainer:container:actions:actions:actionRepeater:0:action:action"); TESTER.assertComponent( "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", BaseModal.class); }
Example #4
Source File: NoNameRendererProvider.java From onedev with MIT License | 6 votes |
@Override public PrioritizedComponentRenderer getRenderer(BlobRenderContext context) { if (context.getMode() == Mode.ADD && context.getNewPath() == null) { return new PrioritizedComponentRenderer() { private static final long serialVersionUID = 1L; @Override public Component render(String componentId) { return new NoNameEditPanel(componentId, context); } @Override public int getPriority() { return 0; } }; } else { return null; } }
Example #5
Source File: OrderItemListPanel.java From the-app with Apache License 2.0 | 6 votes |
private Component orderItemList() { return new ListView<OrderItemInfo>("orderItems", new PropertyModel<List<OrderItemInfo>>(getDefaultModel(), "orderItems")) { private int orderItemCounter = 1; @Override protected void populateItem(ListItem<OrderItemInfo> orderItem) { orderItem.add(new Label("orderItemCounter", Model.of(orderItemCounter++))); orderItem.add(new Label("product", new PropertyModel<String>(orderItem.getModel(), "product.name"))); orderItem.add(new Label("description", new PropertyModel<String>(orderItem.getModel(), "product.description"))); orderItem.add(new Label("totalSum", new PriceModel(new PropertyModel<>(orderItem.getModel(), "totalSum")))); } @Override protected void onDetach() { orderItemCounter = 1; super.onDetach(); } }; }
Example #6
Source File: InfiniteScrollListView.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
private Behavior getScrollBehaviour(){ return new AttributeModifier("scroll", Model.of(this.getMarkupId())){ private static final long serialVersionUID = 3523727356782417598L; @Override public void renderHead(Component component, IHeaderResponse response) { super.renderHead(component, response); response.render(OnDomReadyHeaderItem.forScript("InfiniteScroll.getFromContainer('"+getMarkupId()+"').setUrls('"+upBehavior.getCallbackUrl()+"', '"+downBehavior.getCallbackUrl()+"')")); } @Override protected String newValue(String currentValue, String replacementValue) { return "InfiniteScroll.handleScroll('"+InfiniteScrollListView.this.getMarkupId()+"')"; } }; }
Example #7
Source File: ImageRendererProvider.java From onedev with MIT License | 6 votes |
@Override public PrioritizedComponentRenderer getRenderer(BlobRenderContext context) { if (context.getMode() == Mode.VIEW && context.getBlobIdent().isFile()) { if (context.getProject().getBlob(context.getBlobIdent(), true).getMediaType().getType().equalsIgnoreCase("image")) { return new PrioritizedComponentRenderer() { private static final long serialVersionUID = 1L; @Override public Component render(String componentId) { return new ImageViewPanel(componentId, context); } @Override public int getPriority() { return 0; } }; } } return null; }
Example #8
Source File: AjaxActionTab.java From onedev with MIT License | 6 votes |
@Override public Component render(String componentId) { return new ActionTabLink(componentId, this) { @Override protected WebMarkupContainer newLink(String id, ActionTab tab) { return new AjaxLink<Void>("link") { @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); AjaxActionTab.this.updateAjaxAttributes(attributes); } @Override public void onClick(AjaxRequestTarget target) { selectTab(this); } }; } }; }
Example #9
Source File: AjaxLazyLoadFragment.java From sakai with Educational Community License v2.0 | 5 votes |
/** * @param markupId The components markupid. * @return The component to show while the real component is being created. */ public Component getLoadingComponent(String markupId) { Label indicator = new Label(markupId, "<img src=\"" + RequestCycle.get().urlFor(AbstractDefaultAjaxBehavior.INDICATOR, null) + "\"/>"); indicator.setEscapeModelStrings(false); indicator.add(new AttributeModifier("title", new Model("..."))); return indicator; }
Example #10
Source File: AjaxLazyLoadImage.java From sakai with Educational Community License v2.0 | 5 votes |
/** * @param markupId * The components markupid. * @return The component to show while the real component is being created. */ public Component getLoadingComponent(String markupId) { Label indicator = new Label(markupId, "<img src=\"" + RequestCycle.get().urlFor(AbstractDefaultAjaxBehavior.INDICATOR, null) + "\"/>"); indicator.setEscapeModelStrings(false); indicator.add(new AttributeModifier("title", new Model("..."))); return indicator; }
Example #11
Source File: EmbeddedCollectionViewPanel.java From Orienteer with Apache License 2.0 | 5 votes |
public EmbeddedCollectionViewPanel(String id, final IModel<ODocument> documentModel, final IModel<OProperty> propertyModel) { super(id, new DynamicPropertyValueModel<M>(documentModel, propertyModel)); final DefaultVisualizer visualizer = DefaultVisualizer.INSTANCE; OProperty property = propertyModel.getObject(); final OType oType = property.getLinkedType()!=null?property.getLinkedType():OType.EMBEDDED; ListView<T> listView = new ListView<T>("items", new CollectionAdapterModel<T, M>(getModel())) { @Override protected void populateItem(ListItem<T> item) { item.add(visualizer.createComponent("item", DisplayMode.VIEW, documentModel, propertyModel, oType, item.getModel())); } @Override protected ListItem<T> newItem(int index, IModel<T> itemModel) { return new ListItem<T>(index, itemModel) { @Override public IMarkupFragment getMarkup(Component child) { if(child==null || !child.getId().equals("item")) return super.getMarkup(child); IMarkupFragment ret = markupProvider.provideMarkup(child); return ret!=null?ret:super.getMarkup(child); } }; } }; add(listView); }
Example #12
Source File: PullRequestChangeActivity.java From onedev with MIT License | 5 votes |
@Override public Component render(String panelId, DeleteCallback callback) { return new PullRequestChangePanel(panelId, new LoadableDetachableModel<PullRequestChange>() { @Override protected PullRequestChange load() { return getChange(); } }); }
Example #13
Source File: ConfirmLeaveListener.java From onedev with MIT License | 5 votes |
@Override public CharSequence getPrecondition(Component component) { if (dirtyContainer != null) return String.format("return onedev.server.form.confirmLeave('%s');", dirtyContainer.getMarkupId(true)); else return "return onedev.server.form.confirmLeave();"; }
Example #14
Source File: ProjectFormPopupPanel.java From artifact-listener with Apache License 2.0 | 5 votes |
@Override protected Component createHeader(String wicketId) { if (isAddMode()) { return new Label(wicketId, new ResourceModel("project.add")); } else { return new Label(wicketId, new StringResourceModel("project.edit", getModel())); } }
Example #15
Source File: JavaScriptCodeVisualizer.java From Orienteer with Apache License 2.0 | 5 votes |
@Override public <V> Component createComponent(String id, DisplayMode mode, IModel<ODocument> documentModel, IModel<OProperty> propertyModel, IModel<V> valueModel) { return new HtmlCssJsEditorPanel(id, (IModel<String>) valueModel, Model.of(mode)) { @Override protected void configureEditorParams(Map<String, String> params) { super.configureEditorParams(params); params.put(IEditorOptions.NAME, "'jsEditor'"); params.put(IEditorOptions.MODE, "'javascript'"); } }; }
Example #16
Source File: ProductCatalogPage.java From the-app with Apache License 2.0 | 5 votes |
private Component rowView() { return new ListView<List<ProductInfo>>("row", productListModel) { @Override protected void populateItem(ListItem<List<ProductInfo>> item) { item.add(productView(item.getModel())); } }; }
Example #17
Source File: HomePage.java From yes-cart with Apache License 2.0 | 5 votes |
private AbstractCentralView getCentralPanel() { final Component comp = get("centralView"); if (comp instanceof AbstractCentralView) { return (AbstractCentralView) comp; } return null; }
Example #18
Source File: QualifierEditor.java From inception with Apache License 2.0 | 5 votes |
/** * Creates a new fragement for editing a qualifier.<br> * The editor has two slightly different behaviors, depending on the value of * {@code isNewQualifier}: * <ul> * <li>{@code !isNewQualifier}: Save button commits changes, cancel button discards unsaved * changes, delete button removes the qualifier from the statement.</li> * <li>{@code isNewQualifier}: Save button commits changes (creates a new qualifier in the * statement), cancel button removes the qualifier from the UI, delete button is not visible * .</li> * </ul> * * @param aId * markup ID * @param aQualifier * qualifier model * @param isNewQualifier * whether the qualifier being edited is new, meaning it has no corresponding * qualifier in the KB backend */ public EditMode(String aId, IModel<KBQualifier> aQualifier, boolean isNewQualifier) { super(aId, "editMode", QualifierEditor.this, aQualifier); IModel<KBQualifier> compoundModel = CompoundPropertyModel.of(aQualifier); Form<KBQualifier> form = new Form<>("form", compoundModel); DropDownChoice<KBProperty> type = new BootstrapSelect<>("property"); type.setChoiceRenderer(new ChoiceRenderer<>("uiLabel")); type.setChoices(kbService.listProperties(kbModel.getObject(), false)); type.setRequired(true); type.setOutputMarkupId(true); form.add(type); initialFocusComponent = type; form.add(new TextField<>("language")); Component valueTextArea = new TextArea<String>("value"); form.add(valueTextArea); form.add(new LambdaAjaxButton<>("create", QualifierEditor.this::actionSave)); form.add(new LambdaAjaxLink("cancel", t -> { if (isNewQualifier) { QualifierEditor.this.actionCancelNewQualifier(t); } else { QualifierEditor.this.actionCancelExistingQualifier(t); } })); form.add(new LambdaAjaxLink("delete", QualifierEditor.this::actionDelete) .setVisibilityAllowed(!isNewQualifier)); add(form); }
Example #19
Source File: JobTrigger.java From onedev with MIT License | 5 votes |
@SuppressWarnings("unused") private static List<ParamSpec> getParamSpecs() { Component component = ComponentContext.get().getComponent(); JobAware jobAware = WicketUtils.findInnermost(component, JobAware.class); if (jobAware != null) { Job job = jobAware.getJob(); if (job != null) return job.getParamSpecs(); } return new ArrayList<>(); }
Example #20
Source File: HomePage.java From AppStash with Apache License 2.0 | 5 votes |
private Component topSellerPanel() { boolean userAuthorized = isUserAuthorized(); String ressourceKey = userAuthorized ? "your.favorite.products.topic" : "category.top.seller.topic"; String recommenderType = userAuthorized ? "FAVORITE_PRODUCTS" : "STARTPAGE_TOPSELLER"; return new RecommendationItemListPanel("topSellerProductsContainer", feedback,recommenderType, new ResourceModel(ressourceKey), new LoadableDetachableModel<List<ProductInfo>>() { @Override protected List<ProductInfo> load() { return recommendationService.getTopsellerRecommendations(4); } }) { }; }
Example #21
Source File: SimpleVisualizer.java From Orienteer with Apache License 2.0 | 5 votes |
public <T> Component createComponent(String id, DisplayMode mode, IModel<T> model) { Class<? extends Component> componentClass = DisplayMode.EDIT.equals(mode)?editComponentClass:viewComponentClass; try { return componentClass.getConstructor(String.class, IModel.class).newInstance(id, model); } catch (Exception e) { throw new WicketRuntimeException("Can't create component", e); } }
Example #22
Source File: MarkDownVisualizer.java From Orienteer with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <V> Component createComponent(String id, DisplayMode mode, IModel<ODocument> documentModel, IModel<OProperty> propertyModel, IModel<V> valueModel) { switch (mode) { case VIEW: return new Label(id, new MarkDownModel((IModel<String>) valueModel)).setEscapeModelStrings(false); case EDIT: return new TextArea<String>(id, (IModel<String>) valueModel).setType(String.class); default: return null; } }
Example #23
Source File: RoomFilePanel.java From openmeetings with Apache License 2.0 | 5 votes |
@Override protected Component getUpload() { return super.getUpload() .setVisible(true) .add(new AjaxEventBehavior(EVT_CLICK) { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { room.getSidebar().showUpload(target); } }); }
Example #24
Source File: ProjectIssuesPage.java From onedev with MIT License | 5 votes |
@Override public Component render(String componentId) { return new PageTabLink(componentId, this) { @Override protected Link<?> newLink(String linkId, Class<? extends Page> pageClass) { return new ViewStateAwarePageLink<Void>(linkId, pageClass, paramsOf(getProject())); } }; }
Example #25
Source File: AjaxListSetView.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Iterator<? extends Component> renderIterator() { return IteratorUtils.transformedIterator(getList().iterator(), new Transformer<T, ListSetItem<?>>() { @Override public ListSetItem<?> transform(T el) { ListSetItem<?> component = elementToComponent.get(el); if(component==null) throw new IllegalStateException("could not find element '"+el+"' on computed map"); return component; } }); }
Example #26
Source File: IssueTitleChangeData.java From onedev with MIT License | 5 votes |
@Override public Component render(String componentId, IssueChange change) { return new PropertyChangePanel(componentId, CollectionUtils.newHashMap("Title", oldTitle), CollectionUtils.newHashMap("Title", newTitle), true); }
Example #27
Source File: LinkFunctionBoxPanel.java From ontopia with Apache License 2.0 | 5 votes |
@Override protected List<List<Component>> getFunctionBoxComponentList(String id) { List<Component> heading = Arrays.asList(new Component[] { getLabel(id) }); List<Component> box = Arrays.asList(new Component[] { new Label(id, new ResourceModel("arrow.right")), getLink(id) }); List<List<Component>> result = new ArrayList<List<Component>>(2); result.add(heading); result.add(box); return result; }
Example #28
Source File: MyStatusPanel.java From sakai with Educational Community License v2.0 | 5 votes |
public void renderHead(Component component, IHeaderResponse response) { response.render(StringHeaderItem.forString("<script type=\"text/javascript\">" + "$(document).ready( function(){" + "autoFill('#" + component.getMarkupId() + "', '" + defaultStatus + "');" + "countChars('#" + component.getMarkupId() + "');" + "});" + "</script>")); }
Example #29
Source File: GridPanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * @see org.apache.wicket.MarkupContainer#remove(org.apache.wicket.Component) */ @Override public MarkupContainer remove(final Component component) { if (repeater == null) { div.remove(component); return this; } else { repeater.remove(component); return this; } }
Example #30
Source File: PropertyContext.java From onedev with MIT License | 5 votes |
public static Component viewModel(String componentId, IModel<Serializable> beanModel, String propertyName) { PropertyContext<Serializable> editContext = of(HibernateProxyHelper.getClassWithoutInitializingProxy(beanModel.getObject()), propertyName); return editContext.renderForView(componentId, new LoadableDetachableModel<Serializable>() { @Override protected Serializable load() { return (Serializable) editContext.getDescriptor().getPropertyValue(beanModel.getObject()); } }); }