Java Code Examples for org.apache.wicket.markup.html.form.ChoiceRenderer

The following examples show how to use org.apache.wicket.markup.html.form.ChoiceRenderer. These examples are extracted from open source projects. 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 Project: webanno   Source File: ProjectSelectionPanel.java    License: Apache License 2.0 7 votes vote down vote up
public ProjectSelectionPanel(String id, IModel<Project> aModel)
{
    super(id);

    overviewList = new OverviewListChoice<>("project");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("name"));
    overviewList.setModel(aModel);
    overviewList.setChoices(LambdaModel.of(this::listProjects));
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange));
    add(overviewList);

    add(createLink = new LambdaAjaxLink("create", this::actionCreate));
    MetaDataRoleAuthorizationStrategy.authorize(createLink, Component.RENDER, StringUtils.join(
            new String[] { Role.ROLE_ADMIN.name(), Role.ROLE_PROJECT_CREATOR.name() }, ","));
    
    importProjectPanel = new ProjectImportPanel("importPanel", aModel);
    add(importProjectPanel);
    authorize(importProjectPanel, Component.RENDER,
            String.join(",", ROLE_ADMIN.name(), ROLE_PROJECT_CREATOR.name()));
}
 
Example 2
Source Project: inception   Source File: KnowledgeBaseListPanel.java    License: Apache License 2.0 6 votes vote down vote up
public KnowledgeBaseListPanel(String id, IModel<Project> aProjectModel,
        IModel<KnowledgeBase> aKbModel) {
    super(id, aProjectModel);
    
    setOutputMarkupId(true);
    
    kbModel = aKbModel;        
    
    projectModel = aProjectModel;        
    overviewList = new OverviewListChoice<>("knowledgebases");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("name"));
    overviewList.setChoices(
            LambdaModel.of(() -> kbService.getKnowledgeBases(projectModel.getObject())));
    overviewList.setModel(kbModel);
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange));
    add(overviewList);
    
    modal = new KnowledgeBaseCreationDialog("modal", projectModel);
    add(modal);
    add(new LambdaAjaxLink("new", this::actionCreate));
}
 
Example 3
Source Project: inception   Source File: StatementGroupPanel.java    License: Apache License 2.0 6 votes vote down vote up
public NewStatementGroupFragment(String aId) {
    super(aId, "newStatementGroup", StatementGroupPanel.this, groupModel);
                
    IModel<KBProperty> property = Model.of();
    
    Form<KBProperty> form = new Form<>("form", property);
    DropDownChoice<KBProperty> type = new BootstrapSelect<>("property");
    type.setModel(property);
    type.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));            
    type.setChoices(getUnusedProperties());
    type.setRequired(true);
    type.setOutputMarkupId(true);
    form.add(type);
    focusComponent = type;
    
    form.add(new LambdaAjaxButton<>("create", this::actionNewProperty));
    form.add(new LambdaAjaxLink("cancel", this::actionCancelNewProperty));
    add(form);
}
 
Example 4
Source Project: inception   Source File: RecommenderListPanel.java    License: Apache License 2.0 6 votes vote down vote up
public RecommenderListPanel(String id, IModel<Project> aProject,
        IModel<Recommender> aRecommender, boolean showCreateButton)
{
    super(id);
    
    setOutputMarkupId(true);
    
    projectModel = aProject;
    selectedRecommender = aRecommender;

    overviewList = new OverviewListChoice<>("recommenders");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("name"));
    overviewList.setModel(selectedRecommender);
    overviewList.setChoices(LambdaModel.of(this::listRecommenders));
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange));
    add(overviewList);
    
    LambdaAjaxLink lambdaAjaxLink = new LambdaAjaxLink("create", this::actionCreate);
    add(lambdaAjaxLink);  
    
    if (!showCreateButton)        {
        lambdaAjaxLink.setVisible(false);
    }
}
 
