public void updateChoices(boolean reportError, Form<?> form) {
   final String repoUriStr = repositoryUriModel.getObject();
   if (REPOSITORY.sample != null && REPOSITORY.sample.equals(repoUriStr)) {
     return;
   }
   List<String> branchNames = new ArrayList<>();
   if (repoUriStr != null) {
     try {
       RepositoryManager manager = this.manager.get();
       URI repoURI = new URI(repoUriStr);
       RepositoryResolver resolver = RepositoryResolver.lookup(repoURI);
       String repoName = resolver.getName(repoURI);
       RepositoryInfo repoInfo = manager.getByRepoName(repoName);
       String repoId = repoInfo.getId();
       List<Ref> branchRefs = manager.listBranches(repoId);
       for (Ref branch : branchRefs) {
         branchNames.add(branch.localName());
       }
     } catch (IOException | URISyntaxException e) {
       if (reportError) {
         form.error("Could not list branches: " + e.getMessage());
       }
       branchNames = new ArrayList<String>();
     }
     String current = (String) choice.getModelObject();
     if (current != null && !branchNames.contains(current)) {
       branchNames.add(0, current);
     }
   }
   choice.setChoices(branchNames);
 }
 @Override
 public void convertInput() {
   choice.processInput();
   String branch = choice.getConvertedInput();
   setModelObject(branch);
   setConvertedInput(branch);
 }
  private void addProcessSelect(Form<Void> layoutForm) {
    processNameList = new ArrayList<String>();
    for (SushiProcess process : SushiProcess.findAll()) {
      processNameList.add(process.getName());
    }

    processSelect =
        new DropDownChoice<String>("processSelect", new Model<String>(), processNameList);
    processSelect.setOutputMarkupId(true);
    processSelect.add(
        new AjaxFormComponentUpdatingBehavior("onchange") {

          private static final long serialVersionUID = 1L;

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            process =
                SushiProcess.findByName(
                        processSelect.getChoices().get(Integer.parseInt(processSelect.getValue())))
                    .get(0);
            createProcessInstanceMonitoringProvider();
            target.add(dataTable);
          }
        });

    layoutForm.add(processSelect);
  }
  public BranchSelectionPanel(
      String id,
      IModel<String> repositoryUriModel,
      IModel<String> branchNameModel,
      Form<DataStoreInfo> storeEditForm) {
    super(id, branchNameModel);
    this.repositoryUriModel = repositoryUriModel;

    final List<String> choices = new ArrayList<String>();
    choice = new DropDownChoice<String>("branchDropDown", branchNameModel, choices);
    choice.setOutputMarkupId(true);
    choice.setNullValid(true);
    choice.setRequired(false);
    add(choice);
    updateChoices(false, null);

    final AjaxSubmitLink refreshLink =
        new AjaxSubmitLink("refresh", storeEditForm) {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onError(AjaxRequestTarget target, Form<?> form) {
            onSubmit(target, form);
          }

          @Override
          protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            updateChoices(true, form);
            target.add(BranchSelectionPanel.this.choice);
          }
        };
    add(refreshLink);
  }
Esempio n. 5
0
  @Override
  public void registerFilters(DataTable<?> table, IModel<UserFilter> filterModel) {
    super.registerFilters(table, filterModel);

    List<Boolean> choises = Arrays.asList(Boolean.FALSE, Boolean.TRUE);
    DropDownChoice<Boolean> assignedFilter =
        new DropDownChoice<Boolean>(
            "assignedFilter",
            new PropertyModel<Boolean>(filterModel, UserFilter.FIELD_ASSIGNED),
            choises) {
          @Override
          protected String getNullValidDisplayValue() {
            return getString("assigned.nullValid");
          }
        };
    assignedFilter.setChoiceRenderer(
        new ChoiceRenderer<Boolean>() {
          @Override
          public Object getDisplayValue(Boolean object) {
            String key = "assigned." + object.toString();
            return getString(key);
          }
        });
    assignedFilter.setNullValid(true);
    addFilter(assignedFilter, new ResourceModel("user.assigned"));
  }
  public WorkspaceSwitcher(String id, IModel<Workspace> model) {
    super(id, model);

    IModel<List<? extends Workspace>> workspaceModel =
        new LoadableDetachableModel<List<? extends Workspace>>() {
          @Override
          protected List<? extends Workspace> load() {
            return getWorkspaces();
          }
        };
    DropDownChoice<Workspace> choice =
        new DropDownChoice<Workspace>("workspaces", model, workspaceModel, new Renderer()) {
          @Override
          protected boolean wantOnSelectionChangedNotifications() {
            return true;
          }

          @Override
          protected void onSelectionChanged(Workspace newSelection) {
            detach();
            super.onSelectionChanged(newSelection);
          }
        };
    choice.setNullValid(false);
    add(choice);
  }
