Java Code Examples for org.apache.wicket.markup.html.form.DropDownChoice#add()

The following examples show how to use org.apache.wicket.markup.html.form.DropDownChoice#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KnowledgeBaseIriPanel.java    From inception with Apache License 2.0 6 votes vote down vote up
private DropDownChoice<Reification> selectReificationStrategy(String id, String property)
{
    DropDownChoice<Reification> reificationDropDownChoice = new BootstrapSelect<>(id,
        kbModel.bind(property), asList(Reification.values()));
    reificationDropDownChoice.setRequired(true);
    reificationDropDownChoice.setOutputMarkupPlaceholderTag(true);
    
    // The current reification implementation only really does something useful when the
    // Wikidata schema is used on the actual Wikidata knowledge base (or a mirror). 
    // Thus, we enable the option to activate reification only in this case.
    reificationDropDownChoice.add(visibleWhen(() -> 
            WIKIDATASCHEMA.equals(selectedSchemaProfile.getObject()) &&
            kbModel.getObject().getKb().isReadOnly() &&
            REMOTE.equals(kbModel.getObject().getKb().getType())));
    
    return reificationDropDownChoice;
}
 
Example 2
Source File: ProjectDetailPanel.java    From webanno with Apache License 2.0 6 votes vote down vote up
private DropDownChoice<String> makeProjectTypeChoice()
{
    List<String> types = projectService.listProjectTypes().stream().map(t -> t.id())
            .collect(Collectors.toList());

    DropDownChoice<String> projTypes = new BootstrapSelect<>("mode", types);
    projTypes.setRequired(true);
    projTypes.add(LambdaBehavior.onConfigure(_this -> {
        // If there is only a single project type and the project mode has not been set yet,
        // then we can simply select that and do not need to show the choice at all.
        Project project = projectModel.getObject();
        if (projectTypes.getChoices().size() == 1 && project.getMode() == null) {
            project.setMode(projectTypes.getChoices().get(0));
        }
        
        _this.setEnabled(
                nonNull(projectModel.getObject()) && isNull(projectModel.getObject().getId()));
        
        // If there is only a single project type, then we can simply select that and do not
        // need to show the choice at all.
        _this.setVisible(projTypes.getChoices().size() > 1);
    }));
    
    return projTypes;
}
 
Example 3
Source File: SearchAnnotationSidebar.java    From inception with Apache License 2.0 6 votes vote down vote up
private DropDownChoice<AnnotationLayer> createLayerDropDownChoice(String aId,
    List<AnnotationLayer> aChoices)
{
    DropDownChoice<AnnotationLayer> layerChoice = new BootstrapSelect<>(aId, aChoices,
            new ChoiceRenderer<>("uiName"));

    layerChoice.add(new AjaxFormComponentUpdatingBehavior("change")
    {
        private static final long serialVersionUID = -6095969211884063787L;

        @Override protected void onUpdate(AjaxRequestTarget aTarget)
        {
            //update the choices for the feature selection dropdown
            groupingFeature.setChoices(annotationService
                .listAnnotationFeature(searchOptions.getObject().getGroupingLayer()));
            lowLevelPagingCheckBox.setModelObject(false);
            aTarget.add(groupingFeature, lowLevelPagingCheckBox);
        }
    });
    layerChoice.setNullValid(true);
    return layerChoice;
}
 
Example 4
Source File: ExternalSearchAnnotationSidebar.java    From inception with Apache License 2.0 6 votes vote down vote up
public DocumentRepositorySelectionForm(String aId)
{
    super(aId);

    DropDownChoice<DocumentRepository> repositoryCombo =
        new BootstrapSelect<DocumentRepository>("repositoryCombo",
        new PropertyModel<DocumentRepository>(ExternalSearchAnnotationSidebar.this,
            "currentRepository"), repositoriesModel);

    repositoryCombo.setChoiceRenderer(new ChoiceRenderer<DocumentRepository>("name"));
    repositoryCombo.setNullValid(false);

    // Just update the selection
    repositoryCombo.add(new LambdaAjaxFormComponentUpdatingBehavior("change"));
    add(repositoryCombo);

}
 
Example 5
Source File: CafeAddress.java    From tutorials with MIT License 6 votes vote down vote up
public CafeAddress(final PageParameters parameters) {
    super(parameters);
    initCafes();

    ArrayList<String> cafeNames = new ArrayList<>(cafeNamesAndAddresses.keySet());
    selectedCafe = cafeNames.get(0);
    address = new Address(cafeNamesAndAddresses.get(selectedCafe).getAddress());

    final Label addressLabel = new Label("address", new PropertyModel<String>(this.address, "address"));
    addressLabel.setOutputMarkupId(true);

    final DropDownChoice<String> cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel<>(this, "selectedCafe"), cafeNames);
    cafeDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            String name = (String) cafeDropdown.getDefaultModel().getObject();
            address.setAddress(cafeNamesAndAddresses.get(name).getAddress());
            target.add(addressLabel);
        }
    });

    add(addressLabel);
    add(cafeDropdown);

}
 
