Example usage for org.apache.wicket.bean.validation PropertyValidator PropertyValidator

List of usage examples for org.apache.wicket.bean.validation PropertyValidator PropertyValidator

Introduction

In this page you can find the example usage for org.apache.wicket.bean.validation PropertyValidator PropertyValidator.

Prototype

PropertyValidator

Source Link

Usage

From source file:com.francetelecom.clara.cloud.presentation.applications.ApplicationCreatePanel.java

License:Apache License

private void createAppForm() {

    appForm = new Form<>("appForm", new CompoundPropertyModel<>(new FirstApplicationReleaseInfos()));

    TextField<String> appLabel = new TextField<>("appLabel");
    appLabel.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.label.label"));

    appLabel.add(new AbstractValidator<String>() {
        @Override/*from   w  w w  .  j  a  v a  2 s . com*/
        protected void onValidate(IValidatable<String> iValidatable) {
            if (!parentPage.isApplicationLabelUnique(iValidatable.getValue())) {
                error(iValidatable);
            }
        }

        @Override
        protected String resourceKey() {
            return "portal.application.label.non.unique";
        }

        @Override
        protected Map<String, Object> variablesMap(IValidatable<String> stringIValidatable) {
            Map<String, Object> map = super.variablesMap(stringIValidatable);
            map.put("label", stringIValidatable.getValue());
            return map;
        }
    });
    appLabel.add(new PropertyValidator<>());
    appForm.add(appLabel);

    TextField<String> appCode = new TextField<>("appCode");
    appCode.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.code.label"));
    appCode.add(new PropertyValidator<>());
    appForm.add(appCode);

    TextArea<String> appDescription = new TextArea<>("appDescription");
    appDescription.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.description.label"));
    appDescription.add(new PropertyValidator<>());
    appForm.add(appDescription);

    RadioGroup<Boolean> appVisibility = new RadioGroup<>("appPublic");
    appVisibility.add(new Radio<Boolean>("appVisibilityRadioGroup-public", new Model<>(Boolean.TRUE)));
    appVisibility.add(new Radio<Boolean>("appVisibilityRadioGroup-private", new Model<>(Boolean.FALSE)));
    appVisibility.add(new PropertyValidator<>());
    appForm.add(appVisibility);
    appForm.add(
            new CacheActivatedImage("imageHelp.visibilityField", new ResourceModel("image.help").getObject()));

    TextField<String> members = new TextField<>("members");
    members.add(new PropertyValidator<>());
    appForm.add(members);
    appForm.add(new CacheActivatedImage("imageHelp.membersField", new ResourceModel("image.help").getObject()));

    releaseFiedsetPanel = new ReleaseFieldsetPanel("releaseFieldsetPanel", parentPage,
            manageApplicationRelease);
    appForm.add(releaseFiedsetPanel);

    createFormButtons(appForm);

    // set default visibility to private
    appForm.getModelObject().setAppPublic(Boolean.FALSE);

    add(appForm);
}

From source file:com.francetelecom.clara.cloud.presentation.applications.ApplicationInformationPanel.java

License:Apache License

private void createEditShowInformationComponent(Application app) {

    appForm = new Form<>("appForm");
    appForm.setDefaultModel(new CompoundPropertyModel<Application>(app));

    label = new TextField<>("label");
    label.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.label.label"));
    label.add(new PropertyValidator<>());
    appForm.add(label);/*  w  ww  .  j  a  v  a 2  s.  c om*/

    code = new TextField<>("code");
    code.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.code.label"));
    code.add(new PropertyValidator<>());
    appForm.add(code);

    appVisibility = new RadioGroup<>("isPublic");
    appVisibility.add(new Radio<Boolean>("appVisibilityRadioGroup-public", new Model<>(Boolean.TRUE)));
    appVisibility.add(new Radio<Boolean>("appVisibilityRadioGroup-private", new Model<>(Boolean.FALSE)));
    appVisibility.add(new PropertyValidator<>());

    appVisibility.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.visibility.label"));

    users = new TextField<>("members", new PropertyModel<String>(this, "members"));
    users.add(new PropertyValidator<>());
    appForm.add(users);
    appForm.add(new CacheActivatedImage("membersHelp", new ResourceModel("image.help").getObject()));

    appForm.add(appVisibility);

    description = new TextArea<>("description");
    description.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.description.label"));
    description.add(new PropertyValidator<>());
    appForm.add(description);

    add(appForm);
    createButtons();
    manageButtonsVisibility();
    updateEditableInput();
}

From source file:com.francetelecom.clara.cloud.presentation.common.ReleaseFieldsetPanel.java

License:Apache License