Esempio n. 7
0
    public EnterGameForm(String id, IModel model) {
      super(id, model);

      Game game = (Game) getModelObject();
      Week week = game.getWeek();
      // LeagueType leagueType = week.getLeagueType();
      // List<Team> teams = teamManager.getTeamsByLeagueType(leagueType);
      List<Team> teams = teamManager.getUnenteredTeamsForWeek(week);
      final DropDownChoice fav =
          new DropDownChoice("fav", teams, new ChoiceRenderer("fullTeamName", "id"));
      fav.setRequired(true);
      add(fav);

      final DropDownChoice dog =
          new DropDownChoice("dog", teams, new ChoiceRenderer("fullTeamName", "id"));
      dog.setRequired(true);
      add(dog);

      RequiredTextField spread = new RequiredTextField("spread", Double.class);
      add(spread);

      CheckBox favHome = new CheckBox("favHome");
      add(favHome);

      add(new DateTimeField("gameStart"));

      add(new Button("submit"));
    }
 private void buildGenderInput() {
   genderInput =
       new DropDownChoice<Gender>(
           "gender", Arrays.asList(Gender.values()), new EnumChoiceRenderer<Gender>(this));
   genderInput.setNullValid(true);
   genderInput.setOutputMarkupId(true);
   form.add(genderInput);
 }
 private void buildCountryInput() {
   countryInput =
       new DropDownChoice<Country>(
           "country", Arrays.asList(Country.values()), new EnumChoiceRenderer<Country>(this));
   countryInput.setNullValid(true);
   countryInput.setOutputMarkupId(true);
   form.add(countryInput);
 }
 private void buildNationalityInput() {
   nationalityInput =
       new DropDownChoice<Nationality>(
           "nationality",
           Arrays.asList(Nationality.values()),
           new EnumChoiceRenderer<Nationality>(this));
   nationalityInput.setNullValid(true);
   nationalityInput.setOutputMarkupId(true);
   form.add(nationalityInput);
 }
Esempio n. 11
0
    private void initLayout() {
      final Form searchForm = new Form(ID_SEARCH_FORM);
      add(searchForm);
      searchForm.setOutputMarkupId(true);

      final IModel<ReportOutputSearchDto> model = (IModel) getDefaultModel();

      BasicSearchPanel<ReportOutputSearchDto> basicSearch =
          new BasicSearchPanel<ReportOutputSearchDto>(ID_BASIC_SEARCH, model) {

            @Override
            protected IModel<String> createSearchTextModel() {
              return new PropertyModel<String>(model, UsersDto.F_TEXT);
            }

            @Override
            protected void searchPerformed(AjaxRequestTarget target) {
              PageCreatedReports page = (PageCreatedReports) getPage();
              page.searchPerformed(target);
            }

            @Override
            protected void clearSearchPerformed(AjaxRequestTarget target) {
              PageCreatedReports page = (PageCreatedReports) getPage();
              page.clearSearchPerformed(target);
            }
          };
      searchForm.add(basicSearch);

      DropDownChoice reportTypeSelect =
          new DropDownChoice(
              ID_REPORT_TYPE_SELECT,
              new PropertyModel(model, ReportOutputSearchDto.F_REPORT_TYPE),
              new PropertyModel(model, ReportOutputSearchDto.F_REPORT_TYPES),
              new ChoiceRenderer()) {

            @Override
            protected String getNullValidDisplayValue() {
              return getString("pageCreatedReports.filter.reportType");
            }
          };
      reportTypeSelect.add(
          new OnChangeAjaxBehavior() {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
              PageCreatedReports page = (PageCreatedReports) getPage();
              page.searchPerformed(target);
            }
          });
      reportTypeSelect.setOutputMarkupId(true);
      reportTypeSelect.setNullValid(true);
      searchForm.add(reportTypeSelect);
    }
Esempio n. 12
0
  protected void createDepartmentInput(Form<T> form) {
    Fragment f = new Fragment("dept", "department", this);

    DropDownChoice<UserDepartment> userDepartment =
        new DropDownChoice<UserDepartment>(
            "user.userDepartment",
            getUserDepartments(),
            new ChoiceRenderer<UserDepartment>("name"));
    userDepartment.setRequired(true);
    userDepartment.setLabel(new ResourceModel("admin.user.department"));
    userDepartment.add(new ValidatingFormComponentAjaxBehavior());
    f.add(userDepartment);
    f.add(new AjaxFormComponentFeedbackIndicator("departmentValidationError", userDepartment));
    form.add(f);
  }