Example 5
Source Project: inception   Source File: SearchAnnotationSidebar.java    License: 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 6
Source Project: inception   Source File: DocumentRepositoryListPanel.java    License: Apache License 2.0 6 votes vote down vote up
public DocumentRepositoryListPanel(String id, IModel<Project> aProject,
        IModel<DocumentRepository> aDocumentRepository)
{
    super(id);

    setOutputMarkupId(true);

    projectModel = aProject;
    selectedDocumentRepository = aDocumentRepository;

    overviewList = new OverviewListChoice<>("documentRepositories");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("name"));
    overviewList.setModel(selectedDocumentRepository);
    overviewList.setChoices(LambdaModel.of(this::listDocumentRepositories));
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange));
    add(overviewList);

    add(new LambdaAjaxLink("create", this::actionCreate));
}
 
Example 7
Source Project: inception   Source File: ExternalSearchAnnotationSidebar.java    License: 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 8
Source Project: inception   Source File: SearchPage.java    License: Apache License 2.0 6 votes vote down vote up
public SearchForm(String id)
{
    super(id);
    
    setModel(CompoundPropertyModel.of(new SearchFormModel()));
    
    DropDownChoice<DocumentRepository> repositoryCombo = 
            new BootstrapSelect<DocumentRepository>("repository");
    repositoryCombo.setChoices(LoadableDetachableModel
            .of(() -> externalSearchService.listDocumentRepositories(project)));
    repositoryCombo.setChoiceRenderer(new ChoiceRenderer<DocumentRepository>("name"));
    repositoryCombo.setNullValid(false);
    add(repositoryCombo);
    
    if (!repositoryCombo.getChoices().isEmpty()) {
        repositoryCombo.setModelObject(repositoryCombo.getChoices().get(0));
    }
    
    add(new TextField<>("query", String.class));
    
    LambdaAjaxSubmitLink searchLink = new LambdaAjaxSubmitLink("submitSearch",
            this::actionSearch);
    add(searchLink);
    setDefaultButton(searchLink);
}
 
Example 9
Source Project: webanno   Source File: TagSetSelectionPanel.java    License: Apache License 2.0 6 votes vote down vote up
public TagSetSelectionPanel(String id, IModel<Project> aProject, IModel<TagSet> aTagset)
{
    super(id, aProject);
    
    setOutputMarkupId(true);
    setOutputMarkupPlaceholderTag(true);
    
    selectedProject = aProject;
    
    overviewList = new OverviewListChoice<>("tagset");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("name"));
    overviewList.setModel(aTagset);
    overviewList.setChoices(LambdaModel.of(this::listTagSets));
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange));
    add(overviewList);

    add(new LambdaAjaxLink("create", this::actionCreate));
    
    tagSetImportPanel = new TagSetImportPanel("importPanel", selectedProject);
    tagSetImportPanel.setImportCompleteAction(target -> {
        target.add(findParent(ProjectTagSetsPanel.class));
    });
    add(tagSetImportPanel);
}
 
Example 10
Source Project: webanno   Source File: TagSelectionPanel.java    License: Apache License 2.0 6 votes vote down vote up
public TagSelectionPanel(String id, IModel<TagSet> aTagset, IModel<Tag> aTag)
{
    super(id, aTagset);
    
    setOutputMarkupId(true);
    setOutputMarkupPlaceholderTag(true);
    
    selectedTagSet = aTagset;

    overviewList = new OverviewListChoice<>("tag");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("name"));
    overviewList.setModel(aTag);
    overviewList.setChoices(LambdaModel.of(this::listTags));
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange));
    add(overviewList);

    add(new LambdaAjaxLink("create", this::actionCreate));
}
 
Example 11
Source Project: webanno   Source File: DocumentListPanel.java    License: Apache License 2.0 6 votes vote down vote up
public DocumentListPanel(String aId, IModel<Project> aProject)
{
    super(aId);
 
    setOutputMarkupId(true);
    
    project = aProject;
    selectedDocuments = new CollectionModel<>();

    Form<Void> form = new Form<>("form");
    add(form);
    
    overviewList = new ListMultipleChoice<>("documents");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("name"));
    overviewList.setModel(selectedDocuments);
    overviewList.setChoices(LambdaModel.of(this::listSourceDocuments));
    form.add(overviewList);

    confirmationDialog = new ConfirmationDialog("confirmationDialog");
    confirmationDialog.setTitleModel(new StringResourceModel("DeleteDialog.title", this));
    add(confirmationDialog);

    form.add(new LambdaAjaxButton<>("delete", this::actionDelete));
}
 