private void initComponents() {
    WebMarkupContainer selectApplicationContainer = new WebMarkupContainer("selectApplication");

    initComponentsApplicationSelect(selectApplicationContainer);
    selectApplicationContainer.setVisible(showApplicationSelection);
    add(selectApplicationContainer);/*from   ww  w.  j  av a  2 s  . c  o  m*/

    releaseVersion = new TextField<>("releaseVersion");
    releaseVersion.setLabel(WicketUtils.getStringResourceModel(this, "portal.release.version.label"));
    releaseVersion.add(new PropertyValidator<>());
    if (showApplicationSelection) {
        initReleaseVersionUniqueValidation();
    }
    add(releaseVersion);

    TextArea<String> releaseDescription = new TextArea<>("description");
    releaseDescription.setLabel(WicketUtils.getStringResourceModel(this, "portal.release.description.label"));
    releaseDescription.add(new PropertyValidator<>());
    add(releaseDescription);

    // clone panel
    forkSelectPanel = new ReleaseForkSelectPanel("forkPanel", parentPage);
    forkSelectPanel.setOutputMarkupId(true);
    forkSelectPanel.setOutputMarkupPlaceholderTag(true);
    forkSelectPanel.setVisible(false);
    add(forkSelectPanel);

    // clone checkbox
    AjaxCheckBox forkCheckbox = new AjaxCheckBox("forkCheckbox", new Model<Boolean>()) {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            shouldFork = getModelObject();
            forkSelectPanel.setVisible(shouldFork);
            target.add(forkSelectPanel);
        }
    };
    forkCheckbox.setLabel(WicketUtils.getStringResourceModel(this, "portal.release.creation.fork"));
    add(forkCheckbox);

    // override profile panel
    overrideProfilePanel = new ReleaseOverrideProfilePanel("overrideProfilePanel");
    overrideProfilePanel.setOutputMarkupId(true);
    overrideProfilePanel.setOutputMarkupPlaceholderTag(true);
    overrideProfilePanel.setVisible(false);
    add(overrideProfilePanel);

    // override middleware profile version
    overrideProfileCheckbox = new AjaxCheckBox("overrideProfileCheckbox", new Model<Boolean>(Boolean.FALSE)) {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            boolean showOverrideProfile = getModelObject().booleanValue();
            logger.debug("showOverrideProfile:{}", showOverrideProfile);
            overrideProfilePanel.setVisible(showOverrideProfile);
            target.add(overrideProfilePanel);
        }
    };
    //overrideProfileCheckbox.setLabel(WicketUtils.getStringResourceModel(this, "portal.release.creation.overrideProfile"));
    add(overrideProfileCheckbox);
    add(new CacheActivatedImage("overrideProfileHelp", new ResourceModel("image.help").getObject()));
}

From source file:com.francetelecom.clara.cloud.presentation.common.ReleaseFieldsetPanel.java

License:Apache License

private void initComponentsApplicationSelect(WebMarkupContainer selectApplicationContainer) {
    List<Application> appList = new ArrayList<>();
    if (showApplicationSelection) {
        if (app == null) {
            appList = (List<Application>) manageApplication.findMyApplications();
        } else {//from  w  ww  .ja  v a  2  s.c om
            appList = Arrays.asList(app);
        }
    }
    ChoiceRenderer<Application> choiceRenderer = new ChoiceRenderer<Application>("label", "uid");
    applicationDropDownChoice = new DropDownChoice<Application>("application", appList, choiceRenderer);

    if (app != null) {
        applicationDropDownChoice.setEnabled(false);
    }

    // app required
    applicationDropDownChoice.setRequired(true);
    applicationDropDownChoice.add(new PropertyValidator<>());

    selectApplicationContainer.add(applicationDropDownChoice);
    selectApplicationContainer
            .add(new CacheActivatedImage("applicationHelp", new ResourceModel("image.help").getObject()));
}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.cfjavaprocessing.LogicalCfJavaProcessingServicePanel.java

License:Apache License

