List of usage examples for org.apache.wicket.markup.html.basic Label add
public Component add(final Behavior... behaviors)
From source file:au.org.theark.lims.web.component.button.PrinterListPanel.java
License:Open Source License
private void initPanel() { DropDownChoice<String> printerListDdc = new DropDownChoice<String>("printerList", new PropertyModel<String>(this, "selected"), PRINTERLIST); printerListDdc.add(new AttributeModifier("name", "printerList")); printerListDdc.add(new AttributeModifier("onchange", "changeHiddenInput(this)")); printerListDdc.setOutputMarkupPlaceholderTag(true); this.add(printerListDdc); selectedPrinter = new HiddenField<String>("selectedPrinter", new PropertyModel<String>(this, "selected")); selectedPrinter.setOutputMarkupPlaceholderTag(true); selectedPrinter.add(new AttributeModifier("name", "selectedPrinter")); selectedPrinter.add(new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override//from w w w. j a v a 2 s . co m protected void respond(AjaxRequestTarget arg0) { StringValue selectedPrinter = RequestCycle.get().getRequest().getQueryParameters() .getParameterValue("selectedPrinter"); selected = selectedPrinter.toString(); } }); this.add(selectedPrinter); StringBuilder javaScript = new StringBuilder(); javaScript.append("function findPrinters() {"); javaScript.append("\n"); javaScript.append(" var applet = document.jZebra;"); javaScript.append("\n"); javaScript.append(" if (applet != null) {"); javaScript.append("\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').disabled = false;"); javaScript.append("\n"); javaScript.append(" var listing = applet.getPrinters();"); javaScript.append("\n"); javaScript.append(" var printers = listing.split(',');\n"); javaScript.append(" var objHidden = document.getElementById('"); javaScript.append(selectedPrinter.getMarkupId()); javaScript.append("');\n"); javaScript.append("\n"); javaScript.append(" for ( var i in printers) {"); javaScript.append("\n"); javaScript.append(" if(objHidden.value == printers[i]) {\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').options[i] = new Option(printers[i], printers[i], true, true);\n"); javaScript.append(" } else {\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').options[i] = new Option(printers[i], printers[i], false, false);\n"); javaScript.append(" }\n"); javaScript.append(" }"); javaScript.append("\n"); javaScript.append(" } else {"); javaScript.append("\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').options[i] = new Option('N/A');"); javaScript.append("\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').disabled = true;"); javaScript.append("\n"); javaScript.append(" }"); javaScript.append("\n"); javaScript.append("}"); javaScript.append("\n"); javaScript.append("\n"); javaScript.append("function changeHiddenInput (objDropDown) {"); javaScript.append("\n"); javaScript.append(" var objHidden = document.getElementById('"); javaScript.append(selectedPrinter.getMarkupId()); javaScript.append("');\n"); javaScript.append(" objHidden.value = objDropDown.value;"); javaScript.append("\n"); javaScript.append(" callWicket(objDropDown.value);"); javaScript.append("}"); final Label script = new Label("script", javaScript.toString()); script.setOutputMarkupPlaceholderTag(true); script.add(new AttributeModifier("onload", "findPrinters()")); script.setEscapeModelStrings(false); // do not HTML escape JavaScript code this.add(script); }
From source file:au.org.theark.lims.web.component.inventory.panel.box.display.GridBoxPanel.java
License:Open Source License
/** * Creates the table data that represents the cells of the InvBox in question * @param invBox//from www. ja v a 2 s .c o m * @param invCellList * @return */ @SuppressWarnings({ "unchecked" }) private Loop createMainGrid(final InvBox invBox, final List<InvCell> invCellList) { String colRowNoType = ""; if (invBox.getId() != null) { colRowNoType = invBox.getRownotype().getName(); } else { // handle for null invBox (eg when backend list of cells corrupted) return new Loop("rows", 1) { private static final long serialVersionUID = 1L; @Override protected void populateItem(LoopItem item) { item.add(new Loop("cols", 1) { private static final long serialVersionUID = 1L; @Override protected void populateItem(LoopItem item) { item.add(new EmptyPanel("cell")); } }.setVisible(false)); } @Override public boolean isVisible() { return false; } }; } final String rowNoType = colRowNoType; final int noOfCols = invBox.getNoofcol(); // Outer Loop instance, using a PropertyModel to bind the Loop iteration to invBox "noofrow" value Loop loop = new Loop("rows", new PropertyModel(invBox, "noofrow")) { private static final long serialVersionUID = 1L; public void populateItem(LoopItem item) { final int row = item.getIndex(); // Create the row number/label String label = new String(); if (rowNoType.equalsIgnoreCase("ALPHABET")) { char character = (char) (row + 65); label = new Character(character).toString(); } else { label = new Integer(row + 1).toString(); } Label rowLabel = new Label("rowNo", new Model(label)); rowLabel.add(new Behavior() { private static final long serialVersionUID = 1L; @Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); tag.put("style", "background: none repeat scroll 0 0 #FFFFFF; color: black; font-weight: bold; padding: 1px;"); }; }); rowLabel.setOutputMarkupId(true); item.add(rowLabel); // We create an inner Loop instance and uses PropertyModel to bind the Loop iteration to invBox "noofcol" value item.add(new Loop("cols", new PropertyModel(invBox, "noofcol")) { private static final long serialVersionUID = 1L; public void populateItem(LoopItem item) { final int col = item.getIndex(); final int index = (row * noOfCols) + col; InvCell invCell = invCellList.get(index); GridCellContentPanel gridCellContentPanel; // add the gridCell if (allocating) { gridCellContentPanel = new GridCellContentPanel("cell", limsVo, invCell, modalWindow, true); } else { gridCellContentPanel = new GridCellContentPanel("cell", limsVo, invCell, modalWindow, false); } gridCellContentPanel.setOutputMarkupId(true); gridCellContentPanel.setMarkupId("invCell" + invCell.getId().toString()); item.add(gridCellContentPanel); } }); } }; return loop; }
From source file:au.org.theark.study.web.component.address.form.SearchForm.java
License:Open Source License
public void updateDetailFormPrerender(Address address) { // Ensure we update the CountyStateChoices in DetailsForm // like what happens via DetailForm's updateStateChoices(..) List<State> stateList = iArkCommonService.getStates(address.getCountry()); WebMarkupContainer wmcStateSelector = (WebMarkupContainer) arkCrudContainerVO.getDetailPanelFormContainer() .get(Constants.STATE_SELECTOR_WMC); DropDownChoice<State> detailStateSelector = (DropDownChoice<State>) wmcStateSelector.get("address.state"); Label otherStateInvalidError = (Label) wmcStateSelector.get("address.otherStateInvalidError"); TextField<String> otherState = (TextField<String>) wmcStateSelector.get("address.otherState"); if (stateList != null && stateList.size() > 0) { detailStateSelector.getChoices().clear(); detailStateSelector.setChoices(stateList); detailStateSelector.setVisible(true); otherState.setVisible(false);//ww w .ja v a 2 s.co m //ARK-748 //Ignore the new Address objects from state validation and hide the other state validation label if (getModelObject().getAddress().getId() != null && otherState.getModelObject() != null && !otherState.getModelObject().isEmpty()) { //alert the user otherStateInvalidError = new Label("address.otherStateInvalidError", "Previously uploaded value " + otherState.getModelObject() + " was invalid."); otherStateInvalidError.add(new Behavior() { /** * */ private static final long serialVersionUID = 7964297415151363039L; @Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); tag.put("class", "fieldErrorMessage");//or something like ("style"; "color-red") } }); wmcStateSelector.addOrReplace(otherStateInvalidError); } else { otherStateInvalidError.setVisible(false); } } else { // hide it detailStateSelector.setVisible(false); otherState.setVisible(true); otherStateInvalidError.setVisible(false); } }
From source file:au.org.theark.study.web.component.contact.ContactContainerPanel.java
License:Open Source License
/** * /*from w w w. ja v a2 s . com*/ * @param address */ private void updateDetailFormPrerender(Address address) { // Ensure we update the CountyStateChoices in DetailsForm // like what happens via DetailForm's updateStateChoices(..) List<State> stateList = iArkCommonService.getStates(address.getCountry()); WebMarkupContainer wmcStateSelector = (WebMarkupContainer) arkCrudContainerVO.getDetailPanelFormContainer() .get(Constants.STATE_SELECTOR_WMC); DropDownChoice<State> detailStateSelector = (DropDownChoice<State>) wmcStateSelector .get("addressVo.address.state"); Label otherStateInvalidError = (Label) wmcStateSelector.get("addressVo.address.otherStateInvalidError"); TextField<String> otherState = (TextField<String>) wmcStateSelector.get("addressVo.address.otherState"); if (stateList != null && stateList.size() > 0) { detailStateSelector.getChoices().clear(); detailStateSelector.setChoices(stateList); detailStateSelector.setVisible(true); otherState.setVisible(false); //ARK-748 //Ignore the new Address objects from state validation and hide the other state validation label if (cpModel.getObject().getAddressVo().getAddress().getId() != null && otherState.getModelObject() != null && !otherState.getModelObject().isEmpty()) { //alert the user otherStateInvalidError = new Label("addressVo.address.otherStateInvalidError", "Previously uploaded value " + otherState.getModelObject() + " was invalid."); otherStateInvalidError.add(new Behavior() { /** * */ private static final long serialVersionUID = 7964297415151363039L; @Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); tag.put("class", "fieldErrorMessage");//or something like ("style"; "color-red") } }); wmcStateSelector.addOrReplace(otherStateInvalidError); } else { otherStateInvalidError.setVisible(false); } } else { // hide it detailStateSelector.setVisible(false); otherState.setVisible(true); otherStateInvalidError.setVisible(false); } }
From source file:ch.difty.scipamato.common.web.component.table.column.LinkIconPanel.java
License:Apache License
private Label makeImage(String id) { Label image = new Label(id, ""); image.add(AttributeModifier.replace("class", getDefaultModel())); if (titleModel != null) { image.add(AttributeModifier.replace("title", titleModel)); }//from w w w . j a v a 2 s . co m return image; }
From source file:ch.qos.mistletoe.wicket.TestReportPanel.java
License:Open Source License
void handle_NOT_OK_Description() { Throwable t = testReport.getThrowable(); ExceptionHelper ex = new ExceptionHelper(t); final WebMarkupContainer parent = new WebMarkupContainer(Constants.PAYLOAD_ID); add(parent);// w ww . j av a2s . c om Label exception = new Label(Constants.NODE_ID, ex.asString()); exception.setEscapeModelStrings(false); exception.add(new AttributeModifier("class", "exception")); parent.add(exception); if (ex.getLines() > 50) { System.out.println("ex.getLines() > 50"); AttributeModifier sam = new AttributeModifier("style", "height: 40em; overflow: scroll;"); exception.add(sam); } }
From source file:com.aipo.mobycket.wicket.markup.html.BaseWebPage.java
License:Apache License
@Override protected void onBeforeRender() { WebContext webContext = WebContextLocator.get(); // contentType Label contentType = new Label("contentType", ""); contentType.add(new SimpleAttributeModifier("content", new StringBuilder(webContext.getContentType()) .append("; charset=").append(webContext.getContentCharsetName()))); addOrReplace(contentType);//from ww w . j av a 2s . com super.onBeforeRender(); }
From source file:com.axway.ats.testexplorer.pages.testcase.statistics.DataPanel.java
License:Apache License
/** * Display the collected//from ww w . j av a 2 s .c om * @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.axway.ats.testexplorer.pages.testcase.statistics.StatisticsPanel.java
License:Apache License
/** * @return ListView containing all diagrams *//*from w w w. jav a 2 s .c o m*/ private ListView<DbStatisticDescription> addChartGroupListView() { ListView<DbStatisticDescription> listViewChartGroup = new ListView<DbStatisticDescription>("chartGroupRows", listViewContent) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<DbStatisticDescription> item) { DbStatisticDescription statElement = listViewContent.get(item.getIndex()); if (statElement.name.equals("HEADER")) { // add the header row for the diagram table item.add(AttributeModifier.replace("class", "chartGroupHeader")); Label removeIcon = new Label("removeIcon"); removeIcon.add(AttributeModifier.append("style", ";display:none;")); item.add(removeIcon); item.add(addDiagramHeaderName("statName", "Name")); IModel<String> aliasModel = new Model<String>(); aliasModel.setObject("Alias"); TextField<String> alias = new TextField<String>("alias", aliasModel); alias.setOutputMarkupId(true); alias.add(AttributeModifier.append("style", ";background-color:transparent;border:0px;pointer-events:none;text-align: center;font-family:\"Times New Roman\",Times,serif;")); alias.add(AttributeModifier.replace("class", "chartGroupHeader")); item.add(alias); item.add(addDiagramHeaderName("startDate", "Start Time")); item.add(addDiagramHeaderName("run", "Run")); item.add(addDiagramHeaderName("suite", "Suite")); item.add(addDiagramHeaderName("scenario", "Scenario")); item.add(addDiagramHeaderName("testcase", "Testcase")); } else if (statElement.unit == null) { // add diagram name row final AjaxButton deleteAllButton = new AjaxButton("removeIcon") { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { String diagramName = listViewContent.get(item.getIndex()).name; getTESession().getDiagramContainer().remove(diagramName); updateDiagramTableContent(); target.add(statsForm); } }; deleteAllButton .add(AttributeModifier.replace("class", "fixGroupTableColumn removeAllItemsIcon")); item.add(deleteAllButton); item.add(AttributeModifier.replace("class", "chartGroup")); item.add(new Label("statName", "").setEscapeModelStrings(false)); Label alias = new Label("alias", ""); // disable and change CSS of the input tag alias.add(AttributeModifier.append("style", ";background-color:transparent;border:0px;pointer-events:none")); item.add(alias); item.add(new Label("startDate", statElement.name).setEscapeModelStrings(false)); item.add(new Label("run", "").setEscapeModelStrings(false)); item.add(new Label("suite", "").setEscapeModelStrings(false)); item.add(new Label("scenario", "").setEscapeModelStrings(false)); item.add(new Label("testcase", "").setEscapeModelStrings(false)); } else { // add diagram content List<String> statNavigationTokens = getStatisticNavigation(statElement); final AjaxButton deleteButton = new AjaxButton("removeIcon") { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { deleteSingleRowFromDiagramList(item); updateDiagramTableContent(); target.add(statsForm); } }; item.add(deleteButton); item.add(new Label("statName", statElement.name).setEscapeModelStrings(false)); IModel<String> aliasModel = null; DbStatisticDescription currentElement = listViewContent.get(item.getIndex()); String currentElementKey = null; if (currentElement.getStatisticId() != 0 && currentElement.machineId != 0) { currentElementKey = getDiagramName(item.getIndex()) + "_" + currentElement.testcaseStarttime + "_" + currentElement.getStatisticId() + "_" + currentElement.machineId; } else { currentElementKey = getDiagramName(item.getIndex()) + "_" + currentElement.testcaseStarttime + "_" + currentElement.getName() + "_" + currentElement.getParentName(); } // using diagramName+testcaseStartTime+statisticTypeId+machineId or testcaseStartTime+name+queueName for key IModel<String> alias = getTESession().getStatisticsAliasModels().get(currentElementKey); if (alias != null && alias.getObject() != null) { aliasModel = alias; } else { aliasModel = new Model<String>(); } getTESession().getStatisticsAliasModels().put(currentElementKey, aliasModel); item.add(new TextField<String>("alias", aliasModel).setOutputMarkupId(true)); item.add(new Label("startDate", statNavigationTokens.get(4)).setEscapeModelStrings(false)); item.add(new Label("run", statNavigationTokens.get(0)).setEscapeModelStrings(false)); item.add(new Label("suite", statNavigationTokens.get(1)).setEscapeModelStrings(false)); item.add(new Label("scenario", statNavigationTokens.get(2)).setEscapeModelStrings(false)); item.add(new Label("testcase", statNavigationTokens.get(3)).setEscapeModelStrings(false)); } }; }; listViewChartGroup.setOutputMarkupId(true); return listViewChartGroup; }
From source file:com.axway.ats.testexplorer.pages.testcase.statistics.StatisticsPanel.java
License:Apache License
private Label addDiagramHeaderName(String wicketId, String value) { Label label = new Label(wicketId, value); label.setEscapeModelStrings(false);/*from www . j a v a 2 s. co m*/ label.add(AttributeModifier.append("style", "text-align: center;")); return label; }