Exemplo n.º 1
0
  private void initialize(String titleKey) {
    feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    add(feedback);

    Label titleLabel = new Label("pageTitle", getString(titleKey, null, titleKey));
    titleLabel.setRenderBodyOnly(true);
    add(titleLabel);

    Link<Object> plLangLink =
        new Link<Object>("plLang") {
          private static final long serialVersionUID = 3288754396147822387L;

          @Override
          public void onClick() {
            getSession().setLocale(new Locale("pl", "pl_PL"));
            setResponsePage(getPage().getClass());
          }
        };
    add(plLangLink);

    Link<Object> enLangLink =
        new Link<Object>("enLang") {
          private static final long serialVersionUID = 4601930920670566466L;

          @Override
          public void onClick() {
            getSession().setLocale(Locale.ENGLISH);
            setResponsePage(getPage().getClass());
          }
        };
    add(enLangLink);

    ((Application) getApplication()).getMenuLoader().addMenuPanel(BasePage.this);
  }
Exemplo n.º 2
0
  @Override
  protected void initLayout() {
    Label username =
        new Label(
            ID_USERNAME,
            new AbstractReadOnlyModel<String>() {

              @Override
              public String getObject() {
                return getShortUserName();
              }
            });
    username.setRenderBodyOnly(true);
    add(username);

    ExternalLink logoutLink =
        new ExternalLink(
            ID_LOGOUT_LINK,
            new Model<String>(
                RequestCycle.get().getRequest().getContextPath() + "/j_spring_security_logout"),
            createStringResource("UserMenuPanel.logout"));
    add(logoutLink);

    //        LabeledBookmarkableLink editProfile = new LabeledBookmarkableLink(ID_EDIT_PROFILE,
    //                new MenuItem(createStringResource("UserMenuPanel.editProfile"),
    // PageDashboard.class));
    //        add(editProfile);

    LabeledBookmarkableLink resetPasswords =
        new LabeledBookmarkableLink(
            ID_RESET_PASSWORDS,
            new MenuItem(
                createStringResource("UserMenuPanel.resetPasswords"), PageMyPasswords.class));
    add(resetPasswords);
  }
Exemplo n.º 3
0
  @Override
  public Component preview() {
    final Label commonNameLabel = new Label("certCommonName", new Model<String>());
    final ByteArrayInputStream certificateStream = new ByteArrayInputStream(uploadedBytes);
    try {
      final X509Certificate certificate =
          (X509Certificate)
              CertificateFactory.getInstance("X.509").generateCertificate(certificateStream);

      final StringBuilder commonNameBuilder = new StringBuilder("cn=");

      final LdapName ldapName = new LdapName(certificate.getIssuerDN().getName());

      for (Rdn rdn : ldapName.getRdns()) {
        if ("CN".equalsIgnoreCase(rdn.getType())) {
          commonNameBuilder.append(
              rdn.getValue() == null ? StringUtils.EMPTY : rdn.getValue().toString());
        }
      }
      commonNameLabel.setDefaultModelObject(commonNameBuilder.toString());
    } catch (Exception e) {
      LOG.error("Error evaluating certificate file", e);
      throw new IllegalArgumentException("Error evaluating certificate file", e);
    } finally {
      IOUtils.closeQuietly(certificateStream);
    }
    return this.add(commonNameLabel);
  }
Exemplo n.º 4
0
  /**
   * Constructor
   *
   * @param id the markup id
   * @param model the {@link IModel}
   * @param label {@link Label} on which the current slide value will be displayed
   */
  public AbstractSlider(String id, IModel<T> model, Label label) {
    super(id, model);

    label.setDefaultModel(model);
    label.setOutputMarkupId(true);
    this.setLabelId(label.getMarkupId());
  }
Exemplo n.º 5
0
  /** tests timer behavior in a WebPage. */
  @Test
  public void addToWebPage() {
    Duration dur = Duration.seconds(20);
    final MyAjaxSelfUpdatingTimerBehavior timer = new MyAjaxSelfUpdatingTimerBehavior(dur);
    final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();
    Label label = new Label(MockPageWithLinkAndComponent.COMPONENT_ID, "Hello");
    page.add(label);
    page.add(
        new Link<Void>(MockPageWithLinkAndComponent.LINK_ID) {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick() {
            // do nothing, link is just used to simulate a roundtrip
          }
        });
    label.setOutputMarkupId(true);
    label.add(timer);

    tester.startPage(page);

    validate(timer, true);

    tester.clickLink(MockPageWithLinkAndComponent.LINK_ID);

    validate(timer, true);
  }