Example 6
Source File: BooleanFilterPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public BooleanFilterPanel(String id, final IModel<Boolean> valueModel) {
    super(id, valueModel);
    List<Boolean> list = Lists.newArrayList();
    list.add(Boolean.TRUE);
    list.add(Boolean.FALSE);
    final DropDownChoice<Boolean> choice = new DropDownChoice<>("booleanChoice", valueModel, list);
    choice.add(new AjaxFormSubmitBehavior("change") {});
    choice.setNullValid(true);
    add(choice);
    this.choiceComponent = choice;
}
 
Example 7
Source File: LayerSelectionPanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
private DropDownChoice<AnnotationLayer> createDefaultAnnotationLayerSelector()
{
    DropDownChoice<AnnotationLayer> selector = new BootstrapSelect<>("defaultAnnotationLayer");
    selector.setChoices(LoadableDetachableModel.of(this::getSelectableLayers));
    selector.setChoiceRenderer(new ChoiceRenderer<>("uiName"));
    selector.setOutputMarkupId(true);
    selector.add(LambdaAjaxFormComponentUpdatingBehavior.onUpdate("change",
            this::actionChangeDefaultLayer));
    return selector;
}
 
Example 8
Source File: DocumentMetadataAnnotationSelectionPanel.java    From inception with Apache License 2.0 5 votes vote down vote up
public DocumentMetadataAnnotationSelectionPanel(String aId, IModel<Project> aProject,
        IModel<SourceDocument> aDocument, IModel<String> aUsername,
        CasProvider aCasProvider, AnnotationPage aAnnotationPage,
        AnnotationActionHandler aActionHandler, AnnotatorState aState)
{
    super(aId, aProject);

    setOutputMarkupPlaceholderTag(true);
    
    annotationPage = aAnnotationPage;
    sourceDocument = aDocument;
    username = aUsername;
    jcasProvider = aCasProvider;
    project = aProject;
    selectedLayer = Model.of();
    actionHandler = aActionHandler;
    state = aState;

    annotationsContainer = new WebMarkupContainer(CID_ANNOTATIONS_CONTAINER);
    annotationsContainer.setOutputMarkupId(true);
    annotationsContainer.add(createAnnotationList());
    add(annotationsContainer);
    
    DropDownChoice<AnnotationLayer> layer = new BootstrapSelect<>(CID_LAYER);
    layer.setModel(selectedLayer);
    layer.setChoices(this::listMetadataLayers);
    layer.setChoiceRenderer(new ChoiceRenderer<>("uiName"));
    layer.add(new LambdaAjaxFormComponentUpdatingBehavior("change"));
    add(layer);
    
    add(new LambdaAjaxLink(CID_CREATE, this::actionCreate));
}
 