Esempio n. 13
0
  private void initLayout() {
    IModel data = new PropertyModel(getModel(), SearchValue.F_VALUE);

    final DisplayableRenderer renderer = new DisplayableRenderer(choices);
    final DropDownChoice input =
        new DropDownChoice(ID_COMBO_INPUT, data, choices, renderer) {

          @Override
          public IConverter getConverter(Class type) {
            return renderer;
          }
        };
    input.setNullValid(true);
    input.setOutputMarkupId(true);
    add(input);
  }
 public void validate(Form<?> form) {
   String commonName = this.commonNameTextField.getInput();
   if (commonName != null) {
     commonName = commonName.toLowerCase();
     if (commonNameTextField.getModelObject() != null
         && commonName.equals(commonNameTextField.getModelObject().toLowerCase())) return;
     for (TransferCapability transferCapability :
         this.applicationEntity.getTransferCapabilities()) {
       if (transferCapability.getCommonName() != null
           && commonName.equals(transferCapability.getCommonName().toLowerCase()))
         commonNameTextField.error(
             new StringResourceModel("TransferCapabilityValidator.commonName.invalid", form, null)
                 .getObject());
     }
   }
   String sopClass = this.sopClassTextField.getInput();
   String role = this.roleDropDown.getInput().equals("0") ? "SCP" : "SCU";
   if (sopClass.equals(sopClassTextField.getModelObject())
       && role.equals(roleDropDown.getModelObject().name())) return;
   for (TransferCapability transferCapability : this.applicationEntity.getTransferCapabilities()) {
     if (sopClass.equals(transferCapability.getSopClass())
         && role.equals(transferCapability.getRole().name()))
       sopClassTextField.error(
           new StringResourceModel("TransferCapabilityValidator.sopClass-role.invalid", form, null)
               .getObject());
   }
 }
  @SuppressWarnings("unchecked")
  public void testDemoListLoaded() {
    // print(tester.getLastRenderedPage(), true, true);

    /*
     * Expected choices are the file names in the demo requests dir
     * (/src/test/resources/test-data/demo-requests in this case)
     */
    final List<String> expectedList =
        Arrays.asList(new String[] {"WFS_getFeature-1.1.xml", "WMS_describeLayer.url"});

    DropDownChoice dropDown =
        (DropDownChoice)
            tester.getComponentFromLastRenderedPage("demoRequestsForm:demoRequestsList");
    List choices = dropDown.getChoices();
    assertEquals(expectedList, choices);
  }
Esempio n. 16
0
  private static DropDownChoice<Double> createNotenDropDown(
      String id, final ListItem<ICourse> item, Optional<Double> note) {
    final IModel<Double> noteModel = note.isPresent() ? Model.of(note.get()) : Model.<Double>of();
    DropDownChoice<Double> dropDownNoten = new DropDownChoice<Double>(id, noteModel, NOTEN_LIST);
    dropDownNoten.add(
        new OnChangeAjaxBehavior() {

          private static final long serialVersionUID = 1L;

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            item.getModelObject().setGrade(noteModel.getObject());
            getComponent()
                .send(getComponent().getPage(), Broadcast.DEPTH, new GradeChangedEvent(target));
          }
        });
    return dropDownNoten;
  }
Esempio n. 17
0
    @Override
    protected void onSubmit() {
      Game game = (Game) getModelObject();
      Week week = game.getWeek();
      //			gameManager.insertGame(game);
      gameManager.createUpdateGame(game);

      Game newGame = new Game();
      newGame.setWeek(week);
      //			setModelObject(new CompoundPropertyModel(newGame));

      List<Team> teams = teamManager.getUnenteredTeamsForWeek(week);
      DropDownChoice fav = (DropDownChoice) get("fav");
      fav.setChoices(teams);

      DropDownChoice dog = (DropDownChoice) get("dog");
      dog.setChoices(teams);

      getModel().detach();
    }
Esempio n. 18
0
  private void initAudit() {
    CheckBox auditLog =
        WebComponentUtil.createAjaxCheckBox(
            "auditLog", new PropertyModel<Boolean>(getModel(), "auditLog"));
    add(auditLog);

    CheckBox auditDetails =
        WebComponentUtil.createAjaxCheckBox(
            "auditDetails", new PropertyModel<Boolean>(getModel(), "auditDetails"));
    add(auditDetails);

    DropDownChoice<String> auditAppender =
        new DropDownChoice<>(
            "auditAppender",
            new PropertyModel<String>(getModel(), "auditAppender"),
            createAppendersListModel());
    auditAppender.setNullValid(true);
    auditAppender.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(auditAppender);
  }
    protected void onSubmit() {
      userController = new RegisteredUserController();
      String passwordCheck = password.getModelObjectAsString();
      String passwordAgainCheck = passwordAgain.getModelObjectAsString();

      if (passwordCheck != null && passwordAgainCheck != null && passwordCheck != "")
        if (checkPassword(passwordCheck, passwordAgainCheck)) {

          user.setName(name.getModelObjectAsString());
          user.setSurname(surname.getModelObjectAsString());
          user.setLogin(login.getModelObjectAsString());
          user.setPassword(password.getModelObjectAsString());
          user.setEmail(email.getModelObjectAsString());

          //					user.setRegion(region.getModelObjectAsString());
          user.setTown(new CountyController().getCountyByName(town.getModelObjectAsString()));
          user.setHandicapType(
              new HandicapTypeController()
                  .getHandicapByName(handicapType.getModelObjectAsString()));
          user.setPreferRegion(Boolean.valueOf(preferRegion.getModelObjectAsString()));

          if (userController.updateUser(user)) feedbackPanel.info("Úspešne uložené");
          else feedbackPanel.warn("Problem occured");
        } else feedbackPanel.warn("Nerovnaké heslá");
      else if (passwordCheck == "" || passwordAgainCheck == "") {
        user.setName(name.getModelObjectAsString());
        user.setSurname(surname.getModelObjectAsString());
        user.setLogin(login.getModelObjectAsString());
        user.setEmail(email.getModelObjectAsString());

        //				user.setRegion(region.getModelObjectAsString());
        user.setTown(new CountyController().getCountyByName(town.getModelObjectAsString()));
        user.setHandicapType(
            new HandicapTypeController().getHandicapByName(handicapType.getModelObjectAsString()));
        user.setPreferRegion(Boolean.valueOf(preferRegion.getModelObjectAsString()));

        if (userController.updateUser(user)) feedbackPanel.info("Úspešne uložené");
        else feedbackPanel.warn("Problem occured");
      }
      userController = null;
    }
