@Override protected Component getComponentForProperty(String id, IModel itemModel, Property<WorkspaceInfo> property) { if ( property == NAME ) { return workspaceLink(id, itemModel); } else if (property == DEFAULT) { if(getCatalog().getDefaultWorkspace().equals(itemModel.getObject())) return new Icon(id, CatalogIconFactory.ENABLED_ICON); else return new Label(id, ""); } throw new IllegalArgumentException("No such property "+ property.getName()); }
@Override protected Component getComponentForProperty(String id, IModel itemModel, Property<GeoServerRole> property) { if (property == RoleListProvider.ROLENAME) { return editRoleLink(id, itemModel, property); } else if (RoleListProvider.ParentPropertyName.equals(property.getName())) { return editParentRoleLink(id, itemModel, property); } else if (property == RoleListProvider.HASROLEPARAMS) { if((Boolean) property.getModel(itemModel).getObject()) return new Icon(id, CatalogIconFactory.ENABLED_ICON); else return new Label(id, ""); } throw new RuntimeException("Uknown property " + property); }
@Override protected Component getComponentForProperty(String id, IModel itemModel, Property<GeoServerRole> property) { if (property == RoleListProvider.ROLENAME) { return editRoleLink(id, itemModel, property); } else if (RoleListProvider.ParentPropertyName.equals(property.getName())) { return editParentRoleLink(id, itemModel, property); } else if (property == RoleListProvider.HASROLEPARAMS) { if((Boolean) property.getModel(itemModel).getObject()) return new Icon(id, CatalogIconFactory.ENABLED_ICON); else return new Label(id, ""); } throw new RuntimeException("Uknown property " + property); }
@Override protected void populateItem(ListItem<Property<T>> item) { Property<T> property = item.getModelObject(); Component component = getComponentForProperty("component", itemModel, property); if (component == null) { // show a plain label if the the subclass did not create any component component = new Label("component", property.getModel(itemModel)); } else if (!"component".equals(component.getId())) { // add some checks for the id, the error message // that wicket returns in case of mismatch is not // that helpful throw new IllegalArgumentException( "getComponentForProperty asked " + "to build a component " + "with id = 'component' " + "for property '" + property.getName() + "', but got '" + component.getId() + "' instead"); } item.add(component); onPopulateItem(property, item); } };
/** * Returns a comparator given the sort property. * * @param sort * @return */ protected Comparator<T> getComparator(SortParam sort) { if (sort == null || sort.getProperty() == null) return null; for (Property<T> property : getProperties()) { if (sort.getProperty().equals(property.getName())) { Comparator<T> comparator = property.getComparator(); if (comparator != null) { if (!sort.isAscending()) return new ReverseComparator<T>(comparator); else return comparator; } } } LOGGER.log(Level.WARNING, "Could not find any comparator " + "for sort property " + sort.getProperty()); return null; }
@Override protected Component getComponentForProperty( String id, final IModel<DataAttribute> itemModel, Property<DataAttribute> property) { if (DataAttributesProvider.COMPUTE_STATS.equals(property.getName())) { Fragment f = new Fragment(id, "computeStatsFragment", DataPanel.this); f.add( new AjaxLink<Void>("computeStats") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { DataAttribute attribute = (DataAttribute) itemModel.getObject(); try { updateAttributeStats(attribute); } catch (IOException e) { error( "Failed to compute stats for the attribute: " + e.getMessage()); } target.add(attsContainer); } }); return f; } return null; } };
@Override protected Component getComponentForProperty(String id, IModel itemModel, Property<Resource> property) { if (property == NewLayerPageProvider.NAME) { return new Label(id, property.getModel(itemModel)); } else if (property == NewLayerPageProvider.PUBLISHED) { final Resource resource = (Resource) itemModel.getObject(); final CatalogIconFactory icons = CatalogIconFactory.get(); if(resource.isPublished()) { ResourceReference icon = icons.getEnabledIcon(); Fragment f = new Fragment(id, "iconFragment", NewLayerPage.this); f.add(new Image("layerIcon", icon)); return f; } else { return new Label(id); } } else if(property == NewLayerPageProvider.ACTION) { final Resource resource = (Resource) itemModel.getObject(); if(resource.isPublished()) { return resourceChooserLink(id, itemModel, new ParamResourceModel("publishAgain", this)); } else { return resourceChooserLink(id, itemModel, new ParamResourceModel("publish", this)); } } else { throw new IllegalArgumentException( "Don't know of property " + property.getName()); } }
@Override protected Component getComponentForProperty( String id, IModel<WorkspaceInfo> itemModel, Property<WorkspaceInfo> property) { if (property == NAME) { return workspaceLink(id, itemModel); } else if (property == DEFAULT) { if (getCatalog() .getDefaultWorkspace() .equals(itemModel.getObject())) return new Icon(id, CatalogIconFactory.ENABLED_ICON); else return new Label(id, ""); } else if (property == ISOLATED) { if (itemModel.getObject().isIsolated()) return new Icon(id, CatalogIconFactory.ENABLED_ICON); else return new Label(id, ""); } throw new IllegalArgumentException( "No such property " + property.getName()); }
@Override protected Component getComponentForProperty( String id, IModel<Parameter> itemModel, Property<Parameter> property) { Fragment f = new Fragment(id, "text", SQLViewAbstractPage.this); @SuppressWarnings("unchecked") TextField<String> text = new TextField<String>( "text", (IModel<String>) property.getModel(itemModel)); text.setLabel( new ParamResourceModel( "th." + property.getName(), SQLViewAbstractPage.this)); if (property == SQLViewParamProvider.NAME) { text.setRequired(true); } else if (property == SQLViewParamProvider.REGEXP) { text.add(new RegexpValidator()); } f.add(text); return f; } };
@Override protected Component getComponentForProperty( String id, IModel<GeoServerRole> itemModel, Property<GeoServerRole> property) { if (property == RoleListProvider.ROLENAME) { return editRoleLink(id, itemModel, property); } else if (RoleListProvider.ParentPropertyName.equals( property.getName())) { return editParentRoleLink(id, itemModel, property); } else if (property == RoleListProvider.HASROLEPARAMS) { if ((Boolean) property.getModel(itemModel).getObject()) return new Icon(id, CatalogIconFactory.ENABLED_ICON); else return new Label(id, ""); } throw new RuntimeException("Uknown property " + property); }
@Override public void onClick(AjaxRequestTarget target) { SortParam<?> currSort = dataProvider.getSort(); @SuppressWarnings("unchecked") Property<T> property = (Property<T>) getModelObject(); if (currSort == null || !property.getName().equals(currSort.getProperty())) { dataProvider.setSort(new SortParam<Object>(property.getName(), true)); } else { dataProvider.setSort( new SortParam<Object>(property.getName(), !currSort.isAscending())); } setSelection(false); target.add(listContainer); } };
public WorkspaceProvider() { setSort(NAME.getName(), true); }
@Override protected Component getComponentForProperty(String id, IModel itemModel, Property<Parameter> property) { Fragment f = new Fragment(id, "text", SQLViewAbstractPage.this); TextField text = new TextField("text", property.getModel(itemModel)); text.setLabel(new ParamResourceModel("th." + property.getName(), SQLViewAbstractPage.this)); if(property == SQLViewParamProvider.NAME) { text.setRequired(true); } else if(property == SQLViewParamProvider.REGEXP) { text.add(new RegexpValidator()); } f.add(text); return f; }
public WorkspaceProvider() { setSort(NAME.getName(), SortOrder.ASCENDING); }
public StyleProvider() { setSort(NAME.getName(), true); }
@Override public void onClick(AjaxRequestTarget target) { SortParam currSort = dataProvider.getSort(); Property<T> property = (Property<T>) getModelObject(); if (currSort == null || !property.getName().equals(currSort.getProperty())) { dataProvider.setSort(new SortParam(property.getName(), true)); } else { dataProvider .setSort(new SortParam(property.getName(), !currSort.isAscending())); } setSelection(false); target.addComponent(listContainer); }
public StyleProvider() { setSort(new SortParam<Object>(NAME.getName(), true)); }
/** * Returns a model for this property title. Default behaviour is to lookup for a * resource name <page>.th.<propertyName> * @param property * @return */ IModel getPropertyTitle(Property<T> property) { String pageName = this.getPage().getClass().getSimpleName(); ResourceModel resMod = new ResourceModel("th." + property.getName(), property.getName()); return resMod; }
protected Property<T> getProperty(SortParam<?> sort) { if (sort == null || sort.getProperty() == null) return null; for (Property<T> property : getProperties()) { if (sort.getProperty().equals(property.getName())) { return property; } } return null; } /**
/** * Returns a model for this property title. Default behaviour is to lookup for a resource name * <page>.th.<propertyName> * * @param property */ protected IModel<String> getPropertyTitle(Property<T> property) { ResourceModel resMod = new ResourceModel("th." + property.getName(), property.getName()); return resMod; }