Example 9
Source File: DropDownChoicePanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param id
 * @param label see {@link FormComponent#setLabel(IModel)}
 * @param dropDownChoice
 * @param submitOnChange
 */
public DropDownChoicePanel(final String id, final DropDownChoice<T> dropDownChoice, final boolean submitOnChange)
{
  super(id);
  this.dropDownChoice = dropDownChoice;
  add(dropDownChoice);
  if (submitOnChange == true) {
    dropDownChoice.add(AttributeModifier.replace("onchange", "javascript:submit();"));
  }
  setRenderBodyOnly(true);
}
 
Example 10
Source File: TimesheetEditForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("serial")
protected static DropDownChoice<Integer> createCost2ChoiceRenderer(final String id, final TimesheetDao timesheetDao,
    final TaskTree taskTree, final LabelValueChoiceRenderer<Integer> kost2ChoiceRenderer, final TimesheetDO data,
    final List<Kost2DO> kost2List)
    {
  final DropDownChoice<Integer> choice = new DropDownChoice<Integer>(id, new Model<Integer>() {
    @Override
    public Integer getObject()
    {
      return data.getKost2Id();
    }

    @Override
    public void setObject(final Integer kost2Id)
    {
      if (kost2Id != null) {
        timesheetDao.setKost2(data, kost2Id);
      } else {
        data.setKost2(null);
      }
    }
  }, kost2ChoiceRenderer.getValues(), kost2ChoiceRenderer);
  choice.setNullValid(true);
  choice.add(new IValidator<Integer>() {
    @Override
    public void validate(final IValidatable<Integer> validatable)
    {
      final Integer value = validatable.getValue();
      if (value != null && value >= 0) {
        return;
      }
      if (CollectionUtils.isNotEmpty(kost2List) == true) {
        // Kost2 available but not selected.
        choice.error(PFUserContext.getLocalizedString("timesheet.error.kost2Required"));
      }
    }
  });
  return choice;
    }
 
Example 11
Source File: FieldListEditPanel.java    From onedev with MIT License 4 votes vote down vote up
private Component newFieldsView(Class<?> fieldBeanClass) {
	RepeatingView fieldsView = new RepeatingView("fields");
	fieldsView.setDefaultModel(Model.of(fieldBeanClass.getName()));
	BeanDescriptor beanDescriptor = new BeanDescriptor(fieldBeanClass);
	for (List<PropertyDescriptor> groupProperties: beanDescriptor.getProperties().values()) {
		for (PropertyDescriptor property: groupProperties) {
			if (getFieldSpecs().containsKey(property.getDisplayName())) {
				WebMarkupContainer container = new WebMarkupContainer(fieldsView.newChildId());
				FieldSupply field = fields.get(property.getDisplayName());
				if (field != null) {
					container.add(newValueEditor("value", property, field.getValueProvider()));
					container.setDefaultModel(Model.of(field.getValueProvider().getClass()));
				} else {
					container.add(newValueEditor("value", property, newSpecifiedValueProvider(property)));
					container.setDefaultModel(Model.of(SpecifiedValue.class));
				}
				
				container.add(new Label("name", property.getDisplayName()));

				String required;
				if (property.isPropertyRequired() 
						&& property.getPropertyClass() != boolean.class
						&& property.getPropertyClass() != Boolean.class) {
					required = "*";
				} else {
					required = "&nbsp;";
				}
				
				container.add(new Label("required", required).setEscapeModelStrings(false));
				
				boolean isSecret = property.getPropertyGetter().getAnnotation(Password.class) != null;

				List<String> choices = new ArrayList<>();
				if (isSecret) {
					choices.add(SpecifiedValue.SECRET_DISPLAY_NAME);
					choices.add(ScriptingValue.SECRET_DISPLAY_NAME);
					choices.add(Ignore.DISPLAY_NAME);
				} else {
					choices.add(SpecifiedValue.DISPLAY_NAME);
					choices.add(ScriptingValue.DISPLAY_NAME);
					choices.add(Ignore.DISPLAY_NAME);
				}
				DropDownChoice<String> valueProviderChoice = new DropDownChoice<String>("valueProvider", new IModel<String>() {
					
					@Override
					public void detach() {
					}

					@Override
					public String getObject() {
						Class<?> valueProviderClass = (Class<?>) container.getDefaultModelObject();
						if (valueProviderClass == SpecifiedValue.class)
							return isSecret?SpecifiedValue.SECRET_DISPLAY_NAME:SpecifiedValue.DISPLAY_NAME;
						else if (valueProviderClass == ScriptingValue.class)
							return isSecret?ScriptingValue.SECRET_DISPLAY_NAME:ScriptingValue.DISPLAY_NAME;
						else
							return Ignore.DISPLAY_NAME;
					}

					@Override
					public void setObject(String object) {
						ValueProvider valueProvider;
						if (object.equals(SpecifiedValue.DISPLAY_NAME) || object.equals(SpecifiedValue.SECRET_DISPLAY_NAME))  
							valueProvider = newSpecifiedValueProvider(property);
						else if (object.equals(ScriptingValue.DISPLAY_NAME) || object.equals(ScriptingValue.SECRET_DISPLAY_NAME))
							valueProvider = new ScriptingValue();
						else
							valueProvider = new Ignore();
						container.replace(newValueEditor("value", property, valueProvider));
						container.setDefaultModelObject(valueProvider.getClass());
					}
					
				}, choices);
				
				valueProviderChoice.setNullValid(false);
				
				valueProviderChoice.add(new AjaxFormComponentUpdatingBehavior("change"){

					@Override
					protected void onUpdate(AjaxRequestTarget target) {
						onPropertyUpdating(target);
						target.add(container);
					}
					
				});
				container.add(valueProviderChoice);
				
				container.add(new Label("description", property.getDescription()).setEscapeModelStrings(false));
				container.add(new FencedFeedbackPanel("feedback", container));
				container.setOutputMarkupId(true);
				fieldsView.add(container);
			}
		}
	}
	
	return fieldsView;
}
 
Example 12
Source File: DirectoryPanel.java    From syncope with Apache License 2.0 4 votes vote down vote up
protected void initResultTable() {
    // ---------------------------
    // Result table initialization
    // ---------------------------
    updateResultTable(false);
    // ---------------------------

    // ---------------------------
    // Rows-per-page selector
    // ---------------------------
    Form<?> paginatorForm = new Form<>("paginator");
    paginatorForm.setOutputMarkupPlaceholderTag(true);
    paginatorForm.setVisible(showPaginator);
    container.add(paginatorForm);

    DropDownChoice<Integer> rowsChooser = new DropDownChoice<>(
            "rowsChooser", new PropertyModel<>(this, "rows"), PreferenceManager.getPaginatorChoices());
    rowsChooser.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            PreferenceManager.set(getRequest(), getResponse(), paginatorRowsKey(), String.valueOf(rows));

            EventDataWrapper data = new EventDataWrapper();
            data.setTarget(target);
            data.setRows(rows);

            send(getParent(), Broadcast.BREADTH, data);
        }
    });
    paginatorForm.add(rowsChooser);
    // ---------------------------

    // ---------------------------
    // Table handling
    // ---------------------------
    container.add(getHeader("tablehandling"));
    // ---------------------------
}
 