Esempio n. 20
0
  private void initRoot() {
    DropDownChoice<LoggingLevelType> rootLevel =
        new DropDownChoice<>(
            ID_ROOT_LEVEL,
            new PropertyModel<LoggingLevelType>(getModel(), LoggingDto.F_ROOT_LEVEL),
            WebComponentUtil.createReadonlyModelFromEnum(LoggingLevelType.class));
    rootLevel.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(rootLevel);

    DropDownChoice<String> rootAppender =
        new DropDownChoice<>(
            ID_ROOT_APPENDER,
            new PropertyModel<String>(getModel(), LoggingDto.F_ROOT_APPENDER),
            createAppendersListModel());
    rootAppender.setNullValid(true);
    rootAppender.add(
        new OnChangeAjaxBehavior() {

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            rootAppenderChangePerformed(target);
          }
        });
    rootAppender.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(rootAppender);
  }
Esempio n. 21
0
  /** Constructor. */
  public ChoicePage() {
    modelsMap.put("AUDI", Arrays.asList("A4", "A6", "TT"));
    modelsMap.put("CADILLAC", Arrays.asList("CTS", "DTS", "ESCALADE", "SRX", "DEVILLE"));
    modelsMap.put("FORD", Arrays.asList("CROWN", "ESCAPE", "EXPEDITION", "EXPLORER", "F-150"));

    IModel<List<? extends String>> makeChoices =
        new AbstractReadOnlyModel<List<? extends String>>() {
          private static final long serialVersionUID = 3083223353505563226L;

          @Override
          public List<String> getObject() {
            return new ArrayList<String>(modelsMap.keySet());
          }
        };

    IModel<List<? extends String>> modelChoices =
        new AbstractReadOnlyModel<List<? extends String>>() {
          private static final long serialVersionUID = -582253860769928261L;

          @Override
          public List<String> getObject() {
            List<String> models = modelsMap.get(selectedMake);
            if (models == null) {
              models = Collections.emptyList();
            }
            return models;
          }
        };

    Form<?> form = new Form("formid");
    add(form);

    final DropDownChoice<String> makes =
        new DropDownChoice<String>(
            "makes", new PropertyModel<String>(this, "selectedMake"), makeChoices);

    final DropDownChoice<String> models =
        new DropDownChoice<String>("models", new Model<String>(), modelChoices);
    models.setOutputMarkupId(true);
    final DropDownChoice<String> models2 =
        new DropDownChoice<String>("models2", new Model<String>(), modelChoices);
    models2.setOutputMarkupId(true);

    form.add(makes);
    form.add(models);
    form.add(models2);

    makes.add(
        new AjaxFormComponentUpdatingBehavior("onchange") {
          private static final long serialVersionUID = -4971073888222316420L;

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            target.add(models);
            target.add(models2);
          }
        });
  }
Esempio n. 22
0
 /*
  * (non-Javadoc)
  *
  * @see au.org.theark.core.web.form.AbstractDetailForm#attachValidators()
  */
 @Override
 protected void attachValidators() {
   areaCodeTxtFld.add(StringValidator.maximumLength(10));
   phoneTypeChoice
       .setRequired(true)
       .setLabel(
           (new StringResourceModel(
               "phone.phoneType.required", this, new Model<String>("Phone Type"))));
   phoneNumberTxtFld
       .setRequired(true)
       .setLabel(
           (new StringResourceModel(
               "phone.phoneNumber.required", this, new Model<String>("Phone Number"))));
   phoneStatusChoice
       .setRequired(true)
       .setLabel(
           (new StringResourceModel(
               "phone.phoneStatus.required", this, new Model<String>("Phone Status"))));
   phoneNumberTxtFld.add(StringValidator.maximumLength(20));
   dateReceivedDp
       .add(DateValidator.maximum(new Date()))
       .setLabel(new StringResourceModel("phone.dateReceived.DateValidator.maximum", this, null));
 }
    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);
    }