private void initComponents() {

    getServiceForm().add(new CacheActivatedImage("cfjavaprocessing-icon",
            new ResourceModel("cfjavaprocessing.icon").getObject()));
    // Online help link
    String completeHelpUrl = "";
    try {/*from  w  w  w  .j a  va2s. com*/
        completeHelpUrl = new StringResourceModel("portal.designer.logical.service.online_manual.baseUrl", null)
                .getString()
                + new StringResourceModel(
                        "portal.designer.logical.service.online_manual." + getLogicalModelType(), null)
                                .getString();
    } catch (Exception e) {
        //do nothing
    }
    ExternalLink onlineHelpLink = new ExternalLink("onlineHelpLink", completeHelpUrl);
    getServiceForm().add(onlineHelpLink);
    if (completeHelpUrl.isEmpty()) {
        onlineHelpLink.setVisible(false);
    }

    // FUNCTIONNAL PARAMETERS
    RequiredTextField<String> label = new RequiredTextField<String>("label");
    label.setLabel(new StringResourceModel("portal.designer.service.cfjava.label", null));
    label.add(new PropertyValidator<>());
    getServiceForm().add(label);

    RequiredTextField<String> groupId = new RequiredTextField<String>("softwareReference.groupId");
    groupId.setLabel(new StringResourceModel("portal.designer.service.cfjava.softwareReference.groupId", null));
    groupId.add(new PropertyValidator<>());
    getServiceForm().add(groupId);

    RequiredTextField<String> artifactId = new RequiredTextField<String>("softwareReference.artifactId");
    artifactId.setLabel(
            new StringResourceModel("portal.designer.service.cfjava.softwareReference.artifactId", null));
    artifactId.add(new PropertyValidator<>());
    getServiceForm().add(artifactId);

    RequiredTextField<String> version = new RequiredTextField<String>("softwareReference.version");
    version.setLabel(new StringResourceModel("portal.designer.service.cfjava.softwareReference.version", null));
    version.add(new PropertyValidator<>());
    getServiceForm().add(version);

    RequiredTextField<String> extension = new RequiredTextField<String>("softwareReference.extension");
    if (getServiceForm().getModelObject().getSoftwareReference() == null) {
        getServiceForm().getModelObject().setSoftwareReference(new MavenReference("", "", "", "war"));
    }
    extension.setLabel(
            new StringResourceModel("portal.designer.service.cfjava.softwareReference.extension", null));
    extension.add(new PropertyValidator<>());
    getServiceForm().add(extension);
    /*List<String> extensionList = new ArrayList<String>();
    extensionList.add("jar");
    extensionList.add("war");
    extensionList.add("ear");
    DropDownChoice<String> extension = new DropDownChoice<String>("softwareReference.extension", extensionList);
    extension.setLabel(new StringResourceModel("portal.designer.service.cfjava.softwareReference.extension",null));
    extension.add(new PropertyValidator<>());
    getServiceForm().add(extension);*/

    TextField<String> classifier = new TextField<String>("softwareReference.classifier", String.class);
    classifier.setLabel(
            new StringResourceModel("portal.designer.service.cfjava.softwareReference.classifier", null));
    classifier.add(new PropertyValidator<>());
    getServiceForm().add(classifier);

    CheckBox optionalSoftwareReference = new CheckBox("optionalSoftwareReference");
    optionalSoftwareReference.setLabel(
            new StringResourceModel("portal.designer.service.cfjava.optionalSoftwareReference", null));
    getServiceForm().add(optionalSoftwareReference);

    TextField<Integer> minMemoryMbHint = new TextField<Integer>("minMemoryMbHint");
    minMemoryMbHint.setLabel(new StringResourceModel("portal.designer.service.cfjava.minMemoryMbHint", null));
    minMemoryMbHint.add(new AttributeModifier("class", "small"));
    minMemoryMbHint.add(new PropertyValidator<>());
    getServiceForm().add(minMemoryMbHint);

    final TextField<String> iconUrl = new TextField<String>("iconUrl");
    iconUrl.setLabel(new StringResourceModel("portal.designer.service.cfjava.iconUrl", null));
    //iconUrl.add(new AttributeModifier("title", new StringResourceModel("portal.designer.service.cfjava.iconUrl.help",null)));
    //Add Wicket validation for URL
    iconUrl.add(new UrlValidator());
    iconUrl.add(new PropertyValidator<>());
    iconUrl.add(new OnChangeAjaxBehavior() {

        /**
        * 
        */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            // Important, DO NOT DELETE
            // By Calling OnChangeAjaxBehavior, we update iconUrl field model to can push button preview with updated model

        }

        @Override
        protected void onError(AjaxRequestTarget target, RuntimeException e) {
            iconUrl.updateModel(); // The feedback is handle when click on preview button so we need to updateModel when there is an error
        }
    });
    getServiceForm().add(iconUrl);
    getServiceForm().add(new CacheActivatedImage("imageHelp.iconUrl", getString("image.help")));

    WebMarkupContainer imageContainer = new WebMarkupContainer("imageContainer");

    final WebMarkupContainer icon = new WebMarkupContainer("icon");
    icon.setOutputMarkupId(true);
    icon.setOutputMarkupPlaceholderTag(true);
    if (iconUrl.getModelObject() == null || iconUrl.getModelObject().equals("")) {
        setDefaultIconAndUpdateFeedBack(icon, null, "");
    } else {
        setCustomIconAndUpdateFeedBack(icon, iconUrl, null);
    }
    imageContainer.add(icon);

    final Label feedback = new Label("feedbackError", new Model<String>(""));
    feedback.setOutputMarkupId(true);
    imageContainer.add(feedback);

    AjaxLink preview = new AjaxLink("preview", new Model()) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            try {

                //If null or empty when click on preview button, clean feedBack and display default image
                if (iconUrl.getModelObject() == null || iconUrl.getModelObject().equals("")) {
                    setDefaultIconAndCleanFeedBack(icon, feedback);
                } // Else try to display custom image
                else {
                    //Construct URL to test integrity of what user typing
                    URL url = new URL(iconUrl.getModelObject().toString());
                    if (iconUrl.getModelObject() != null) {
                        setCustomIconAndUpdateFeedBack(icon, iconUrl, feedback);
                    }
                }
            } catch (MalformedURLException e) {
                setDefaultIconAndUpdateFeedBack(icon, feedback, e.getMessage());
                e.printStackTrace();
            }
            target.add(icon);
            target.add(feedback);
        }
    };
    imageContainer.add(preview);
    getServiceForm().add(imageContainer);

}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.config.LogicalConfigServicePanel.java