Example 13
Source File: AnnotationPreferencesDialogContent.java    From webanno with Apache License 2.0 4 votes vote down vote up
public AnnotationPreferencesDialogContent(String aId, final ModalWindow aModalWindow,
        IModel<AnnotatorState> aModel)
{
    super(aId);
    
    stateModel = aModel;
    modalWindow = aModalWindow;
    
    form = new Form<>("form", new CompoundPropertyModel<>(loadModel(stateModel.getObject())));

    NumberTextField<Integer> windowSizeField = new NumberTextField<>("windowSize");
    windowSizeField.setType(Integer.class);
    windowSizeField.setMinimum(1);
    form.add(windowSizeField);

    NumberTextField<Integer> sidebarSizeField = new NumberTextField<>("sidebarSize");
    sidebarSizeField.setType(Integer.class);
    sidebarSizeField.setMinimum(AnnotationPreference.SIDEBAR_SIZE_MIN);
    sidebarSizeField.setMaximum(AnnotationPreference.SIDEBAR_SIZE_MAX);
    form.add(sidebarSizeField);

    NumberTextField<Integer> fontZoomField = new NumberTextField<>("fontZoom");
    fontZoomField.setType(Integer.class);
    fontZoomField.setMinimum(AnnotationPreference.FONT_ZOOM_MIN);
    fontZoomField.setMaximum(AnnotationPreference.FONT_ZOOM_MAX);
    form.add(fontZoomField);

    List<Pair<String, String>> editorChoices = annotationEditorRegistry.getEditorFactories()
            .stream()
            .map(f -> Pair.of(f.getBeanName(), f.getDisplayName()))
            .collect(Collectors.toList());
    DropDownChoice<Pair<String, String>> editor = new BootstrapSelect<>("editor");
    editor.setChoiceRenderer(new ChoiceRenderer<>("value"));
    editor.setChoices(editorChoices);
    editor.add(visibleWhen(() -> editor.getChoices().size() > 1
            && ANNOTATION.equals(stateModel.getObject().getMode())));
    form.add(editor);

    // Add layer check boxes and combo boxes
    form.add(createLayerContainer());

    // Add a check box to enable/disable automatic page navigations while annotating
    form.add(new CheckBox("scrollPage"));

    // Add a check box to enable/disable arc collapsing
    form.add(new CheckBox("collapseArcs"));

    form.add(new CheckBox("rememberLayer"));

    // Add global read-only coloring strategy combo box
    DropDownChoice<ReadonlyColoringBehaviour> readOnlyColor = new BootstrapSelect<>(
            "readonlyLayerColoringBehaviour");
    readOnlyColor.setChoices(asList(ReadonlyColoringBehaviour.values()));
    readOnlyColor.setChoiceRenderer(new ChoiceRenderer<>("descriptiveName"));
    form.add(readOnlyColor);

    form.add(new LambdaAjaxButton<>("save", this::actionSave));
    form.add(new LambdaAjaxLink("cancel", this::actionCancel));
    
    add(form);
}
 
