List of usage examples for org.apache.wicket.markup.html.form CheckBox CheckBox
public CheckBox(final String id, IModel<Boolean> model)
From source file:at.ac.tuwien.ifs.tita.ui.administration.project.ProjectForm.java
License:Apache License
/** * add all controls./*w w w .ja va2s. c o m*/ */ private void addComponents() { log.info("Adding Controls to the Form"); addOrReplace(new TextField<String>("tfDescription", new PropertyModel<String>(project, "description"))); addOrReplace(new TextField<String>("tfName", new PropertyModel<String>(project, "name"))); addOrReplace(new CheckBox("checkBoxDeleted", new PropertyModel<Boolean>(project, "deleted"))); addOrReplace(new DropDownChoice<ProjectStatus>("dropDownProjectStatus", new PropertyModel<ProjectStatus>(project, "projectStatus"), projectStati)); issueTrackerProjectTM = new TableModelIssueTrackerProject(this.issueTrackerProjects); issueTrackerProjectTable = new Table("issueTrackerProjectTable", issueTrackerProjectTM); DeleteRenderer deleteRenderer = new DeleteRenderer(); issueTrackerProjectTable.setDefaultRenderer(ButtonDelete.class, deleteRenderer); issueTrackerProjectTable.setDefaultEditor(ButtonDelete.class, deleteRenderer); addOrReplace(issueTrackerProjectTable); // other components will not be displayed, they are not part of the // ProjectAdministration }
From source file:at.ac.tuwien.ifs.tita.ui.administration.user.UserForm.java
License:Apache License
/** * Method for Adding the Fields to the Form. */// ww w.ja v a2 s.co m private void addComponents() { addOrReplace(new TextField<String>("tfUserName", new PropertyModel<String>(user, "userName"))); addOrReplace(new TextField<String>("tfFirstName", new PropertyModel<String>(user, "firstName"))); addOrReplace(new TextField<String>("tfLastName", new PropertyModel<String>(user, "lastName"))); addOrReplace(new TextField<String>("tfEmail", new PropertyModel<String>(user, "email"))); ptfPassword = new PasswordTextField("ptfPassword", new PropertyModel<String>(user, "password")); ptfPassword.setRequired(false); addOrReplace(ptfPassword); ptfPasswordRepetition = new PasswordTextField("ptfPasswordRepetition", new PropertyModel<String>(this, "passwordRepetition")); ptfPasswordRepetition.setRequired(false); addOrReplace(ptfPasswordRepetition); addOrReplace(new CheckBox("checkBoxDeleted", new PropertyModel<Boolean>(user, "deleted"))); dropDownrole = new DropDownChoice<Role>("dropDownRole", new PropertyModel<Role>(user, "role"), roles); if (user.getRole() != null) { dropDownrole.setConvertedInput(user.getRole()); } dropDownrole.setRequired(false); addOrReplace(dropDownrole); userProjectTM = new TableModelUserProject(titaProjects); userProjectTM.reload(); userProjectTable = new Table(C_USER_PROJECT_TABLE_NAME, userProjectTM); issueTrackerLoginTM = new TableModelIssueTrackerLoginWithoutButtons(titaIssueTracker); issueTrackerLoginTM.reload(); issueTrackerLoginTable = new Table(C_ISSUE_TRACKER_TABLE_NAME, issueTrackerLoginTM); addOrReplace(issueTrackerLoginTable); addOrReplace(userProjectTable); }
From source file:at.molindo.esi4j.example.web.HomePage.java
License:Apache License
public HomePage() { add(new UrlSubmissionForm("urlForm")); _searchModel = new AbstractReadOnlyModel<Search>() { private final Search _search = new Search(); @Override/*w ww . j av a 2s . c o m*/ public Search getObject() { return _search; } }; _searchResponseModel = new LoadableDetachableModel<ListenableActionFuture<SearchResponseWrapper>>() { @Override protected ListenableActionFuture<SearchResponseWrapper> load() { Search search = _searchModel.getObject(); return _searchService.search(search.getQuery(), search.getCategories()); } }; IModel<List<SearchHitWrapper>> articlesModel = new AbstractReadOnlyModel<List<SearchHitWrapper>>() { @Override public List<SearchHitWrapper> getObject() { return _searchResponseModel.getObject().actionGet().getSearchHits(); } }; IModel<List<? extends TermsFacet.Entry>> facetsModel = new AbstractReadOnlyModel<List<? extends TermsFacet.Entry>>() { @Override public List<? extends TermsFacet.Entry> getObject() { Facets facets = _searchResponseModel.getObject().actionGet().getSearchResponse().getFacets(); if (facets == null) { return Collections.emptyList(); } TermsFacet facet = (TermsFacet) facets.facet("categories"); if (facet == null) { return Collections.emptyList(); } return facet.getEntries(); } }; add(new TextField<String>("search", new PropertyModel<String>(_searchModel, "query")) .add(new OnChangeUpdateSearchBehavior())); // category select add(_facetsContainer = new CheckGroup<String>("facetsContainer")); _facetsContainer.setOutputMarkupId(true).setRenderBodyOnly(false); _facetsContainer.add(new ListView<TermsFacet.Entry>("categoryFacets", facetsModel) { @Override protected IModel<TermsFacet.Entry> getListItemModel( IModel<? extends List<TermsFacet.Entry>> listViewModel, int index) { return new CompoundPropertyModel<TermsFacet.Entry>(super.getListItemModel(listViewModel, index)); } @Override protected void populateItem(final ListItem<Entry> item) { CheckBox box; item.add(box = new CheckBox("check", new IModel<Boolean>() { @Override public Boolean getObject() { return _searchModel.getObject().getCategories().contains(item.getModelObject().getTerm()); } @Override public void setObject(Boolean checked) { List<String> categories = _searchModel.getObject().getCategories(); String category = item.getModelObject().getTerm().string(); if (Boolean.TRUE.equals(checked)) { categories.add(category); } else { categories.remove(category); } } @Override public void detach() { } })); box.add(new OnChangeUpdateSearchBehavior()); item.add(new SimpleFormComponentLabel("term", box.setLabel(new PropertyModel<String>(item.getModel(), "term")))); item.add(new Label("count")); } }); // search results add(_container = new WebMarkupContainer("container")); _container.setOutputMarkupId(true); _container.add(new Label("query", _searchModel.getObject().getQuery())); _container.add(new ListView<SearchHitWrapper>("result", articlesModel) { @Override protected IModel<SearchHitWrapper> getListItemModel( IModel<? extends List<SearchHitWrapper>> listViewModel, int index) { return new CompoundPropertyModel<SearchHitWrapper>(super.getListItemModel(listViewModel, index)); } @Override protected void populateItem(final ListItem<SearchHitWrapper> item) { item.add(new Label("object.subject")); item.add(new Label("object.date")); item.add(new Label("object.body", new AbstractReadOnlyModel<String>() { @Override public String getObject() { SearchHitWrapper wrapper = item.getModelObject(); HighlightField field = wrapper.getSearchHit().getHighlightFields().get("body"); if (field == null) { return wrapper.getObject(Article.class).getBody(); } Object[] fragments = field.getFragments(); if (fragments == null) { return wrapper.getObject(Article.class).getBody(); } return StringUtils.join(" ... ", fragments); } })); item.add(new ExternalLink("link", new PropertyModel<String>(item.getModel(), "object.url"))); item.add(new ListView<String>("categories", new PropertyModel<List<String>>(item.getModel(), "object.categories")) { @Override protected void populateItem(ListItem<String> item) { item.add(new Label("name", item.getModel())); } }); } }); add(new IndicatingAjaxLink<Void>("rebuild") { @Override public void onClick(AjaxRequestTarget target) { _searchService.rebuild(); updateSearch(target); } }); add(new IndicatingAjaxLink<Void>("delete") { @Override public void onClick(AjaxRequestTarget target) { _articleService.deleteArticles(); _searchService.refresh(); updateSearch(target); } }); }
From source file:au.org.emii.geoserver.extensions.filters.LayerFilterForm.java
License:Open Source License
public LayerFilterForm(final String id, IModel<FilterConfiguration> model) { super(id, model); add(new ListView<Filter>("layerDataProperties", model.getObject().getFilters()) { public void populateItem(final ListItem<Filter> item) { final Filter filter = item.getModelObject(); item.add(new CheckBox("propertyEnabled", new PropertyModel<Boolean>(filter, "enabled"))); item.add(new Label("propertyName", filter.getName())); item.add(new TextField<String>("propertyType", new Model<String>() { @Override//from w w w . ja va 2 s .co m public String getObject() { return filter.getType(); } @Override public void setObject(final String value) { filter.setType(value); } })); item.add(new TextField<String>("propertyLabel", new Model<String>() { @Override public String getObject() { return filter.getLabel(); } @Override public void setObject(final String value) { filter.setLabel(value); } })); item.add(new CheckBox("propertyWmsFilter", new Model<Boolean>() { @Override public Boolean getObject() { return new Boolean(!filter.getVisualised().booleanValue()); } @Override public void setObject(Boolean value) { filter.setVisualised(new Boolean(!value.booleanValue())); } })); item.add(new CheckBox("propertyWfsExcluded", new PropertyModel<Boolean>(filter, "excludedFromDownload"))); } }); add(saveLink()); add(cancelLink()); }
From source file:au.org.theark.admin.web.component.rolePolicy.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public DataView<ArkRoleModuleFunctionVO> buildDataView( ArkDataProvider<ArkRoleModuleFunctionVO, IAdminService> dataProvider) { DataView<ArkRoleModuleFunctionVO> dataView = new DataView<ArkRoleModuleFunctionVO>( "arkRoleModuleFunctionVoList", dataProvider) { private static final long serialVersionUID = -7977497161071264676L; @Override//from w w w . j ava2 s . c o m protected void populateItem(final Item<ArkRoleModuleFunctionVO> item) { final ArkRoleModuleFunctionVO arkRoleModuleFunctionVo = item.getModelObject(); item.setOutputMarkupId(true); item.setOutputMarkupPlaceholderTag(true); WebMarkupContainer rowEditWMC = new WebMarkupContainer("rowEditWMC", item.getModel()); AjaxButton listEditButton = new AjaxButton("listEditButton", new StringResourceModel(au.org.theark.core.Constants.EDIT, this, null)) { private static final long serialVersionUID = 197521505680635043L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { item.setEnabled(true); item.get("arkCreatePermissionImg").setVisible(false); item.get("arkReadPermissionImg").setVisible(false); item.get("arkUpdatePermissionImg").setVisible(false); item.get("arkDeletePermissionImg").setVisible(false); item.addOrReplace(new CheckBox("arkCreatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkCreatePermission")) .setEnabled(true)); item.addOrReplace(new CheckBox("arkReadPermission", new PropertyModel(arkRoleModuleFunctionVo, "arkReadPermission")).setEnabled(true)); item.addOrReplace(new CheckBox("arkUpdatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkUpdatePermission")) .setEnabled(true)); item.addOrReplace(new CheckBox("arkDeletePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkDeletePermission")) .setEnabled(true)); item.get("rowSaveWMC").setVisible(true); target.add(item); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("onError called when listEditButton pressed"); } }; listEditButton.setDefaultFormProcessing(false); rowEditWMC.add(listEditButton); item.add(rowEditWMC); if (arkRoleModuleFunctionVo.getArkRole() != null) { item.add(new Label("arkRole", arkRoleModuleFunctionVo.getArkRole().getName())); } else { item.add(new Label("arkRole", "")); } if (arkRoleModuleFunctionVo.getArkModule() != null) { item.add(new Label("arkModule", arkRoleModuleFunctionVo.getArkModule().getName())); } else { item.add(new Label("arkModule", "")); } if (arkRoleModuleFunctionVo.getArkFunction() != null) { item.add(new Label("arkFunction", arkRoleModuleFunctionVo.getArkFunction().getName())); } else { item.add(new Label("arkFunction", "")); } if (arkRoleModuleFunctionVo.getArkCreatePermission()) { item.addOrReplace( new ContextImage("arkCreatePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkCreatePermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkReadPermission()) { item.addOrReplace( new ContextImage("arkReadPermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("arkReadPermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkUpdatePermission()) { item.addOrReplace( new ContextImage("arkUpdatePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkUpdatePermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkDeletePermission()) { item.addOrReplace( new ContextImage("arkDeletePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkDeletePermissionImg", new Model<String>("images/icons/cross.png"))); } item.addOrReplace(new CheckBox("arkCreatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkCreatePermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkReadPermission", new PropertyModel(arkRoleModuleFunctionVo, "arkReadPermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkUpdatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkUpdatePermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkDeletePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkDeletePermission")).setVisible(false)); WebMarkupContainer rowSaveWMC = new WebMarkupContainer("rowSaveWMC", item.getModel()); AjaxButton listSaveButton = new AjaxButton("listSaveButton", new StringResourceModel(au.org.theark.core.Constants.SAVE, this, null)) { private static final long serialVersionUID = -7382768898426488999L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onSave(target, arkRoleModuleFunctionVo); target.add(SearchResultsPanel.this); target.add(feedbackPanel); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("onError called when listSaveButton pressed"); } }; rowSaveWMC.add(listSaveButton); rowSaveWMC.setVisible(false); item.add(rowSaveWMC); item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1938679383897533820L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }
From source file:ch.tkuhn.nanobrowser.PublishPage.java
License:Open Source License
public PublishPage(final PageParameters parameters) { add(new MenuBar("menubar")); Form<?> form = new Form<Void>("form") { private static final long serialVersionUID = -6839390607867733448L; protected void onSubmit() { sentenceError.setObject(""); doiError.setObject(""); String s = sentenceField.getModelObject(); SentenceElement sentence = null; if (s != null && SentenceElement.isSentenceURI(s)) { sentence = new SentenceElement(s); } else { try { sentence = SentenceElement.withText(s); } catch (AidaException ex) { sentenceError.setObject("ERROR: " + ex.getMessage()); return; }/*from w ww .j a v a 2s. co m*/ } String d = doiField.getModelObject(); PaperElement paper = null; if (d != null && !d.isEmpty()) { try { paper = PaperElement.forDoi(d); } catch (IllegalArgumentException ex) { doiError.setObject("ERROR: Invalid DOI"); return; } } String prov = ""; if (paper != null) { prov = ": swan:citesAsSupportiveEvidence <" + paper.getURI() + "> ."; } URI nanopubUri = sentence.publish(getUser(), exampleNanopubCheckbox.getModel().getObject(), prov); PageParameters params = new PageParameters(); params.add("uri", nanopubUri.stringValue()); MainPage.addToList(new NanopubElement(nanopubUri.stringValue())); MainPage.addToList(getUser()); MainPage.addToList(sentence); setResponsePage(NanopubPage.class, params); } }; add(form); form.add(new Label("author", NanobrowserSession.get().getUser().getName())); form.add(exampleNanopubCheckbox = new CheckBox("examplenanopub", new Model<>(false))); form.add(sentenceField = new TextField<String>("sentence", Model.of(""))); sentenceError = Model.of(""); form.add(new Label("sentenceerror", sentenceError)); form.add(doiField = new TextField<String>("doi", Model.of(""))); doiError = Model.of(""); form.add(new Label("doierror", doiError)); }
From source file:com.axway.ats.testexplorer.pages.model.ColumnsDialog.java
License:Apache License
@SuppressWarnings({ "rawtypes" }) public ColumnsDialog(String id, final DataGrid grid, List<TableColumn> columnDefinitions) { super(id);/* w ww . ja v a2s. co m*/ setOutputMarkupId(true); this.dbColumnDefinitions = columnDefinitions; DataView<TableColumn> table = new DataView<TableColumn>("headers", new ListDataProvider<TableColumn>(dbColumnDefinitions), 100) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<TableColumn> item) { final TableColumn column = item.getModelObject(); item.add(new CheckBox("visible", new PropertyModel<Boolean>(column, "visible"))); item.add(new Label("columnName", new PropertyModel<String>(column, "columnName"))); item.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { TableColumn tableColumn = (TableColumn) this.getComponent().getDefaultModelObject(); tableColumn.setVisible(!tableColumn.isVisible()); if (tableColumn.isVisible()) { item.add(AttributeModifier.replace("class", "selected")); } else { item.add(AttributeModifier.replace("class", "notSelected")); } grid.getColumnState().setColumnVisibility(tableColumn.getColumnId(), tableColumn.isVisible()); target.add(grid); target.add(this.getComponent()); open(target); } }); item.setOutputMarkupId(true); if (column.isVisible()) { item.add(AttributeModifier.replace("class", "selected")); } else { item.add(AttributeModifier.replace("class", "notSelected")); } } }; add(table); final Form<Void> columnDefinitionsForm = new Form<Void>("columnDefinitionsForm"); add(columnDefinitionsForm); AjaxSubmitLink saveButton = new AjaxSubmitLink("saveButton", columnDefinitionsForm) { private static final long serialVersionUID = 1L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); AjaxCallListener ajaxCallListener = new AjaxCallListener(); ajaxCallListener.onPrecondition("getTableColumnDefinitions(); "); attributes.getAjaxCallListeners().add(ajaxCallListener); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { String columnDefinitionsString = form.getRequest().getPostParameters() .getParameterValue("columnDefinitions").toString(); List<TableColumn> jsColDefinitions = asList(columnDefinitionsString); orderTableColumns(dbColumnDefinitions, jsColDefinitions); try { saveColumnDefinitionsToDb(jsColDefinitions); modifyDBColumnDefinitionList(jsColDefinitions); } catch (DatabaseAccessException dae) { throw new RuntimeException("Unable to save table Column definitions in db: " + ((TestExplorerSession) Session.get()).getDbName(), dae); } catch (SQLException sqle) { throw new RuntimeException("Unable to save table Column definitions in db: " + ((TestExplorerSession) Session.get()).getDbName(), sqle); } close(target); } }; add(AttributeModifier.append("class", "runsTableColDialogDivWrapper")); columnDefinitionsForm.add(saveButton); add(new Behavior() { private static final long serialVersionUID = 1L; @Override public void renderHead(Component component, IHeaderResponse response) { if (autoAddToHeader()) { String script = "jQuery.fn.center=function(){" + "this.css(\"position\",\"absolute\");" + "this.css(\"top\",(jQuery(window).height()-this.height())/2+jQuery(window).scrollTop()+\"px\");" + "this.css(\"left\",(jQuery(window).width()-this.width())/2+jQuery(window).scrollLeft()+\"px\");" + "return this};"; String css = "#settingsoverlay,.settingsoverlay,#settingsoverlay_high," + ".settingsoverlay_high{filter:Alpha(Opacity=40);" + "-moz-opacity:.4;opacity:.4;background-color:#444;display:none;position:absolute;" + "left:0;top:0;width:100%;height:100%;text-align:center;z-index:5000;}" + "#settingsoverlay_high,.settingsoverlay_high{z-index:6000;}" + "#settingsoverlaycontent,#settingsoverlaycontent_high{display:none;z-index:5500;" + "text-align:center;}.settingsoverlaycontent," + ".settingsoverlaycontent_high{display:none;z-index:5500;text-align:left;}" + "#settingsoverlaycontent_high,.settingsoverlaycontent_high{z-index:6500;}" + "#settingsoverlaycontent .modalborder," + "#settingsoverlaycontent_high .modalborder{padding:15px;width:300px;" + "border:1px solid #444;background-color:white;" + "-webkit-box-shadow:0 0 10px rgba(0,0,0,0.8);-moz-box-shadow:0 0 10px rgba(0,0,0,0.8);" + "box-shadow:0 0 10px rgba(0,0,0,0.8);" + "filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=5,OffY=5,Color='gray');" + "-ms-filter:\"progid:DXImageTransform.Microsoft.dropshadow(OffX=5,OffY=5,Color='gray')\";}"; response.render(JavaScriptHeaderItem.forScript(script, null)); response.render(CssHeaderItem.forCSS(css, null)); if (isSupportIE6()) { response.render(JavaScriptHeaderItem .forReference(new PackageResourceReference(getClass(), "jquery.bgiframe.js"))); } } response.render(OnDomReadyHeaderItem.forScript(getJS())); } private String getJS() { StringBuilder sb = new StringBuilder(); sb.append("if (jQuery('#").append(getDivId()) .append("').length == 0) { jQuery(document.body).append('") .append(getDiv().replace("'", "\\'")).append("'); }"); return sb.toString(); } private String getDivId() { return getMarkupId() + "_ovl"; } private String getDiv() { if (isClickBkgToClose()) { return ("<div id=\"" + getDivId() + "\" class=\"settingsoverlayCD\" onclick=\"" + getCloseString() + "\"></div>"); } else { return ("<div id=\"" + getDivId() + "\" class=\"settingsoverlayCD\"></div>"); } } }); }
From source file:com.axway.ats.testexplorer.pages.reports.compare.ComparePage.java
License:Apache License
private Form<Object> getItemsToCompareForm(final Label noRunsLabel, final Label noTestcasesLabel) { final Form<Object> itemsToCompareForm = new Form<Object>("itemsToCompareForm"); itemsToCompareForm.setOutputMarkupId(true); IModel<? extends List<Run>> runsListModel = new LoadableDetachableModel<List<Run>>() { private static final long serialVersionUID = 1L; protected List<Run> load() { return getTESession().getCompareContainer().getRunsList(); }/* w w w . j ava 2 s.c o m*/ }; final ListView<Run> runsToCompare = new ListView<Run>("runsToCompare", runsListModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<Run> item) { final ListView<Run> runsToCompareComponent = this; if (item.getIndex() % 2 != 0) { item.add(AttributeModifier.replace("class", "oddRow")); } Map<Run, Model<Boolean>> runs = getTESession().getCompareContainer().getRuns(); item.add(new CheckBox("checkbox", runs.get(item.getModelObject()))); item.add(new Label("runName", item.getModelObject().runName).setEscapeModelStrings(false)); item.add(new Label("version", item.getModelObject().versionName).setEscapeModelStrings(false)); item.add(new Label("build", item.getModelObject().buildName).setEscapeModelStrings(false)); item.add(new Label("startDate", item.getModelObject().getDateStart()).setEscapeModelStrings(false)); item.add(new Label("endDate", item.getModelObject().getDateEnd()).setEscapeModelStrings(false)); item.add(new AjaxButton("removeIcon") { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { CompareContainer compareContainer = getTESession().getCompareContainer(); compareContainer.removeObject(item.getModelObject()); runsToCompareComponent.setModelObject(compareContainer.getRunsList()); noRunsLabel.setVisible(compareContainer.getRuns().size() == 0); target.add(noRunsLabel); target.add(itemsToCompareForm); } }); } }; itemsToCompareForm.add(runsToCompare); AjaxButton removeAllRunsButton = new AjaxButton("removeAllRuns") { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { CompareContainer compareContainer = getTESession().getCompareContainer(); compareContainer.getRuns().clear(); runsToCompare.setModelObject(compareContainer.getRunsList()); noRunsLabel.setVisible(true); target.add(noRunsLabel); target.add(itemsToCompareForm); } }; itemsToCompareForm.add(removeAllRunsButton); IModel<? extends List<Testcase>> testcasesListModel = new LoadableDetachableModel<List<Testcase>>() { private static final long serialVersionUID = 1L; protected List<Testcase> load() { return getTESession().getCompareContainer().getTestcasesList(); } }; final TestcaseListView<Testcase> testcasesToCompare = new TestcaseListView<Testcase>("testcasesToCompare", testcasesListModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<Testcase> item) { final ListView<Testcase> testcasesToCompareComponent = this; if (item.getIndex() % 2 != 0) { item.add(AttributeModifier.replace("class", "oddRow")); } Map<Testcase, Model<Boolean>> testcases = getTESession().getCompareContainer().getTestcases(); item.add(new CheckBox("checkbox", testcases.get(item.getModelObject()))); item.add(new Label("runName", item.getModelObject().runName).setEscapeModelStrings(false)); item.add(new Label("suiteName", item.getModelObject().suiteName).setEscapeModelStrings(false)); item.add( new Label("scenarioName", item.getModelObject().scenarioName).setEscapeModelStrings(false)); item.add(new Label("testcaseName", item.getModelObject().name).setEscapeModelStrings(false)); item.add(new Label("dateStart", item.getModelObject().getDateStart()).setEscapeModelStrings(false)); item.add(new TextField<String>("testcaseAlias", new PropertyModel<String>(item.getModelObject(), "alias"))); item.add(moveLinkUp("moveUpLink", item)); item.add(new AjaxButton("removeIcon") { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { CompareContainer compareContainer = getTESession().getCompareContainer(); compareContainer.removeObject(item.getModelObject()); testcasesToCompareComponent.setModelObject(compareContainer.getTestcasesList()); noTestcasesLabel.setVisible(compareContainer.getTestcases().size() == 0); target.add(noTestcasesLabel); target.add(itemsToCompareForm); } }); } }; itemsToCompareForm.add(testcasesToCompare); AjaxButton removeAllTestcasesButton = new AjaxButton("removeAllTestcases") { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { CompareContainer compareContainer = getTESession().getCompareContainer(); compareContainer.getTestcases().clear(); testcasesToCompare.setModelObject(compareContainer.getTestcasesList()); noTestcasesLabel.setVisible(true); target.add(noTestcasesLabel); target.add(itemsToCompareForm); } }; itemsToCompareForm.add(removeAllTestcasesButton); // Standard Runs Compare buttons itemsToCompareForm.add(getStandardRunsCompareButtons()); // Custom Runs Compare buttons itemsToCompareForm.add(getCustomRunsCompareButtons()); // Standard Testcases Compare buttons itemsToCompareForm.add(getStandardTestcasesCompareButtons()); // Custom Testcases Compare buttons itemsToCompareForm.add(getCustomTestcasesCompareButtons()); noRunsLabel.setVisible(getTESession().getCompareContainer().getRuns().size() == 0); itemsToCompareForm.add(noRunsLabel); noTestcasesLabel.setVisible(getTESession().getCompareContainer().getTestcases().size() == 0); itemsToCompareForm.add(noTestcasesLabel); return itemsToCompareForm; }
From source file:com.axway.ats.testexplorer.pages.testcase.statistics.DataPanel.java
License:Apache License
/** * Display the collected//from www. j a v a 2 s. c o m * @param statsForm */ public void displayStatisticDescriptions(Form<Object> statsForm) { boolean isDataPanelVisible = machineDescriptions.size() > 0; List<List<StatisticsTableCell>> rows = new ArrayList<List<StatisticsTableCell>>(); List<StatisticsTableCell> columns = new ArrayList<StatisticsTableCell>(); // add machine columns columns.add(new StatisticsTableCell("<img class=\"arrowUD\" src=\"images/up.png\">", false)); columns.add(new StatisticsTableCell(this.name, false)); for (MachineDescription machine : machineDescriptions) { String machineName = machine.getMachineAlias(); if (SQLServerDbReadAccess.MACHINE_NAME_FOR_ATS_AGENTS.equals(machineName)) { machineName = ""; } StatisticsTableCell cell = new StatisticsTableCell( "<b style=\"padding: 0 5px;\">" + machineName + "</b>", false, "centeredLabel"); cell.cssClass = "fixTableColumn"; columns.add(cell); } rows.add(columns); // add empty row columns = new ArrayList<StatisticsTableCell>(); for (int i = 0; i < 2 + machineDescriptions.size(); i++) { columns.add(NBSP_EMPTY_CELL); } rows.add(columns); final Set<Integer> hiddenRowIndexes = new HashSet<Integer>(); for (StatisticContainer statContainer : statContainers.values()) { List<DbStatisticDescription> statDescriptions = sortQueueItems(statContainer.getStatDescriptions()); String lastStatParent = ""; for (DbStatisticDescription statDescription : statDescriptions) { String statisticLabel = "<span class=\"statName\">" + statDescription.name + "</span><span class=\"statUnit\">(" + statDescription.unit + ")</span>"; // add parent table line if needed String statParent = statDescription.parentName; if (!StringUtils.isNullOrEmpty(statParent) && !statParent.equals(StatisticsPanel.SYSTEM_STATISTIC_CONTAINER) && !lastStatParent.equals(statParent)) { columns = new ArrayList<StatisticsTableCell>(); columns.add(NBSP_EMPTY_CELL); if (statParent.startsWith(PROCESS_STAT_PREFIX)) { // only Process parent element can hide its children (it is not a good idea to hide the User actions behind queue names) columns.add(new StatisticsTableCell( "<a href=\"#\" onclick=\"showHiddenStatChildren(this);return false;\">" + statParent + "</a>", false, "parentStatTd")); } else { columns.add(new StatisticsTableCell(statParent, false, "parentStatTd")); } for (int i = 0; i < machineDescriptions.size(); i++) { columns.add(NBSP_EMPTY_CELL); } rows.add(columns); } lastStatParent = statParent; columns = new ArrayList<StatisticsTableCell>(); columns.add(new StatisticsTableCell(true)); StatisticsTableCell statName = new StatisticsTableCell(statisticLabel, true); statName.title = statDescription.params; columns.add(statName); for (MachineDescription machine : machineDescriptions) { Model<Boolean> selectionModel = machine.getStatDescriptionSelectionModel(statDescription); // selectionModel.getObject() should sometimes return // NULL - when comparing with other testcases if (selectionModel != null && selectionModel.getObject() != null) { columns.add(new StatisticsTableCell(selectionModel)); } else { columns.add(EMPTY_CELL); } } // hide only the Process child elements if (!StringUtils.isNullOrEmpty(lastStatParent) && lastStatParent.startsWith(PROCESS_STAT_PREFIX)) { // add current row number as a child row which must be hidden hiddenRowIndexes.add(rows.size()); } rows.add(columns); } } statisticsUIContainer = new ListView<List<StatisticsTableCell>>(uiPrefix + "StatsRows", rows) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<List<StatisticsTableCell>> item) { // table TR if (item.getIndex() == 0) { item.add(AttributeModifier.replace("class", "statisticsHeaderRow")); item.add(AttributeModifier.replace("onclick", "showOrHideTableRows('" + uiPrefix + "StatsTable',1,true);")); } else if (item.getIndex() > 3) { // skip the machines,label and // measurement rows item.add(AttributeModifier.replace("class", "statisticRow")); } if (hiddenRowIndexes.contains(item.getIndex())) { item.add(new AttributeAppender("class", new Model<String>("hiddenStatRow"), " ")); } item.add(new ListView<StatisticsTableCell>(uiPrefix + "StatsColumns", item.getModelObject()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<StatisticsTableCell> item) { // table TD if (item.getIndex() > 0) { // skip the first (CheckBox) // column item.add(AttributeModifier.replace("class", "statisticColumn")); } StatisticsTableCell cell = item.getModelObject(); CheckBox checkBox = new CheckBox("checkbox", cell.checkboxModel); if (cell.isCheckbox) { if (item.getIndex() == 0) { // this is the first/main CheckBox // binding onclick function which will (un)select all the CheckBoxes on that row // and will change the line color if it is selected or not checkBox.add(AttributeModifier.replace("onclick", "selectAllCheckboxes(this,'" + uiPrefix + "StatsTable');")); checkBox.add(AttributeModifier.replace("class", "allMachinesCheckbox")); } else { // binding onclick function which will (un)select the main/first CheckBox on that row // when all the CheckBoxes are selected or some are unselected. // Also the row/cell color will be changed. checkBox.add(AttributeModifier.replace("onclick", "unselectMainTrCheckbox(this,'" + uiPrefix + "StatsTable');")); checkBox.add(AttributeModifier.replace("class", "machineCheckbox")); item.add(AttributeModifier.replace("class", "statisticColumnWithCheckboxOnly")); } } else { checkBox.setVisible(false); } item.add(checkBox); Label label = new Label("label", cell.labelText); label.setEscapeModelStrings(false).setVisible(!cell.isCheckbox && !cell.isInputText); if (cell.isCheckboxLabel) { // binding JavaScript function which will click on the first/main CheckBox of this statistic label.add(AttributeModifier.replace("onclick", "clickSelectAllCheckbox(this);")); label.add(AttributeModifier.replace("class", "checkboxLabel noselection")); if (cell.title != null && !cell.title.isEmpty()) { String title = cell.title; int readingStartIndex = cell.title.indexOf(PARAMS_READING_UNIQUENESS_MAKRER); if (readingStartIndex > 0) { title = cell.title.substring(0, readingStartIndex) + cell.title.substring(cell.title.indexOf("_", readingStartIndex + 1)); } label.add(AttributeModifier.replace("title", title.replace("_", ", ").trim())); } } else if (label.isVisible() && cell.cssClass != null) { label.add(AttributeModifier.replace("class", cell.cssClass)); } item.add(label); Label machineAliasLabel = new Label("inputText", cell.getMachineLabelModel()); machineAliasLabel.setVisible(cell.isInputText); if (cell.getMachineLabelModel() != null && cell.getMachineLabelModel().getObject() != null) { machineAliasLabel.setOutputMarkupId(true); machineAliasLabel.add( AttributeModifier.replace("title", cell.getMachineLabelModel().getObject())); globalPanel.rememberMachineAliasLabel(machineAliasLabel); } item.add(machineAliasLabel); } }); } }; statisticsUIContainer.setVisible(isDataPanelVisible); statsForm.add(statisticsUIContainer); }
From source file:com.cubeia.backoffice.web.wallet.CreateAccount.java
License:Open Source License
/** * Constructor that is invoked when page is invoked without a session. * * @param parameters/*from ww w .ja v a2s .c om*/ * Page parameters */ public CreateAccount(final PageParameters parameters) { resetFormData(); final FeedbackPanel feedback = new FeedbackPanel("feedback"); add(feedback); Form<?> accountForm = new Form<Void>("userForm") { private static final long serialVersionUID = 1L; @Override protected void onSubmit() { CreateAccountRequest createAccountRequest = new CreateAccountRequest(null, account.getUserId(), currency, account.getType(), info); createAccountRequest.setNegativeBalanceAllowed(account.getNegativeAmountAllowed()); CreateAccountResult createResponse = null; try { createResponse = walletService.createAccount(createAccountRequest); } catch (Exception e) { log.error("Failed to create new account", e); feedback.error("Failed to create new account. Cause: " + e.getMessage()); return; } log.debug("created account id = " + createResponse.getAccountId()); feedback.info("Account created!"); } }; CompoundPropertyModel<CreateAccount> cpm = new CompoundPropertyModel<CreateAccount>(this); accountForm.add(new RequiredTextField<String>("userId", cpm.<String>bind("account.userId"))); accountForm.add(new DropDownChoice<AccountType>("accountType", cpm.<AccountType>bind("account.type"), Arrays.asList(AccountType.values())).setRequired(true)); accountForm .add(new DropDownChoice<AccountStatus>("accountStatus", cpm.<AccountStatus>bind("account.status"), Arrays.asList(AccountStatus.values())).setRequired(true)); accountForm.add(new RequiredTextField<String>("currency", cpm.<String>bind("currency"))); accountForm.add(new TextField<String>("name", cpm.<String>bind("info.name"))); accountForm.add(new CheckBox("negativeAmountAllowed", cpm.<Boolean>bind("account.negativeAmountAllowed"))); add(accountForm); }