Example 12
Source Project: webanno   Source File: ProjectCasDoctorPanel.java    License: Apache License 2.0 6 votes vote down vote up
public ProjectCasDoctorPanel(String id, IModel<Project> aProjectModel)
{
    super(id, aProjectModel);

    setOutputMarkupId(true);
    
    Form<FormModel> form = new Form<>("casDoctorForm", PropertyModel.of(this, "formModel"));
    add(form);

    CheckBoxMultipleChoice<Class<? extends Repair>> repairs = new CheckBoxMultipleChoice<>(
            "repairs");
    repairs.setModel(PropertyModel.of(this, "formModel.repairs"));
    repairs.setChoices(CasDoctor.scanRepairs());
    repairs.setChoiceRenderer(new ChoiceRenderer<>("simpleName"));
    repairs.setPrefix("<div class=\"checkbox\">");
    repairs.setSuffix("</div>");
    repairs.setLabelPosition(LabelPosition.WRAP_AFTER);
    form.add(repairs);
        
    form.add(new LambdaAjaxButton<FormModel>("check", this::actionCheck));
    form.add(new LambdaAjaxButton<FormModel>("repair", this::actionRepair));
    add(createMessageSetsView());
}
 
Example 13
Source Project: webanno   Source File: UserSelectionPanel.java    License: Apache License 2.0 6 votes vote down vote up
public UserSelectionPanel(String id, IModel<User> aModel)
{
    super(id);
    setOutputMarkupPlaceholderTag(true);

    overviewList = new OverviewListChoice<>("user");
    overviewList.setChoiceRenderer(new ChoiceRenderer<User>() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(User aUser)
        {
            return aUser.getUsername() + (aUser.isEnabled() ? "" : " (disabled)");
        }
    });
    overviewList.setModel(aModel);
    overviewList.setChoices(this::listUsers);
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange));
    add(overviewList);

    add(new LambdaAjaxLink("create", this::actionCreate));
    showDisabled = new CheckBox("showDisabled", Model.of(false));
    showDisabled.add(
            new LambdaAjaxFormComponentUpdatingBehavior("change", this::toggleShowDisabled));
    add(showDisabled);
}
 
Example 14
Source Project: oodt   Source File: TypeBrowser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param id
 *          The wicket:id component ID of this form.
 */
public AddCriteriaForm(String id) {
  super(id, new CompoundPropertyModel<ElementCrit>(new ElementCrit()));
  List<Element> ptypeElements = fm.safeGetElementsForProductType(type);
  Collections.sort(ptypeElements, new Comparator<Element>() {
    public int compare(Element e1, Element e2) {
      return e1.getElementName().compareTo(e2.getElementName());
    }
  });

  add(new DropDownChoice<Element>("criteria_list", new PropertyModel(
      getDefaultModelObject(), "elem"), new ListModel<Element>(
      ptypeElements), new ChoiceRenderer<Element>("elementName",
      "elementId")));
  add(new TextField<TermQueryCriteria>(
      "criteria_form_add_element_value",
      new PropertyModel<TermQueryCriteria>(getDefaultModelObject(), "value")));
  add(new Button("criteria_elem_add"));
}
 
Example 15
Source Project: inception   Source File: QualifierEditor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new fragement for editing a qualifier.<br>
 * The editor has two slightly different behaviors, depending on the value of
 * {@code isNewQualifier}:
 * <ul>
 * <li>{@code !isNewQualifier}: Save button commits changes, cancel button discards unsaved
 * changes, delete button removes the qualifier from the statement.</li>
 * <li>{@code isNewQualifier}: Save button commits changes (creates a new qualifier in the
 * statement), cancel button removes the qualifier from the UI, delete button is not visible
 * .</li>
 * </ul>
 *
 * @param aId
 *            markup ID
 * @param aQualifier
 *            qualifier model
 * @param isNewQualifier
 *            whether the qualifier being edited is new, meaning it has no corresponding
 *            qualifier in the KB backend
 */