License:Apache License

private void initComponents() {

    getServiceForm().add(new CacheActivatedImage("logicalconfig-icon",
            new ResourceModel("cfconfigservice.icon").getObject()));
    // Online help link
    String completeHelpUrl = "";
    try {//from   ww w  .ja v a  2  s .c  o m
        completeHelpUrl = new StringResourceModel("portal.designer.logical.service.online_manual.baseUrl", null)
                .getString()
                + new StringResourceModel(
                        "portal.designer.logical.service.online_manual." + getLogicalModelType(), null)
                                .getString();
    } catch (Exception e) {
        //do nothing
    }
    ExternalLink onlineHelpLink = new ExternalLink("onlineHelpLink", completeHelpUrl);
    ExternalLink onlineHelpLinkOverride = new ExternalLink("onlineHelpLinkOverride", completeHelpUrl);

    if (completeHelpUrl.isEmpty()) {
        onlineHelpLink.setVisible(false);
        onlineHelpLinkOverride.setVisible(false);
    }

    // Creates 2 blocks only for good displaying : Read more... juste after description (not possible with span wicket:id=descriptionLabel).
    WebMarkupContainer descriptionBlock = new WebMarkupContainer("descriptionBlock");
    descriptionBlock.add(onlineHelpLink);
    getServiceForm().add(descriptionBlock);

    WebMarkupContainer overrideDescriptionBlock = new WebMarkupContainer("overrideDescriptionBlock");
    overrideDescriptionBlock.add(onlineHelpLinkOverride);
    getServiceForm().add(overrideDescriptionBlock);

    if (configOverride) {
        descriptionBlock.setVisible(false);
    } else {
        overrideDescriptionBlock.setVisible(false);
    }

    // FUNCTIONNAL PARAMETERS    
    RequiredTextField<String> label = new RequiredTextField<>("label");
    label.setLabel(new StringResourceModel("portal.designer.service.config.label", null));
    label.add(new PropertyValidator<>());
    getServiceForm().add(label);

    TextField<String> keyPrefix = new TextField<>("keyPrefix", String.class);
    keyPrefix.setConvertEmptyInputStringToNull(false);
    keyPrefix.setLabel(new StringResourceModel("portal.designer.service.config.keyPrefix", null));
    keyPrefix.add(new PropertyValidator<>());
    getServiceForm().add(keyPrefix);

    configSetContent = new CodeMirrorTextArea<>("configSetContent", readOnly && !configOverride);

    configSetContent.setLabel(new StringResourceModel("portal.designer.service.config.configSetContent", null));
    configSetContent.add(new PropertyValidator<>());
    getServiceForm().add(configSetContent);

    configSetContent.add(new ConfigDuplicateKeysValidator());
    configSetContent.add(new ConfigMaxSizeValidator());
    configSetContent.add(new ConfigMaxNumberKeysValidator());
    configSetContent.add(new InvalidCharsetValidator());

}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.internalMom.LogicalInternalMomServicePanel.java

License:Apache License