Esempio n. 24
0
  public void initialiseDetailForm() {
    phoneIdTxtFld = new TextField<String>("phoneVo.phone.id");
    areaCodeTxtFld = new TextField<String>("phoneVo.phone.areaCode");
    phoneNumberTxtFld = new TextField<String>("phoneVo.phone.phoneNumber");

    source = new TextField<String>("phoneVo.phone.source");
    commentsTxtArea = new TextArea<String>("phoneVo.phone.comment");

    dateReceivedDp =
        new DateTextField("phoneVo.phone.dateReceived", au.org.theark.core.Constants.DD_MM_YYYY);
    ArkDatePicker datePicker = new ArkDatePicker();
    datePicker.bind(dateReceivedDp);
    dateReceivedDp.add(datePicker);

    List<PhoneStatus> phoneStatusSourceList = iArkCommonService.getPhoneStatus();
    ChoiceRenderer<PhoneStatus> phoneStatusRenderer =
        new ChoiceRenderer<PhoneStatus>(Constants.NAME, Constants.ID);
    phoneStatusChoice =
        new DropDownChoice<PhoneStatus>(
            "phoneVo.phone.phoneStatus", phoneStatusSourceList, phoneStatusRenderer);

    List<YesNo> yesNoListSource = iArkCommonService.getYesNoList();
    ChoiceRenderer<YesNo> yesNoRenderer = new ChoiceRenderer<YesNo>(Constants.NAME, Constants.ID);
    silentModeChoice =
        new DropDownChoice<YesNo>("phoneVo.phone.silentMode", yesNoListSource, yesNoRenderer);

    List<PhoneType> phoneTypeList = iArkCommonService.getListOfPhoneType();
    ChoiceRenderer<PhoneType> defaultChoiceRenderer =
        new ChoiceRenderer<PhoneType>(Constants.NAME, Constants.ID);
    phoneTypeChoice =
        new DropDownChoice<PhoneType>(
            "phoneVo.phone.phoneType", phoneTypeList, defaultChoiceRenderer);
    phoneTypeChoice.add(new ArkDefaultFormFocusBehavior());
    addDetailFormComponents();
    attachValidators();
  }