public EditMode(String aId, IModel<KBQualifier> aQualifier, boolean isNewQualifier)
{
    super(aId, "editMode", QualifierEditor.this, aQualifier);

    IModel<KBQualifier> compoundModel = CompoundPropertyModel.of(aQualifier);

    Form<KBQualifier> form = new Form<>("form", compoundModel);
    DropDownChoice<KBProperty> type = new BootstrapSelect<>("property");
    type.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));
    type.setChoices(kbService.listProperties(kbModel.getObject(), false));
    type.setRequired(true);
    type.setOutputMarkupId(true);
    form.add(type);
    initialFocusComponent = type;

    form.add(new TextField<>("language"));

    Component valueTextArea = new TextArea<String>("value");
    form.add(valueTextArea);

    form.add(new LambdaAjaxButton<>("create", QualifierEditor.this::actionSave));
    form.add(new LambdaAjaxLink("cancel", t -> {
        if (isNewQualifier) {
            QualifierEditor.this.actionCancelNewQualifier(t);
        } else {
            QualifierEditor.this.actionCancelExistingQualifier(t);
        }
    }));
    form.add(new LambdaAjaxLink("delete", QualifierEditor.this::actionDelete)
        .setVisibilityAllowed(!isNewQualifier));

    add(form);
}
 
Example 16
Source Project: inception   Source File: ConceptListPanel.java    License: Apache License 2.0 5 votes vote down vote up
public ConceptListPanel(String aId, IModel<KnowledgeBase> aKbModel,
        IModel<KBHandle> selectedConceptModel) {
    super(aId, selectedConceptModel);

    setOutputMarkupId(true);

    selectedConcept = selectedConceptModel;
    kbModel = aKbModel;
    preferences = Model.of(new Preferences());

    OverviewListChoice<KBHandle> overviewList = new OverviewListChoice<>("concepts");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));
    overviewList.setModel(selectedConceptModel);
    overviewList.setChoices(LambdaModel.of(this::getConcepts));
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change",
            this::actionSelectionChanged));
    overviewList.setMaxRows(LIST_MAX_ROWS);
    add(overviewList);

    add(new Label("count", LambdaModel.of(() -> overviewList.getChoices().size())));

    LambdaAjaxLink addLink = new LambdaAjaxLink("add", target -> send(getPage(),
            Broadcast.BREADTH, new AjaxNewConceptEvent(target)));
    addLink.add(new Label("label", new ResourceModel("concept.list.add")));
    addLink.add(new WriteProtectionBehavior(kbModel));
    add(addLink);

    Form<Preferences> form = new Form<>("form", CompoundPropertyModel.of(preferences));
    form.add(new CheckBox("showAllConcepts").add(
            new LambdaAjaxFormSubmittingBehavior("change", this::actionPreferenceChanged)));
    add(form);
}
 
Example 17
Source Project: inception   Source File: PropertyListPanel.java    License: Apache License 2.0 5 votes vote down vote up
public PropertyListPanel(String aId, IModel<KnowledgeBase> aKbModel, IModel<KBProperty> aModel)
{
    super(aId, aModel);

    setOutputMarkupId(true);

    selectedProperty = aModel;
    kbModel = aKbModel;
    preferences = Model.of(new Preferences());

    OverviewListChoice<KBProperty> overviewList = new OverviewListChoice<>("properties");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));
    overviewList.setModel(selectedProperty);
    overviewList.setChoices(LambdaModel.of(this::getProperties));
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change",
            this::actionSelectionChanged));
    
    add(overviewList);

    add(new Label("count", LambdaModel.of(() -> overviewList.getChoices().size())));

    LambdaAjaxLink addLink = new LambdaAjaxLink("add",
        target -> send(getPage(), Broadcast.BREADTH, new AjaxNewPropertyEvent(target)));
    addLink.add(new Label("label", new ResourceModel("property.list.add")));
    addLink.add(new WriteProtectionBehavior(kbModel));
    add(addLink);

    Form<Preferences> form = new Form<>("form", CompoundPropertyModel.of(preferences));
    form.add(new CheckBox("showAllProperties").add(
            new LambdaAjaxFormSubmittingBehavior("change", this::actionPreferenceChanged)));
    add(form);
}
 
