private List<IColumn<Foo, String>> createColumns() {
    List<IColumn<Foo, String>> columns = new ArrayList<IColumn<Foo, String>>();

    columns.add(new PropertyColumn<Foo, String>(Model.of("ID"), "id"));

    columns.add(new TreeColumn<Foo, String>(Model.of("Tree")));

    columns.add(
        new AbstractColumn<Foo, String>(Model.of("Depth")) {
          private static final long serialVersionUID = 1L;

          @Override
          public void populateItem(
              Item<ICellPopulator<Foo>> cellItem, String componentId, IModel<Foo> rowModel) {
            NodeModel<Foo> nodeModel = (NodeModel<Foo>) rowModel;

            cellItem.add(new Label(componentId, "" + nodeModel.getDepth()));
          }

          @Override
          public String getCssClass() {
            return "number";
          }
        });

    columns.add(new PropertyColumn<Foo, String>(Model.of("Bar"), "bar"));
    columns.add(new PropertyColumn<Foo, String>(Model.of("Baz"), "baz"));

    return columns;
  }
  /**
   * Construct.
   *
   * @param id the wicket component id
   */
  public FormGroup(final String id, final IModel<String> label, final IModel<String> help) {
    super(id, Model.of(""));

    this.labelModel = label;
    this.helpModel = help;
    stateClassName = Model.of("");
  }
  public TelefoneUsuarioPanel(String id) {
    super(id);

    add(new TextField<String>("telefone", Model.of("")));
    add(new Button("addTelefone", Model.of("")));
    add(new Button("removeTelefone", Model.of("")));
  }
 /**
  * Adds a SimpleAttributeModifier("title", ...) to the given component.
  *
  * @param component
  * @param title
  * @param text
  * @see #createTooltip(String, String)
  * @see #setStyleHasTooltip(Component)
  */
 public static Component addTooltip(
     final Component component,
     final String title,
     final String text,
     final boolean rightAlignment) {
   return addTooltip(component, Model.of(title), Model.of(text), rightAlignment);
 }
  /**
   * Returns a list of columns for the repository list
   *
   * @return Columns list
   */
  private List<IColumn<ImportableRemoteRepo>> getColumns() {
    List<IColumn<ImportableRemoteRepo>> columns = Lists.newArrayList();
    columns.add(
        new SelectAllCheckboxColumn<ImportableRemoteRepo>("", "selected", null) {
          @Override
          protected void onUpdate(
              FormComponent checkbox,
              ImportableRemoteRepo rowObject,
              boolean value,
              AjaxRequestTarget target) {
            super.onUpdate(checkbox, rowObject, value, target);
            // On each update, refresh import button to customize the warning messages of the call
            // decorator
            target.add(importButton);
          }

          @Override
          protected void onSelectAllUpdate(AjaxRequestTarget target) {
            target.add(importButton);
          }
        });
    columns.add(new KeyTextFieldColumn());
    columns.add(
        new TooltipLabelColumn<ImportableRemoteRepo>(Model.of("URL"), "repoUrl", "repoUrl", 50));
    columns.add(
        new TooltipLabelColumn<ImportableRemoteRepo>(
            Model.of("Description"), "repoDescription", "repoDescription", 25));
    return columns;
  }
 public AddressPanel(final String id, final IModel<HomeAddress> model) {
   super(id, model);
   setOutputMarkupId(true);
   add(
       streetNumberPanel =
           newStreetNumberPanel("streetNumberPanel", Model.of("Street / number:")));
   add(zipcodeCityPanel = newZipcodeCityPanel("zipcodeCityPanel", Model.of("Zip / City:")));
 }
  /** Constructor. */
  public CodeBehavior() {
    super();

    lineNumbers = Model.of(false);
    cssClassNameModel = Model.of("");
    language = Model.of(Language.DYNAMIC);
    from = Model.of(0);

    cssClassNameAppender = new CssClassNameAppender(cssClassNameModel);
  }
 public TestCaptchaRatingPanel(String id) {
   super(
       id,
       Model.of(5),
       Model.of(5),
       Model.of(5),
       Model.of(Boolean.FALSE),
       true,
       new BubblePanel("id"));
 }
  public GlossResultsSeparatedPanel(String id, IModel<List<SegmentedWord>> model) {
    super(id, model);

    Form<List<SegmentedWord>> form = new Form<>("form", model);
    add(form);

    Border textBorder =
        new HeaderPanel(
            "text",
            hid ->
                new HeaderButtonTitlePanel(
                    hid,
                    Model.of("Text"),
                    bid ->
                        new EditButton(bid, new ResourceModel("label.edit")).setSize(Size.Small)));
    form.add(textBorder);

    textBorder.add(
        new ListView<>(
            "text",
            model,
            item -> {
              ExternalLink link =
                  new ExternalLink(
                      "word",
                      Model.of("#def_link_" + item.getIndex()),
                      new LambdaModel<>(
                          item.getModel(), new OptionalFunction<>(SegmentedWord.FUNCTION_TEXT)));
              link.add(
                  new EnabledModelBehavior(
                      new SupplierModel<>(() -> item.getModelObject().hasDefinition())));
              link.setMarkupId("word_link_" + item.getIndex());
              item.add(link);
            }));

    Border defBorder = new HeaderPanel("defs", Model.of("Definitions"));
    form.add(defBorder);

    defBorder.add(
        new ListView<>(
            "defs",
            model,
            item ->
                item.add(
                        new WordPartsListPanel(
                            "def",
                            item.getModel(),
                            new SupplierModel<>(() -> "#word_link_" + item.getIndex())))
                    .setMarkupId("def_link_" + item.getIndex())
                    .add(
                        new VisibleModelBehavior(
                            new SupplierModel<>(() -> item.getModelObject().hasDefinition())))));
  }
 /**
  * Uses "jiraSupportTooltipImage" as component id.
  *
  * @param parent only needed for localization
  * @param id
  * @return IconPanel which is invisible if JIRA isn't configured.
  */
 public static IconPanel getJIRASupportTooltipIcon(final Component parent, final String id) {
   final IconPanel icon =
       new IconPanel(
           id,
           IconType.JIRA_SUPPORT,
           Model.of(parent.getString("tooltip.jiraSupport.field.title")),
           Model.of(parent.getString("tooltip.jiraSupport.field.content")));
   if (isJIRAConfigured() == false) {
     icon.setVisible(false);
   }
   return icon;
 }
    public VistaHorasForm(String id) {
      super(id);
      this.setDefaultModel(modeloHoras);
      this.setOutputMarkupId(true);

      this.fechaDesde =
          new DropDownChoice<String>(
              "fechaDesde", Model.of("7/2013"), VistaHorasPage.this.fechasModel);

      this.fechaDesde.add(
          new AjaxFormComponentUpdatingBehavior("onchange") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {

              VistaHorasPage.this.lstUsuariosModel.detach();
              VistaHorasPage.this.lstUsuariosEnRojoModel.detach();
              String seleccionado = fechaDesde.getModelObject();
              List<String> fechas = Arrays.asList(seleccionado.split("/"));
              int dia = 1;
              int mes = Integer.parseInt(fechas.get(0));
              int anio = Integer.parseInt(fechas.get(1));
              VistaHorasPage.this.desde = new LocalDate(anio, mes, dia).toDate();
              target.add(VistaHorasPage.this.listViewContainer);
            }
          });
      this.fechaDesde.setOutputMarkupId(true);
      List<String> sectores = new ArrayList<String>();
      sectores.add("TI");
      sectores.add("E&P");
      sectores.add("Administracion");
      sectores.add("ExOdea");
      sectores.add("Todos");
      sectores.add("Ninguno");
      sector = new DropDownChoice<String>("sector", Model.of("Todos"), sectores);
      sector.add(
          new AjaxFormComponentUpdatingBehavior("onchange") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
              VistaHorasPage.this.lstUsuariosModel.detach();
              VistaHorasPage.this.lstUsuariosEnRojoModel.detach();
              VistaHorasPage.this.sectorGlobal = sector.getModelObject();
              target.add(VistaHorasPage.this.listViewContainer);
            }
          });
      add(fechaDesde);
      add(sector);
    }
  /**
   * Defines an {@link AddCommentPanel} object of a file or an album, either album or file must be
   * null, but not both.
   *
   * @param id This panel {@code wicket:id}
   * @param commentsPanel Comment panel, to reload it on adding comments, it can be {@code null}
   * @param album The {@link #album}, or {@code null} for a file panel
   * @param file The {@link #file}, or {@code null} for an album panel
   */
  private AddCommentPanel(String id, ShowCommentsPanel commentsPanel, Album album, File file) {
    super(id);
    this.album = album;
    this.file = file;

    final ShowCommentsPanel showCommentsPanel = commentsPanel;
    final TextArea<String> text = new TextArea<String>("text", Model.of(""));
    text.setRequired(true);

    Form<Void> form =
        new Form<Void>("addCommentForm") {
          @Override
          protected void onSubmit() {
            String textString = cleanComment(text.getModelObject());
            if (validateComment(textString)) {
              createComment(textString);
              if (showCommentsPanel != null) {
                showCommentsPanel.reload();
              }
            }
            setResponsePage(this.getPage());
          }
        };
    add(form);
    form.add(text);
    form.add(new Label("maxLength", String.valueOf(Comment.MAX_TEXT_LENGTH)));
  }