Esempio n. 25
0
  public GridSubsetsEditor(final String id, final IModel<Set<XMLGridSubset>> model) {
    super(id, model);
    add(validator = new GridSubsetListValidator());

    // container for ajax updates
    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true);
    add(container);

    // the link list
    table = new WebMarkupContainer("table");
    table.setOutputMarkupId(true);

    container.add(table);

    grids =
        new ListView<XMLGridSubset>(
            "gridSubsets", new ArrayList<XMLGridSubset>(model.getObject())) {

          private static final long serialVersionUID = 1L;

          @Override
          protected void onBeforeRender() {
            super.onBeforeRender();
          }

          @Override
          protected void populateItem(final ListItem<XMLGridSubset> item) {
            // odd/even style
            final int index = item.getIndex();
            item.add(new SimpleAttributeModifier("class", index % 2 == 0 ? "even" : "odd"));

            final XMLGridSubset gridSubset = item.getModelObject();
            GridSetBroker gridSetBroker = GWC.get().getGridSetBroker();

            String gridsetDescription = null;
            int gridsetLevels;
            boolean gridsetExists;
            {
              final GridSet gridSet = gridSetBroker.get(gridSubset.getGridSetName());
              gridsetExists = gridSet != null;
              if (gridsetExists) {
                gridsetLevels = gridSet.getNumLevels();
                gridsetDescription = gridSet.getDescription();
              } else {
                gridsetLevels =
                    gridSubset.getZoomStop() == null ? 1 : gridSubset.getZoomStop().intValue();
              }
            }
            final Label gridSetLabel;
            final Component gridSetBounds;

            gridSetLabel =
                new Label("gridSet", new PropertyModel<String>(item.getModel(), "gridSetName"));
            if (!gridsetExists) {
              gridSetLabel.add(
                  new AttributeModifier(
                      "style", true, new Model<String>("color:red;text-decoration:line-through;")));
              getPage().warn("GridSet " + gridSubset.getGridSetName() + " does not exist");
            }
            item.add(gridSetLabel);
            if (null != gridsetDescription) {
              gridSetLabel.add(
                  new AttributeModifier("title", true, new Model<String>(gridsetDescription)));
            }

            final Component removeLink;

            final int maxZoomLevel = gridsetLevels - 1;
            final ArrayList<Integer> zoomLevels = new ArrayList<Integer>(maxZoomLevel + 1);
            for (int z = 0; z <= maxZoomLevel; z++) {
              zoomLevels.add(Integer.valueOf(z));
            }

            // zoomStart has all zoom levels as choices
            // zoomStop choices start at zoomStart's selection
            // minCachedLevel start at zoomStart's selection and ends at zoomStop's selection
            // maxCachedLevel start at minCachedLevels' and ends at zoomStop's selection

            final IModel<Integer> zoomStartModel;
            final IModel<Integer> zoomStopModel;
            final IModel<Integer> minCachedLevelModel;
            final IModel<Integer> maxCachedLevelModel;

            final ZoomLevelDropDownChoice zoomStart;
            final ZoomLevelDropDownChoice zoomStop;
            final ZoomLevelDropDownChoice minCachedLevel;
            final ZoomLevelDropDownChoice maxCachedLevel;

            zoomStartModel = new PropertyModel<Integer>(item.getModel(), "zoomStart");
            zoomStopModel = new PropertyModel<Integer>(item.getModel(), "zoomStop");
            minCachedLevelModel = new PropertyModel<Integer>(item.getModel(), "minCachedLevel");
            maxCachedLevelModel = new PropertyModel<Integer>(item.getModel(), "maxCachedLevel");

            @SuppressWarnings({"rawtypes", "unchecked"})
            final IModel<List<Integer>> allLevels = new Model(zoomLevels);

            zoomStart = new ZoomLevelDropDownChoice("zoomStart", zoomStartModel, allLevels);
            zoomStart.setEnabled(gridsetExists);
            item.add(zoomStart);

            zoomStop = new ZoomLevelDropDownChoice("zoomStop", zoomStopModel, allLevels);
            zoomStop.setEnabled(gridsetExists);
            item.add(zoomStop);

            minCachedLevel =
                new ZoomLevelDropDownChoice("minCachedLevel", minCachedLevelModel, allLevels);
            minCachedLevel.setEnabled(gridsetExists);
            item.add(minCachedLevel);

            maxCachedLevel =
                new ZoomLevelDropDownChoice("maxCachedLevel", maxCachedLevelModel, allLevels);
            maxCachedLevel.setEnabled(gridsetExists);
            item.add(maxCachedLevel);

            for (ZoomLevelDropDownChoice dropDown :
                Arrays.asList(zoomStart, zoomStop, minCachedLevel, maxCachedLevel)) {
              dropDown.add(
                  new OnChangeAjaxBehavior() {
                    private static final long serialVersionUID = 1L;

                    // cascades to zoomStop, min and max cached levels
                    @Override
                    protected void onUpdate(AjaxRequestTarget target) {
                      updateValidZoomRanges(
                          zoomStart, zoomStop, minCachedLevel, maxCachedLevel, target);
                    }
                  });
            }

            updateValidZoomRanges(zoomStart, zoomStop, minCachedLevel, maxCachedLevel, null);

            // gridSetBounds = new EnvelopePanel("bounds");
            // gridSetBounds.setCRSFieldVisible(false);
            // gridSetBounds.setCrsRequired(false);
            // gridSetBounds.setLabelsVisibility(false);
            // gridSetBounds.setModel(new Model<ReferencedEnvelope>(new ReferencedEnvelope()));
            gridSetBounds =
                new Label("bounds", new ResourceModel("GridSubsetsEditor.bounds.dynamic"));
            item.add(gridSetBounds);

            removeLink =
                new ImageAjaxLink("removeLink", GWCIconFactory.DELETE_ICON) {
                  private static final long serialVersionUID = 1L;

                  @Override
                  protected void onClick(AjaxRequestTarget target) {
                    List<XMLGridSubset> list;
                    list = new ArrayList<XMLGridSubset>(grids.getModelObject());
                    final XMLGridSubset subset = (XMLGridSubset) getDefaultModelObject();

                    list.remove(subset);

                    grids.setModelObject(list);

                    List<String> choices = new ArrayList<String>(availableGridSets.getChoices());
                    choices.add(subset.getGridSetName());
                    Collections.sort(choices);
                    availableGridSets.setChoices(choices);

                    target.addComponent(container);
                    target.addComponent(availableGridSets);
                  }
                };
            removeLink.setDefaultModel(item.getModel());
            removeLink.add(
                new AttributeModifier(
                    "title", true, new ResourceModel("GridSubsetsEditor.removeLink")));
            item.add(removeLink);
          }
        };

    grids.setOutputMarkupId(true);
    // this is necessary to avoid loosing item contents on edit/validation checks
    grids.setReuseItems(true);
    table.add(grids);

    List<String> gridSetNames = new ArrayList<String>(GWC.get().getGridSetBroker().getNames());
    for (XMLGridSubset gs : model.getObject()) {
      gridSetNames.remove(gs.getGridSetName());
    }
    Collections.sort(gridSetNames);

    GeoServerAjaxFormLink addGridsubsetLink =
        new GeoServerAjaxFormLink("addGridSubset") {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onClick(AjaxRequestTarget target, Form form) {
            availableGridSets.processInput();

            final String selectedGridset = availableGridSets.getModelObject();
            if (null == selectedGridset) {
              return;
            }

            List<String> choices = new ArrayList<String>(availableGridSets.getChoices());
            choices.remove(selectedGridset);
            availableGridSets.setChoices(choices);
            availableGridSets.setEnabled(!choices.isEmpty());

            XMLGridSubset newSubset = new XMLGridSubset();
            newSubset.setGridSetName(selectedGridset);
            grids.getModelObject().add(newSubset);

            target.addComponent(table);
            target.addComponent(availableGridSets);
          }
        };
    addGridsubsetLink.add(new Icon("addIcon", GWCIconFactory.ADD_ICON));
    add(addGridsubsetLink);

    availableGridSets =
        new DropDownChoice<String>("availableGridsets", new Model<String>(), gridSetNames);
    availableGridSets.setOutputMarkupId(true);
    add(availableGridSets);
  }