Exemplo n.º 6
0
 public LinkPanel(
     String wicketId,
     String bootstrapIcon,
     String linkCssClass,
     IModel<String> model,
     Class<? extends WebPage> clazz,
     PageParameters parameters,
     boolean newWindow) {
   super(wicketId);
   this.labelModel = model;
   Link<Void> link = null;
   if (parameters == null) {
     link = new BookmarkablePageLink<Void>("link", clazz);
   } else {
     link = new BookmarkablePageLink<Void>("link", clazz, parameters);
   }
   if (newWindow) {
     link.add(new SimpleAttributeModifier("target", "_blank"));
   }
   if (linkCssClass != null) {
     link.add(new SimpleAttributeModifier("class", linkCssClass));
   }
   Label icon = new Label("icon");
   if (StringUtils.isEmpty(bootstrapIcon)) {
     link.add(icon.setVisible(false));
   } else {
     WicketUtils.setCssClass(icon, bootstrapIcon);
     link.add(icon);
   }
   link.add(new Label("label", labelModel).setRenderBodyOnly(true));
   add(link);
 }
Exemplo n.º 7
0
  /**
   * Constructor.
   *
   * @param id
   * @param inputComponent
   * @param labelModel optional
   * @param helpModel optional
   */
  public InputBorder(
      final String id,
      final FormComponent<T> inputComponent,
      final IModel<String> labelModel,
      final IModel<String> helpModel) {
    super(id);

    Args.notNull(labelModel, "labelModel");
    Args.notNull(helpModel, "helpModel");

    // set html id so that this border can be refreshed by ajax
    this.setOutputMarkupId(true);

    // add the form component to the border
    this.inputComponent = inputComponent;
    add(this.inputComponent);

    // add the label
    WebMarkupContainer labelContainer = new WebMarkupContainer(labelContainerID);
    Label label = new Label(labelID, labelModel);
    label.setEscapeModelStrings(false);
    labelContainer.add(new AttributeModifier("for", Model.of(inputComponent.getMarkupId())));
    labelContainer.add(label);
    addToBorder(labelContainer);

    // add the help label
    addToBorder(new Label(helpID, helpModel).setEscapeModelStrings(false));

    // add the feedback panel with filter so that it only shows messages
    // relevant for this input component
    this.feedback = new FeedbackPanel(feedbackPanelID, new ContainerFeedbackMessageFilter(this));
    addToBorder(this.feedback.setOutputMarkupId(true));
  }
  public ContributionCommentSuccessPage(PageParameters parameters) {
    super(parameters);

    contributionId = parameters.getInt("contribution");

    boolean success =
        HibernateUtils.wrapTransaction(
            getHibernateSession(),
            new HibernateTask() {
              public boolean run(Session session) {
                contribution =
                    (Contribution)
                        session
                            .createQuery("select c from Contribution as c where c.id = :id")
                            .setInteger("id", contributionId)
                            .uniqueResult();
                return true;
              }
            });

    if (!success) {
      logger.info("unknown contribution of id " + contributionId);
      throw new RestartResponseAtInterceptPageException(NotFoundPage.class);
    }

    initializeLocation(getNavMenu().getLocationByKey("teacherIdeas"));

    add(
        new LocalizedText(
            "comment-header",
            "contribution.comment.success",
            new Object[] {HtmlUtils.encode(contribution.getTitle())}));

    add(
        new LocalizedText(
            "comment-success",
            "contribution.comment.successRedirection",
            new Object[] {
              ContributionPage.getLinker(contributionId).getHref(getPageContext(), getPhetCycle()),
              REDIRECTION_DELAY_SECONDS
            }));

    Label redirector = new Label("redirector", "");
    redirector.add(
        new AttributeModifier(
            "content",
            true,
            new Model<String>(
                REDIRECTION_DELAY_SECONDS
                    + ";url="
                    + ContributionPage.getLinker(contributionId)
                        .getRawUrl(getPageContext(), getPhetCycle()))));
    add(redirector);

    setTitle(
        StringUtils.messageFormat(
            PhetLocalizer.get().getString("contribution.comment.success", this),
            new Object[] {HtmlUtils.encode(contribution.getTitle())}));
  }