public class ImportServiceTable extends BaseDataTable<ServiceReference> {

  private static final long serialVersionUID = 1L;

  @SuppressWarnings("unchecked")
  private static IColumn<ServiceReference, String>[] columns =
      new IColumn[] {
        new ServicePropertyColumn("Service Id", Constants.SERVICE_ID),
        new ObjectClassColumn(Model.of("Object classes")),
        new ServiceProviderColumn(Model.of("Provider")),
      };

  public ImportServiceTable(String id, Bundle bundle) {
    super(id, Arrays.asList(columns), new ImportServiceDataProvider(bundle), Integer.MAX_VALUE);
  }
}
Exemple #14
0
    private CaptchaRatingPanel newRatingPanel() {
      IModel<Integer> calculatedRatingModel =
          new PropertyModel<Integer>(downloadModel, "calculatedRating");
      IModel<Integer> numberOfVotesModel =
          new PropertyModel<Integer>(downloadModel, "numberOfVotes");
      return new CaptchaRatingPanel(
          "vote",
          calculatedRatingModel,
          Model.of(5),
          numberOfVotesModel,
          hasVoted,
          true,
          getBubblePanel()) {
        private static final long serialVersionUID = 1L;

        @Override
        protected boolean onIsStarActive(int star) {
          Download download = downloadModel.getObject();
          return star < ((int) (download.getCalculatedRating() + 0.5));
        }

        @Override
        protected void onRatedAndCaptchaValidated(int rating, AjaxRequestTarget target) {
          Download download = downloadModel.getObject();
          hasVoted.setObject(Boolean.TRUE);
          downloadService.rateDownload(rating, download);
        }

        @Override
        public boolean isEnabled() {
          return isAllowedToVote();
        }
      };
    }
  @Override
  protected WebMarkupContainer newContent(String markupId) {
    Fragment fragment = new Fragment(markupId, "tooltip-fragment", markupProvider);
    fragment.add(new Label("content", Model.of(this.content)));

    return fragment;
  }
  public SearchBookForm(String id, String action) {
    super(id);
    this.action = action;
    setDefaultModel(new CompoundPropertyModel<SearchBookForm>(this));

    TextField<String> title = new TextField<>("title");
    title.setLabel(Model.of("Title"));
    add(title);

    TextField<String> author = new TextField<>("author");
    author.setLabel(Model.of("Author"));
    author.setRequired(false);
    add(author);

    add(new Button("searchBookSubmit"));
  }
    @Override
    protected TextField<String> newTextField(
        String id, IModel<String> valueModel, final ImportableRemoteRepo rowObject) {
      TextField<String> textField = super.newTextField(id, valueModel, rowObject);
      textField.setLabel(Model.of("Key"));
      textField.setOutputMarkupId(true);
      textField.setRequired(true);
      textField.add(new NameValidator("Invalid repository key '%s'."));
      textField.add(new XsdNCNameValidator("Invalid repository key '%s'."));
      textField.add(
          new AjaxFormComponentUpdatingBehavior("onkeyup") {
            @Override
            protected void onUpdate(AjaxRequestTarget target) {
              validateRepoKey(rowObject);
              // On each update, refresh import button to customize the warning messages of the call
              // decorator
              target.add(importButton);
            }

            @Override
            protected void onError(AjaxRequestTarget target, RuntimeException e) {
              super.onError(target, e);
              AjaxUtils.refreshFeedback();
            }

            @Override
            protected IAjaxCallDecorator getAjaxCallDecorator() {
              return new NoAjaxIndicatorDecorator();
            }
          });
      return textField;
    }
  /**
   * Constructor.
   *
   * @param pageParameters the page parameters
   */
  public EditTemplateFamilyPage(PageParameters pageParameters) {

    final TemplateFamily family = PapyrosDataUtil.loadTemplateFamily(pageParameters);
    oldKey = family.getKey();

    BookmarkablePageLink<?> templateFamilyLink =
        new BookmarkablePageLink<>(
            "templateFamilyLink",
            TemplateFamilyPage.class,
            new PageParameters().add("key", family.getKey()));
    templateFamilyLink.add(new Label("templateFamilyName", family.getName()));
    add(templateFamilyLink);

    BeanStandardFormPanel<TemplateFamily> stdform =
        new BeanStandardFormPanel<TemplateFamily>("stdform", Model.of(family), true) {
          @Override
          protected void onSubmit() {
            String newKey = getBean().getKey();
            String newName = getBean().getName();
            QTemplateFamily qtf = QTemplateFamily.templateFamily;
            SQLUpdateClause update = EntityConnectionManager.getConnection().createUpdate(qtf);
            update.set(qtf.key, newKey).set(qtf.name, newName).where(qtf.key.eq(oldKey));
            try {
              update.execute();
              setResponsePage(TemplateFamilyPage.class, new PageParameters().add("key", newKey));
            } catch (QueryException e) {
              keyComponent.error("could not change key");
            }
          };
        };
    keyComponent = stdform.addTextField("Key", "key").setRequired().getFormComponent();
    stdform.addTextField("Name", "name").setRequired();
    stdform.addSubmitButton();
    add(stdform);
  }
 /** Constructor. */
 public CreateTemplateFamilyPage() {
   add(new BookmarkablePageLink<>("templateFamilyListLink", TemplateFamilyListPage.class));
   BeanStandardFormPanel<TemplateFamily> stdform =
       new BeanStandardFormPanel<TemplateFamily>("stdform", Model.of(new TemplateFamily()), true) {
         @Override
         protected void onSubmit() {
           TemplateFamily templateFamily = getBean();
           try {
             templateFamily.insert();
           } catch (QueryException e) {
             System.out.println(e);
           }
           if (templateFamily.getId() == null) {
             keyComponent.error("could not create template family");
           } else {
             setResponsePage(
                 TemplateFamilyPage.class,
                 new PageParameters().add("key", templateFamily.getKey()));
           }
         };
       };
   keyComponent = stdform.addTextField("Key", "key").setRequired().getFormComponent();
   stdform.addTextField("Name", "name").setRequired();
   stdform.addSubmitButton();
   add(stdform);
 }