Esempio n. 26
0
  @Override
  protected void onInitialize() {
    super.onInitialize();

    this.add(JQueryWidget.newWidgetBehavior(this));
  }
  @SuppressWarnings("serial")
  void init(final WebMarkupContainer item) {

    final DropDownChoice<InstantMessagingType> socialMediaChoice =
        new DropDownChoice<InstantMessagingType>(
            "socialMediaChoice",
            new PropertyModel<InstantMessagingType>(newSocialMediaValue, "label"),
            socialMediaChoiceRenderer.getValues(),
            socialMediaChoiceRenderer);
    item.add(socialMediaChoice);
    socialMediaChoice.add(
        new AjaxFormComponentUpdatingBehavior("onchange") {
          @Override
          protected void onUpdate(final AjaxRequestTarget target) {
            //
            // newSocialMediaValue.setLabel(socialMediaChoice.getModelObject().get(socialMediaChoice.getModelObject().getKey()));
            //
            // model.getObject().setSocialMediaValues(contactDao.getSocialMediaValuesAsXml(socialMediaValues));
            // target.add(mainContainer);
          }
        });

    item.add(
        new AjaxMaxLengthEditableLabel(
            "editableLabel", new PropertyModel<String>(newSocialMediaValue, "value")) {
          @Override
          protected void onSubmit(final AjaxRequestTarget target) {
            super.onSubmit(target);
            if (StringUtils.isNotBlank(newSocialMediaValue.getValue()) == true
                && newSocialMediaValue.getValue().equals(DEFAULT_IM_VALUE) == false) {
              model
                  .getObject()
                  .setSocialMedia(newSocialMediaValue.getLabel(), newSocialMediaValue.getValue());
            }
            newSocialMediaValue.setValue(DEFAULT_IM_VALUE);
            rebuildSocialMedias();
            target.add(mainContainer);
          }
        });

    final WebMarkupContainer deleteDiv = new WebMarkupContainer("deleteDiv");
    deleteDiv.setOutputMarkupId(true);
    deleteDiv.add(
        delete =
            new AjaxIconLinkPanel(
                "delete",
                IconType.REMOVE,
                new PropertyModel<String>(newSocialMediaValue, "value")) {
              /**
               * @see
               *     org.projectforge.web.wicket.flowlayout.AjaxIconLinkPanel#onClick(org.apache.wicket.ajax.AjaxRequestTarget)
               */
              @Override
              protected void onClick(final AjaxRequestTarget target) {
                //        super.onClick(target);
                //        final Iterator<SocialMediaValue> it = socialMediaValues.iterator();
                //        while (it.hasNext() == true) {
                //          if (it.next() == newSocialMediaValue) {
                //            it.remove();
                //          }
                //        }
                //        rebuildSocialMedias();
                //
                // model.getObject().setSocialMediaValues(contactDao.getSocialMediaValuesAsXml(socialMediaValues));
                //        target.add(mainContainer);
              }
            });
    item.add(deleteDiv);
    delete.setVisible(false);
  }