Example 14
Source File: StringFeatureTraitsEditor.java    From webanno with Apache License 2.0 4 votes vote down vote up
public StringFeatureTraitsEditor(String aId,
        UimaPrimitiveFeatureSupport_ImplBase<StringFeatureTraits> aFS,
        IModel<AnnotationFeature> aFeature)
{
    super(aId, aFeature);

    // We cannot retain a reference to the actual SlotFeatureSupport instance because that
    // is not serializable, but we can retain its ID and look it up again from the registry
    // when required.
    featureSupportId = aFS.getId();
    feature = aFeature;

    traits = CompoundPropertyModel.of(getFeatureSupport().readTraits(feature.getObject()));

    keyBindings = newKeyBindingsConfigurationPanel(aFeature);
    add(keyBindings);

    Form<StringFeatureTraits> form = new Form<StringFeatureTraits>(MID_FORM, traits)
    {
        private static final long serialVersionUID = -3109239605783291123L;

        @Override
        protected void onSubmit()
        {
            super.onSubmit();

            // Tagsets only are allowed for single-row input fields, not for textareas
            if (traits.getObject().isMultipleRows()) {
                feature.getObject().setTagset(null);
            } else {
                traits.getObject().setDynamicSize(false);
            }

            getFeatureSupport().writeTraits(feature.getObject(), traits.getObject());
        }
    };
    form.setOutputMarkupPlaceholderTag(true);
    add(form);

    NumberTextField<Integer> collapsedRows = new NumberTextField<>("collapsedRows",
            Integer.class);
    collapsedRows.setModel(PropertyModel.of(traits, "collapsedRows"));
    collapsedRows.setMinimum(1);
    collapsedRows.add(visibleWhen(() -> traits.getObject().isMultipleRows()
            && !traits.getObject().isDynamicSize()));
    form.add(collapsedRows);

    NumberTextField<Integer> expandedRows = new NumberTextField<>("expandedRows",
            Integer.class);
    expandedRows.setModel(PropertyModel.of(traits, "expandedRows"));
    expandedRows.setMinimum(1);
    expandedRows.add(visibleWhen(() -> traits.getObject().isMultipleRows() 
            && !traits.getObject().isDynamicSize()));
    form.add(expandedRows);

    DropDownChoice<TagSet> tagset = new BootstrapSelect<>("tagset");
    tagset.setOutputMarkupPlaceholderTag(true);
    tagset.setChoiceRenderer(new ChoiceRenderer<>("name"));
    tagset.setNullValid(true);
    tagset.setModel(PropertyModel.of(aFeature, "tagset"));
    tagset.setChoices(LoadableDetachableModel
            .of(() -> annotationService.listTagSets(aFeature.getObject().getProject())));
    tagset.add(visibleWhen(() -> !traits.getObject().isMultipleRows()));
    // If we change the tagset, the input component for the key bindings may change, so we need
    // to re-generate the key bindings
    tagset.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> {
        KeyBindingsConfigurationPanel newKeyBindings = newKeyBindingsConfigurationPanel(
                aFeature);
        keyBindings.replaceWith(newKeyBindings);
        keyBindings = newKeyBindings;
        _target.add(keyBindings);
    }));
    form.add(tagset);

    CheckBox multipleRows = new CheckBox("multipleRows");
    multipleRows.setModel(PropertyModel.of(traits, "multipleRows"));
    multipleRows.add(
            new LambdaAjaxFormComponentUpdatingBehavior("change", target -> target.add(form)));
    form.add(multipleRows);

    CheckBox dynamicSize = new CheckBox("dynamicSize");
    dynamicSize.setModel(PropertyModel.of(traits, "dynamicSize"));
    dynamicSize.add(new LambdaAjaxFormComponentUpdatingBehavior("change",
        target -> target.add(form)
    ));
    dynamicSize.add(visibleWhen(() -> traits.getObject().isMultipleRows()));
    form.add(dynamicSize);
}
 
Example 15
Source File: PullRequestDetailPage.java    From onedev with MIT License 4 votes vote down vote up
private WebMarkupContainer newMergeStrategyContainer() {
	WebMarkupContainer mergeStrategyContainer = new WebMarkupContainer("mergeStrategy");
	mergeStrategyContainer.setOutputMarkupId(true);

	mergeStrategy = getPullRequest().getMergeStrategy();
	
	IModel<MergeStrategy> mergeStrategyModel = new PropertyModel<MergeStrategy>(this, "mergeStrategy");
	
	List<MergeStrategy> mergeStrategies = Arrays.asList(MergeStrategy.values());
	DropDownChoice<MergeStrategy> editor = 
			new DropDownChoice<MergeStrategy>("editor", mergeStrategyModel, mergeStrategies) {

		@Override
		protected void onConfigure() {
			super.onConfigure();
			
			setVisible(!getPullRequest().isMerged() && SecurityUtils.canModify(getPullRequest()));						
		}
		
	};
	editor.add(new OnChangeAjaxBehavior() {
				
		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			OneDev.getInstance(PullRequestChangeManager.class).changeMergeStrategy(getPullRequest(), mergeStrategy);
		}
		
	});
	mergeStrategyContainer.add(editor);
	
	mergeStrategyContainer.add(new Label("viewer", new AbstractReadOnlyModel<String>() {

		@Override
		public String getObject() {
			return getPullRequest().getMergeStrategy().toString();
		}
		
	}) {

		@Override
		protected void onConfigure() {
			super.onConfigure();
			
			setVisible(getPullRequest().isMerged() || !SecurityUtils.canModify(getPullRequest()));						
		}
		
	});

	mergeStrategyContainer.add(new Label("help", new AbstractReadOnlyModel<String>() {

		@Override
		public String getObject() {
			return getPullRequest().getMergeStrategy().getDescription();
		}
		
	}) {
		
		@Override
		protected void onConfigure() {
			super.onConfigure();
			
			setVisible(!getPullRequest().isMerged() && SecurityUtils.canModify(getPullRequest()));						
		}
		
	});
	
	return mergeStrategyContainer;
}
 