Exemple #20
0
  public HomePage(PageParameters parameters) {
    super(parameters);

    recentWords =
        new HeaderPanel("panel", cid -> new ActivityHeaderPanel(cid))
            .add(new Label("title", new ResourceModel("label.recently_added_words")))
            .add(
                new ActivityPanel(
                    "activity",
                    Model.of(new WordDetailSearchCriteria()),
                    new SupplierModel<>(
                        () -> ZhGlossSession.get().getUserSettings().getTranscriptionSystem()),
                    20));
    add(recentWords);

    add(
        new BootstrapBookmarkablePageLink<>("dictionaryLink", DictionaryPage.class, Type.Menu)
            .setIconType(Icons.ICON_DICTIONARY)
            .setLabel(new ResourceModel("label.dictionary"))
            .setSize(Size.Large));
    add(new Label("dictionaryDescription", new ResourceModel("dictionaryDescription")));

    add(
        new BootstrapBookmarkablePageLink<>("glossLink", GlossPage.class, Type.Menu)
            .setIconType(Icons.ICON_GLOSS)
            .setLabel(new ResourceModel("label.gloss"))
            .setSize(Size.Large));
    add(new Label("glossDescription", new ResourceModel("glossDescription")));
  }
  @Override
  protected void onInitialize() {
    super.onInitialize();

    TextField<String> userinput = new TextField<String>("userinput", Model.of(""));
    userinput.add(
        new AjaxFormSubmitBehavior("onchange") {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onSubmit(AjaxRequestTarget target) {}

          @Override
          protected void onError(AjaxRequestTarget target) {}

          @Override
          protected IAjaxCallDecorator getAjaxCallDecorator() {
            super.getAjaxCallDecorator();
            return new MyAjaxCallDecorator();
          }
        });

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

    form.add(userinput);

    AjaxRequestTarget.get();
    getPageParameters();
  }
 @Test
 public void testBasic3() {
   testButton(
       new WicketTester(),
       new FoundationTestAjaxLink("btn", Model.of("foo"), new ButtonOptions()),
       new ArrayList<String>());
 }
  /**
   * 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));
  }
  private void addSaveResultsForm() {
    Form form = new SecureForm("saveResultsForm");
    messageModel = Model.of();
    form.add(new TooltipBehavior(messageModel));
    add(form);

    form.add(
        new HelpBubble(
            "help",
            "The name of the search result to use.\n"
                + "By saving and assembling named search results, you can perform bulk artifact operations."));

    form.add(newResultCombo("resultName"));

    Component saveResultsLink = createSaveResultsLink("saveResultsLink", "Save");
    form.add(saveResultsLink);

    Component addResultsLink = createAddResultsLink("addResultsLink", "Add");
    form.add(addResultsLink);

    form.add(createSubtractResultsLink("subtractResultsLink", "Subtract"));
    form.add(createIntersectResultsLink("intersectResultsLink", "Intersect"));

    form.add(new DefaultSubmit("defaultSubmit", saveResultsLink, addResultsLink));

    addAdditionalFields(form);

    postInit();
  }
  public TweetBoxBehaviorPage() {
    super();

    final WebMarkupContainer tb = new WebMarkupContainer("tb");
    tb.add(new TweetBoxBehavior("RLVad4j5xse3QwL06eEg", Model.of("Test Tweet"), 400, 300));

    add(tb);
  }
 public static void addTargetBlankIfActionReturnsUrl(
     final AbstractLink link, final ObjectAction action) {
   final ObjectSpecification returnType = action.getReturnType();
   if (returnType != null && "java.net.URL".equals(returnType.getFullIdentifier())) {
     link.add(new AttributeAppender("target", Model.of("_blank")));
     link.add(new CssClassAppender("noVeil"));
   }
 }
Exemple #27
0
  @Test
  public void toStringNeverFails() {
    IModel<B> model = model(from(A.class).getB()).bind(Model.of((A) null));

    // targetType is unknown, thus #getPath() fails - but #toString()
    // catches all exceptions anyway
    assertEquals("", model.toString());
  }
  protected void constructPanel() {
    Form<AgentPortalCustomCashInConfirmPanel> form =
        new Form<AgentPortalCustomCashInConfirmPanel>(
            "cashInConfirmForm",
            new CompoundPropertyModel<AgentPortalCustomCashInConfirmPanel>(this));

    form.add(new FeedbackPanel("errorMessages"));

    form.add(new Label("cashInBean.accountNumber"));
    form.add(new Label("cashInBean.msisdn"));
    form.add(new Label("cashInBean.displayName"));
    form.add(new AmountLabel("cashInBean.cashinAmount", true, true));

    // Add Confirm button
    Button confirmButton =
        new Button("submitConfirm") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            if (!PortalUtils.exists(cashInBean)) {
              cashInBean = new AgentCustomCashInBean();
            }

            performCashIn();
          };
        };

    confirmButton.add(new AttributePrepender("onclick", Model.of("loading(submitConfirm)"), ";"));

    form.add(confirmButton);

    // Add Back button
    form.add(
        new Button("submitBack") {

          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            setResponsePage(new AgentPortalCustomCashInPage());
          };
        });

    // Add Cancel button
    form.add(
        new Button("submitCancle") {

          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            basePage.handleCancelButtonRedirectToHomePage(AgentPortalHomePage.class);
          };
        });

    add(form);
  }
Exemple #29
0
 private void redirectToCreateDownloadPage() {
   // link from upload center
   if (isCreateLinkFromUploadCenter() && isAuthor()) {
     Download newDownload = downloadService.newDownloadEntity();
     newDownload.setUrl(params.getString("create"));
     IModel<Download> downloadModel = Model.of(newDownload);
     setResponsePage(new DownloadEditPage(downloadModel));
   }
 }
  /** Adds the dependencies table */
  protected void addTable() {
    List<IColumn<ModuleDependencyActionableItem>> columns = Lists.newArrayList();
    columns.add(new ActionsColumn<ModuleDependencyActionableItem>(""));
    columns.add(
        new ModuleDependencyPropertyColumn(Model.of("ID"), "dependency.id", "dependency.id"));
    columns.add(
        new ModuleDependencyGroupableColumn(
            Model.of("Scopes"), "dependencyScope", "dependencyScope"));
    columns.add(
        new ModuleDependencyPropertyColumn(Model.of("Type"), "dependency.type", "dependency.type"));
    columns.add(
        new ModuleDependencyPropertyColumn(
            Model.of("Repo Path"), null, "repoPathOrMissingMessage"));

    add(
        new GroupableTable<ModuleDependencyActionableItem>(
            "dependencies", columns, new ModuleDependenciesDataProvider(), 10));
  }