Esempio n. 28
0
 @Override
 protected void onSelectionChanged(WeekType newSelection) {
   weekType = newSelection;
   updateDataPanel();
   super.onSelectionChanged(newSelection);
 }
 @SuppressWarnings("serial")
 @Override
 protected void init() {
   super.init();
   /* GRID16 - BLOCK */
   gridBuilder.newGridPanel();
   {
     // Number
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.kunde.nummer"));
     final MinMaxNumberField<Integer> number =
         new MinMaxNumberField<Integer>(
             InputPanel.WICKET_ID, new PropertyModel<Integer>(data, "id"), 0, KundeDO.MAX_ID) {
           @SuppressWarnings({"unchecked", "rawtypes"})
           @Override
           public IConverter getConverter(final Class type) {
             return new IntegerConverter(3);
           }
         };
     WicketUtils.setSize(number, 7);
     fs.add(number);
     if (isNew() == true) {
       WicketUtils.setFocus(number);
     }
   }
   {
     // Name
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.kunde.name"));
     final RequiredMaxLengthTextField name =
         new RequiredMaxLengthTextField(
             InputPanel.WICKET_ID, new PropertyModel<String>(data, "name"));
     fs.add(name);
     if (isNew() == false) {
       WicketUtils.setFocus(name);
     }
   }
   if (Registry.instance().getKontoCache().isEmpty() == false) {
     // Show this field only if DATEV accounts does exist.
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.konto"));
     final KontoSelectPanel kontoSelectPanel =
         new KontoSelectPanel(
             fs.newChildId(), new PropertyModel<KontoDO>(data, "konto"), null, "kontoId");
     kontoSelectPanel
         .setKontoNumberRanges(AccountingConfig.getInstance().getDebitorsAccountNumberRanges())
         .init();
     fs.addHelpIcon(getString("fibu.kunde.konto.tooltip"));
     fs.add(kontoSelectPanel);
   }
   {
     // Identifier
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.kunde.identifier"));
     fs.add(
         new MaxLengthTextField(
             InputPanel.WICKET_ID, new PropertyModel<String>(data, "identifier")));
   }
   {
     // Identifier
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.kunde.division"));
     fs.add(
         new MaxLengthTextField(
             InputPanel.WICKET_ID, new PropertyModel<String>(data, "division")));
   }
   {
     // Identifier
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("description"));
     fs.add(
         new MaxLengthTextArea(
             TextAreaPanel.WICKET_ID, new PropertyModel<String>(data, "description")));
   }
   {
     // Status drop down box:
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("status"));
     final LabelValueChoiceRenderer<KundeStatus> statusChoiceRenderer =
         new LabelValueChoiceRenderer<KundeStatus>(fs, KundeStatus.values());
     final DropDownChoice<KundeStatus> statusChoice =
         new DropDownChoice<KundeStatus>(
             fs.getDropDownChoiceId(),
             new PropertyModel<KundeStatus>(data, "status"),
             statusChoiceRenderer.getValues(),
             statusChoiceRenderer);
     statusChoice.setNullValid(false).setRequired(true);
     fs.add(statusChoice);
   }
 }
  @SuppressWarnings("serial")
  private void rebuildSocialMedias() {
    socialMediaRepeater.removeAll();
    if (model.getObject().getSocialMedia() != null) {
      for (final LabelValueBean<InstantMessagingType, String> socialMediaValue :
          model.getObject().getSocialMedia()) {

        final WebMarkupContainer item = new WebMarkupContainer(socialMediaRepeater.newChildId());
        socialMediaRepeater.add(item);

        final DropDownChoice<InstantMessagingType> socialMediaChoice =
            new DropDownChoice<InstantMessagingType>(
                "socialMediaChoice",
                new PropertyModel<InstantMessagingType>(socialMediaValue, "label"),
                socialMediaChoiceRenderer.getValues(),
                socialMediaChoiceRenderer);
        item.add(socialMediaChoice);
        socialMediaChoice.add(
            new AjaxFormComponentUpdatingBehavior("onchange") {
              @Override
              protected void onUpdate(final AjaxRequestTarget target) {
                //          socialMediaValue.setSocialMediaType(socialMediaChoice.getModelObject());
                //
                // model.getObject().setSocialMediaValues(contactDao.getSocialMediaValuesAsXml(socialMediaValues));
                // target.add(mainContainer);
              }
            });

        item.add(
            new AjaxMaxLengthEditableLabel(
                "editableLabel", new PropertyModel<String>(socialMediaValue, "value")) {
              @Override
              protected void onSubmit(final AjaxRequestTarget target) {
                super.onSubmit(target);
                model
                    .getObject()
                    .setSocialMedia(socialMediaValue.getLabel(), socialMediaValue.getValue());
                rebuildSocialMedias();
                target.add(mainContainer);
              }
            });

        final WebMarkupContainer deleteDiv = new WebMarkupContainer("deleteDiv");
        deleteDiv.setOutputMarkupId(true);
        deleteDiv.add(
            new AjaxIconLinkPanel(
                "delete", IconType.REMOVE, new PropertyModel<String>(socialMediaValue, "value")) {
              /**
               * @see
               *     org.projectforge.web.wicket.flowlayout.AjaxIconLinkPanel#onClick(org.apache.wicket.ajax.AjaxRequestTarget)
               */
              @Override
              protected void onClick(final AjaxRequestTarget target) {
                //          super.onClick(target);
                //          final Iterator<SocialMediaValue> it = socialMediaValues.iterator();
                //          while (it.hasNext() == true) {
                //            if (it.next() == socialMediaValue) {
                //              it.remove();
                //            }
                //          }
                //          rebuildSocialMedias();
                //
                // model.getObject().setSocialMediaValues(contactDao.getSocialMediaValuesAsXml(socialMediaValues));
                //          target.add(mainContainer);
              }
            });
        item.add(deleteDiv);
      }
    }
  }