Example 16
Source File: ParamListEditPanel.java    From onedev with MIT License 4 votes vote down vote up
private Component newParamsView(Class<?> paramBeanClass) {
	RepeatingView paramsView = new RepeatingView("params");
	paramsView.setDefaultModel(Model.of(paramBeanClass.getName()));
	BeanDescriptor beanDescriptor = new BeanDescriptor(paramBeanClass);
	for (List<PropertyDescriptor> groupProperties: beanDescriptor.getProperties().values()) {
		for (PropertyDescriptor property: groupProperties) {
			WebMarkupContainer container = new WebMarkupContainer(paramsView.newChildId());
			container.add(new Label("name", property.getDisplayName()));

			ParamSupply param = params.get(property.getDisplayName());
			if (param != null) {
				container.add(newValuesEditor("values", property, param.getValuesProvider()));
				container.setDefaultModel(Model.of(param.getValuesProvider().getClass()));
			} else {
				container.add(newValuesEditor("values", property, newSpecifiedValuesProvider(property)));
				container.setDefaultModel(Model.of(SpecifiedValues.class));
			}

			String required;
			if (property.isPropertyRequired() 
					&& property.getPropertyClass() != boolean.class
					&& property.getPropertyClass() != Boolean.class) {
				required = "*";
			} else {
				required = "&nbsp;";
			}
			
			container.add(new Label("required", required).setEscapeModelStrings(false));
			
			boolean isSecret = property.getPropertyGetter().getAnnotation(Password.class) != null;

			List<String> choices = new ArrayList<>();
			if (isSecret) {
				choices.add(SpecifiedValues.SECRET_DISPLAY_NAME);
				choices.add(ScriptingValues.SECRET_DISPLAY_NAME);
				choices.add(Ignore.DISPLAY_NAME);
			} else {
				choices.add(SpecifiedValues.DISPLAY_NAME);
				choices.add(ScriptingValues.DISPLAY_NAME);
				choices.add(Ignore.DISPLAY_NAME);
			}
			DropDownChoice<String> valuesProviderChoice = new DropDownChoice<String>("valuesProvider", new IModel<String>() {
				
				@Override
				public void detach() {
				}

				@Override
				public String getObject() {
					Class<?> valuesProviderClass = (Class<?>) container.getDefaultModelObject();
					if (valuesProviderClass == SpecifiedValues.class)
						return isSecret?SpecifiedValues.SECRET_DISPLAY_NAME:SpecifiedValues.DISPLAY_NAME;
					else if (valuesProviderClass == ScriptingValues.class)
						return isSecret?ScriptingValues.SECRET_DISPLAY_NAME:ScriptingValues.DISPLAY_NAME;
					else
						return Ignore.DISPLAY_NAME;
				}

				@Override
				public void setObject(String object) {
					ValuesProvider valuesProvider;
					if (object.equals(SpecifiedValues.DISPLAY_NAME) || object.equals(SpecifiedValues.SECRET_DISPLAY_NAME))  
						valuesProvider = newSpecifiedValuesProvider(property);
					else if (object.equals(ScriptingValues.DISPLAY_NAME) || object.equals(ScriptingValues.SECRET_DISPLAY_NAME))
						valuesProvider = new ScriptingValues();
					else
						valuesProvider = new Ignore();
					container.replace(newValuesEditor("values", property, valuesProvider));
					container.setDefaultModelObject(valuesProvider.getClass());
				}
									
			}, choices);
			
			valuesProviderChoice.setNullValid(false);
			
			valuesProviderChoice.add(new AjaxFormComponentUpdatingBehavior("change"){

				@Override
				protected void onUpdate(AjaxRequestTarget target) {
					onPropertyUpdating(target);
					target.add(container);
				}
				
			});
			container.add(valuesProviderChoice);
			container.add(new Label("description", property.getDescription()).setEscapeModelStrings(false));
			container.add(new FencedFeedbackPanel("feedback", container));
			container.setOutputMarkupId(true);
			paramsView.add(container);
		}
	}
	
	return paramsView;
}
 
Example 17
Source File: MetricSelectDropDownPanel.java    From inception with Apache License 2.0 4 votes vote down vote up
public MetricSelectDropDownPanel(String aId)
{
    super(aId);

    final DropDownChoice<RecommenderEvaluationScoreMetricEnum> dropdown = new 
            DropDownChoice<RecommenderEvaluationScoreMetricEnum>(
            MID_METRIC_SELECT, new Model<RecommenderEvaluationScoreMetricEnum>(METRICS.get(0)),
            new ListModel<RecommenderEvaluationScoreMetricEnum>(METRICS));
    dropdown.setRequired(true);
    dropdown.setOutputMarkupId(true);

    dropdown.add(new AjaxFormComponentUpdatingBehavior("change")
    {
        private static final long serialVersionUID = -6744838136235652577L;

        protected void onUpdate(AjaxRequestTarget target)
        {
            DropDownEvent dropDownEvent = new DropDownEvent();
            dropDownEvent.setSelectedValue(dropdown.getModelObject());
            dropDownEvent.setTarget(target);

            send(getPage(), Broadcast.BREADTH, dropDownEvent); 
            
            Effects.hide(target, dropdown);
            Effects.show(target, dropdown);
            target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                    + "').classList.remove('fa-chevron-circle-right');");
            target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                    + "').classList.add('fa-chevron-circle-left');");
        }
    });

    add(dropdown);

    link = new AjaxLink<Void>(MID_METRIC_LINK)
    {            
        private static final long serialVersionUID = 1L;

        
        @Override
        public void onClick(AjaxRequestTarget target)
        {
            if (isDropdownVisible) {
                Effects.hide(target, dropdown);
                target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                        + "').classList.remove('fa-chevron-circle-left');");
                target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                        + "').classList.add('fa-chevron-circle-right');");
                isDropdownVisible = false;

            }
            else {

                Effects.show(target, dropdown);
                target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                        + "').classList.remove('fa-chevron-circle-right');");
                target.appendJavaScript("document.getElementById('" + link.getMarkupId()
                        + "').classList.add('fa-chevron-circle-left');");
                isDropdownVisible = true;
            }
        }
    };

    link.setOutputMarkupId(true);
    add(link);
}
 