Exemplo n.º 9
0
  private void createPasswordInput(IModel<T> userModel, T manageUserBackingBean, Form<T> form) {
    Label label = new Label("passwordEditLabel", new ResourceModel("admin.user.editPassword"));
    label.setVisible(manageUserBackingBean.isEditMode());
    form.add(label);

    PasswordFieldFactory.createOptionalPasswordFields(
        form, new PropertyModel<String>(userModel, "user.password"));
  }
Exemplo n.º 10
0
 public FailureMessageModal(final PageReference pageRef, final String failureMessage) {
   super(BaseModal.CONTENT_ID);
   final Label executionFailureMessage;
   if (!failureMessage.isEmpty()) {
     executionFailureMessage = new Label("failureMessage", new Model<String>(failureMessage));
   } else {
     executionFailureMessage = new Label("failureMessage");
   }
   add(executionFailureMessage.setOutputMarkupId(true));
 }
  @Override
  protected void populateItem(ListItem<LiveTiming> item) {

    LiveTiming timing = item.getModelObject();
    Label nameLabel = new Label("name", LfsNames.getHtmlColoredName(timing.getDriverName()));
    nameLabel.setEscapeModelStrings(false);
    item.add(nameLabel);
    int lapNumber = timing.getLapsCompleted();
    String laptimeString;
    String lapNumberString;
    String totalTimeString;
    if (lapNumber > 0) {

      laptimeString = dateFormat.format(timing.getLastLapTime());
      laptimeString = laptimeString.substring(0, laptimeString.length() - 1);

      lapNumberString = Integer.toString(lapNumber);

      logger.debug(
          "time {} - laps {} ",
          (timing.getTotalTime() - first.getTotalTime()),
          timing.getLapsCompleted() - first.getLapsCompleted());
      if (timing == first) {
        totalTimeString = dateFormat.format(timing.getTotalTime());
        totalTimeString = totalTimeString.substring(0, totalTimeString.length() - 1);
      } else if ((timing.getTotalTime() > first.getTotalTime())
          && (timing.getLapsCompleted() < first.getLapsCompleted())) {
        totalTimeString =
            "+" + Integer.toString(first.getLapsCompleted() - timing.getLapsCompleted()) + " Laps";
      } else if (timing.getLapsCompleted() < (first.getLapsCompleted() - 1)) {
        totalTimeString =
            "+"
                + Integer.toString(first.getLapsCompleted() - timing.getLapsCompleted() - 1)
                + " Laps";
      } else {
        int value = timing.getTotalTime() - first.getTotalTime(lapNumber);
        if (value > 60000) {
          totalTimeString = dateFormat.format(value);
        } else {
          totalTimeString = dateFormatShort.format(value);
        }
        totalTimeString = "+" + totalTimeString.substring(0, totalTimeString.length() - 1);
      }

    } else {
      laptimeString = "-";
      totalTimeString = "-";
      lapNumberString = "0";
    }

    item.add(new Label("position", Integer.toString(timing.getPosition())));
    item.add(new Label("laptime", laptimeString));
    item.add(new Label("lapnumber", lapNumberString));
    item.add(new Label("totaltime", totalTimeString));
  }
