List of usage examples for org.apache.wicket.markup.html.list ListView ListView
public ListView(final String id, final List<T> list)
From source file:gr.abiss.calipso.wicket.asset.AssetFormCustomAttributePanel.java
License:Open Source License
private void renderAttributes(List<KeyValuePair> attributeEntryList) { // remove the old listView if (customAttributesList != null) { remove(customAttributesList);//from w ww . j a v a2s . c om } customAttributesList = new ListView("fields", attributeEntryList) { @Override protected void populateItem(ListItem listItem) { KeyValuePair entry = (KeyValuePair) listItem.getModelObject(); final AssetTypeCustomAttribute attribute = (AssetTypeCustomAttribute) entry.getKey(); if (attribute.isActive()) { Fragment labelFragment = new Fragment("fieldLabel", "mandatory", this); //Label label = new Label("label", attribute.getName()); Label label = new Label("label", new ResourceModel(attribute.getNameTranslationResourceKey())); labelFragment.add(label); if (attribute.isMandatory() && !isSearchMode) { labelFragment.add(new MandatoryPanel("mandatoryPanel")); } else { labelFragment.add(new WebMarkupContainer("mandatoryPanel")); } listItem.add(labelFragment); //String value = null; //if (AssetFormCustomAttributePanel.this.attributesMap != null // && AssetFormCustomAttributePanel.this.attributesMap.size() > 0) { // value = AssetFormCustomAttributePanel.this.attributesMap.get(attribute); //}// if /*AssetCustomAttributeValue attributeValue = new AssetCustomAttributeValue( AssetFormCustomAttributePanel.this.asset, attribute, value);*/ listItem.add(renderAttribute(entry)); } // if else { listItem.add(new WebMarkupContainer("fieldLabel").setVisible(false)); listItem.add(new WebMarkupContainer("customAttributes").setVisible(false)); } }// populateItem }; add(customAttributesList); }
From source file:gr.abiss.calipso.wicket.asset.AssetsListPanel.java
License:Open Source License
private void addComponents(List<Asset> assets) { // Pagination PaginationPanel paginationPanel = new PaginationPanel("paginationPanel", getBreadCrumbModel(), this.assetSearch) { IBreadCrumbPanelFactory breadCrumbPanelFactory = new IBreadCrumbPanelFactory() { public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) { //Remove last breadcrumb participant if (breadCrumbModel != null && breadCrumbModel.allBreadCrumbParticipants().size() > 0) { breadCrumbModel.allBreadCrumbParticipants() .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1); } //if return new AssetSpacePanel(getBreadCrumbModel().getActive().getComponent().getId(), getBreadCrumbModel(), AssetsListPanel.this.assetSearch); }//w ww.j av a2 s. c o m }; public void onNextPageClick() { activate(breadCrumbPanelFactory); } public void onPreviousPageClick() { activate(breadCrumbPanelFactory); } public void onPageNumberClick() { activate(breadCrumbPanelFactory); } }; add(paginationPanel); // List view headers List<String> columnHeaders = this.assetSearch.getColumnHeaders(); ListView headings = new ListView("headings", columnHeaders) { protected void populateItem(ListItem listItem) { final String header = (String) listItem.getModelObject(); Link headingLink = new Link("heading") { public void onClick() { AssetsListPanel.this.assetSearch.doSort(header); } }; listItem.add(headingLink); String label = localize("asset.assetsList." + header); headingLink.add(new Label("heading", label)); if (header.equals(AssetsListPanel.this.assetSearch.getSortFieldName())) { String order = AssetsListPanel.this.assetSearch.isSortDescending() ? "order-down" : "order-up"; listItem.add(new SimpleAttributeModifier("class", order)); } } }; add(headings); //Header message Label hAction = new Label("hAction"); hAction.setDefaultModel(new Model(localize("edit"))); add(hAction); ///////////////// // Asset List // ///////////////// final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt"); ListView listView = new ListView("assetsList", assets) { protected void populateItem(ListItem listItem) { /* final Asset asset; if (listItem.getModelObject().getClass().equals(AssetCustomAttributeValue.class)){ AssetCustomAttributeValue assetCustomAttributeValue = (AssetCustomAttributeValue)listItem.getModelObject(); asset = assetCustomAttributeValue.getAsset(); } else{ asset = (Asset)listItem.getModelObject(); }*/ final Asset asset = (Asset) listItem.getModelObject(); if (selectedAssetId != null && selectedAssetId.equals(asset.getId())) { listItem.add(new SimpleAttributeModifier("class", "selected")); } else if (listItem.getIndex() % 2 != 0) { listItem.add(sam); } //if Label assetType = new Label("assetType", localize(asset.getAssetType().getNameTranslationResourceKey())); listItem.add(assetType); final WebMarkupContainer customAttributesContainer = new WebMarkupContainer( "customAttributesContainer"); customAttributesContainer.setOutputMarkupId(true); listItem.add(customAttributesContainer); final WebMarkupContainer customAttributesPanelContainer = new WebMarkupContainer( "customAttributesPanel"); customAttributesPanelContainer.setOutputMarkupId(true); customAttributesContainer.add(customAttributesPanelContainer); ExpandCustomAttributesLink customAttributesLink = new ExpandCustomAttributesLink( "showCustomAttributesLink", getBreadCrumbModel(), asset); customAttributesLink.setComponentWhenCollapsed(customAttributesPanelContainer); customAttributesLink.setTargetComponent(customAttributesContainer); customAttributesLink.setImageWhenCollapsed(new CollapsedPanel("imagePanel")); customAttributesLink.setImageWhenExpanded(new ExpandedPanel("imagePanel")); CollapsedPanel imagePanel = new CollapsedPanel("imagePanel"); customAttributesLink.add(imagePanel); listItem.add(customAttributesLink); //listItem.add(new Label("inventoryCode", asset.getInventoryCode())); listItem.add(new AssetViewLink("inventoryCode", getBreadCrumbModel(), asset)); // display space listItem.add(new Label("space", localize(asset.getSpace().getNameTranslationResourceKey()))); //format and display dates SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); // start date if (asset.getSupportStartDate() != null) { listItem.add(new Label("supportStartDate", dateFormat.format(asset.getSupportStartDate()))); } else { listItem.add(new Label("supportStartDate", "")); } // end date if (asset.getSupportEndDate() != null) { listItem.add(new Label("supportEndDate", dateFormat.format(asset.getSupportEndDate())) .add(AssetsUtils.getSupportEndDateStyle(asset.getSupportEndDate()))); } else { listItem.add(new Label("supportEndDate", "")); } //edit or other action button/link AbstractLink link = getAssetActionLink("actionLink", asset); listItem.add(link); //For future use WebMarkupContainer add = new WebMarkupContainer("add"); add.setVisible(false); listItem.add(add); }//populateItem };//ListView add(listView); add(new WebMarkupContainer("noData").setVisible(this.assetSearch.getResultCount() == 0)); }
From source file:gr.abiss.calipso.wicket.asset.AssetTypeCustomAttributeValues.java
License:Open Source License
private void addComponents(List<KeyValuePair> customAttributes, Asset asset) { final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt"); @SuppressWarnings("serial") ListView listView = new ListView("attributeValuesList", customAttributes) { @Override/*from w w w . java 2 s. c o m*/ protected void populateItem(ListItem listItem) { KeyValuePair entry = (KeyValuePair) listItem.getModelObject(); AssetTypeCustomAttribute customAttr = (AssetTypeCustomAttribute) entry.getKey(); String sValue = CustomAttribute.FORM_TYPE_TABULAR.equals(customAttr.getFormType()) ? null : (String) entry.getValue(); if (listItem.getIndex() % 2 == 0) { listItem.add(sam); } //if /* if(customAttr.getFormType().equals(AssetTypeCustomAttribute.FORM_TYPE_ASSET)){ value = customAttr.getAssetValue().getInventoryCode(); } else if(customAttr.getFormType().equals(AssetTypeCustomAttribute.FORM_TYPE_USER)){ value =customAttr.getUserValue().getDisplayValue(); } else if(customAttr.getFormType().equals(AssetTypeCustomAttribute.FORM_TYPE_ORGANIZATION)){ value =customAttr.getOrganizationValue().getName(); } else{ value = customAttributesMap.get(customAttr); } Label customAttributeValueLabel = new Label("customAttributeValue", value); listItem.add(customAttributeValueLabel); */ // Label, attribute name Label customAttributeLabel = new Label("customAttribute", localize(customAttr.getNameTranslationResourceKey())); listItem.add(customAttributeLabel); String value = new String(localize("asset.customAttributeNoValue")); if (sValue != null && !sValue.isEmpty()) { value = sValue; } if (customAttr.getFormType().equals(AssetTypeCustomAttribute.FORM_TYPE_SELECT) || customAttr.getFormType().equals(AssetTypeCustomAttribute.FORM_TYPE_OPTIONS_TREE)) { CustomAttributeLookupValue lookupValue = customAttr.getLookupValue(); logger.info("lookupValue: " + lookupValue); Label customAttributeValueLabel; if (lookupValue != null) { customAttributeValueLabel = (Label) new Label("customAttributeValue", localize(lookupValue.getNameTranslationResourceKey())).setEscapeModelStrings(false); } else { customAttributeValueLabel = new Label(""); } listItem.add(customAttributeValueLabel); } // this works for all componentViewLinks else if (customAttr.getFormType().equals(AssetTypeCustomAttribute.FORM_TYPE_USER)) { // used this to proper render value and not throw exception if breadcrumb not exists if (getBreadCrumbModel() != null) { UserViewLink userViewLink = new UserViewLink("customAttributeValue", getBreadCrumbModel(), customAttr.getUserValue()); listItem.add(userViewLink); } else { Label customAttributeValueLabel = (Label) new Label("customAttributeValue", customAttr.getUserValue().getDisplayValue()).setEscapeModelStrings(false); listItem.add(customAttributeValueLabel); } } else if (customAttr.getFormType().equals(AssetTypeCustomAttribute.FORM_TYPE_ORGANIZATION)) { if (getBreadCrumbModel() != null) {// this works for all componentViewLinks OrganizationViewLink organizationViewLink = new OrganizationViewLink("customAttributeValue", getBreadCrumbModel(), customAttr.getOrganizationValue()); listItem.add(organizationViewLink); } else { Label customAttributeValueLabel = (Label) new Label("customAttributeValue", customAttr.getOrganizationValue().getName()).setEscapeModelStrings(false); listItem.add(customAttributeValueLabel); } } else if (customAttr.getFormType().equals(AssetTypeCustomAttribute.FORM_TYPE_COUNTRY)) { Country country = customAttr.getCountryValue(); Label customAttributeValueLabel = (Label) new Label("customAttributeValue", country != null ? localize(country) : "").setEscapeModelStrings(false); listItem.add(customAttributeValueLabel); } else if (customAttr.getFormType().equals(AssetTypeCustomAttribute.FORM_TYPE_ASSET)) { if (getBreadCrumbModel() != null) {// this works for all componentViewLinks // this works for all componentViewLinks AssetViewLink assetViewLink = new AssetViewLink("customAttributeValue", getBreadCrumbModel(), customAttr.getAssetValue()); listItem.add(assetViewLink); } else { Label customAttributeValueLabel = (Label) new Label("customAttributeValue", customAttr.getAssetValue().getDisplayedValue()); listItem.add(customAttributeValueLabel); } } else { Label customAttributeValueLabel = (Label) new Label("customAttributeValue", value) .setEscapeModelStrings(false); listItem.add(customAttributeValueLabel); } }//populateItem }; // WebMarkupContainer noCustomAttributes = new WebMarkupContainer("noCustomAttributes"); Label noCustomAttributes = new Label("noCustomAttributes", new Model(localize("asset.noCustomAttributes", localize(asset.getAssetType().getNameTranslationResourceKey())))); //asset.noCustomAttributes noCustomAttributes .setVisible(customAttributes == null || (customAttributes != null && customAttributes.size() == 0)); add(noCustomAttributes); add(listView); }
From source file:gr.abiss.calipso.wicket.asset.AssetTypeFormPanel.java
License:Open Source License
/** * Renders UI Components//from w ww . j a va 2 s .c o m * */ private void addComponents(final List<AssetTypeCustomAttribute> assetTypeCustomAttributes, final CompoundPropertyModel model) { //Mandatory mark. red asterisk (*) add(new MandatoryPanel("mandatoryPanel")); //name /* TextField name = new TextField("name"); name.setRequired(true); name.add(new ErrorHighlighter()); add(name); model.bind(name); //form label for name name.setLabel(new ResourceModel("asset.assetTypes.description")); add(new SimpleFormComponentLabel("textLabel", name)); */ if (MapUtils.isEmpty(this.assetType.getNameTranslations())) { this.assetType.setNameTranslations(getCalipso().getNameTranslations(this.assetType)); } // TODO: switch to space or spacegroup languages when we move asset type creation context there add(new ListView("nameTranslations", getCalipso().getSupportedLanguages()) { protected void populateItem(ListItem listItem) { Language language = (Language) listItem.getModelObject(); TextField description = new TextField("name"); // name translations are required. description.setRequired(true); description.add(new ErrorHighlighter()); listItem.add(description); description.setModel(new PropertyModel(assetType, "nameTranslations[" + language.getId() + "]")); //model.bind(description, "nameTranslations["+language.getId()+"]"); // form label for name description.setLabel(new ResourceModel("language." + language.getId())); listItem.add(new SimpleFormComponentLabel("languageLabel", description)); } }); WebMarkupContainer customAttributes = new WebMarkupContainer("customAttributes"); //Add new attribute Link addNewAttribute = new Link("add") { public void onClick() { activate(new IBreadCrumbPanelFactory() { public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) { return new AssetCustomAttributesPanel( getBreadCrumbModel().getActive().getComponent().getId(), getBreadCrumbModel(), AssetTypeFormPanel.this.assetType); } }); }//onClick }; customAttributes.add(addNewAttribute); final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt"); //customAttributes ListView listView = new ListView("customAttributesList", assetTypeCustomAttributes) { protected void populateItem(ListItem listItem) { if (listItem.getIndex() % 2 != 0) { listItem.add(sam); } //if final AssetTypeCustomAttribute assetTypeCustomAttribute = (AssetTypeCustomAttribute) listItem .getModelObject(); boolean canDeleteCustomAttribute = false;//getJtrac().loadCountForAssetTypeAndCustomAttribute(assetType, assetTypeCustomAttribute); //Name Label name = new Label("name", localize(assetTypeCustomAttribute.getNameTranslationResourceKey())); listItem.add(name); //Type Label type = new Label("type", localize("asset.attributeType_" + assetTypeCustomAttribute.getFormType())); listItem.add(type); //Active Label active = new Label("active", assetTypeCustomAttribute.isActive() ? localize("yes") : localize("no")); listItem.add(active); //Mandatory Label mandatory = new Label("mandatory", assetTypeCustomAttribute.isMandatory() ? localize("yes") : localize("no")); listItem.add(mandatory); //Remove Link remove = new Link("remove") { public void onClick() { assetTypeCustomAttributes.remove(assetTypeCustomAttribute); assetType.remove(assetTypeCustomAttribute); BreadCrumbUtils.removeActiveBreadCrumbPanel(getBreadCrumbModel()); activate(new IBreadCrumbPanelFactory() { public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) { return new AssetTypeFormPagePanel( getBreadCrumbModel().getActive().getComponent().getId(), getBreadCrumbModel(), assetType); }//create }); }//onClick }; listItem.add(remove); remove.setVisible(canDeleteCustomAttribute); }//populateItem };//ListView add(customAttributes.add(listView).setVisible(isEdit)); }
From source file:gr.abiss.calipso.wicket.asset.AssetTypesListPanel.java
License:Open Source License
private void addComponents(IModel assetTypes) { //////////////// // Pagination // //////////////// PaginationPanel paginationPanel = new PaginationPanel("paginationPanel", getBreadCrumbModel(), this.assetTypeSearch) { IBreadCrumbPanelFactory breadCrumbPanelFactory = new IBreadCrumbPanelFactory() { public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) { //Remove last breadcrumb participant if (breadCrumbModel.allBreadCrumbParticipants().size() > 0) { breadCrumbModel.allBreadCrumbParticipants() .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1); } //if return new AssetTypesPanel(getBreadCrumbModel().getActive().getComponent().getId(), getBreadCrumbModel(), AssetTypesListPanel.this.assetTypeSearch); }/*from www . j a v a 2s .c o m*/ }; public void onNextPageClick() { activate(breadCrumbPanelFactory); } public void onPreviousPageClick() { activate(breadCrumbPanelFactory); } public void onPageNumberClick() { activate(breadCrumbPanelFactory); } }; add(paginationPanel); ///////////////// // List header // ///////////////// List<String> columnHeaders = this.assetTypeSearch.getColumnHeaders(); ListView headings = new ListView("headings", columnHeaders) { protected void populateItem(ListItem listItem) { final String header = (String) listItem.getModelObject(); Link headingLink = new Link("heading") { public void onClick() { AssetTypesListPanel.this.assetTypeSearch.doSort(header); } }; listItem.add(headingLink); String label = localize("asset.assetTypes." + header); headingLink.add(new Label("heading", label)); if (header.equals(AssetTypesListPanel.this.assetTypeSearch.getSortFieldName())) { String order = AssetTypesListPanel.this.assetTypeSearch.isSortDescending() ? "order-down" : "order-up"; listItem.add(new SimpleAttributeModifier("class", order)); } } }; add(headings); ///////////////////// // Asset Type List // ///////////////////// final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt"); ListView listView = new ListView("assetTypeList", assetTypes) { protected void populateItem(ListItem listItem) { final AssetType assetType = (AssetType) listItem.getModelObject(); if (selectedAssetTypeId != null && assetType.getId() == selectedAssetTypeId.longValue()) { listItem.add(new SimpleAttributeModifier("class", "selected")); } else if (listItem.getIndex() % 2 != 0) { listItem.add(sam); } //if // TODO: remove the getName part after ele finishes listItem.add(new Label("description", localize(assetType.getNameTranslationResourceKey()))); listItem.add(new BreadCrumbLink("edit", getBreadCrumbModel()) { @Override protected IBreadCrumbParticipant getParticipant(String id) { return new AssetTypeFormPagePanel(id, getBreadCrumbModel(), getCalipso().loadAssetType(assetType.getId())); } }); }//populateItem };//ListView add(listView); add(new WebMarkupContainer("noData").setVisible(this.assetTypeSearch.getResultCount() == 0)); }
From source file:gr.abiss.calipso.wicket.asset.ItemAssetsPanel.java
License:Open Source License
/** * /* www . j a v a 2 s .c o m*/ * @param assetsModel * @param isViewMode * @return */ private WebMarkupContainer renderAssetList(final IModel assetsModel, final boolean isViewMode) { //Assets list container ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ final WebMarkupContainer itemAssetsListContainer = new WebMarkupContainer("itemAssetsListContainer"); //Assets list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt"); if (!isViewMode) { Label hCheckbox = new Label("hCheckbox", localize("asset.assetPanel.choose")); itemAssetsListContainer.add(hCheckbox); } else { itemAssetsListContainer.add(new WebMarkupContainer("hCheckbox").setVisible(false)); } ListView assetsListView = new ListView("assetsList", assetsModel) { protected void populateItem(final ListItem listItem) { if (listItem.getIndex() % 2 != 0) { listItem.add(sam); } //if final Asset asset = (Asset) listItem.getModelObject(); WebMarkupContainer chooseContainer = new WebMarkupContainer("chooseContainer"); listItem.add(chooseContainer); if (!isViewMode) { // TODO: final CheckBox chooseAssetCheckBox = new CheckBox("choose", new Model(selectedAssets.contains(asset))); if (isEditMode) { if (allItemAssetsList.contains(asset)) { chooseAssetCheckBox.setDefaultModelObject(new String("1")); selectedAssets.add(asset); } //if } //if chooseContainer.add(chooseAssetCheckBox); chooseAssetCheckBox.setOutputMarkupId(true); chooseAssetCheckBox.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (chooseAssetCheckBox.getModelObject() != null) { Boolean isSelected = (Boolean) chooseAssetCheckBox.getModelObject(); if (isSelected.equals(true)) { selectedAssets.add(asset); } else { selectedAssets.remove(asset); } } } }); } else { chooseContainer.add(new WebMarkupContainer("choose").setVisible(false)); chooseContainer.setVisible(false); } //else // --- Asset Type ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Label assetType = new Label("assetType", localize(asset.getAssetType().getNameTranslationResourceKey())); listItem.add(assetType); final WebMarkupContainer customAttributesContainer = new WebMarkupContainer( "customAttributesContainer"); customAttributesContainer.setOutputMarkupId(true); listItem.add(customAttributesContainer); final WebMarkupContainer customAttributesPanelContainer = new WebMarkupContainer( "customAttributesPanel"); customAttributesPanelContainer.setOutputMarkupId(true); customAttributesContainer.add(customAttributesPanelContainer); ExpandCustomAttributesLink customAttributesLink = new ExpandCustomAttributesLink( "showCustomAttributesLink", asset); customAttributesLink.setComponentWhenCollapsed(customAttributesPanelContainer); customAttributesLink.setTargetComponent(customAttributesContainer); customAttributesLink.setImageWhenCollapsed(new CollapsedPanel("imagePanel")); customAttributesLink.setImageWhenExpanded(new ExpandedPanel("imagePanel")); CollapsedPanel imagePanel = new CollapsedPanel("imagePanel"); customAttributesLink.add(imagePanel); listItem.add(customAttributesLink); // --- Inventory Code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ listItem.add(new Label("inventoryCode", asset.getInventoryCode())); //format and display dates SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); // --- Support Start Date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (asset.getSupportStartDate() != null) { listItem.add(new Label("supportStartDate", dateFormat.format(asset.getSupportStartDate())) .add(new SimpleAttributeModifier("class", "date"))); } else { listItem.add(new Label("supportStartDate", "")); } // --- Support End Date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (asset.getSupportEndDate() != null) { listItem.add(new Label("supportEndDate", dateFormat.format(asset.getSupportEndDate())) .add(AssetsUtils.getSupportEndDateStyle(asset.getSupportEndDate()))); } else { listItem.add(new Label("supportEndDate", "")); } } }; itemAssetsListContainer.add(assetsListView); itemAssetsListContainer.setOutputMarkupId(true); return itemAssetsListContainer; }
From source file:gr.abiss.calipso.wicket.asset.ItemAssetsViewPanel.java
License:Open Source License
private void addComponents(final IModel assets) { final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt"); ListView listView = new ListView("assetsList", assets) { protected void populateItem(final ListItem listItem) { if (listItem.getIndex() % 2 != 0) { listItem.add(sam);/* w w w . j ava 2s . c o m*/ } //if final Asset asset = (Asset) listItem.getModelObject(); listItem.add( new Label("assetType", localize(asset.getAssetType().getNameTranslationResourceKey()))); listItem.add(new Label("inventoryCode", asset.getInventoryCode())); listItem.add(new Label("supportStartDate", asset.getSupportStartDate().toString())); listItem.add(new Label("supportEndDate", asset.getSupportEndDate().toString()) .add(AssetsUtils.getSupportEndDateStyle(asset.getSupportEndDate()))); } }; add(listView); }
From source file:gr.abiss.calipso.wicket.asset.ItemAssetTypesPanel.java
License:Open Source License
private void renderItemAssetTypes(final IModel itemAssetTypesModel) { final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "altRow"); ListView listView = new ListView("assetTypesList", itemAssetTypesModel) { protected void populateItem(final ListItem listItem) { if (listItem.getIndex() % 2 != 0) { listItem.add(sam);// www . j a v a 2s . c om } //if final AssetType assetType = (AssetType) listItem.getModelObject(); listItem.add(new Label("assetType", localize(assetType.getNameTranslationResourceKey()))); } }; add(listView); }
From source file:gr.abiss.calipso.wicket.asset.ItemFormAssetSearchPanel.java
License:Open Source License
public ItemFormAssetSearchPanel(String id, AssetSearch as) { super(id);/*from ww w . j a v a 2s. c om*/ this.setOutputMarkupId(true); this.setVisible(true); final AssetSearch assetSearch = as; this.setDefaultModel(new CompoundPropertyModel(assetSearch)); final WebMarkupContainer assetSearchForm = new WebMarkupContainer("assetAjaxSearchForm"); assetSearchForm.setOutputMarkupId(true); add(assetSearchForm); assetSearchForm.add(new AjaxLink("close") { @Override public void onClick(AjaxRequestTarget target) { closePanel(target); } }); // inventory code final TextField inventoryCode = new TextField("asset.inventoryCode"); inventoryCode.setLabel(new ResourceModel("asset.inventoryCode")); inventoryCode.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { // Reset the inventoryCode model dropdown when the vendor changes assetSearch.getAsset().setInventoryCode(inventoryCode.getDefaultModelObjectAsString()); } }); assetSearchForm.add(inventoryCode); assetSearchForm.add(new SimpleFormComponentLabel("assetInventoryCodeLabel", inventoryCode)); AssetSearchDataProvider assetSearchDataProvider = new AssetSearchDataProvider(assetSearch); // if AssetSearch only addresses one AssetType, do not allow other choices List<AssetType> assetTypes = null; if (assetSearch.getAsset().getAssetType() != null) { assetTypes = new ArrayList<AssetType>(1); assetTypes.add(assetSearch.getAsset().getAssetType()); } else { assetTypes = getCalipso().findAllAssetTypes(); } @SuppressWarnings("serial") final DropDownChoice assetTypeChoice = new DropDownChoice("asset.assetType", assetTypes, new IChoiceRenderer() { public Object getDisplayValue(Object o) { return localize(((AssetType) o).getNameTranslationResourceKey()); } public String getIdValue(Object o, int i) { return localize(((AssetType) o).getName()); } }); if (assetTypes.size() == 1) { logger.debug("Only allow one Asset TypeChoice"); assetTypeChoice.setNullValid(false).setRequired(true); } else { logger.debug("Only any AssetType Choice"); } // List view headers List<String> columnHeaders = assetSearch.getColumnHeaders(); ListView headings = new ListView("headings", columnHeaders) { private static final long serialVersionUID = 1L; protected void populateItem(ListItem listItem) { final String header = (String) listItem.getModelObject(); AjaxLink headingLink = new AjaxLink("heading") { @Override public void onClick(AjaxRequestTarget target) { assetSearch.doSort(header); target.addComponent(ItemFormAssetSearchPanel.this); } }; listItem.add(headingLink); String label = localize("asset.assetsList." + header); headingLink.add(new Label("heading", label)); if (header.equals(assetSearch.getSortFieldName())) { String order = assetSearch.isSortDescending() ? "order-down" : "order-up"; listItem.add(new SimpleAttributeModifier("class", order)); } } }; assetSearchForm.add(headings); //Header message Label hAction = new Label("hAction"); hAction.setDefaultModel(new Model(localize("edit"))); assetSearchForm.add(hAction); // the DataView with the results of the search final AssetsDataView assetDataView = new AssetsDataView("assetDataView", assetSearchDataProvider, getBreadCrumbModel(), getCalipso().getRecordsPerPage()) { // when click the add button @Override public void onAddAssetClick(Asset asset, AjaxRequestTarget target) { // re-render onAssetSelect(asset, target); } }; assetSearchForm.add(assetDataView); AjaxPagingNavigator panelNavigator = new AjaxPagingNavigator("navigator", assetDataView) { @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.addComponent(ItemFormAssetSearchPanel.this); } }; assetSearchForm.add(panelNavigator); // back to our asset type choice.... assetSearchForm.add(assetTypeChoice); assetTypeChoice.setLabel(new ResourceModel("asset.assetType")); // Add Ajax Behaviour... assetTypeChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { // Reset the phone model dropdown when the vendor changes assetDataView.setCurrentPage(0); assetSearch.getAsset().setAssetType((AssetType) assetTypeChoice.getModelObject()); } }); assetSearchForm.add(new SimpleFormComponentLabel("assetTypeLabel", assetTypeChoice)); AjaxLink submitLink = new AjaxLink("submit") { @Override public void onClick(AjaxRequestTarget target) { //assetSearchForm.replace(getConfiguredAssetListPanel(assetSearch)); target.addComponent(ItemFormAssetSearchPanel.this); } }; assetSearchForm.add(submitLink); }
From source file:gr.abiss.calipso.wicket.asset.PaginationPanel.java
License:Open Source License
public PaginationPanel(String id, IBreadCrumbModel breadCrumbModel, AbstractSearch abstractSearch) { super(id, breadCrumbModel); this.abstractSearch = abstractSearch; long resultCount = this.abstractSearch.getResultCount(); final int currentPage = this.abstractSearch.getCurrentPage(); String resultCountMessage = resultCount == 1 ? "asset.customAttributes.recordFound" : "asset.customAttributes.recordsFound"; Label recordsFound = new Label("recordsFound", localize(resultCountMessage, String.valueOf(resultCount))); add(recordsFound);/*from w w w . j a v a 2 s.c o m*/ recordsFound.setVisible(resultCount > 0); WebMarkupContainer pagination = new WebMarkupContainer("pagination"); if (this.abstractSearch.getPageCount() > 1) { //Previous Page Link prevOn = new Link("prevOn") { public void onClick() { PaginationPanel.this.abstractSearch.setCurrentPage(currentPage - 1); onPreviousPageClick(); } }; prevOn.add(new Label("prevOn", "<<")); pagination.add(prevOn); Label prevOff = new Label("prevOff", "<<"); if (this.abstractSearch.getCurrentPage() == 1) { prevOn.setVisible(false); } else { prevOff.setVisible(false); } pagination.add(prevOff); //Discrete Page Numbers List<Integer> pageNumbers = new ArrayList<Integer>((int) this.abstractSearch.getPageCount()); for (int i = 0; i < (int) this.abstractSearch.getPageCount(); i++) { pageNumbers.add(new Integer(i)); } ListView pages = new ListView("pages", pageNumbers) { protected void populateItem(ListItem listItem) { final Integer i = (Integer) listItem.getModelObject(); String pageNumber = i + 1 + ""; Link pageOn = new Link("pageOn") { public void onClick() { PaginationPanel.this.abstractSearch.setCurrentPage(i + 1); onPageNumberClick(); } }; pageOn.add(new Label("pageOn", pageNumber)); Label pageOff = new Label("pageOff", pageNumber); if (i == PaginationPanel.this.abstractSearch.getCurrentPage() - 1) { pageOn.setVisible(false); } else { pageOff.setVisible(false); } listItem.add(pageOn); listItem.add(pageOff); } }; pagination.add(pages); //Next page Link nextOn = new Link("nextOn") { public void onClick() { PaginationPanel.this.abstractSearch.setCurrentPage(currentPage + 1); onNextPageClick(); } }; nextOn.add(new Label("nextOn", ">>")); Label nextOff = new Label("nextOff", ">>"); if (PaginationPanel.this.abstractSearch.getCurrentPage() == PaginationPanel.this.abstractSearch .getPageCount()) { nextOn.setVisible(false); } else { nextOff.setVisible(false); } pagination.add(nextOn); pagination.add(nextOff); } //if else { pagination.setVisible(false); } //else add(pagination); }