Example 18
Source File: SimulationLearningCurvePanel.java    From inception with Apache License 2.0 4 votes vote down vote up
public SimulationLearningCurvePanel(String aId, Project aProject,
        IModel<Recommender> aSelectedRecommenderPanel)
{
    super(aId);
    project = aProject;
    selectedRecommenderPanel = aSelectedRecommenderPanel;
    evaluate = true;

    Form<Recommender> form = new Form<>(MID_FORM);
    add(form);
    
    final DropDownChoice<RecommenderEvaluationScoreMetricEnum> dropdown = 
            new BootstrapSelect<RecommenderEvaluationScoreMetricEnum>(
            "select", new Model<RecommenderEvaluationScoreMetricEnum>(DROPDOWN_VALUES.get(0)),
            new ListModel<RecommenderEvaluationScoreMetricEnum>(DROPDOWN_VALUES));
    dropdown.setOutputMarkupId(true);
    selectedValue = RecommenderEvaluationScoreMetricEnum.Accuracy;

    dropdown.add(new AjaxFormComponentUpdatingBehavior("change")
    {
        private static final long serialVersionUID = -6744838136235652577L;

        @Override
        protected void onUpdate(AjaxRequestTarget _target)
        {
            selectedValue = dropdown.getModelObject();

            if (chartPanel == null) {
                return;
            }
            
            startEvaluation(_target, form);
        }
    });

    form.add(dropdown);
    
    emptyPanel  = new EmptyPanel(MID_CHART_CONTAINER);
    emptyPanel.setOutputMarkupPlaceholderTag(true);
    emptyPanel.setMarkupId(OUTPUT_MID_CHART_CONTAINER);
    emptyPanel.setOutputMarkupId(true);
    form.add(emptyPanel);
    
    // clicking the start button the annotated documents are evaluated and the learning curve
    // for the selected recommender is plotted in the hCart Panel
    @SuppressWarnings({ "unchecked", "rawtypes" })
    LambdaAjaxButton startButton = new LambdaAjaxButton(MID_SIMULATION_START_BUTTON,
        (_target, _form) -> 
            startEvaluation(_target, _form )
        );
    
    form.add(startButton);
}
 
Example 19
Source File: KnowledgeBasePanel.java    From inception with Apache License 2.0 4 votes vote down vote up
public KnowledgeBasePanel(String id, IModel<Project> aProjectModel,
        IModel<KnowledgeBase> aKbModel)
{
    super(id, aKbModel);

    setOutputMarkupId(true);

    kbModel = aKbModel;
    
    // add the selector for the knowledge bases
    DropDownChoice<KnowledgeBase> ddc = new BootstrapSelect<KnowledgeBase>("knowledgebases",
            LoadableDetachableModel
                    .of(() -> kbService.getEnabledKnowledgeBases(aProjectModel.getObject())));
    
    ddc.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> {
        long projectId = aProjectModel.getObject().getId();
        String kbName = aKbModel.getObject().getName();

        PageParameters params = new PageParameters()
            .set(PAGE_PARAM_PROJECT_ID, projectId)
            .set(PAGE_PARAM_KB_NAME, kbName);

        setResponsePage(KnowledgeBasePage.class, params);
    }));

    ddc.setModel(aKbModel);
    ddc.setChoiceRenderer(new ChoiceRenderer<>("name"));
    add(ddc);

    add(createSearchField("searchBar", searchHandleModel, aProjectModel));

    add(conceptTreePanel = new ConceptTreePanel("concepts", kbModel, selectedConceptHandle));
    add(propertyListPanel = new PropertyListPanel("properties", kbModel,
            selectedPropertyHandle));
    
    detailContainer = new WebMarkupContainer(DETAIL_CONTAINER_MARKUP_ID);
    detailContainer.setOutputMarkupId(true);
    add(detailContainer);
    
    details = new EmptyPanel(DETAILS_MARKUP_ID);
    detailContainer.add(details);
}
 