Exemplo n.º 12
0
  private void setFormFieldsFromQuestion(Question question) {
    Answer.AnswerType aType = question.getAnswerType();

    questionTitleField.setModelObject(question.getTitle());
    questionPromptField.setModelObject(question.getPrompt());
    questionPrefaceField.setModelObject(question.getPreface());
    questionCitationField.setModelObject(question.getCitation());
    questionResponseTypeModel.setObject(question.getAnswerType());
    Long answerReasonId = question.getAnswerReasonExpressionId();
    questionAnswerReasonModel.setObject(
        answerReasonId == null ? answerAlways : Expressions.get(answerReasonId));
    String msg = "Asking style in setFormFields: " + askingStyleModel.getObject();
    askingStyleModel.setObject(question.getAskingStyleList());
    msg +=
        " -> "
            + askingStyleModel.getObject()
            + " (question had "
            + question.getAskingStyleList()
            + ")";
    // throw new RuntimeException(msg);
    // questionUseIfField.setModelObject(question.getUseIfExpression());
    otherSpecifyCheckBox.setModelObject(question.getOtherSpecify());
    noneButtonCheckBox.setModelObject(question.getNoneButton());
    if (aType == Answer.AnswerType.NUMERICAL) {
      numericLimitsPanel.setVisible(true);
    } else if (aType == Answer.AnswerType.MULTIPLE_SELECTION) {
      multipleSelectionLimitsPanel.setVisible(true);
      noneButtonLabel.setVisible(true);
      noneButtonCheckBox.setVisible(true);
    }
    if (aType == Answer.AnswerType.SELECTION || aType == Answer.AnswerType.MULTIPLE_SELECTION) {
      otherSpecifyLabel.setVisible(true);
      otherSpecifyCheckBox.setVisible(true);
    } else {
      otherSpecifyLabel.setVisible(false);
      otherSpecifyCheckBox.setVisible(false);
    }
    if (aType == Answer.AnswerType.DATE || aType == Answer.AnswerType.TIME_SPAN) {
      timeUnitsPanel.setVisible(true);
    } else {
      timeUnitsPanel.setVisible(false);
    }
    numericLimitsPanel.setMinLimitType(question.getMinLimitType());
    numericLimitsPanel.setMinLiteral(question.getMinLiteral());
    numericLimitsPanel.setMinPrevQues(question.getMinPrevQues());
    numericLimitsPanel.setMaxLimitType(question.getMaxLimitType());
    numericLimitsPanel.setMaxLiteral(question.getMaxLiteral());
    numericLimitsPanel.setMaxPrevQues(question.getMaxPrevQues());

    multipleSelectionLimitsPanel.setMinCheckableBoxes(question.getMinCheckableBoxes());
    multipleSelectionLimitsPanel.setMaxCheckableBoxes(question.getMaxCheckableBoxes());

    listLimitsPanel.setQuestion(question);
  }
Exemplo n.º 13
0
  public ContextualHelpPanel(
      String id, String headerResourceId, String bodyResourceId, String wikiPageTitle) {
    super(id);

    add(new Label("header", new ResourceModel(headerResourceId)));
    Label body = new Label("body", new ResourceModel(bodyResourceId));
    body.setEscapeModelStrings(false);
    add(body);
    add(createReadMoreLink(wikiPageTitle));
    setOutputMarkupId(true);
  }
Exemplo n.º 14
0
  @SuppressWarnings("rawtypes")
  public RestaurantPage(Restaurant r) {
    add(new Label("nameText", r.getName()));
    User user = BaseSession.get().getUser();
    List<Order> order_list = new ArrayList<Order>();
    try {
      order_list = orders.getHistory(r);
    } catch (LoadOrderException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }
    int orderId = -1;
    for (Order order : order_list) {
      if (order.getUser().equals(user) && order.getStatus() == 0) {
        orderId = order.getId();
      }
    }
    Label lbl_order = new Label("orderText", "Su numero de pedido es: " + orderId);
    add(lbl_order.setVisible(orderId != -1));

    add(new Label("score", String.valueOf(r.getScore())));
    add(new Label("count", String.valueOf(r.getCountComments())));

    Link menuLink =
        new Link("menuLink") {

          @Override
          public void onClick() {
            setResponsePage(new RestaurantMenuPage(r.getId()));
          }
        };
    add(menuLink.setVisible(true));

    Link infoLink =
        new Link("infoLink") {

          @Override
          public void onClick() {}
        };
    add(infoLink.setVisible(true));

    add(new Label("descriptionText", r.getDescription()));
    boolean isClosed = false;
    ClosingPeriod cp = closingPeriods.getLastClosingPeriod(r);
    if (cp != null) {
      isClosed = !(new LocalDate()).isAfter(new LocalDate(cp.getFrom()));
    }
    add(
        new Label("restClose", new StringResourceModel("close", this, new Model<ClosingPeriod>(cp)))
            .setEscapeModelStrings(false)
            .setVisible(isClosed));
  }
