View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.client.console.wizards;
20  
21  import org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel;
22  import org.apache.syncope.client.ui.commons.Constants;
23  import org.apache.syncope.client.ui.commons.markup.html.form.AjaxTextFieldPanel;
24  import org.apache.syncope.common.lib.Attr;
25  import org.apache.wicket.PageReference;
26  import org.apache.wicket.extensions.wizard.WizardModel;
27  import org.apache.wicket.extensions.wizard.WizardStep;
28  import org.apache.wicket.model.Model;
29  import org.apache.wicket.model.PropertyModel;
30  
31  public abstract class AttrWizardBuilder extends BaseAjaxWizardBuilder<Attr> {
32  
33      private static final long serialVersionUID = 7618745848468848923L;
34  
35      public AttrWizardBuilder(final Attr defaultItem, final PageReference pageRef) {
36          super(defaultItem, pageRef);
37      }
38  
39      @Override
40      protected WizardModel buildModelSteps(final Attr modelObject, final WizardModel wizardModel) {
41          wizardModel.add(new AttrStep(modelObject));
42          return wizardModel;
43      }
44  
45      protected static class AttrStep extends WizardStep {
46  
47          private static final long serialVersionUID = 8145346883748040158L;
48  
49          AttrStep(final Attr modelObject) {
50              AjaxTextFieldPanel schema = new AjaxTextFieldPanel(
51                      Constants.KEY_FIELD_NAME, Constants.KEY_FIELD_NAME, new PropertyModel<>(modelObject, "schema"));
52              schema.addRequiredLabel();
53              schema.setEnabled(modelObject.getSchema() == null);
54              add(schema);
55  
56              AjaxTextFieldPanel value = new AjaxTextFieldPanel("panel", "values", new Model<>());
57              add(new MultiFieldPanel.Builder<String>(
58                      new PropertyModel<>(modelObject, "values")).build("values", "values", value));
59          }
60      }
61  }