List of usage examples for org.apache.wicket.util.string Strings isEmpty
public static boolean isEmpty(final CharSequence string)
string
is considered empty. From source file:org.cipango.ims.hss.web.adminuser.SetPasswordPage.java
License:Apache License
@SuppressWarnings("unchecked") public SetPasswordPage(PageParameters pageParameters) { super(pageParameters); _key = pageParameters.getString("id"); AdminUser adminUser = null;//from ww w . j ava 2 s . co m if (_key != null) { adminUser = _dao.findById(_key); if (adminUser == null) { error(MapVariableInterpolator.interpolate(getString(getPrefix() + ".error.notFound"), new MicroMap("id", _key))); _key = null; } } IModel model = new DaoDetachableModel(adminUser); _title = getString(getPrefix() + ".setPassword.title", model); Form form = new Form("form", new CompoundPropertyModel(model)); add(form); form.add(new Label("title", adminUser == null ? "" : adminUser.getLogin())); final PasswordTextField password1 = new PasswordTextField("password1", new Model<String>()); form.add(password1); final PasswordTextField password2 = new PasswordTextField("password2", new Model<String>()); form.add(password2); form.add(new EqualPasswordInputValidator(password1, password2)); form.add(new Button("submit") { @Override public void onSubmit() { if (!Strings.isEmpty(password1.getModelObject()) && password1.getModelObject().equals(password2.getModelObject())) { AdminUser admin = (AdminUser) getForm().getModelObject(); admin.setClearPassword(password1.getModelObject()); _dao.save(admin); getSession().info(getString("adminUser.passwordUpdated", getForm().getModel())); setResponsePage(EditAdminUserPage.class, new PageParameters("id=" + admin.getLogin())); } else getSession().warn(getString("adminUser.error.passwordsDontMatch", getForm().getModel())); } }); form.add(new Button("cancel") { @Override public void onSubmit() { getSession().info(getString("modification.cancel")); AdminUser admin = (AdminUser) getForm().getModelObject(); setResponsePage(EditAdminUserPage.class, new PageParameters("id=" + admin.getLogin())); } }.setDefaultFormProcessing(false)); if (adminUser != null) setContextMenu(new ContextPanel(adminUser)); }
From source file:org.cipango.ims.hss.web.ifc.IfcBrowserPage.java
License:Apache License
@SuppressWarnings("unchecked") public IfcBrowserPage(PageParameters pageParameters) { super(pageParameters); String asName = pageParameters.getString("applicationServer"); add(new BookmarkablePageLink("createLink", EditIfcPage.class)); IColumn[] columns = new IColumn[5]; columns[0] = new PropertyColumn(new StringResourceModel(getPrefix() + ".name", this, null), "name", "name"); columns[1] = new PropertyColumn(new StringResourceModel(getPrefix() + ".priority", this, null), "priority", "priority"); columns[2] = new PropertyColumn(new StringResourceModel(getPrefix() + ".applicationServer", this, null), "application_server", "applicationServerName"); columns[3] = new AbstractColumn(new Model(getString("contextPanel.serviceProfiles"))) { public void populateItem(Item cellItem, String componentId, IModel model) { cellItem.add(new NbElemsPanel(componentId, (InitialFilterCriteria) model.getObject())); }/*from w w w. ja v a 2 s. c o m*/ }; columns[4] = new AbstractColumn(new Model(getString("actions"))) { public void populateItem(Item cellItem, String componentId, IModel model) { cellItem.add(new ActionsPanel(componentId, (InitialFilterCriteria) model.getObject())); } }; DaoDataProvider daoDataProvider = new DaoDataProvider("name", asName); DefaultDataTable table = new DefaultDataTable("browser", columns, daoDataProvider, getItemByPage()); table.setOutputMarkupId(true); add(table); asName = daoDataProvider.getAsName(); if (!Strings.isEmpty(asName)) { setContextMenu(new ContextPanel(_applicationServerDao.findById(asName))); _title = MapVariableInterpolator.interpolate(getString("as.ifcs.browser.title"), new MicroMap("id", asName)); } else _title = getString(getPrefix() + ".browser.title"); add(new Label("title", _title)); setContextMenu(new ServicesContextPanel()); }
From source file:org.cipango.ims.hss.web.publicid.PublicIdBrowserPage.java
License:Apache License
@SuppressWarnings("unchecked") public PublicIdBrowserPage(PageParameters pageParameters) { super(pageParameters); String serviceProfile = pageParameters.getString("serviceProfile"); String applicationServer = pageParameters.getString("applicationServer"); String scscf = pageParameters.getString("scscf"); String search = pageParameters.getString("search"); addSearchField(search);/*from w w w .jav a 2 s . c o m*/ add(new BookmarkablePageLink("createLink", EditPublicUserIdPage.class)); add(new BookmarkablePageLink("createPsiLink", EditPsiPage.class)); IColumn[] columns = new IColumn[5]; columns[0] = new PropertyColumn(new StringResourceModel(getPrefix() + ".name", this, null), "identity", "identity"); columns[1] = new PropertyColumn(new StringResourceModel(getPrefix() + ".barred", this, null), "barred", "barred"); columns[2] = new PropertyColumn(new StringResourceModel(getPrefix() + ".identityType", this, null), "TYPE,regex", "identityTypeAsString"); columns[3] = new PropertyColumn(new StringResourceModel(getPrefix() + ".state", this, null), "stateAsString"); columns[4] = new FilteredAbstractColumn(new Model("Actions")) { public void populateItem(Item cellItem, String componentId, IModel model) { final PublicIdentity id = (PublicIdentity) model.getObject(); cellItem.add(new ActionsPanel(componentId, id)); } // return the go-and-clear filter for the filter toolbar public Component getFilter(String componentId, FilterForm form) { return new GoAndClearFilter(componentId, form); } }; DaoDataProvider daoDataProvider = new DaoDataProvider("identity", serviceProfile, applicationServer, scscf, search); DefaultDataTable table = new DefaultDataTable("browser", columns, daoDataProvider, getItemByPage()); add(table); serviceProfile = daoDataProvider.getServiceProfile(); applicationServer = daoDataProvider.getApplicationServer(); scscf = daoDataProvider.getScscf(); if (!Strings.isEmpty(serviceProfile)) { setContextMenu(new ContextPanel(_serviceProfileDao.findById(serviceProfile))); _title = MapVariableInterpolator.interpolate(getString("serviceProfile.publicIds.browser.title"), new MicroMap("name", serviceProfile)); } else if (!Strings.isEmpty(applicationServer)) { setContextMenu( new org.cipango.ims.hss.web.as.ContextPanel(_applicationServerDao.findById(applicationServer))); _title = MapVariableInterpolator.interpolate(getString("as.psi.browser.title"), new MicroMap("name", applicationServer)); } else if (!Strings.isEmpty(scscf)) { setContextMenu(new org.cipango.ims.hss.web.scscf.ContextPanel(_scscfDao.findById(scscf))); _title = MapVariableInterpolator.interpolate(getString("scscf.psi.browser.title"), new MicroMap("name", scscf)); } else _title = getString(getPrefix() + ".browser.title"); add(new Label("title", _title)); setContextMenu(new IdentitiesContextPanel()); }
From source file:org.cipango.ims.hss.web.publicid.PublicIdBrowserPage.java
License:Apache License
@SuppressWarnings("unchecked") private void addSearchField(String search) { Form form = new Form("form"); add(form);/*from w w w. j av a 2s.co m*/ AutoCompleteTextField<String> field = new AutoCompleteTextField<String>("searchInput", new Model<String>(search)) { @Override protected Iterator<String> getChoices(String input) { if (input == null || input.length() < 2 && input.trim().length() < 2) { List<String> emptyList = Collections.emptyList(); return emptyList.iterator(); } List<String> choices = _dao.findLike("%" + input + "%", 10); return choices.iterator(); } }; form.add(field); form.add(new Button("search") { @Override public void onSubmit() { String id = (String) getForm().get("searchInput").getDefaultModelObject(); if (!Strings.isEmpty(id)) { PublicIdentity publicIdentity = _dao.findById(id); if (publicIdentity == null) setResponsePage(PublicIdBrowserPage.class, new PageParameters("search=" + id)); else if (publicIdentity instanceof PSI) setResponsePage(EditPsiPage.class, new PageParameters("id=" + id)); else setResponsePage(EditPublicUserIdPage.class, new PageParameters("id=" + id)); } } }); }
From source file:org.cipango.ims.hss.web.serviceprofile.ServiceProfileBrowserPage.java
License:Apache License
@SuppressWarnings("unchecked") public ServiceProfileBrowserPage(PageParameters pageParameters) { super(pageParameters); String ifcName = pageParameters.getString("ifc"); add(new BookmarkablePageLink("createLink", EditServiceProfilePage.class)); IColumn[] columns = new IColumn[4]; columns[0] = new PropertyColumn(new StringResourceModel(getPrefix() + ".name", this, null), "name", "name"); columns[1] = new AbstractColumn(new StringResourceModel(getPrefix() + ".nbPublicIds", this, null)) { public void populateItem(Item cellItem, String componentId, IModel model) { cellItem.add(new NbPublicIdsPanel(componentId, (ServiceProfile) model.getObject())); }/*from w w w.j av a 2 s .c om*/ }; columns[2] = new AbstractColumn(new StringResourceModel(getPrefix() + ".ifcs", this, null)) { public void populateItem(Item cellItem, String componentId, IModel model) { ServiceProfile sp = (ServiceProfile) model.getObject(); cellItem.add(new Label(componentId, String.valueOf(sp.getAllIfcs().size()))); } }; columns[3] = new FilteredAbstractColumn(new Model("Actions")) { public void populateItem(Item cellItem, String componentId, IModel model) { ServiceProfile id = (ServiceProfile) model.getObject(); cellItem.add(new ActionsPanel(componentId, id)); } public Component getFilter(String componentId, FilterForm form) { return new GoAndClearFilter(componentId, form); } }; DaoDataProvider daoDataProvider = new DaoDataProvider("name", ifcName); DefaultDataTable table = new DefaultDataTable("browser", columns, daoDataProvider, getItemByPage()); add(table); ifcName = daoDataProvider.getIfc(); if (!Strings.isEmpty(ifcName)) { setContextMenu(new ContextPanel(_ifcDao.findById(ifcName))); _title = MapVariableInterpolator.interpolate(getString("ifc.serviceProfile.browser.title"), new MicroMap("name", ifcName)); } else _title = getString(getPrefix() + ".browser.title"); add(new Label("title", _title)); setContextMenu(new ServicesContextPanel()); }
From source file:org.cipango.ims.hss.web.spt.HeaderSptPanel.java
License:Apache License
public HeaderSptPanel(String id, IModel<SPT> sptModel) { super(id, sptModel); add(new AutoCompleteTextField<String>("header", String.class) { @Override/*www .j a va 2s . co m*/ protected Iterator<String> getChoices(String input) { if (Strings.isEmpty(input)) { return Headers.ALL_HEADERS.iterator(); } input = input.trim().toLowerCase(); List<String> headers = new ArrayList<String>(); Iterator<String> it = Headers.ALL_HEADERS.iterator(); while (it.hasNext()) { String name = (String) it.next(); if (name.toLowerCase().startsWith(input)) headers.add(name); } return headers.iterator(); } @SuppressWarnings("unchecked") public boolean isRequired() { return EditSptsPage.isRequired((Form) findParent(Form.class)); } }.add(new EditSptsPage.SptUpdatingBehaviour())); add(new ConditionalTextField("content")); }
From source file:org.cipango.ims.hss.web.subscription.SubscriptionBrowserPage.java
License:Apache License
@SuppressWarnings("unchecked") public SubscriptionBrowserPage(PageParameters pageParameters) { super(pageParameters); String scscf = pageParameters.getString("scscf"); add(new BookmarkablePageLink("createLink", AddSubscriptionPage.class)); IColumn[] columns = new IColumn[5]; columns[0] = new PropertyColumn(new StringResourceModel(getPrefix() + ".name", this, null), "name", "name"); columns[1] = new PropertyColumn(new StringResourceModel(getPrefix() + ".scscf", this, null), "scscf", "scscf"); columns[2] = new PropertyColumn(new Model(getString("contextPanel.privateIdentities")), null) { public void populateItem(Item cellItem, String componentId, IModel model) { final Subscription id = (Subscription) model.getObject(); cellItem.add(new IdentityPanel(componentId, id.getPrivateIds(), false)); }/* www. j av a 2 s . co m*/ }; columns[3] = new PropertyColumn(new Model(getString("contextPanel.publicIdentities")), null) { public void populateItem(Item cellItem, String componentId, IModel model) { final Subscription id = (Subscription) model.getObject(); cellItem.add(new IdentityPanel(componentId, id.getPublicIds(), true)); } }; columns[4] = new FilteredAbstractColumn(new Model(getString("actions"))) { public void populateItem(Item cellItem, String componentId, IModel model) { final Subscription id = (Subscription) model.getObject(); cellItem.add(new ActionsPanel(componentId, id)); } public Component getFilter(String componentId, FilterForm form) { return new GoAndClearFilter(componentId, form); } }; DaoDataProvider daoDataProvider = new DaoDataProvider("name", scscf); DefaultDataTable table = new DefaultDataTable("browser", columns, daoDataProvider, getItemByPage()); table.setOutputMarkupId(true); add(table); scscf = daoDataProvider.getScscf(); if (!Strings.isEmpty(scscf)) { setContextMenu(new ContextPanel(_scscfDao.findById(scscf))); _title = MapVariableInterpolator.interpolate(getString("scscf.subscriptions.browser.title"), new MicroMap("name", scscf)); } else _title = getString(getPrefix() + ".browser.title"); add(new Label("title", _title)); setContextMenu(new IdentitiesContextPanel()); }
From source file:org.complitex.common.web.component.wiquery.autocomplete.AbstractAutocompleteComponent.java
License:Open Source License
@Override public final void convertInput() { String valueId = autocompleteHidden.getConvertedInput(); String input = autocompleteField.getConvertedInput(); final T object = this.getModelObject(); final IChoiceRenderer<? super T> renderer = getChoiceRenderer(); if (NOT_ENTERED.equals(valueId)) valueId = null;// w ww . j av a2 s . c o m if (valueId == null || Strings.isEmpty(input)) { setConvertedInput(null); } else if (valueId == null) { setConvertedInput(getValueOnSearchFail(input)); } else if (object == null || input.compareTo((String) renderer.getDisplayValue(object)) != 0) { final List<? extends T> choices = getChoices(); boolean found = false; for (int index = 0; index < choices.size(); index++) { // Get next choice final T choice = choices.get(index); final String idValue = renderer.getIdValue(choice, index + 1); if (idValue.equals(valueId)) { setConvertedInput(choice); found = true; break; } } if (!found) { // if it is still not entered, then it means this field was not touched // so keep the original value if (valueId.equals(NOT_ENTERED)) { setConvertedInput(getModelObject()); } else { setConvertedInput(getValueOnSearchFail(input)); } } } else { setConvertedInput(object); } }
From source file:org.devgateway.eudevfin.dim.pages.transaction.custom.ViewCustomTransactionPage.java
License:Open Source License
/** * /*w w w . ja va 2s .c om*/ */ public ViewCustomTransactionPage(final PageParameters parameters) { super(parameters); pageTitle.setDefaultModel(new StringResourceModel( parameters.get(Constants.PARAM_TRANSACTION_TYPE).toString(""), this, null, null)); List<ITabWithKey> tabList = populateTabList(parameters); long transactionId = parameters.get(PARAM_TRANSACTION_ID).toLong(); CustomFinancialTransaction financialTransaction = (CustomFinancialTransaction) financialTransactionService .findOne(transactionId).getEntity(); // redirect to self if the transactionType parameter is empty, throw an // exception to prevent any infinite cycle if (parameters.get(Constants.PARAM_TRANSACTION_TYPE).isEmpty()) { if (Strings.isEmpty(financialTransaction.getFormType())) throw new RuntimeException("Cannot guess the form type because the persisted property is empty"); PageParameters newPageParameters = new PageParameters(); newPageParameters.add(Constants.PARAM_TRANSACTION_TYPE, financialTransaction.getFormType()); newPageParameters.add(TransactionPage.PARAM_TRANSACTION_ID, financialTransaction.getId()); getRequestCycle().setResponsePage(ViewCustomTransactionPage.class, newPageParameters); return; } CompoundPropertyModel<FinancialTransaction> model = new CompoundPropertyModel<FinancialTransaction>( financialTransaction); setModel(model); form = new Form("form"); add(form); PreviewTabbedPannel<ITabWithKey> bc = new PreviewTabbedPannel<>("bc", tabList); form.add(bc); }
From source file:org.devgateway.eudevfin.ui.common.components.DetailedHelpControlGroup.java
License:Open Source License
@Override protected void onConfigure() { super.onConfigure(); Components.hideIfModelIsEmpty(detailedHelp); if (isFormInPreview()) { detailedHelp.setVisible(false);// w w w . j a va2 s. co m get("help").setVisible(false); //why make field private, why why :( } detailedHelpIcon.setVisible( (isFormInPreview() || Strings.isEmpty((String) detailedHelp.getDefaultModelObject())) ? false : true); }