Example 18
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 19
public LappsGridRecommenderTraitsEditor(String aId, IModel<Recommender> aRecommender)
{
    super(aId, aRecommender);

    traits = toolFactory.readTraits(aRecommender.getObject());
    traitsModel = CompoundPropertyModel.of(traits);
    Form<LappsGridRecommenderTraits> form =
            new Form<LappsGridRecommenderTraits>(MID_FORM, traitsModel)
    {
        private static final long serialVersionUID = -3109239605742291123L;

        @Override
        protected void onSubmit()
        {
            super.onSubmit();
            toolFactory.writeTraits(aRecommender.getObject(), traits);
        }
    };

    urlField = new TextField<>(MID_URL);
    urlField.setRequired(true);
    urlField.add(new UrlValidator());
    urlField.setOutputMarkupId(true);
    form.add(urlField);

    servicesDropDown = new BootstrapSelect<>(MID_SERVICES);
    servicesDropDown.setModel(Model.of());
    servicesDropDown.setChoices(LoadableDetachableModel.of(this::getPredefinedServicesList));
    servicesDropDown.setChoiceRenderer(new ChoiceRenderer<>("description"));
    servicesDropDown.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> {
        LappsGridService selection = servicesDropDown.getModelObject();
        if (selection != null) {
            traits.setUrl(selection.getUrl());
        }
        t.add(urlField);
    }));
    form.add(servicesDropDown);

    add(form);
}
 
Example 20
Source Project: openmeetings   Source File: OAuthForm.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize() {
	add(new CheckBox("isEnabled"));
	add(new RequiredTextField<String>("name").setLabel(new ResourceModel("165")));
	add(new TextField<String>("iconUrl").setLabel(new ResourceModel("1575")));
	add(new RequiredTextField<String>("clientId").setLabel(Model.of("client_id")));
	add(new RequiredTextField<String>("clientSecret").setLabel(Model.of("client_secret")));
	add(redirectUriText = (TextField<String>) new TextField<>("redirectUri", Model.of("")).setLabel(new ResourceModel("1587")));
	add(new RequiredTextField<String>("requestKeyUrl").setLabel(new ResourceModel("1578")));
	add(new DropDownChoice<>("requestTokenMethod", List.of(RequestTokenMethod.values()), new ChoiceRenderer<RequestTokenMethod>("name", "name")));
	add(new RequiredTextField<String>("requestTokenUrl").setLabel(new ResourceModel("1579")));
	add(new RequiredTextField<String>("requestTokenAttributes").setLabel(new ResourceModel("1586")));
	add(new RequiredTextField<String>("requestInfoUrl").setLabel(new ResourceModel("1580")));
	add(new DropDownChoice<>("requestInfoMethod", List.of(RequestInfoMethod.values()), new ChoiceRenderer<RequestInfoMethod>("name", "name")));
	Form<Void> mappingForm = new Form<>("mappingForm");
	final TextField<String> omAttr = new TextField<>("omAttr", Model.of(""));
	final TextField<String> oauthAttr = new TextField<>("oauthAttr", Model.of(""));
	add(mappingForm.add(omAttr, oauthAttr
			, new BootstrapAjaxButton("addMapping", new ResourceModel("1261"), mappingForm, Buttons.Type.Outline_Primary) {
				private static final long serialVersionUID = 1L;

				@Override
				protected void onSubmit(AjaxRequestTarget target) {
					if (Strings.isEmpty(omAttr.getModelObject()) || Strings.isEmpty(oauthAttr.getModelObject())) {
						return;
					}
					OAuthServer s = OAuthForm.this.getModelObject();
					s.addMapping(omAttr.getModelObject(), oauthAttr.getModelObject());
					updateMapping();
					target.add(attrsContainer, mappingForm);
				}
			}).setOutputMarkupId(true));
	add(attrsContainer.add(updateMapping()).setOutputMarkupId(true));
	super.onInitialize();
}
 