Example 20
Source File: KnowledgeBaseIriPanel.java    From inception with Apache License 2.0 4 votes vote down vote up
public KnowledgeBaseIriPanel(String id, CompoundPropertyModel<KnowledgeBaseWrapper> aModel)
{
    super(id);
    setOutputMarkupId(true);
    selectedSchemaProfile = Model.of(SchemaProfile.RDFSCHEMA);

    kbModel = aModel;

    DropDownChoice<Reification> reificationChoice = selectReificationStrategy("reification",
            "kb.reification");
    add(reificationChoice);

    // The Kendo comboboxes do not redraw properly when added directly to an
    // AjaxRequestTarget (for each combobox, a text field and a dropdown will be shown).
    // Instead, wrap all of them in a WMC and redraw that.
    WebMarkupContainer comboBoxWrapper = new WebMarkupContainer("comboBoxWrapper");
    comboBoxWrapper.setOutputMarkupId(true);
    add(comboBoxWrapper);
    
    // Add comboboxes for classIri, subclassIri, typeIri and descriptionIri
    ComboBox<String> classField = buildComboBox("classIri", kbModel.bind("kb.classIri"),
            IriConstants.CLASS_IRIS);
    ComboBox<String> subclassField = buildComboBox("subclassIri",
            kbModel.bind("kb.subclassIri"), IriConstants.SUBCLASS_IRIS);
    ComboBox<String> typeField = buildComboBox("typeIri", kbModel.bind("kb.typeIri"),
            IriConstants.TYPE_IRIS);
    ComboBox<String> subPropertyField = buildComboBox("subPropertyIri",
        kbModel.bind("kb.subPropertyIri"), IriConstants.SUBPROPERTY_IRIS);
    ComboBox<String> descriptionField = buildComboBox("descriptionIri",
            kbModel.bind("kb.descriptionIri"), IriConstants.DESCRIPTION_IRIS);
    ComboBox<String> labelField = buildComboBox("labelIri",
            kbModel.bind("kb.labelIri"), IriConstants.LABEL_IRIS);
    ComboBox<String> propertyTypeField = buildComboBox("propertyTypeIri",
            kbModel.bind("kb.propertyTypeIri"), IriConstants.PROPERTY_TYPE_IRIS);
    ComboBox<String> propertyLabelField = buildComboBox("propertyLabelIri",
            kbModel.bind("kb.propertyLabelIri"), IriConstants.PROPERTY_LABEL_IRIS);
    ComboBox<String> propertyDescriptionField = buildComboBox("propertyDescriptionIri",
            kbModel.bind("kb.propertyDescriptionIri"), IriConstants.PROPERTY_DESCRIPTION_IRIS);
    comboBoxWrapper
        .add(classField, subclassField, typeField, subPropertyField, descriptionField,
            labelField, propertyTypeField, propertyLabelField, propertyDescriptionField);
    
    // RadioGroup to select the IriSchemaType
    DropDownChoice<SchemaProfile> iriSchemaChoice = new BootstrapSelect<SchemaProfile>(
            "iriSchema", selectedSchemaProfile, Arrays.asList(SchemaProfile.values()),
            new EnumChoiceRenderer<>(this))
    {
        private static final long serialVersionUID = 3863260896285332033L;

        @Override
        protected void onInitialize()
        {
            super.onInitialize();
            // Initialize according to current model values
            SchemaProfile modelProfile = SchemaProfile
                .checkSchemaProfile(kbModel.getObject().getKb());

            setModelObject(modelProfile);
        }
    };
    iriSchemaChoice.setOutputMarkupId(true);
    // OnChange update the model with corresponding iris
    iriSchemaChoice.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> {
        SchemaProfile profile = iriSchemaChoice.getModelObject();
        // If the user switches to the custom profile, we retain the values from the
        // previously selected profile and just make the IRI mapping ediable. If the user
        // switches to a pre-defined profile, we reset the values.
        if (SchemaProfile.CUSTOMSCHEMA != profile) {
            classField.setModelObject(profile.getClassIri().stringValue());
            subclassField.setModelObject(profile.getSubclassIri().stringValue());
            typeField.setModelObject(profile.getTypeIri().stringValue());
            descriptionField.setModelObject(profile.getDescriptionIri().stringValue());
            labelField.setModelObject(profile.getLabelIri().stringValue());
            propertyTypeField.setModelObject(profile.getPropertyTypeIri().stringValue());
            propertyLabelField.setModelObject(profile.getPropertyLabelIri().stringValue());
            propertyDescriptionField
                .setModelObject(profile.getPropertyDescriptionIri().stringValue());
        }
        _target.add(comboBoxWrapper, iriSchemaChoice, reificationChoice);
    }));
    comboBoxWrapper.add(iriSchemaChoice);
}