Exemplo n.º 15
0
 /**
  * Return a component with a list of steps.
  *
  * @param model wizard model
  * @return a RepeatingView with step list
  */
 private RepeatingView getStepList(IWizardModel model) {
   Iterator<IWizardStep> it = model.stepIterator();
   RepeatingView view = new RepeatingView("repeater");
   while (it.hasNext()) {
     IWizardStep step = it.next();
     Label label = new Label(view.newChildId(), new PropertyModel<WizardStep>(step, "title"));
     if (step.equals(model.getActiveStep())) {
       label.add(new AttributeModifier("class", new Model<String>("selectedStep")));
     }
     view.add(label);
   }
   return view;
 }
Exemplo n.º 16
0
  private void changeMonth(AjaxEvent ajaxEvent) {
    createModelForMonth(getEhourWebSession().getNavCalendar());

    Component originalForm = get(ID_FRAME + ":" + ID_BLUE_BORDER + ":" + ID_SELECTION_FORM);

    ExportCriteriaPanel replacementPanel = createExportCriteriaPanel(ID_SELECTION_FORM);

    originalForm.replaceWith(replacementPanel);
    ajaxEvent.getTarget().addComponent(replacementPanel);

    Label newLabel = getTitleLabel(getEhourWebSession().getNavCalendar());
    newLabel.setOutputMarkupId(true);
    titleLabel.replaceWith(newLabel);
    titleLabel = newLabel;
    ajaxEvent.getTarget().addComponent(newLabel);
  }
Exemplo n.º 17
0
  private void checkResponse(AjaxRequestTarget target) {
    // Show cancel
    if (response.isCancelVisible()) {
      cancelDiv.setVisible(true);
      target.addComponent(cancelDiv);
    }
    // Show retry
    if (response.isRetryVisible()) {
      retryDiv.setVisible(true);
      target.addComponent(retryDiv);
    }

    // Show error Text
    if (PortalUtils.exists(response.getErrorMessage())) {
      errorMsg.setVisible(true);
      target.addComponent(errorMsg);
    }

    // Return to URL
    if (PortalUtils.exists(response.getReturnUrl()) && response.isRedirect())
      try {
        getWebRequestCycle()
            .getWebResponse()
            .getHttpServletResponse()
            .sendRedirect(response.getReturnUrl());
        isRedirected = true;
      } catch (IOException e) {
        LOG.error(
            "#An error occurred while redirecting to the return url["
                + response.getReturnUrl()
                + "]",
            e);
        return;
      }
  }
Exemplo n.º 18
0
  /** {@inheritDoc} */
  @Override
  protected List<Component> createFormComponents() {
    List<Component> components = new ArrayList<Component>();

    components.add(this.createTextField("username"));

    Label label = new Label("passwordLabel", "Password:"******"password");
    passwordField.setVisible(this.getFormType().isNew());
    components.add(passwordField);

    return components;
  }
Exemplo n.º 19
0
 public void updateCommentsCount() {
   viewComments.addOrReplace(
       commentsCount =
           new Label(
               "commentsCount",
               String.valueOf(activeInterviewService.getInterviewComments().size())));
   commentsCount.setOutputMarkupId(true);
 }
Exemplo n.º 20
0
  public HomePage(final PageParameters parameters) {
    super(parameters);

    final Label toReplace = new Label("toReplace", "Initial content");
    toReplace.setOutputMarkupId(true);
    add(toReplace);

    AjaxLink<Void> link =
        new AjaxLink<Void>("link") {
          @Override
          public void onClick(AjaxRequestTarget target) {
            toReplace.setDefaultModelObject("New value");
            Effects.replace(target, toReplace);
          }
        };
    add(link);
  }
Exemplo n.º 21
0
 @SuppressWarnings("unchecked")
 public static void setLabel(final FormComponent<?> component, final Label label) {
   final IModel<String> labelModel = (IModel<String>) label.getDefaultModel();
   if (component instanceof DatePanel) {
     ((DatePanel) component).getDateField().setLabel(labelModel);
   } else {
     component.setLabel(labelModel);
   }
 }