Example 21
Source Project: openmeetings   Source File: LangForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Render Main
 *
 * @param id - id of this form
 * @param listContainer - container holds list of labels
 * @param langPanel - language panel
 */
public LangForm(String id, final WebMarkupContainer listContainer, final LangPanel langPanel) {
	super(id);
	setOutputMarkupId(true);

	languages = new DropDownChoice<>("language"
			, new PropertyModel<Map.Entry<Long, Locale>>(langPanel, "language")
			, getLanguages()
			, new ChoiceRenderer<Map.Entry<Long, Locale>>() {
				private static final long serialVersionUID = 1L;

				@Override
				public Object getDisplayValue(Map.Entry<Long, Locale> object) {
					return object.getValue().getDisplayName();
				}

				@Override
				public String getIdValue(Map.Entry<Long, Locale> object, int index) {
					return "" + object.getKey();
				}
			});

	languages.add(new OnChangeAjaxBehavior() {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			target.add(listContainer);
		}
	});
	add(languages);
	// attach an ajax validation behavior to all form component's keydown
	// event and throttle it down to once per second
	add(new AjaxFormValidatingBehavior("keydown", Duration.ofSeconds(1)));
}
 
Example 22
Source Project: webanno   Source File: OpenDocumentDialogPanel.java    License: Apache License 2.0 5 votes vote down vote up
private OverviewListChoice<DecoratedObject<SourceDocument>> createDocListChoice()
{
    docListChoice = new OverviewListChoice<>("documents", Model.of(), listDocuments());
    docListChoice.setChoiceRenderer(new ChoiceRenderer<DecoratedObject<SourceDocument>>()
    {
        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(DecoratedObject<SourceDocument> aDoc)
        {
            return defaultIfEmpty(aDoc.getLabel(), aDoc.get().getName());
        }
    });
    docListChoice.setOutputMarkupId(true);
    docListChoice.add(new OnChangeAjaxBehavior()
    {
        private static final long serialVersionUID = -8232688660762056913L;

        @Override
        protected void onUpdate(AjaxRequestTarget aTarget)
        {
            aTarget.add(buttonsContainer);
        }
    }).add(AjaxEventBehavior.onEvent("dblclick", _target -> actionOpenDocument(_target, null)));

    if (!docListChoice.getChoices().isEmpty()) {
        docListChoice.setModelObject(docListChoice.getChoices().get(0));
    }
    
    return docListChoice;
}
 
Example 23
Source Project: webanno   Source File: ProjectConstraintsPanel.java    License: Apache License 2.0 5 votes vote down vote up
public SelectionForm(String aId, IModel<ConstraintSet> aModel)
{
    super(aId, aModel);

    LoadableDetachableModel<List<ConstraintSet>> rulesets = 
            new LoadableDetachableModel<List<ConstraintSet>>()
    {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<ConstraintSet> load()
        {
            return constraintsService
                    .listConstraintSets(ProjectConstraintsPanel.this.getModelObject());
        }
    };
    
    add(new ListChoice<ConstraintSet>("ruleset", SelectionForm.this.getModel(), rulesets) {
        private static final long serialVersionUID = 1L;
        
        {
            setChoiceRenderer(new ChoiceRenderer<>("name"));
            setNullValid(false);
            add(new FormComponentUpdatingBehavior());
        }
        
        @Override
        protected CharSequence getDefaultChoice(String aSelectedValue)
        {
            return "";
        }
    });
}
 
Example 24
Source Project: webanno   Source File: LayerSelectionPanel.java    License: 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 25
Source Project: webanno   Source File: AgreementPage.java    License: Apache License 2.0 5 votes vote down vote up
public ProjectSelectionForm(String id)
{
    super(id, new CompoundPropertyModel<>(new ProjectSelectionModel()));

    ListChoice<Project> projectList = new OverviewListChoice<>("project");
    projectList.setChoiceRenderer(new ChoiceRenderer<>("name"));
    projectList.setChoices(LoadableDetachableModel.of(this::listAllowedProjects));
    projectList.add(new LambdaAjaxFormComponentUpdatingBehavior("change",
            this::onSelectionChanged));
    add(projectList);
}
 