private void initComponents() {

    getServiceForm().add(new CacheActivatedImage("logicalInternalMomIcon",
            new ResourceModel("internalMom-icon").getObject()));
    // Online help link
    String completeHelpUrl = "";
    try {/*from   ww w.  j  a v a2  s .co  m*/
        completeHelpUrl = new StringResourceModel("portal.designer.logical.service.online_manual.baseUrl", null)
                .getString()
                + new StringResourceModel(
                        "portal.designer.logical.service.online_manual." + getLogicalModelType(), null)
                                .getString();
    } catch (Exception e) {
        //do nothing
    }
    ExternalLink onlineHelpLink = new ExternalLink("onlineHelpLink", completeHelpUrl);
    getServiceForm().add(onlineHelpLink);
    if (completeHelpUrl.isEmpty()) {
        onlineHelpLink.setVisible(false);
    }

    // FUNCTIONNAL PARAMETERS
    RequiredTextField<String> serviceLabel = new RequiredTextField<String>("label");
    serviceLabel.setLabel(new StringResourceModel("portal.designer.service.mom.ml.label", null));
    serviceLabel.add(new PropertyValidator<>());
    getServiceForm().add(serviceLabel);

    TextField<String> destinationName = new TextField<String>("destinationName");
    //add help tooltip
    destinationName.add(new AttributeModifier("title",
            new StringResourceModel("portal.designer.service.mom.ml.destinationName.help", null)));
    destinationName.setLabel(new StringResourceModel("portal.designer.service.mom.ml.destinationName", null));
    destinationName.add(new PropertyValidator<>());
    getServiceForm().add(destinationName);

    // Connection factory JNDI Name
    TextField<String> jmsConnectionFactoryJndiName = new TextField<String>("jmsConnectionFactoryJndiName");
    //add help tooltip
    jmsConnectionFactoryJndiName.add(new AttributeModifier("title",
            new StringResourceModel("portal.designer.service.mom.ml.jmsConnectionFactoryJndiName.help", null)));
    jmsConnectionFactoryJndiName.setLabel(
            new StringResourceModel("portal.designer.service.mom.ml.jmsConnectionFactoryJndiName", null));
    jmsConnectionFactoryJndiName.add(new PropertyValidator<>());
    getServiceForm().add(jmsConnectionFactoryJndiName);

    // Non Functionnal attributes
    // Max size Kb
    TextField msgMaxSizeKB = new TextField("msgMaxSizeKB");
    //add help tooltip
    msgMaxSizeKB.add(new AttributeModifier("title",
            new StringResourceModel("portal.designer.service.mom.ml.msgMaxSizeKB.help", null)));
    msgMaxSizeKB.setLabel(new StringResourceModel("portal.designer.service.mom.ml.msgMaxSizeKB", null));
    msgMaxSizeKB.add(new PropertyValidator<>());
    getServiceForm().add(msgMaxSizeKB);

    // destination capacity (nb msg)
    TextField destinationCapacity = new TextField("destinationCapacity");
    //add help tooltip
    destinationCapacity.add(new AttributeModifier("title",
            new StringResourceModel("portal.designer.service.mom.ml.destinationCapacity.help", null)));
    destinationCapacity
            .setLabel(new StringResourceModel("portal.designer.service.mom.ml.destinationCapacity", null));
    destinationCapacity.add(new PropertyValidator<>());
    getServiceForm().add(destinationCapacity);

    // Persistent message used
    CheckBox persistentMessagesUsed = new CheckBox("persistentMessagesUsed");
    persistentMessagesUsed
            .setLabel(new StringResourceModel("portal.designer.service.mom.ml.persistentMessagesUsed", null));
    persistentMessagesUsed.add(new PropertyValidator<>());
    getServiceForm().add(persistentMessagesUsed);

    // High availability
    CheckBox highAvailability = new CheckBox("highAvailability");
    highAvailability.setLabel(new StringResourceModel("portal.designer.service.mom.ml.highAvailability", null));
    highAvailability.setEnabled(false);
    //add help tooltip
    highAvailability.add(new AttributeModifier("title",
            new StringResourceModel("portal.designer.service.mom.ml.highAvailability.help", null)));
    highAvailability.add(new PropertyValidator<>());
    getServiceForm().add(highAvailability);

    // Dead Letter
    // jndi queue name
    deadLetterQueueName = new TextField<String>("deadLetterQueueName", String.class);
    //add help tooltip
    deadLetterQueueName.add(new AttributeModifier("title",
            new StringResourceModel("portal.designer.service.mom.dl.deadLetterQueueName.help", null)));
    deadLetterQueueName.setOutputMarkupId(true);
    deadLetterQueueName.add(new PropertyValidator<>());
    //        deadLetterQueueName.setLabel(new StringResourceModel("portal.designer.service.mom.dl.deadLetterQueueName",null));

    // queue capacity
    deadLetterQueueCapacity = new TextField("deadLetterQueueCapacity");
    //add help tooltip
    deadLetterQueueCapacity.add(new AttributeModifier("title",
            new StringResourceModel("portal.designer.service.mom.dl.deadLetterQueueCapacity.help", null)));
    deadLetterQueueCapacity.setOutputMarkupId(true);
    deadLetterQueueCapacity.add(new PropertyValidator<>());
    //        deadLetterQueueCapacity.setLabel(new StringResourceModel("portal.designer.service.mom.dl.deadLetterQueueCapacity",null));

    // retries before deadqueue
    retriesBeforeMovingToDeadLetterQueue = new TextField("retriesBeforeMovingToDeadLetterQueue");
    //add help tooltip
    retriesBeforeMovingToDeadLetterQueue.add(new AttributeModifier("title", new StringResourceModel(
            "portal.designer.service.mom.dl.retriesBeforeMovingToDeadLetterQueue.help", null)));
    //        retriesBeforeMovingToDeadLetterQueue.setLabel(new StringResourceModel("portal.designer.service.mom.dl.retriesBeforeMovingToDeadLetterQueue",null));
    retriesBeforeMovingToDeadLetterQueue.setOutputMarkupId(true);
    retriesBeforeMovingToDeadLetterQueue.add(new PropertyValidator<>());

    // enable dead letter queue
    hasDeadLetterQueue = new AjaxCheckBox("hasDeadLetterQueue") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            deadLetterQueueName.setEnabled(getModelObject());
            deadLetterQueueCapacity.setEnabled(getModelObject());
            retriesBeforeMovingToDeadLetterQueue.setEnabled(getModelObject());

            target.add(deadLetterQueueName);
            target.add(deadLetterQueueCapacity);
            target.add(retriesBeforeMovingToDeadLetterQueue);
        }
    };
    hasDeadLetterQueue
            .setLabel(new StringResourceModel("portal.designer.service.mom.dl.hasDeadLetterQueue", null));
    hasDeadLetterQueue.add(new AttributeModifier("title",
            new StringResourceModel("portal.designer.service.mom.dl.hasDeadLetterQueue.help", null)));
    getServiceForm().add(hasDeadLetterQueue);

    if (hasDeadLetterQueue.getModelObject() != null) {
        deadLetterQueueName.setEnabled(hasDeadLetterQueue.getModelObject());
        deadLetterQueueCapacity.setEnabled(hasDeadLetterQueue.getModelObject());
        retriesBeforeMovingToDeadLetterQueue.setEnabled(hasDeadLetterQueue.getModelObject());
    }

    getServiceForm().add(retriesBeforeMovingToDeadLetterQueue);
    getServiceForm().add(deadLetterQueueCapacity);
    getServiceForm().add(deadLetterQueueName);

}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.jeeprocessing.LogicalJeeProcessingServicePanel.java