Exemplo n.º 22
0
  public ConfirmEmailLandingPanel(
      String id,
      PageContext context,
      PhetUser user,
      String destination,
      boolean wasPreviouslyConfirmed,
      boolean changedEmail) {
    super(id, context);

    if (changedEmail) {
      add(new LocalizedText("now-subscribed", "newsletter.emailChanged"));
      add(new InvisibleComponent("redirector"));
      add(new InvisibleComponent("now-registered"));
      destination = null;
      PhetSession.get().signOut();
    } else if (user.isNewsletterOnlyAccount() || wasPreviouslyConfirmed) {
      add(new LocalizedText("now-subscribed", "newsletter.nowSubscribed"));
      add(new InvisibleComponent("redirector"));
      add(new InvisibleComponent("now-registered"));
    } else {
      add(new InvisibleComponent("now-subscribed"));

      if (destination != null) {
        Label redirector = new Label("redirector", "");
        redirector.add(
            new AttributeModifier(
                "content",
                true,
                new Model<String>(REDIRECTION_DELAY_SECONDS + ";url=" + destination)));
        add(redirector);
      } else {
        add(new InvisibleComponent("redirector"));
      }

      add(new LocalizedText("now-registered", "newsletter.nowRegistered"));
    }

    if (destination != null) {
      add(new LocalizedText("redirection", "newsletter.redirection"));
    } else {
      add(new InvisibleComponent("redirection"));
    }
  }
Exemplo n.º 23
0
  /**
   * called by the dropdownchoice when its selection changes to hide/make visible panels that deal
   * with range limits and the 'Other/Specify' check box the value we get from the ajax onUpdate
   * getModelValue() is a string indicating the position of the selected choice in the drop down
   *
   * @param iValue
   */
  protected void onSelectionChanged(int iValue) {
    boolean numericLimitsVisible = false;
    boolean multipleSelectionLimitsVisible = false;
    boolean timeSpanUnitsVisible = false;
    boolean otherSpecifyVisible = false;
    boolean listLimitsVisible = false;
    boolean isListStyle = (Boolean) askingStyleModel.getObject();

    switch (iValue) {
      case 0: // TEXT
        break;
      case 1: // NUMERIC
        numericLimitsVisible = true;
        break;
      case 2: // DROP_DOWN - single SELECTION
        otherSpecifyVisible = true;
        listLimitsVisible = isListStyle;
        break;
      case 3: // MULTIPLE_SELECTION
        multipleSelectionLimitsVisible = true;
        otherSpecifyVisible = true;
        listLimitsVisible = isListStyle;
        break;
      case 4: // DATE
      case 5: // TIME_SPAN
        timeSpanUnitsVisible = true;
        break;
    }

    numericLimitsPanel.setVisible(numericLimitsVisible);
    multipleSelectionLimitsPanel.setVisible(multipleSelectionLimitsVisible);
    noneButtonLabel.setVisible(multipleSelectionLimitsVisible);
    noneButtonCheckBox.setVisible(multipleSelectionLimitsVisible);
    otherSpecifyLabel.setVisible(otherSpecifyVisible);
    otherSpecifyCheckBox.setVisible(otherSpecifyVisible);
    timeUnitsPanel.setVisible(timeSpanUnitsVisible);
    timeUnitsPanel.setWeeksVisible((iValue == 5) ? true : false);
    listLimitsPanel.setVisible(listLimitsVisible);
  }
  /**
   * Constructor
   *
   * @param id
   * @param index
   * @param animSelectOption
   * @param settings
   */
  public AnimSelectOptionBox(
      String id, final int index, AnimSelectOption animSelectOption, AnimSelectSettings settings) {
    super(id);
    add(YuiHeaderContributor.forModule("animation"));
    this.settings = settings;
    this.easing = settings.getEasing();
    this.duration = settings.getDuration();
    this.maxSelection = settings.getMaxSelection();
    this.message = settings.getMessage();

    ImgStyle style = new ImgStyle("imgStyle");
    add(style);
    style.add(
        new AnimSelectBox("defaultImg", index, "DefaultImg", animSelectOption.getDefaultImg()));
    style.add(
        new AnimSelectBox(
            "defaultImgOver", index, "DefaultImgOver", animSelectOption.getDefaultImgOver()));
    style.add(
        new AnimSelectBox("selectedImg", index, "SelectedImg", animSelectOption.getSelectedImg()));
    style.add(
        new AnimSelectBox(
            "selectedImgOver", index, "SelectedImgOver", animSelectOption.getSelectedImgOver()));

    Label animSelect =
        new Label(
            "animSelectScript",
            new AbstractReadOnlyModel() {
              private static final long serialVersionUID = 1L;

              @Override
              public Object getObject() {
                return getAnimSelectInitializationScript(index);
              }
            });
    animSelect.setEscapeModelStrings(false);
    add(animSelect);
  }
  public RangeTextFieldDemo() {

    Model<Double> model = Model.of(2.3d);

    Form<Void> form = new Form<Void>("form");
    add(form);

    RangeTextField<Double> rangeTextField =
        new RangeTextField<Double>("range", model, Double.class);
    form.add(rangeTextField);

    rangeTextField.setMinimum(1.4d);
    rangeTextField.setMaximum(10.0d);

    final Label rangeLabel = new Label("rangeLabel", model);
    rangeLabel.setOutputMarkupId(true);
    add(rangeLabel);

    rangeTextField.add(
        new AjaxFormComponentUpdatingBehavior("change") {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            target.add(rangeLabel);
          }

          @Override
          protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);

            ThrottlingSettings throttleSettings =
                new ThrottlingSettings("rangeTextFieldDemoId", Duration.milliseconds(500));
            attributes.setThrottlingSettings(throttleSettings);
          }
        });
  }