Example 26
Source Project: Orienteer   Source File: AddRuleDialog.java    License: Apache License 2.0 5 votes vote down vote up
public AddRuleDialog(ModalWindow modal) {
	super(modal);
	form.add(new DropDownChoice<ORule.ResourceGeneric>("resource", resourceModel, 
							Arrays.asList(ORule.ResourceGeneric.values()), new ChoiceRenderer<ORule.ResourceGeneric>("name"))
				.setNullValid(true));
	form.add(new TextField<String>("specific", specificModel));
	
	addCommand(new AjaxFormCommand<Void>(newCommandId(), "command.submit") {
		@Override
		public void onSubmit(AjaxRequestTarget target) {
			onRuleEntered(target, resourceModel.getObject(), specificModel.getObject());
		}
	}.setBootstrapType(BootstrapType.PRIMARY));
}
 
Example 27
Source Project: nextreports-server   Source File: NextRuntimePanel.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
  public void addWicketComponents() {    	        	    	
  	
      final DropDownChoice<String> exportChoice = new DropDownChoice<String>("exportType", new PropertyModel<String>(runtimeModel, "exportType"), typeList,
      		new ChoiceRenderer<String>() {
			@Override
			public Object getDisplayValue(String name) {
				if (name.equals(ReportConstants.ETL_FORMAT)) {
					return getString("Analysis.source");
				} else {
					return name;
				}
			}
});
      exportChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {
          @Override
          protected void onUpdate(AjaxRequestTarget target) {
              String format = (String) getFormComponent().getConvertedInput();
              if (ReportConstants.ETL_FORMAT.equals(format)) {
			System.out.println("***** ETL selected");
			//analysisPanel.setVisible(true);
		} else {
			System.out.println("***** " + format);
			//analysisPanel.setVisible(false);
		}
              //target.add(analysisPanel);
          }
      });
	
      exportChoice.setRequired(true);
      add(exportChoice);
      
      if (report.isAlarmType() || report.isIndicatorType() || report.isDisplayType()) {
      	exportChoice.setEnabled(false);
      } else {
      	exportChoice.setRequired(true);
      }
      
      
  }
 
Example 28
Source Project: inception   Source File: InstanceListPanel.java    License: Apache License 2.0 4 votes vote down vote up
public InstanceListPanel(String aId, IModel<KnowledgeBase> aKbModel, IModel<KBObject> aConcept,
        IModel<KBObject> aInstance) {
    super(aId, aInstance);

    setOutputMarkupId(true);

    kbModel = aKbModel;
    conceptModel = aConcept;
    showAll = Model.of(Boolean.FALSE);
    
    IModel<List<KBHandle>> instancesModel = LoadableDetachableModel.of(this::getInstances);

    OverviewListChoice<KBObject> overviewList = new OverviewListChoice<KBObject>("instances") {
        private static final long serialVersionUID = -122960232588575731L;

        @Override
        protected void onConfigure()
        {
            super.onConfigure();
            
            setVisible(!instancesModel.getObject().isEmpty());
        }
    };
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));
    overviewList.setModel(aInstance);
    overviewList.setChoices(instancesModel);
    overviewList
            .add(new LambdaAjaxFormComponentUpdatingBehavior("change",
                target -> send(getPage(), Broadcast.BREADTH,
                            new AjaxInstanceSelectionEvent(target, aInstance.getObject()))));
    add(overviewList);

    add(new Label("count", LambdaModel.of(() -> overviewList.getChoices().size())));

    LambdaAjaxLink addLink = new LambdaAjaxLink("add",
        target -> send(getPage(), Broadcast.BREADTH, new AjaxNewInstanceEvent(target)));
    addLink.add(new Label("label", new ResourceModel("instance.add")));
    addLink.add(new WriteProtectionBehavior(kbModel));
    add(addLink);

    add(new Label("noInstancesNotice", new ResourceModel("instance.nonedefined")) {
        private static final long serialVersionUID = 2252854898212441711L;

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

            setVisible(instancesModel.getObject().isEmpty());
        }
    });

    CheckBox showAllCheckBox = new CheckBox("showAllInstances", showAll);
    showAllCheckBox
            .add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> t.add(this)));
    add(showAllCheckBox);
}
 