License:Apache License

private void initComponents() {

    getServiceForm().add(new CacheActivatedImage("logicalJeeProcessingPanelIcon",
            new ResourceModel("jeeProcessing-icon").getObject()));
    // Online help link
    String completeHelpUrl = "";
    try {//ww w. j a va  2 s  .co  m
        completeHelpUrl = new StringResourceModel("portal.designer.logical.service.online_manual.baseUrl", null)
                .getString()
                + new StringResourceModel(
                        "portal.designer.logical.service.online_manual." + getLogicalModelType(), null)
                                .getString();
    } catch (Exception e) {
        //do nothing
    }
    ExternalLink onlineHelpLink = new ExternalLink("onlineHelpLink", completeHelpUrl);
    getServiceForm().add(onlineHelpLink);
    if (completeHelpUrl.isEmpty()) {
        onlineHelpLink.setVisible(false);
    }

    // FUNCTIONNAL PARAMETERS
    RequiredTextField<String> label = new RequiredTextField<String>("label");
    label.setLabel(new StringResourceModel("portal.designer.service.jee.label", null));
    label.add(new PropertyValidator<>());
    getServiceForm().add(label);

    RequiredTextField<String> groupId = new RequiredTextField<String>("softwareReference.groupId");
    groupId.setLabel(new StringResourceModel("portal.designer.service.jee.softwareReference.groupId", null));
    groupId.add(new PropertyValidator<>());
    getServiceForm().add(groupId);

    RequiredTextField<String> artifactId = new RequiredTextField<String>("softwareReference.artifactId");
    artifactId.setLabel(
            new StringResourceModel("portal.designer.service.jee.softwareReference.artifactId", null));
    artifactId.add(new PropertyValidator<>());
    getServiceForm().add(artifactId);

    RequiredTextField version = new RequiredTextField("softwareReference.version");
    version.setLabel(new StringResourceModel("portal.designer.service.jee.softwareReference.version", null));
    version.add(new PropertyValidator<>());
    getServiceForm().add(version);

    TextField classifier = new TextField("softwareReference.classifier", String.class);
    classifier.setLabel(
            new StringResourceModel("portal.designer.service.jee.softwareReference.classifier", null));
    classifier.add(new PropertyValidator<>());
    getServiceForm().add(classifier);

    CheckBox optionalSoftwareReference = new CheckBox("optionalSoftwareReference");
    optionalSoftwareReference
            .setLabel(new StringResourceModel("portal.designer.service.jee.optionalSoftwareReference", null));
    getServiceForm().add(optionalSoftwareReference);

    TextField minMemoryMbHint = new TextField("minMemoryMbHint");
    minMemoryMbHint.setLabel(new StringResourceModel("portal.designer.service.jee.minMemoryMbHint", null));
    minMemoryMbHint.add(new AttributeModifier("class", "small"));
    minMemoryMbHint.add(new PropertyValidator<>());
    getServiceForm().add(minMemoryMbHint);

    final TextField<String> iconUrl = new TextField<String>("iconUrl");
    iconUrl.setLabel(new StringResourceModel("portal.designer.service.jee.iconUrl", null));
    //iconUrl.add(new AttributeModifier("title", new StringResourceModel("portal.designer.service.jee.iconUrl.help",null)));
    //Add Wicket validation for URL
    iconUrl.add(new UrlValidator());
    iconUrl.add(new PropertyValidator<>());
    iconUrl.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            // Important, DO NOT DELETE
            // By Calling OnChangeAjaxBehavior, we update iconUrl field model to can push button preview with updated model

        }

        @Override
        protected void onError(AjaxRequestTarget target, RuntimeException e) {
            iconUrl.updateModel(); // The feedback is handle when click on preview button so we need to updateModel when there is an error
        }
    });
    getServiceForm().add(iconUrl);
    getServiceForm()
            .add(new CacheActivatedImage("imageHelp.iconUrl", new ResourceModel("image.help").getObject()));

    WebMarkupContainer imageContainer = new WebMarkupContainer("imageContainer");

    final WebMarkupContainer icon = new WebMarkupContainer("icon");
    icon.setOutputMarkupId(true);
    icon.setOutputMarkupPlaceholderTag(true);
    if (iconUrl.getModelObject() == null || iconUrl.getModelObject().equals("")) {
        setDefaultIconAndUpdateFeedBack(icon, null, "");
    } else {
        setCustomIconAndUpdateFeedBack(icon, iconUrl, null);
    }
    imageContainer.add(icon);

    final Label feedback = new Label("feedbackError", new Model<String>(""));
    feedback.setOutputMarkupId(true);
    imageContainer.add(feedback);

    AjaxLink preview = new AjaxLink("preview", new Model()) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            try {

                //If null or empty when click on preview button, clean feedBack and display default image
                if (iconUrl.getModelObject() == null || iconUrl.getModelObject().equals("")) {
                    setDefaultIconAndCleanFeedBack(icon, feedback);
                } // Else try to display custom image
                else {
                    //Construct URL to test integrity of what user typing
                    URL url = new URL(iconUrl.getModelObject().toString());
                    if (iconUrl.getModelObject() != null) {
                        setCustomIconAndUpdateFeedBack(icon, iconUrl, feedback);
                    }
                }
            } catch (MalformedURLException e) {
                setDefaultIconAndUpdateFeedBack(icon, feedback, e.getMessage());
                logger.info("Exception while getting new icon", e);
            }
            target.add(icon);
            target.add(feedback);
        }
    };
    imageContainer.add(preview);
    getServiceForm().add(imageContainer);

}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.nodeprocessing.LogicalNodeProcessingServicePanel.java