Exemplo n.º 26
0
  @Override
  protected void onBeforeRender() {
    super.onBeforeRender();
    this.setDefaultModel(null);
    if (this.component.getFeedbackMessage() != null) {
      if (this.text != null)
        this.setDefaultModel(
            new Model<String>(this.text.getObject().toString().replaceAll("\"", "")));
      else
        this.setDefaultModel(
            new Model<String>(
                component.getFeedbackMessage().getMessage().toString().replaceAll("\"", "")));

      // set this message rendered to avoid the warning concerning the feedback panel
      component.getFeedbackMessage().markRendered();
      this.add(new AttributeModifier("class", true, new Model<String>("message-validator")));
    } else this.setDefaultModel(null);
  }
Exemplo n.º 27
0
  public ExportMonthSelectionPage(Calendar forMonth) {
    super(new ResourceModel("printMonth.title"));

    setDefaultModel(createModelForMonth(forMonth));

    add(createCalendarPanel("sidePanel"));

    titleLabel = getTitleLabel(forMonth);
    titleLabel.setOutputMarkupId(true);

    add(
        new ContextualHelpPanel(
            "contextHelp", "printMonth.help.header", "printMonth.help.body", "Export+month"));

    CustomTitledGreyRoundedBorder greyBorder =
        new CustomTitledGreyRoundedBorder(ID_FRAME, titleLabel);
    GreyBlueRoundedBorder blueBorder = new GreyBlueRoundedBorder(ID_BLUE_BORDER);
    greyBorder.add(blueBorder);
    add(greyBorder);

    blueBorder.add(createExportCriteriaPanel(ID_SELECTION_FORM));
  }
  @Override
  @SuppressWarnings({"unchecked", "rawtypes"})
  protected void populateItem(final ListItem<ConnConfProperty> item) {
    final ConnConfProperty property = item.getModelObject();

    final Label label =
        new Label(
            "connPropAttrSchema",
            StringUtils.isBlank(property.getSchema().getDisplayName())
                ? property.getSchema().getName()
                : property.getSchema().getDisplayName());
    item.add(label);

    FieldPanel<? extends Serializable> field;
    boolean required = false;
    boolean isArray = false;

    if (property.getSchema().isConfidential()
        || Constants.GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType())
        || Constants.GUARDED_BYTE_ARRAY.equalsIgnoreCase(property.getSchema().getType())) {

      field =
          new AjaxPasswordFieldPanel(
              "panel", label.getDefaultModelObjectAsString(), new Model<String>());
      ((PasswordTextField) field.getField()).setResetPassword(false);

      required = property.getSchema().isRequired();
    } else {
      Class<?> propertySchemaClass;
      try {
        propertySchemaClass =
            ClassUtils.forName(property.getSchema().getType(), ClassUtils.getDefaultClassLoader());
        if (ClassUtils.isPrimitiveOrWrapper(propertySchemaClass)) {
          propertySchemaClass =
              org.apache.commons.lang3.ClassUtils.primitiveToWrapper(propertySchemaClass);
        }
      } catch (Exception e) {
        LOG.error("Error parsing attribute type", e);
        propertySchemaClass = String.class;
      }

      if (ClassUtils.isAssignable(Number.class, propertySchemaClass)) {
        @SuppressWarnings("unchecked")
        final Class<Number> numberClass = (Class<Number>) propertySchemaClass;
        field =
            new SpinnerFieldPanel<Number>(
                "panel",
                label.getDefaultModelObjectAsString(),
                numberClass,
                new Model<Number>(),
                null,
                null);

        required = property.getSchema().isRequired();
      } else if (ClassUtils.isAssignable(Boolean.class, propertySchemaClass)) {
        field =
            new AjaxCheckBoxPanel(
                "panel", label.getDefaultModelObjectAsString(), new Model<Boolean>());
      } else {
        field =
            new AjaxTextFieldPanel(
                "panel", label.getDefaultModelObjectAsString(), new Model<String>());

        required = property.getSchema().isRequired();
      }

      if (propertySchemaClass.isArray()) {
        isArray = true;
      }
    }

    field.setTitle(property.getSchema().getHelpMessage());

    if (required) {
      field.addRequiredLabel();
    }

    if (isArray) {
      if (property.getValues().isEmpty()) {
        property.getValues().add(null);
      }

      final MultiFieldPanel multiFieldPanel =
          new MultiFieldPanel("panel", new PropertyModel<List<String>>(property, "values"), field);
      item.add(multiFieldPanel);
    } else {
      setNewFieldModel(field, property.getValues());
      item.add(field);
    }

    if (withOverridable) {
      item.add(
          new AjaxCheckBoxPanel(
              "connPropAttrOverridable",
              "connPropAttrOverridable",
              new PropertyModel<Boolean>(property, "overridable")));
    }

    configuration.add(property);
  }