Example 29
Source Project: inception   Source File: StatementEditor.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new fragement for editing a statement.<br>
 * The editor has two slightly different behaviors, depending on the value of
 * {@code isNewStatement}:
 * <ul>
 * <li>{@code !isNewStatement}: Save button commits changes, cancel button discards unsaved
 * changes, delete button removes the statement from the KB.</li>
 * <li>{@code isNewStatement}: Save button commits changes (creates a new statement in the
 * KB), cancel button removes the statement from the UI, delete button is not visible.</li>
 * </ul>
 * 
 * @param aId
 *            markup ID
 * @param aStatement
 *            statement model
 * @param isNewStatement
 *            whether the statement being edited is new, meaning it has no corresponding
 *            statement in the KB backend
 */
 
public EditMode(String aId, IModel<KBStatement> aStatement, boolean isNewStatement)
{
    super(aId, "editMode", StatementEditor.this, aStatement);
    CompoundPropertyModel<KBStatement> model = CompoundPropertyModel.of(aStatement);
    Form<KBStatement> form = new Form<>("form", model);
    // Set property to the property of the current statement
    if (property.getObject() == null) {
        Optional<KBProperty> prop = kbService.readProperty(kbModel.getObject(),
            aStatement.getObject().getProperty().getIdentifier());
        if (prop.isPresent()) {
            property.setObject(prop.get());
        }
    }

    String rangeValue = null;
    if (property.getObject() != null) {
        rangeValue = property.getObject().getRange();
    }

    List<ValueType> valueTypes;
    if (rangeValue != null) {
        Optional<KBObject> rangeKBHandle = kbService.readItem(kbModel.getObject(),
                rangeValue);
        valueTypes = valueTypeRegistry.getRangeTypes(rangeValue, rangeKBHandle);
    }
    else {
        valueTypes = valueTypeRegistry.getAllTypes();
    }
    
    valueType = new BootstrapSelect<>("valueType", valueTypes);
    valueType.setChoiceRenderer(new ChoiceRenderer<>("uiName"));
    valueType.setModel(Model.of(
            valueTypeRegistry.getValueType(aStatement.getObject(), property.getObject())));
    // replace the editor when the choice is changed
    valueType.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> {
        ValueEditor newEditor = valueTypeRegistry
                .getValueSupport(valueType.getModelObject())
                .createEditor("value", model, property, kbModel);
        editor.setOutputMarkupId(true);
        editor = (ValueEditor) editor.replaceWith(newEditor);
        t.add(editor);
    }));
    form.add(valueType);
    // use the IRI to obtain the appropriate value editor
    try {
        editor = valueTypeRegistry
            .getValueSupport(aStatement.getObject(), property.getObject())
           .createEditor("value", model, property, kbModel);
    }
    catch (IllegalArgumentException e) {
        LOG.warn("Unable to find an editor that supports the value type. "
                + "String Editor is used as default: {}", e.getLocalizedMessage());
        editor = new StringLiteralValueEditor("value", model);
    }
    editor.setOutputMarkupId(true);
    form.add(editor);
    form.add(new LambdaAjaxButton<>("save", StatementEditor.this::actionSave));
    form.add(new LambdaAjaxLink("cancel", t -> {
        if (isNewStatement) {
            StatementEditor.this.actionCancelNewStatement(t);
        }
        else {
            StatementEditor.this.actionCancelExistingStatement(t);
        }
    }));
    form.add(new LambdaAjaxLink("delete", StatementEditor.this::actionDelete)
            .setVisibilityAllowed(!isNewStatement));
    add(form);
}
 
Example 30
Source Project: inception   Source File: KnowledgeBasePanel.java    License: 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);
}