License:Apache License

private void initComponents() {

    getServiceForm().add(new CacheActivatedImage("nodeprocessingIcon",
            new ResourceModel("nodeprocessing-icon").getObject()));
    // Online help link
    String completeHelpUrl = "";
    try {//from w  ww.  ja v a 2  s  .c  o m
        completeHelpUrl = new StringResourceModel("portal.designer.logical.service.online_manual.baseUrl", null)
                .getString()
                + new StringResourceModel(
                        "portal.designer.logical.service.online_manual." + getLogicalModelType(), null)
                                .getString();
    } catch (Exception e) {
        //do nothing
    }
    ExternalLink onlineHelpLink = new ExternalLink("onlineHelpLink", completeHelpUrl);
    getServiceForm().add(onlineHelpLink);
    if (completeHelpUrl.isEmpty()) {
        onlineHelpLink.setVisible(false);
    }

    // FUNCTIONNAL PARAMETERS
    /*RequiredTextField<String> label = new RequiredTextField<String>("label");
     label.setLabel(new StringResourceModel("portal.designer.service.cfjava.label",null));
     label.add(new PropertyValidator<>());
     getServiceForm().add(label);
            
     RequiredTextField<String> groupId = new RequiredTextField<String>("softwareReference.groupId");
     groupId.setLabel(new StringResourceModel("portal.designer.service.cfjava.softwareReference.groupId",null));
     groupId.add(new PropertyValidator<>());
     getServiceForm().add(groupId);
            
     RequiredTextField<String> artifactId = new RequiredTextField<String>("softwareReference.artifactId");
     artifactId.setLabel(new StringResourceModel("portal.designer.service.cfjava.softwareReference.artifactId",null));
     artifactId.add(new PropertyValidator<>());
     getServiceForm().add(artifactId);
            
     RequiredTextField<?> version = new RequiredTextField("softwareReference.version");
     version.setLabel(new StringResourceModel("portal.designer.service.cfjava.softwareReference.version",null));
     version.add(new PropertyValidator<>());
     getServiceForm().add(version);
            
     TextField classifier = new TextField("softwareReference.classifier", String.class);
     classifier.setLabel(new StringResourceModel("portal.designer.service.cfjava.softwareReference.classifier",null));
     classifier.add(new PropertyValidator<>());
     getServiceForm().add(classifier);
            
             
     CheckBox optionalSoftwareReference=new CheckBox("optionalSoftwareReference");
     optionalSoftwareReference.setLabel(new StringResourceModel("portal.designer.service.cfjava.optionalSoftwareReference",null));
     getServiceForm().add(optionalSoftwareReference);
             
             
             
     TextField minMemoryMbHint = new TextField("minMemoryMbHint");
     minMemoryMbHint.setLabel(new StringResourceModel("portal.designer.service.cfjava.minMemoryMbHint",null));
     minMemoryMbHint.add(new AttributeModifier("class","small"));
     minMemoryMbHint.add(new PropertyValidator<>());
     getServiceForm().add(minMemoryMbHint);
    */

    //****** Change Icon ******//

    final TextField<String> iconUrl = new TextField<String>("iconUrl");
    iconUrl.setLabel(new StringResourceModel("portal.designer.service.cfjava.iconUrl", null));
    //iconUrl.add(new AttributeModifier("title", new StringResourceModel("portal.designer.service.cfjava.iconUrl.help",null)));
    //Add Wicket validation for URL
    iconUrl.add(new UrlValidator());
    iconUrl.add(new PropertyValidator<>());
    iconUrl.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            // Important, DO NOT DELETE
            // By Calling OnChangeAjaxBehavior, we update iconUrl field model to can push button preview with updated model

        }

        @Override
        protected void onError(AjaxRequestTarget target, RuntimeException e) {
            iconUrl.updateModel(); // The feedback is handle when click on preview button so we need to updateModel when there is an error
        }
    });
    getServiceForm().add(iconUrl);
    getServiceForm().add(new CacheActivatedImage("imageHelp.iconUrl", getString("image.help")));

    WebMarkupContainer imageContainer = new WebMarkupContainer("imageContainer");

    final WebMarkupContainer icon = new WebMarkupContainer("icon");
    icon.setOutputMarkupId(true);
    icon.setOutputMarkupPlaceholderTag(true);
    if (iconUrl.getModelObject() == null || iconUrl.getModelObject().equals("")) {
        setDefaultIconAndUpdateFeedBack(icon, null, "");
    } else {
        setCustomIconAndUpdateFeedBack(icon, iconUrl, null);
    }
    imageContainer.add(icon);

    final Label feedback = new Label("feedbackError", new Model<String>(""));
    feedback.setOutputMarkupId(true);
    imageContainer.add(feedback);

    AjaxLink preview = new AjaxLink("preview", new Model()) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            try {

                //If null or empty when click on preview button, clean feedBack and display default image
                if (iconUrl.getModelObject() == null || iconUrl.getModelObject().equals("")) {
                    setDefaultIconAndCleanFeedBack(icon, feedback);
                } // Else try to display custom image
                else {
                    //Construct URL to test integrity of what user typing
                    URL url = new URL(iconUrl.getModelObject().toString());
                    if (iconUrl.getModelObject() != null) {
                        setCustomIconAndUpdateFeedBack(icon, iconUrl, feedback);
                    }
                }
            } catch (MalformedURLException e) {
                setDefaultIconAndUpdateFeedBack(icon, feedback, e.getMessage());
                e.printStackTrace();
            }
            target.add(icon);
            target.add(feedback);
        }
    };
    imageContainer.add(preview);
    getServiceForm().add(imageContainer);

}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.onlinestorage.LogicalOnlineStorageServicePanel.java