Exemplo n.º 29
0
  public AlertWidget(final String id) {
    super(id);
    this.latestAlerts = getLatestAlerts();

    setOutputMarkupId(true);

    final LoadableDetachableModel<Integer> size =
        new LoadableDetachableModel<Integer>() {

          private static final long serialVersionUID = 7474274077691068779L;

          @Override
          protected Integer load() {
            return AlertWidget.this.latestAlerts.getObject().size();
          }
        };

    final LoadableDetachableModel<List<T>> items =
        new LoadableDetachableModel<List<T>>() {

          private static final long serialVersionUID = 7474274077691068779L;

          @Override
          protected List<T> load() {
            final List<T> latest = AlertWidget.this.latestAlerts.getObject();
            return latest.subList(0, latest.size() < 6 ? latest.size() : 5);
          }
        };

    add(getIcon("icon"));

    linkAlertsNumber =
        new Label("alerts", size) {

          private static final long serialVersionUID = 4755868673082976208L;

          @Override
          protected void onComponentTag(final ComponentTag tag) {
            super.onComponentTag(tag);
            if (Integer.valueOf(getDefaultModelObject().toString()) > 0) {
              tag.put("class", "label label-danger");
            } else {
              tag.put("class", "label label-info");
            }
          }
        };
    add(linkAlertsNumber.setOutputMarkupId(true));

    headerAlertsNumber = new Label("number", size);
    headerAlertsNumber.setOutputMarkupId(true);
    add(headerAlertsNumber);

    latestAlertsList = new WebMarkupContainer("latestAlertsList");
    latestAlertsList.setOutputMarkupId(true);
    add(latestAlertsList);

    latestFive =
        new ListView<T>("latestAlerts", items) {

          private static final long serialVersionUID = 4949588177564901031L;

          @Override
          protected void populateItem(final ListItem<T> item) {
            item.add(getAlertLink("alert", item.getModelObject()).setRenderBodyOnly(true));
          }
        };
    latestAlertsList.add(latestFive.setReuseItems(false).setOutputMarkupId(true));

    add(getEventsLink("alertsLink"));
  }
 private static Label createRowSpanLabel(
     final String pId, final String pLabel, final AttributeModifier pRowSpan) {
   final Label ret = new Label(pId, pLabel);
   ret.add(pRowSpan);
   return ret;
 }