Exemplo n.º 1
0
  private List<IColumn<PasswordAccountDto, String>> initColumns() {
    List<IColumn<PasswordAccountDto, String>> columns =
        new ArrayList<IColumn<PasswordAccountDto, String>>();

    IColumn column =
        new IconColumn<PasswordAccountDto>(new Model<String>()) {
          private static final long serialVersionUID = 1L;

          @Override
          protected IModel<String> createIconModel(final IModel<PasswordAccountDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {
              private static final long serialVersionUID = 1L;

              @Override
              public String getObject() {
                PasswordAccountDto item = rowModel.getObject();
                if (item.getCssClass() == null || item.getCssClass().trim().equals("")) {
                  if (item.isMidpoint()) {
                    item.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                  } else if (item.isPasswordOutbound()) {
                    item.setCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                  } else {
                    item.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                  }
                }
                return item.getCssClass();
              }
            };
          }

          @Override
          public void populateItem(
              Item<ICellPopulator<PasswordAccountDto>> item,
              String componentId,
              final IModel<PasswordAccountDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            final ImagePanel imagePanel = (ImagePanel) item.get(0);

            final PasswordAccountDto passwordAccountDto = rowModel.getObject();

            imagePanel.add(
                new AjaxEventBehavior("click") {
                  private static final long serialVersionUID = 1L;

                  protected void onEvent(final AjaxRequestTarget target) {
                    if (!passwordAccountDto.isMidpoint()) {
                      if (passwordAccountDto.getCssClass().equals(PROPAGATED_ACCOUNT_ICON_CSS)) {
                        passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                      } else if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)
                          && passwordAccountDto.isPasswordOutbound()
                          && midpointAccountSelected) {
                        passwordAccountDto.setCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                      } else if (passwordAccountDto
                          .getCssClass()
                          .equals(SELECTED_ACCOUNT_ICON_CSS)) {
                        passwordAccountDto.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                      } else if (passwordAccountDto
                          .getCssClass()
                          .equals(DESELECTED_ACCOUNT_ICON_CSS)) {
                        passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                      }
                      target.add(imagePanel);
                    } else {
                      midpointAccountSelected = !midpointAccountSelected;
                      if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)) {
                        passwordAccountDto.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                        updatePropagatedAccountIconsCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                        target.add(imagePanel.findParent(SelectableDataTable.class));
                      } else if (passwordAccountDto
                          .getCssClass()
                          .equals(DESELECTED_ACCOUNT_ICON_CSS)) {
                        passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                        updatePropagatedAccountIconsCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                        target.add(imagePanel.findParent(SelectableDataTable.class));
                      }
                    }
                  }
                });
          }
        };
    columns.add(column);

    columns.add(
        new AbstractColumn<PasswordAccountDto, String>(
            createStringResource("ChangePasswordPanel.name")) {
          private static final long serialVersionUID = 1L;

          @Override
          public void populateItem(
              Item<ICellPopulator<PasswordAccountDto>> item,
              String componentId,
              final IModel<PasswordAccountDto> rowModel) {
            item.add(
                new Label(
                    componentId,
                    new AbstractReadOnlyModel<Object>() {
                      private static final long serialVersionUID = 1L;

                      @Override
                      public Object getObject() {
                        PasswordAccountDto dto = rowModel.getObject();
                        return dto.getDisplayName();
                      }
                    }));
          }
        });

    column =
        new PropertyColumn(
            createStringResource("ChangePasswordPanel.resourceName"),
            PasswordAccountDto.F_RESOURCE_NAME);
    columns.add(column);

    CheckBoxColumn enabled =
        new CheckBoxColumn(
            createStringResource("ChangePasswordPanel.enabled"), PasswordAccountDto.F_ENABLED);
    enabled.setEnabled(false);
    columns.add(enabled);

    return columns;
  }
