public static void show(Component... components) { if (components != null) { for (Component component : components) { component.setVisible(true); } } }
public static void hideIfModelIsEmpty(Component component) { if (component != null && (component.getDefaultModel() == null || component.getDefaultModelObject() == null || Strings.isNullOrEmpty(component.getDefaultModelObjectAsString()))) { component.setVisible(false); } }
protected void constructPanel() { final String chooseDtTxt = this.getLocalizer().getString("datepicker.chooseDate", mobBasePage); add( new HeaderContributor( new IHeaderContributor() { private static final long serialVersionUID = 1L; @Override public void renderHead(IHeaderResponse response) { // localize the jquery datepicker based on users locale setting // locale specific js includes for datepicker are available at // http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/ String localeLang = getLocale().getLanguage().toLowerCase(); LOG.debug("Using DatePicker for locale language: {}", localeLang); if (PortalUtils.exists(localeLang)) { response.renderJavascriptReference( "scripts/jquery/i18n/jquery.ui.datepicker-" + localeLang + ".js"); } response.renderJavascript( "\n" + "jQuery(document).ready(function($) { \n" + " $('#birthDate').datepicker( { \n" + " 'buttonText' : '" + chooseDtTxt + "', \n" + " 'changeMonth' : true, \n" + " 'changeYear' : true, \n" + " 'yearRange' : '-100:+0', \n" + " 'showOn': 'both', \n" + " 'dateFormat' : '" + Constants.DATE_FORMAT_PATTERN_PICKER + "', \n" + " 'buttonImage': 'images/calendar.gif', \n" + " 'buttonOnlyImage': true} ); \n" + "});\n", "datePicker"); } })); final Form<?> form = new Form("standingDataForm", new CompoundPropertyModel<StandingDataPanel>(this)); if (!PortalUtils.exists(getCustomer().getTaskId())) mobBasePage.getMobiliserWebSession().setShowContact(true); form.add(new FeedbackPanel("errorMessages")); form.add( new RequiredTextField<String>("customer.address.firstName") .setRequired(true) .add(new PatternValidator(Constants.REGEX_FIRSTNAME)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier)) .add(new ErrorIndicator()); form.add( new DateTextField( "birthDateField", new PropertyModel<Date>(this, "customer.birthDateString"), new PatternDateConverter(Constants.DATE_FORMAT_PATTERN_PARSE, false)) .setRequired(true) .add(new ErrorIndicator())); form.add( new LocalizableLookupDropDownChoice<Integer>( "customer.customerTypeId", Integer.class, Constants.RESOURCE_BUNDLE_CUSTOMER_TYPE, this, Boolean.FALSE, true) .setNullValid(false) .setRequired(true)); form.add( new RequiredTextField<String>("customer.address.lastName") .setRequired(true) .add(new PatternValidator(Constants.REGEX_FIRSTNAME)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier)) .add(new ErrorIndicator()); form.add( new LocalizableLookupDropDownChoice<String>( "customer.language", String.class, Constants.RESOURCE_BUNDLE_LANGUAGES, this, false, true) .add(new ErrorIndicator())); form.add( new LocalizableLookupDropDownChoice<String>( "customer.timeZone", String.class, Constants.RESOURCE_BUNDLE_TIMEZONES, this, false, true) .add(new ErrorIndicator())); form.add( new TextField<String>("customer.address.street1") .add(new PatternValidator(Constants.REGEX_STREET1)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier) .add(new ErrorIndicator())); form.add( new TextField<String>("customer.address.houseNo") .add(StringValidator.lengthBetween(1, 20)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier) .add(new ErrorIndicator())); form.add( new TextField<String>("customer.address.state") .add(new PatternValidator(Constants.REGEX_STATE)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier) .add(new ErrorIndicator())); form.add( new LocalizableLookupDropDownChoice<String>( "customer.address.kvCountry", String.class, "countries", this, false, true) .setNullValid(false) .setRequired(true) .add(new ErrorIndicator())); form.add( new TextField<String>("customer.address.street2") .add(new PatternValidator(Constants.REGEX_STREET1)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier) .add(new ErrorIndicator())); form.add( new TextField<String>("customer.address.city") .setRequired(false) .add(new PatternValidator(Constants.REGEX_CITY)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier) .add(new ErrorIndicator())); form.add( new TextField<String>("customer.address.zip") .add(new PatternValidator(Constants.REGEX_ZIP)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier) .add(new ErrorIndicator())); TextField<String> msisdn = new TextField<String>("customer.msisdn"); if (!mobBasePage.getConfiguration().isMsisdnOtpConfirmed()) { msisdn.add(new SimpleAttributeModifier("readonly", "readonly")); msisdn.add(new SimpleAttributeModifier("style", "background-color: #E6E6E6;")); } form.add( msisdn .add(new PatternValidator(Constants.REGEX_PHONE_NUMBER)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier) .add(new ErrorIndicator())); form.add( new TextField<String>("customer.address.email") .setRequired(true) .add(EmailAddressValidator.getInstance()) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier) .add(new ErrorIndicator())); form.add( new LocalizableLookupDropDownChoice<Integer>( "customer.kvInfoMode", Integer.class, "sendModes", this, Boolean.FALSE, true) .setNullValid(false) .setRequired(true)); WebMarkupContainer networkProviderDiv = new WebMarkupContainer("networkProviderDiv"); networkProviderDiv.add( new LocalizableLookupDropDownChoice<String>( "customer.networkProvider", String.class, "networkproviders", this, false, true) .setNullValid(false) .setRequired(true) .add(new ErrorIndicator())); // network provider selection to be made only for mbanking customer // types if (customer.getCustomerTypeId() != null && customer.getCustomerTypeId().intValue() == Constants.MBANKING_CUSTOMER_TYPE) { networkProviderDiv.setVisible(true); } else { networkProviderDiv.setVisible(false); } form.add(networkProviderDiv); form.add( new KeyValueDropDownChoice<Long, String>( "customer.feeSetId", mobBasePage.getFeeSets(getCustomer().getFeeSetId())) { private static final long serialVersionUID = 1L; @Override protected CharSequence getDefaultChoice(Object selected) { return null; }; }.setNullValid(false)); form.add( new KeyValueDropDownChoice<Long, String>( "customer.limitId", getLimitSets(getCustomer().getLimitId())) { private static final long serialVersionUID = 1L; }.setNullValid(true)); Button feeSetConfButton = new Button("feeSetConf") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { setResponsePage(new IndividualFeeSetConfig(getCustomer())); }; }.setDefaultFormProcessing(false); feeSetConfButton.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE)); form.add(feeSetConfButton); Button limitSetConfButton = new Button("limitSetConf") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { setResponsePage(new IndividualLimitSetConfig(getCustomer())); }; }.setDefaultFormProcessing(false); limitSetConfButton.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE)); form.add(limitSetConfButton); form.add( new LocalizableLookupDropDownChoice<String>( "customer.securityQuestion", String.class, Constants.RESOURCE_BUNDLE_SEC_QUESTIONS, this, false, true) .setNullValid(false) .setRequired(true) .add(new ErrorIndicator())); form.add( new TextField<String>("customer.userName") .add(new PatternValidator(Constants.REGEX_USERNAME)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier) .add(new ErrorIndicator())); form.add( new RequiredTextField<String>("customer.SecQuesAns") .add(new PatternValidator(Constants.REGEX_SECURITY_ANSWER)) .add(Constants.mediumStringValidator) .add(Constants.mediumSimpleAttributeModifier) .add(new ErrorIndicator())); PrivilegedBehavior cancelReasonBehavior = new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_CANCEL); cancelReasonBehavior.setMissingPrivilegeHidesComponent(false); KeyValueDropDownChoice<Integer, String> custStatus = new KeyValueDropDownChoice<Integer, String>( "customer.active", mobBasePage.getCustomerStatus()); custStatus.add( new SimpleAttributeModifier( "onchange", "confirmDeactivation('" + getLocalizer().getString("customer.deactivate.warning", mobBasePage) + "')")); form.add(custStatus.setNullValid(false).setRequired(true).add(cancelReasonBehavior)); WebMarkupContainer blackListReasonDiv = new WebMarkupContainer("blackListReasonDiv"); PrivilegedBehavior blackListBehavior = new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_BLACKLIST); blackListBehavior.setMissingPrivilegeHidesComponent(false); blackListReasonDiv.add( new LocalizableLookupDropDownChoice<Integer>( "customer.blackListReason", Integer.class, "blackListReasons", this, Boolean.FALSE, true) .setNullValid(false) .setRequired(true) .add(blackListBehavior)); form.add(blackListReasonDiv); WebMarkupContainer cancelDivContainer = new WebMarkupContainer("cancelDivContainer"); LocalizableLookupDropDownChoice<Integer> cancelationreason = new LocalizableLookupDropDownChoice<Integer>( "customer.cancelationReason", Integer.class, "cancellationReasons", this, false, true); cancelationreason.add( new SimpleAttributeModifier( "onchange", "confirmCancellation('" + getLocalizer().getString("customer.cancel.warning", mobBasePage) + "')")); cancelDivContainer.add( cancelationreason.setNullValid(false).setRequired(true).add(cancelReasonBehavior)); // cancelDivContainer // .setVisible(getCustomer().getCustomerTypeId() == // Constants.CONSUMER_IDTYPE // || getCustomer().getCustomerTypeId() == // Constants.CUSTOMER_ROLE_MONEY_MERCHANT); form.add(cancelDivContainer); Button changenMsisdnButton = new Button("changeMsisdn") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { Customer customer = mobBasePage.getCustomerByIdentification( Constants.IDENT_TYPE_CUST_ID, String.valueOf(getCustomer().getId())); if (customer.getCancellationReasonId() != 0 || !customer.isActive()) { error( getLocalizer() .getString("customer.msisdn.change.error.customerinactive", mobBasePage)); return; } mobBasePage.getMobiliserWebSession().setCustomerOtp(null); mobBasePage.getMobiliserWebSession().setCustomerOtpCount(0); mobBasePage.getMobiliserWebSession().setCustomerOtpLimitHit(false); setResponsePage(new ChangeMsisdnPage(getCustomer())); }; }.setDefaultFormProcessing(false); changenMsisdnButton.setVisible(!mobBasePage.getConfiguration().isMsisdnOtpConfirmed()); changenMsisdnButton.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE)); form.add(changenMsisdnButton); changenMsisdnButton.setVisible(!mobBasePage.getConfiguration().isMsisdnOtpConfirmed()); form.add( new Button("resetPin") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { Customer customer = mobBasePage.getCustomerByIdentification( Constants.IDENT_TYPE_MSISDN, getCustomer().getMsisdn()); if (!PortalUtils.exists(customer)) { error(getLocalizer().getString("customer.reset.password.noMsisdn", mobBasePage)); return; } setResponsePage(new ResetCredentialPage(getCustomer(), this.getWebPage(), "pin")); }; }.setDefaultFormProcessing(false) .add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_PINCALL))); form.add( new Button("resetPassword") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { Address address = mobBasePage.getAddressByCustomer(getCustomer().getId()); if (address == null || !PortalUtils.exists(address.getEmail())) { error(getLocalizer().getString("customer.reset.password.noEmail", mobBasePage)); return; } setResponsePage(new ResetCredentialPage(getCustomer(), this.getWebPage(), "password")); }; }.setDefaultFormProcessing(false) .add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_PASSWORD))); form.add( new Button("update") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { if (updateCustomer()) { LOG.info( "Data updated successfully for customer[" + mobBasePage.getMobiliserWebSession().getCustomer().getId() + "]"); getSession().info(getLocalizer().getString("data.update.successful", mobBasePage)); setResponsePage(new StandingDataPage(getCustomer())); } }; }.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE)) .setVisible(!PortalUtils.exists(getCustomer().getTaskId()))); form.add( new Button("approve") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { approveCustomer(true); }; }.setDefaultFormProcessing(false) .setVisible(PortalUtils.exists(getCustomer().getTaskId()))); form.add( new Button("reject") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { approveCustomer(false); }; }.setDefaultFormProcessing(false) .setVisible(PortalUtils.exists(getCustomer().getTaskId()))); if (PortalUtils.exists(getCustomer().getTaskId())) { Iterator iter = form.iterator(); Component component; for (int i = 0; iter.hasNext(); i++) { component = (Component) iter.next(); if (component.getId().equals("approve") || component.getId().equals("reject") || component instanceof FeedbackPanel) { continue; } else if (component instanceof Button) { component.setVisible(false); } else { if (component.getId().equals("blackListReasonDiv") || component.getId().equals("cancelDivContainer")) { Iterator iter1 = ((WebMarkupContainer) component).iterator(); Component comp; for (int j = 0; iter1.hasNext(); j++) { comp = (Component) iter1.next(); comp.setEnabled(false); comp.add(new SimpleAttributeModifier("readonly", "readonly")); comp.add(new SimpleAttributeModifier("style", "background-color: #E6E6E6;")); } } else { component.setEnabled(false); component.add(new SimpleAttributeModifier("readonly", "readonly")); component.add(new SimpleAttributeModifier("style", "background-color: #E6E6E6;")); } } } } add(form); LOG.debug( "PatternDateConverter format: " + Constants.DATE_FORMAT_PATTERN_PARSE + " DatePicker format: " + Constants.DATE_FORMAT_PATTERN_PICKER); }
@SuppressWarnings("serial") void init(final WebMarkupContainer item) { final DropDownChoice<InstantMessagingType> socialMediaChoice = new DropDownChoice<InstantMessagingType>( "socialMediaChoice", new PropertyModel<InstantMessagingType>(newSocialMediaValue, "label"), socialMediaChoiceRenderer.getValues(), socialMediaChoiceRenderer); item.add(socialMediaChoice); socialMediaChoice.add( new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(final AjaxRequestTarget target) { // // newSocialMediaValue.setLabel(socialMediaChoice.getModelObject().get(socialMediaChoice.getModelObject().getKey())); // // model.getObject().setSocialMediaValues(contactDao.getSocialMediaValuesAsXml(socialMediaValues)); // target.add(mainContainer); } }); item.add( new AjaxMaxLengthEditableLabel( "editableLabel", new PropertyModel<String>(newSocialMediaValue, "value")) { @Override protected void onSubmit(final AjaxRequestTarget target) { super.onSubmit(target); if (StringUtils.isNotBlank(newSocialMediaValue.getValue()) == true && newSocialMediaValue.getValue().equals(DEFAULT_IM_VALUE) == false) { model .getObject() .setSocialMedia(newSocialMediaValue.getLabel(), newSocialMediaValue.getValue()); } newSocialMediaValue.setValue(DEFAULT_IM_VALUE); rebuildSocialMedias(); target.add(mainContainer); } }); final WebMarkupContainer deleteDiv = new WebMarkupContainer("deleteDiv"); deleteDiv.setOutputMarkupId(true); deleteDiv.add( delete = new AjaxIconLinkPanel( "delete", IconType.REMOVE, new PropertyModel<String>(newSocialMediaValue, "value")) { /** * @see * org.projectforge.web.wicket.flowlayout.AjaxIconLinkPanel#onClick(org.apache.wicket.ajax.AjaxRequestTarget) */ @Override protected void onClick(final AjaxRequestTarget target) { // super.onClick(target); // final Iterator<SocialMediaValue> it = socialMediaValues.iterator(); // while (it.hasNext() == true) { // if (it.next() == newSocialMediaValue) { // it.remove(); // } // } // rebuildSocialMedias(); // // model.getObject().setSocialMediaValues(contactDao.getSocialMediaValuesAsXml(socialMediaValues)); // target.add(mainContainer); } }); item.add(deleteDiv); delete.setVisible(false); }
public SummaryPage(PageParameters params) { super(params); int numberCommits = GitBlit.getInteger(Keys.web.summaryCommitCount, 20); if (numberCommits <= 0) { numberCommits = 20; } int numberRefs = GitBlit.getInteger(Keys.web.summaryRefsCount, 5); Repository r = getRepository(); RepositoryModel model = getRepositoryModel(); List<Metric> metrics = null; Metric metricsTotal = null; if (!model.skipSummaryMetrics && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) { metrics = GitBlit.self().getRepositoryDefaultMetrics(model, r); metricsTotal = metrics.remove(0); } addSyndicationDiscoveryLink(); // repository description add(new Label("repositoryDescription", getRepositoryModel().description)); add(new Label("repositoryOwner", getRepositoryModel().owner)); add( WicketUtils.createTimestampLabel( "repositoryLastChange", JGitUtils.getLastChange(r), getTimeZone())); if (metricsTotal == null) { add(new Label("branchStats", "")); } else { add( new Label( "branchStats", MessageFormat.format( "{0} commits and {1} tags in {2}", metricsTotal.count, metricsTotal.tag, TimeUtils.duration(metricsTotal.duration)))); } add( new BookmarkablePageLink<Void>( "metrics", MetricsPage.class, WicketUtils.newRepositoryParameter(repositoryName))); List<String> repositoryUrls = new ArrayList<String>(); if (GitBlit.getBoolean(Keys.git.enableGitServlet, true)) { AccessRestrictionType accessRestriction = getRepositoryModel().accessRestriction; switch (accessRestriction) { case NONE: add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false)); break; case PUSH: add( WicketUtils.newImage( "accessRestrictionIcon", "lock_go_16x16.png", getAccessRestrictions().get(accessRestriction))); break; case CLONE: add( WicketUtils.newImage( "accessRestrictionIcon", "lock_pull_16x16.png", getAccessRestrictions().get(accessRestriction))); break; case VIEW: add( WicketUtils.newImage( "accessRestrictionIcon", "shield_16x16.png", getAccessRestrictions().get(accessRestriction))); break; default: add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false)); } // add the Gitblit repository url repositoryUrls.add(getRepositoryUrl(getRepositoryModel())); } else { add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false)); } repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName)); String primaryUrl = ArrayUtils.isEmpty(repositoryUrls) ? "" : repositoryUrls.remove(0); add(new RepositoryUrlPanel("repositoryCloneUrl", primaryUrl)); add( new Label("otherUrls", StringUtils.flattenStrings(repositoryUrls, "<br/>")) .setEscapeModelStrings(false)); add( new LogPanel( "commitsPanel", repositoryName, getRepositoryModel().HEAD, r, numberCommits, 0)); add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty()); add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs).hideIfEmpty()); if (getRepositoryModel().showReadme) { String htmlText = null; String readme = null; try { RevCommit head = JGitUtils.getCommit(r, null); List<String> markdownExtensions = GitBlit.getStrings(Keys.web.markdownExtensions); List<PathModel> paths = JGitUtils.getFilesInPath(r, null, head); for (PathModel path : paths) { if (!path.isTree()) { String name = path.name.toLowerCase(); if (name.startsWith("readme")) { if (name.indexOf('.') > -1) { String ext = name.substring(name.lastIndexOf('.') + 1); if (markdownExtensions.contains(ext)) { readme = path.name; break; } } } } } if (!StringUtils.isEmpty(readme)) { String markdownText = JGitUtils.getStringContent(r, head.getTree(), readme); htmlText = MarkdownUtils.transformMarkdown(markdownText); } } catch (ParseException p) { error(p.getMessage()); } Fragment fragment = new Fragment("readme", "markdownPanel"); fragment.add(new Label("readmeFile", readme)); // Add the html to the page Component content = new Label("readmeContent", htmlText).setEscapeModelStrings(false); fragment.add(content.setVisible(!StringUtils.isEmpty(htmlText))); add(fragment); } else { add(new Label("readme").setVisible(false)); } // Display an activity line graph insertActivityGraph(metrics); }
protected Component createLink(String id, String key, int idx) { Component link = new ModalLink(id, key, idx); link.setVisible(key != null); return link; }