License:Apache License

private void initComponents() {

    getServiceForm().add(new CacheActivatedImage("logicalOnlineStorageServicePanelIcon",
            new ResourceModel("onlineStorage-icon").getObject()));
    // Online help link
    String completeHelpUrl = "";
    try {/* w  ww  .  j ava 2s .  com*/
        completeHelpUrl = new StringResourceModel("portal.designer.logical.service.online_manual.baseUrl", null)
                .getString()
                + new StringResourceModel(
                        "portal.designer.logical.service.online_manual." + getLogicalModelType(), null)
                                .getString();
    } catch (Exception e) {
        //do nothing
    }
    ExternalLink onlineHelpLink = new ExternalLink("onlineHelpLink", completeHelpUrl);
    getServiceForm().add(onlineHelpLink);
    if (completeHelpUrl.isEmpty()) {
        onlineHelpLink.setVisible(false);
    }

    // FUNCTIONNAL PARAMETERS
    RequiredTextField<String> label = new RequiredTextField<String>("label");
    label.setLabel(new StringResourceModel("portal.designer.service.storage.label", null));
    label.add(new PropertyValidator<>());
    getServiceForm().add(label);

    TextField<String> serviceName = new TextField<String>("serviceName");
    serviceName.setLabel(new StringResourceModel("portal.designer.service.storage.name", null));
    serviceName.add(new PropertyValidator<>());
    getServiceForm().add(serviceName);

    TextField storageCapacityMb = new TextField("storageCapacityMb");
    storageCapacityMb
            .setLabel(new StringResourceModel("portal.designer.service.storage.storageCapacityMb", null));
    storageCapacityMb.add(new AttributeModifier("class", "small"));
    storageCapacityMb.add(new PropertyValidator<>());
    getServiceForm().add(storageCapacityMb);

}