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:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.DsListPanel.java
License:Apache License
private ListView<String> createDsListView(final Behavior updater, final ModalWindow modalWindow) { return new ListView<String>("ds", getDsList()) { private static final long serialVersionUID = 1L; @Override/*w w w. j a va 2s . c o m*/ protected void populateItem(final ListItem<String> item) { final String dsName = item.getModelObject(); item.add(new UpdatingAttributeAppender("class", new Model<String>("") { private static final long serialVersionUID = 1L; @Override public String getObject() { // if ( cacheState.isError() ) return "error"; final DsState cs = DsState.get(dsName); if (cs != null && !cs.isAvailable()) { return "error"; } // "grey" else { return " "; } } }, " ")); item.add(updater); Label label = new Label("status", new DsStateModel(dsName, "_status_string_")); label.add(updater); item.add(label); label = new Label("kbps", new DsStateModel(dsName, "total.kbps")); label.add(updater); item.add(label); label = new Label("tps", new DsStateModel(dsName, "total.tps_total")); label.add(updater); item.add(label); label = new Label("disabled", new DsStateModel(dsName, "disabledLocations")); label.add(updater); item.add(label); label = new Label("caches-reporting", new DsStateModel(dsName, "caches-reporting")); label.add(updater); item.add(label); label = new Label("caches-available", new DsStateModel(dsName, "caches-available")); label.add(updater); item.add(label); label = new Label("caches-configured", new DsStateModel(dsName, "caches-configured")); label.add(updater); item.add(label); final AjaxLink<Void> link = new AjaxLink<Void>("fulldetails") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { dsId = dsName; modalWindow.show(target); } }; link.setBody(new Model<String>(dsName)); item.add(link); } }; }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.EditConfigPanel.java
License:Apache License
private final void setForm(final Form<MonitorConfig> editform, final Map<String, String> baseconfig) { final MonitorConfig config = ConfigHandler.getConfig(); if (config == null || !config.allowConfigEdit()) { return;/*from w w w .j a v a 2s . co m*/ } final List<String> keys = sort(baseconfig.keySet()); keys.remove(TM_HOSTNAME_KEY); keys.remove(CDN_NAME_KEY); final List<String> TM_HOSTS = Arrays.asList(new String[] { "tm.company.net" }); final ArrayList<String> cdnList = new ArrayList<String>(); final String hostName = baseconfig.get(TM_HOSTNAME_KEY); setCdnList(cdnList, hostName); final AjaxEditableChoiceLabel<String> tmHost = new AjaxEditableChoiceLabel<String>("tmHost", new BaseConfigModel(TM_HOSTNAME_KEY, baseconfig), TM_HOSTS) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(final AjaxRequestTarget target) { super.onSubmit(target); final String hostName = baseconfig.get(TM_HOSTNAME_KEY); setCdnList(cdnList, hostName); target.add(cdnName); } }; // listSites editform.add(tmHost); cdnName = new AjaxEditableChoiceLabel<String>(CDN_NAME_KEY, new BaseConfigModel(CDN_NAME_KEY, baseconfig), new WildcardListModel<String>(cdnList)); // listSites editform.add(cdnName); final ListView<String> propView = new ListView<String>("propList", keys) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<String> item) { final String key = item.getModelObject(); final Label label = new Label("key", key); item.add(label); // editform.add(new TextField("value", new Model<String>(baseconfig.get(key)))) ; item.add(new AjaxEditableLabel<String>("value", new BaseConfigModel(key, baseconfig))); item.add(label); } }; editform.add(propView); editform.add(new AjaxLink<Object>("cancel") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { final Map<String, String> oldProps = ConfigHandler.getConfig().getBaseProps(); baseconfig.putAll(oldProps); final String hostName = baseconfig.get(TM_HOSTNAME_KEY); setCdnList(cdnList, hostName); if (target != null) { target.add(EditConfigPanel.this); } } }); editform.add(new AjaxButton("submit", editform) { private static final long serialVersionUID = 1L; @Override public void onSubmit(final AjaxRequestTarget target, final Form<?> form) { try { ConfigHandler.saveBaseConfig(baseconfig); TmWatcher.getInstance().refresh(); } catch (JSONException e) { LOGGER.warn(e, e); } catch (IOException e) { LOGGER.warn(e, e); } // EditConfigPanel.this.showForm(false); if (target != null) { target.add(EditConfigPanel.this); } } }); }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.EventLogPanel.java
License:Apache License
public EventLogPanel(final String id) { super(id);// w w w. j a v a 2s .co m final IModel<ArrayList<JSONObject>> listModel = new Model<ArrayList<JSONObject>>() { private static final long serialVersionUID = 1L; @Override @SuppressWarnings("PMD") public ArrayList<JSONObject> getObject() { return new ArrayList<JSONObject>(Event.getEventLog()); } }; final ListView<JSONObject> propView2 = new ListView<JSONObject>("events", listModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<JSONObject> item) { final JSONObject jo = item.getModelObject(); String errorClass = ""; try { item.add(new Label("index", Long.toString(jo.getLong("index")))); // long time = System.currentTimeMillis(); long time = jo.getLong("time"); synchronized (formatter) { item.add(new Label("time", formatter.format(new Date(time)))); } item.add(new Label("timeraw", Long.toString(jo.getLong("time")))); item.add(new Label("description", jo.getString("description"))); item.add(new Label("hostname", jo.getString("hostname"))); String status = "available"; if (!jo.getBoolean("isAvailable")) { status = "offline"; errorClass = "error"; } item.add(new Label("status", status)); } catch (JSONException e) { LOGGER.warn(e, e); } item.add(new UpdatingAttributeAppender("class", new Model<String>(errorClass), " ")); } }; this.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5))); add(propView2); }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.StatusPanel.java
License:Apache License
public StatusPanel(final String id) { super(id);// ww w. j a va2 s.co m final WebMarkupContainer c = new WebMarkupContainer("container"); add(c); // final Model<String> count = new Model<String>("0"); c.add(new Clock("clock", TimeZone.getTimeZone("America/Denver"))); c.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1))); final ListView<Model<String>> props = new ListView<Model<String>>("props", CacheWatcher.getProps()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<Model<String>> item) { final Model<String> val = item.getModelObject(); item.add(new Label("value", val)); } }; c.add(props); final JSONObject stats = Stats.getVersionInfo().optJSONObject("stats"); final String[] keys = (stats == null || stats.length() == 0) ? new String[0] : JSONObject.getNames(stats); final ListView<String> props2 = new ListView<String>("versionInfo", Arrays.asList(keys)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<String> item) { final String key = item.getModelObject(); item.add(new Label("key", key)); item.add(new Label("value", new Model<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { JSONObject stats = Stats.getVersionInfo().optJSONObject("stats"); return stats.optString(key); } })); } }; c.add(props2); }
From source file:com.cubeia.backoffice.web.MenuPanel.java
License:Open Source License
@SuppressWarnings("serial") public MenuPanel(String id, BasePage currentPage) { super(id);//from ww w. j a v a 2 s. c o m Class<? extends BasePage> currentPageClass = currentPage.getClass(); add(createPageLink("homePage", Home.class, currentPageClass)); add(createPageLink("userListPage", UserList.class, currentPageClass)); add(createPageLink("createUserPage", CreateUser.class, currentPageClass)); add(createPageLink("accountListPage", AccountList.class, currentPageClass)); add(createPageLink("createAccountPage", CreateAccount.class, currentPageClass)); add(createPageLink("createTransactionPage", CreateTransaction.class, currentPageClass)); add(createPageLink("currenciesPage", EditCurrencies.class, currentPageClass)); add(createPageLink("transactionListPage", TransactionList.class, currentPageClass)); add(createPageLink("operatorListPage", OperatorList.class, currentPageClass)); add(createPageLink("createOperatorPage", CreateOperator.class, currentPageClass)); // add(createPageLink("reportsPage", Reports.class, currentPageClass)); String signedInMessage; String signInOutMessage; Link<Void> signInOutLink; BackofficeAuthSession session = currentPage.getBackofficeSession(); if (session.isSignedIn()) { signedInMessage = "Logged in as " + session.getUserName(); signInOutMessage = "log out"; signInOutLink = new BookmarkablePageLink<Void>("signInOutLink", BackofficeSignOutPage.class); } else { signedInMessage = "Not logged in."; signInOutMessage = "log in"; // TODO: make this a panel signInOutLink = new BookmarkablePageLink<Void>("signInOutLink", Home.class); signInOutLink.setEnabled(false); signInOutLink.add(AttributeModifier.replace("style", "display: none;")); } signInOutLink.add(new Label("signInOutMessage", signInOutMessage)); add(signInOutLink); add(new Label("signedInMessage", signedInMessage)); // create external links List<String> extKeys = new ArrayList<String>(); if (externalMenuLinks != null) { extKeys.addAll(externalMenuLinks.keySet()); } Collections.sort(extKeys); add(new ListView<String>("externalLinkList", extKeys) { @Override protected void populateItem(ListItem<String> item) { String linkText = item.getModelObject(); String url = externalMenuLinks.get(linkText); item.add(new ExternalLink("link", url, linkText)); } }); }
From source file:com.cubeia.backoffice.web.user.EditUser.java
License:Open Source License
private ListView<String[]> createAttributesListView() { Model<ArrayList<String[]>> attributeModel = new Model<ArrayList<String[]>>() { private static final long serialVersionUID = 1L; @Override/*from w w w.jav a 2s . c o m*/ public ArrayList<String[]> getObject() { ArrayList<String[]> keyValueList = new ArrayList<String[]>(); if (user.getAttributes() != null) { ArrayList<String> keysSorted = new ArrayList<String>(user.getAttributes().keySet()); Collections.sort(keysSorted); for (String key : keysSorted) { if (key != null) { keyValueList.add(new String[] { key, user.getAttributes().get(key) }); } } } return keyValueList; } }; return new ListView<String[]>("attributes", attributeModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<String[]> item) { String[] keyValue = item.getModelObject(); if (keyValue[0] != null) { item.add(new Label("key", keyValue[0])); item.add(new TextField<String>("value", new PropertyModel<String>(EditUser.this, "user.attributes[" + keyValue[0] + "]"))); } } }; }
From source file:com.cubeia.backoffice.web.user.UserSummary.java
License:Open Source License
private ListView<String[]> createAttributesListView() { Model<ArrayList<String[]>> attributeModel = new Model<ArrayList<String[]>>() { private static final long serialVersionUID = 1L; @Override// w w w. j a v a 2s . c o m public ArrayList<String[]> getObject() { ArrayList<String[]> keyValueList = new ArrayList<String[]>(); if (user.getAttributes() != null) { ArrayList<String> keysSorted = new ArrayList<String>(user.getAttributes().keySet()); Collections.sort(keysSorted); for (String key : keysSorted) { keyValueList.add(new String[] { key, user.getAttributes().get(key) }); } } return keyValueList; } }; return new ListView<String[]>("attributes", attributeModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<String[]> item) { String[] keyValue = item.getModelObject(); item.add(new Label("key", keyValue[0])); item.add(new Label("value", keyValue[1])); } }; }
From source file:com.cubeia.backoffice.web.user.UserSummary.java
License:Open Source License
private ListView<Account> createAccountListView(AccountQueryResult accountResult) { log.debug("account result: {}", accountResult); List<Account> accounts = accountResult.getAccounts(); if (accounts == null) { accounts = new ArrayList<Account>(); }//from ww w. j a va2 s . com HashSet<Account> accountSet = new HashSet<Account>(accounts); List<Account> accountList = new ArrayList<Account>(accountSet); Collections.sort(accountList, Collections.reverseOrder(new Comparator<Account>() { @Override public int compare(Account a1, Account a2) { return a1.getType().name().compareTo(a2.getType().name()); } })); return new ListView<Account>("accounts", Model.ofList(accountList)) { private static final long serialVersionUID = 1L; @SuppressWarnings("serial") @Override protected void populateItem(ListItem<Account> item) { final Account account = item.getModelObject(); item.add(new LabelLinkPanel("accountId", "" + account.getId(), "View account " + account.getId(), AccountDetails.class, params(PARAM_ACCOUNT_ID, account.getId()))); item.add(new Label("name", new PropertyModel<String>(account, "information.name"))); item.add(new Label("currency", new PropertyModel<String>(account, "currencyCode"))); item.add(new Label("created", new DateDisplayModel(account, "created"))); item.add(new Label("type", new PropertyModel<String>(account, "type"))); item.add(new Label("balance", new Model<BigDecimal>() { public BigDecimal getObject() { BigDecimal amount; try { amount = walletService.getAccountBalance(account.getId()).getBalance().getAmount(); } catch (AccountNotFoundException e) { throw new RuntimeException(e); } return amount; }; })); item.add(new OddEvenRowsAttributeModifier(item.getIndex())); } }; }
From source file:com.cubeia.backoffice.web.wallet.EditCurrencies.java
License:Open Source License
/** * Constructor that is invoked when page is invoked without a session. * *//* www .ja v a 2 s .c o m*/ @SuppressWarnings("serial") public EditCurrencies() { add(new FeedbackPanel("feedback", new ComponentFeedbackMessageFilter(EditCurrencies.this))); IModel<List<Currency>> currencyModel = new LoadableDetachableModel<List<Currency>>() { @Override protected List<Currency> load() { CurrencyListResult supportedCurrencies = walletService.getSupportedCurrencies(); if (supportedCurrencies == null) { return Collections.<Currency>emptyList(); } ArrayList<Currency> curs = new ArrayList<Currency>(supportedCurrencies.getCurrencies()); log.debug("got currencies: {}", curs); Collections.sort(curs, new Comparator<Currency>() { @Override public int compare(Currency o1, Currency o2) { return o1.getCode().compareTo(o2.getCode()); } }); return curs; } }; add(new ListView<Currency>("currencies", currencyModel) { @Override protected void populateItem(ListItem<Currency> item) { final Currency c = item.getModelObject(); item.add(new Label("code", Model.of(c.getCode()))); item.add(new Label("digits", Model.of(c.getFractionalDigits()))); item.add(new Link<String>("removeLink") { @Override public void onClick() { log.debug("removing currency: {}", c); walletService.removeCurrency(c.getCode()); } }.add(new ConfirmOnclickAttributeModifier("Really remove this currency?"))); } }); final CompoundPropertyModel<Currency> newCurrencyModel = new CompoundPropertyModel<Currency>( new Currency(null, 2)); Form<Currency> addForm = new Form<Currency>("addForm", newCurrencyModel) { @Override protected void onSubmit() { Currency cur = getModelObject(); log.debug("submit: {}", cur); try { walletService.addCurrency(cur); } catch (Exception e) { error("Error creating currency: " + e.getMessage()); return; } info("Added currency " + cur.getCode() + " with " + cur.getFractionalDigits() + " fractional digits"); newCurrencyModel.setObject(new Currency(null, 2)); } }; addForm.add(new RequiredTextField<String>("code", newCurrencyModel.<String>bind("code")) .add(StringValidator.exactLength(3))); addForm.add(new RequiredTextField<Integer>("digits", newCurrencyModel.<Integer>bind("fractionalDigits")) .add(new RangeValidator<Integer>(0, 8))); addForm.add(new FeedbackPanel("feedback", new ContainerFeedbackMessageFilter(addForm))); addForm.add(new WebMarkupContainer("submitButton") .add(new ConfirmOnclickAttributeModifier("Are you sure you want to add this currency?"))); add(addForm); }
From source file:com.cubeia.backoffice.web.wallet.EntriesPanel.java
License:Open Source License
public EntriesPanel(final Collection<Long> highlightAccountIds, final Collection<Long> highlightUserIds, String id, Collection<Entry> entries) { super(id);// w ww . j ava 2s . c om ArrayList<Entry> entryList = new ArrayList<Entry>(); if (entries != null) { entryList.addAll(entries); } Collections.sort(entryList, new Comparator<Entry>() { @Override public int compare(Entry o1, Entry o2) { return o1.getAccountId().compareTo(o2.getAccountId()); } }); ListView<Entry> entryListView = new ListView<Entry>("entries", entryList) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<Entry> item) { Entry e = item.getModelObject(); String label = "" + e.getAccountId() + " (" + e.getAccountUserId() + ")"; String toolTip = "Details for account id = " + e.getAccountId() + ". User id = " + e.getAccountUserId() + ", entry id = " + e.getId() + "."; LabelLinkPanel labelLink = new LabelLinkPanel("accountEntriesLink", label, toolTip, AccountDetails.class, params(AccountDetails.PARAM_ACCOUNT_ID, e.getAccountId())); item.add(labelLink); Label amountLabel = new Label("amount", "" + e.getAmount()); item.add(amountLabel); boolean highlight = highlightAccountIds.contains(e.getAccountId()) || highlightUserIds.contains(e.getAccountUserId()); if (highlight) { AttributeModifier highlightModifier = new AttributeModifier("class", Model.of("highlight")); labelLink.add(highlightModifier); amountLabel.add(highlightModifier); } } }; add(entryListView); }