Exemplo n.º 2
0
  private List<IColumn<AppenderConfiguration, String>> initAppenderColumns() {
    List<IColumn<AppenderConfiguration, String>> columns = new ArrayList<>();

    IColumn column = new CheckBoxHeaderColumn<AppenderConfiguration>();
    columns.add(column);

    // name columns (editable)
    column =
        new EditableLinkColumn<AppenderConfiguration>(
            createStringResource("LoggingConfigPanel.appenders.name"), "name") {

          @Override
          public void onClick(AjaxRequestTarget target, IModel<AppenderConfiguration> rowModel) {
            appenderEditPerformed(target, rowModel);
          }

          @Override
          protected Component createInputPanel(
              String componentId, IModel<AppenderConfiguration> model) {
            TextPanel<String> panel =
                new TextPanel<String>(
                    componentId, new PropertyModel(model, getPropertyExpression()));
            panel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            panel.getBaseFormComponent().add(new NotNullValidator<String>("message.emptyString"));
            addAjaxFormComponentUpdatingBehavior(panel.getBaseFormComponent());
            return panel;
          }
        };
    columns.add(column);

    // pattern column (editable)
    column =
        new EditablePropertyColumn(
            createStringResource("LoggingConfigPanel.appenders.pattern"), "pattern") {

          @Override
          protected InputPanel createInputPanel(String componentId, IModel model) {
            InputPanel panel = super.createInputPanel(componentId, model);
            panel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            panel.getBaseFormComponent().add(new NotNullValidator<String>("message.emptyString"));
            addAjaxFormComponentUpdatingBehavior(panel.getBaseFormComponent());
            return panel;
          }
        };
    columns.add(column);

    // file path column (editable)
    column =
        new FileAppenderColumn(
            createStringResource("LoggingConfigPanel.appenders.filePath"), "filePath");
    columns.add(column);

    // file pattern column (editable)
    //                jj
    column =
        new FileAppenderColumn(
            createStringResource("LoggingConfigPanel.appenders.filePattern"), "filePattern");
    columns.add(column);

    // max history column (editable)
    column =
        new FileAppenderColumn(
            createStringResource("LoggingConfigPanel.appenders.maxHistory"), "maxHistory") {

          @Override
          protected InputPanel createInputPanel(String componentId, IModel model) {
            TextPanel panel =
                new TextPanel<>(
                    componentId, new PropertyModel<String>(model, getPropertyExpression()));
            FormComponent component = panel.getBaseFormComponent();
            component.add(new AttributeModifier("size", 5));
            component.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            addAjaxFormComponentUpdatingBehavior(component);
            return panel;
          }
        };
    columns.add(column);

    // max file size column (editable)
    column =
        new FileAppenderColumn(
            createStringResource("LoggingConfigPanel.appenders.maxFileSize"), "maxFileSize") {

          @Override
          protected InputPanel createInputPanel(String componentId, IModel model) {
            TextPanel<String> panel =
                new TextPanel<>(
                    componentId, new PropertyModel<String>(model, getPropertyExpression()));
            FormComponent component = panel.getBaseFormComponent();
            component.add(new AttributeModifier("size", 5));
            component.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            component.add(new NotNullValidator<String>("message.emptyString"));
            addAjaxFormComponentUpdatingBehavior(component);
            return panel;
          }
        };
    columns.add(column);

    CheckBoxColumn check =
        new EditableCheckboxColumn(
            createStringResource("LoggingConfigPanel.appenders.appending"), "appending") {

          @Override
          protected InputPanel createInputPanel(String componentId, IModel model) {
            InputPanel panel = super.createInputPanel(componentId, model);
            panel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            panel.getBaseFormComponent().add(new NotNullValidator<String>("message.emptyString"));
            addAjaxFormComponentUpdatingBehavior(panel.getBaseFormComponent());
            return panel;
          }
        };
    check.setEnabled(false);
    columns.add(check);

    return columns;
  }