List of usage examples for org.apache.wicket.model LoadableDetachableModel getObject
@Override
public final T getObject()
From source file:eu.uqasar.web.dashboard.widget.reportingwidget.ReportingWidgetView.java
License:Apache License
public ReportingWidgetView(String id, IModel<Widget> model) { super(id, model); final ReportingWidget qualityWidget = (ReportingWidget) model.getObject(); // Create a quarry for Report Generation. cube = qualityWidget.getSettings().get("cube"); chartType = qualityWidget.getSettings().get("chartType"); urlToLoad = qualityWidget.getSettings().get("urlToLoad"); Form<Void> formVoid = new Form<>("formVoid"); LoadableDetachableModel<List<ReportMeasurement>> mdl = new LoadableDetachableModel<List<ReportMeasurement>>() { private static final long serialVersionUID = 1L; protected List<ReportMeasurement> load() { measurements = qualityWidget.getMeasurements(cube, urlToLoad); return measurements; }/*from w ww . j av a 2s .c o m*/ }; Chart chart; chart = new Chart("chart", qualityWidget.getChartOptions(mdl.getObject(), chartType)); add(chart); add(formVoid); reportWMC = new WebMarkupContainer("reportWMC", new Model<ReportMeasurement>()); reportWMC.setOutputMarkupId(true); formVoid.add(reportWMC); if (measurements.size() != 0) { reportWMC.add(new Label("type", measurements.get(0).getReportType())); } else { reportWMC.add(new Label("type", "Rule")); } reportWMC.add(reportView = new ListView<ReportMeasurement>("reportListView", Model.ofList(measurements)) { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); // update model reportView.setModelObject(measurements); } @Override protected void populateItem(ListItem<ReportMeasurement> item) { final ReportMeasurement proposedReport = item.getModelObject(); item.add(new Label("value", proposedReport.getReportValue())); item.add(new Label("count", proposedReport.getCount())); } }); }
From source file:eu.uqasar.web.dashboard.widget.sonarqualitywidget.SonarQualityWidgetView.java
License:Apache License
public SonarQualityWidgetView(String id, IModel<Widget> model) { super(id, model); final SonarQualityWidget qualityWidget = (SonarQualityWidget) model.getObject(); if (qualityWidget.getSettings().get("period") != null) { period = qualityWidget.getSettings().get("period"); } else {/* ww w . j ava 2 s . c om*/ // if there is no selection of period then it should be the latest values period = "Latest"; } System.out.println("period: " + period); LoadableDetachableModel<List<SonarMetricMeasurement>> mdl = new LoadableDetachableModel<List<SonarMetricMeasurement>>() { private static final long serialVersionUID = 1L; protected List<SonarMetricMeasurement> load() { measurements = qualityWidget.getMeasurements(period); System.out.println("measurements : " + measurements); return measurements; } }; Chart chart; individualMetric = qualityWidget.getSettings().get("individualMetric"); if (individualMetric != null) { chart = new Chart("chart", qualityWidget.getChartOptionsDifferently(mdl.getObject(), individualMetric)); } else { chart = new Chart("chart", qualityWidget.getChartOptions(mdl.getObject())); } add(chart); }
From source file:eu.uqasar.web.dashboard.widget.testlinkwidget.TestLinkWidgetView.java
License:Apache License
public TestLinkWidgetView(String id, IModel<Widget> model) { super(id, model); final TestLinkWidget testLinkWidget = (TestLinkWidget) model.getObject(); try {/*from www . j av a 2s. c o m*/ InitialContext ic = new InitialContext(); TDT = (TestLinkDataService) ic.lookup("java:module/TestLinkDataService"); } catch (NamingException e) { e.printStackTrace(); } if (testLinkWidget.getSettings().get("period") != null) { period = testLinkWidget.getSettings().get("period"); } else { period = "Latest"; } if (testLinkWidget.getSettings().get("project") != null && !testLinkWidget.getSettings().get("project").isEmpty()) { String name = testLinkWidget.getSettings().get("project"); } LoadableDetachableModel<List<TestLinkMetricMeasurement>> metricsData = new LoadableDetachableModel<List<TestLinkMetricMeasurement>>() { private static final long serialVersionUID = -8120427341331851718L; @Override protected List<TestLinkMetricMeasurement> load() { Date latestSnapshotDate = TDT.getLatestDate(); if (latestSnapshotDate != null) { if (period.compareToIgnoreCase("Latest") == 0) { return TDT.getMeasurementsForProjectByLatestDate("UQASAR"); } else { return TDT.getMeasurementsForProjectByPeriod("UQASAR", period); } } else { return new ArrayList<>(); } } }; Chart chart; individualMetric = testLinkWidget.getSettings().get("individualMetric"); if (individualMetric != null) { chart = new Chart("chart", testLinkWidget.getChartOptionsDifferently(metricsData.getObject(), individualMetric)); } else { chart = new Chart("chart", testLinkWidget.getChartOptions(metricsData.getObject())); } // Add TestLink image add(new ContextImage("img", "assets/img/testlink.png")); add(chart); }
From source file:gr.abiss.calipso.wicket.asset.AssetCustomAttributesPanel.java
License:Open Source License
/** * Renders custom attribute list/* w w w .jav a 2s . co m*/ * */ private void listAttributes() { LoadableDetachableModel attributesListModel = new LoadableDetachableModel() { @Override protected Object load() { return getCalipso().findCustomAttributesMatching( AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch); }//load }; attributesListModel.getObject(); //////////////// // Pagination // //////////////// PaginationPanel paginationPanel = new PaginationPanel("paginationPanel", getBreadCrumbModel(), this.assetTypeCustomAttributeSearch) { IBreadCrumbPanelFactory breadCrumbPanelFactory = new IBreadCrumbPanelFactory() { @Override 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 AssetCustomAttributesPanel(breadCrumbModel.getActive().getComponent().getId(), breadCrumbModel, AssetCustomAttributesPanel.this.referenceAssetType, AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch, AssetCustomAttributesPanel.this.isSearchOpen); } }; @Override public void onNextPageClick() { activate(breadCrumbPanelFactory); } @Override public void onPreviousPageClick() { activate(breadCrumbPanelFactory); } @Override public void onPageNumberClick() { activate(breadCrumbPanelFactory); } }; add(paginationPanel); ///////////////// // List header // ///////////////// List<String> columnHeaders = AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch .getColumnHeaders(); ListView headings = new ListView("headings", columnHeaders) { @Override protected void populateItem(ListItem listItem) { final String header = (String) listItem.getModelObject(); Link headingLink = new Link("heading") { @Override public void onClick() { AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch.doSort(header); } }; listItem.add(headingLink); String label = localize("asset.customAttributes." + header); headingLink.add(new Label("heading", label)); if (header.equals( AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch.getSortFieldName())) { String order = AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch.isSortDescending() ? "order-down" : "order-up"; listItem.add(new SimpleAttributeModifier("class", order)); } } }; add(headings); ///////////////////// // Attributes List // ///////////////////// final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt"); if (this.referenceAssetType != null) { add(new Label("add", localize("asset.assetTypes.addCustomAttributeToType", localize(this.referenceAssetType.getNameTranslationResourceKey())))); } //if else { add(new WebMarkupContainer("add").setVisible(false)); } //else ListView listView = new ListView("attributesList", attributesListModel) { AssetType referenceAssetType = AssetCustomAttributesPanel.this.referenceAssetType; @Override protected void populateItem(ListItem listItem) { final AssetTypeCustomAttribute attribute = (AssetTypeCustomAttribute) listItem.getModelObject(); if (attribute.getId().equals(selectedAttributeId)) { listItem.add(new SimpleAttributeModifier("class", "selected")); } else if (listItem.getIndex() % 2 != 0) { listItem.add(sam); } //if // listItem.add(new Label("name", new PropertyModel(attribute, "name"))); listItem.add(new Label("name", localize(attribute.getNameTranslationResourceKey()))); listItem.add(new Label("formType", new Model(localize("asset.attributeType_" + attribute.getFormType())))); listItem.add(new Label("mandatory", new Model(attribute.isMandatory() ? localize("yes") : localize("no")))); listItem.add( new Label("active", new Model(attribute.isActive() ? localize("yes") : localize("no")))); Link edit = new Link("edit") { @Override public void onClick() { activate(new IBreadCrumbPanelFactory() { @Override public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) { AssetCustomAttributeFormPagePanel assetCustomAttributeFormPagePanel = new AssetCustomAttributeFormPagePanel( id, breadCrumbModel, attribute); if (referenceAssetType != null) { assetCustomAttributeFormPagePanel.setReferenceAssetType(referenceAssetType); } //if return assetCustomAttributeFormPagePanel; } }); }//onClick }; listItem.add(edit); if (referenceAssetType == null) { listItem.add(new WebMarkupContainer("add").setVisible(false)); } //if else { WebMarkupContainer add; if (referenceAssetType.getAllowedCustomAttributes().contains(attribute)) {//if this customAttribute is used add = new Fragment("add", "removeLink", this); if (logger.isDebugEnabled()) { logger.debug("Allowed custom attributes : " + referenceAssetType.getAllowedCustomAttributes()); } add.add(new Link("link") { //remove a custom attribute to the Asset Type in question @Override public void onClick() { if (logger.isDebugEnabled()) { logger.debug("Allowed custom attributes : " + referenceAssetType.getAllowedCustomAttributes()); logger.debug("Removing attribute : " + attribute.getName()); } AssetCustomAttributesPanel.this.referenceAssetType.getAllowedCustomAttributes() .remove(attribute); if (logger.isDebugEnabled()) { logger.debug("new Allowed custom attributes : " + referenceAssetType.getAllowedCustomAttributes()); } //Remove last 2 breadcrumb participants if (breadCrumbModel.allBreadCrumbParticipants().size() > 2) { breadCrumbModel.allBreadCrumbParticipants() .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1); breadCrumbModel.allBreadCrumbParticipants() .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1); } //if activate(new IBreadCrumbPanelFactory() { @Override public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) { return new AssetTypeFormPagePanel( getBreadCrumbModel().getActive().getComponent().getId(), getBreadCrumbModel(), AssetCustomAttributesPanel.this.referenceAssetType); } }); }//onClick }); } else {//if this customAttribute is not used, can add it add = new Fragment("add", "addLink", this); add.add(new Link("link") { //Adds a custom attribute to the Asset Type in question @Override public void onClick() { if (logger.isDebugEnabled()) { logger.debug("Allowed custom attributes : " + referenceAssetType.getAllowedCustomAttributes()); logger.debug("Added custom attribute : " + attribute.getName()); } AssetCustomAttributesPanel.this.referenceAssetType.getAllowedCustomAttributes() .add(attribute); if (logger.isDebugEnabled()) { logger.debug("New Allowed custom attributes : " + referenceAssetType.getAllowedCustomAttributes()); } //Remove last 2 breadcrumb participants if (breadCrumbModel.allBreadCrumbParticipants().size() > 2) { breadCrumbModel.allBreadCrumbParticipants() .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1); breadCrumbModel.allBreadCrumbParticipants() .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1); } //if activate(new IBreadCrumbPanelFactory() { @Override public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) { return new AssetTypeFormPagePanel( getBreadCrumbModel().getActive().getComponent().getId(), getBreadCrumbModel(), AssetCustomAttributesPanel.this.referenceAssetType); } }); }//onClick }); } listItem.add(add); } //else } }; add(listView); add(new WebMarkupContainer("noData").setVisible(this.assetTypeCustomAttributeSearch.getResultCount() == 0)); }
From source file:gr.abiss.calipso.wicket.asset.AssetTypesListPanel.java
License:Open Source License
public AssetTypesListPanel(String id, IBreadCrumbModel breadCrumbModel, final AssetTypeSearch assetTypeSearch) { super(id, breadCrumbModel); this.assetTypeSearch = assetTypeSearch; LoadableDetachableModel assetTypesListModel = new LoadableDetachableModel() { protected Object load() { List<AssetType> assetTypeList = new LinkedList<AssetType>(); assetTypeList = getCalipso().findAssetTypesMatching(assetTypeSearch); return assetTypeList; }// www. j ava 2 s . com }; assetTypesListModel.getObject(); addComponents(assetTypesListModel); }
From source file:gr.abiss.calipso.wicket.asset.ItemAssetsPanel.java
License:Open Source License
/** * /* w w w . j a va 2s .c o m*/ * @return * The assets that belong to the space but don't belong to the item */ private IModel getRemainingAssets() { LoadableDetachableModel remainingAssetsForItemModel = new LoadableDetachableModel() { protected Object load() { List<Asset> freshAvailableAssets = getCalipso().findAssetsMatching(assetSearch, false); ItemAssetsPanel.this.availableAssets = new ArrayList<Asset>(); if (CollectionUtils.isNotEmpty(freshAvailableAssets)) { for (Asset asset : freshAvailableAssets) { if (!ItemAssetsPanel.this.allItemAssetsList.contains(asset)) { ItemAssetsPanel.this.availableAssets.add(asset); if (!ItemAssetsPanel.this.availableAssetTypesList.contains(asset.getAssetType())) { ItemAssetsPanel.this.availableAssetTypesList.add(asset.getAssetType()); } //if } //if } //for } //if return ItemAssetsPanel.this.availableAssets; }//load };//assetsListModel remainingAssetsForItemModel.getObject(); return remainingAssetsForItemModel; }
From source file:gr.abiss.calipso.wicket.asset.ItemAssetsPanel.java
License:Open Source License
/** * //from w ww . j a v a2s . co m * @return * All assets that belong to the item */ private IModel getAllAssetsForCurrentItem() { LoadableDetachableModel itemAssetsListModel = new LoadableDetachableModel() { private static final long serialVersionUID = 1L; protected Object load() { ItemAssetsPanel.this.allItemAssetsList = getCalipso() .findAllAssetsByItem(ItemAssetsPanel.this.item); if (allItemAssetsList != null) { for (Asset asset : ItemAssetsPanel.this.allItemAssetsList) { if (!allItemAssetTypeList.contains(asset.getAssetType())) { allItemAssetTypeList.add(asset.getAssetType()); } } } return allItemAssetsList; } }; itemAssetsListModel.getObject(); return itemAssetsListModel; }
From source file:gr.abiss.calipso.wicket.asset.ItemAssetsViewPanel.java
License:Open Source License
public ItemAssetsViewPanel(String id, final Item item) { super(id);/* w w w. java2s . co m*/ LoadableDetachableModel assetsListModel = new LoadableDetachableModel() { protected Object load() { List<Asset> assetList = getCalipso().findAllAssetsByItem(item); return assetList; }//load };//assetsListModel assetsListModel.getObject(); addComponents(assetsListModel); }
From source file:gr.abiss.calipso.wicket.asset.ItemAssetTypesPanel.java
License:Open Source License
private IModel loadItemAssetTypes() { LoadableDetachableModel itemAssetsListModel = new LoadableDetachableModel() { protected Object load() { List<Asset> itemAssets = getCalipso().findAllAssetsByItem(ItemAssetTypesPanel.this.item); ItemAssetTypesPanel.this.assetTypes = new ArrayList<AssetType>(); if (itemAssets != null) { for (Asset asset : itemAssets) { if (!ItemAssetTypesPanel.this.assetTypes.contains(asset.getAssetType())) { ItemAssetTypesPanel.this.assetTypes.add(asset.getAssetType()); } //if } //for } //if return ItemAssetTypesPanel.this.assetTypes; }//load//from w w w .j a v a 2 s . c o m };//assetsListModel itemAssetsListModel.getObject(); return itemAssetsListModel; }
From source file:gr.abiss.calipso.wicket.OrganizationListPanel.java
License:Open Source License
public OrganizationListPanel(String id, IBreadCrumbModel breadCrumbModel, final OrganizationSearch organizationSearch) { super(id, breadCrumbModel); this.organizationSearch = organizationSearch; LoadableDetachableModel assetTypesListModel = new LoadableDetachableModel() { protected Object load() { List<Organization> organizationsList = new LinkedList<Organization>(); organizationsList = getCalipso().findOrganizationsMatching(organizationSearch); return organizationsList; }/* w w w .jav a 2 s .co m*/ }; assetTypesListModel.getObject(); addComponents(assetTypesListModel); }