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

The following are top voted examples for showing how to use org.apache.wicket.markup.html.form.DropDownChoice. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: artifactory   File: RepositoriesTabPanel.java   View source code 7 votes vote down vote up
private void addExcludesPatternFields(StringResourceModel helpMessage,
        final List<CommonPathPattern> includesExcludesSuggestions) {
    TextArea excludesTa = new TextArea("excludesPattern");
    excludesTa.setEnabled(isSystemAdmin());
    excludesTa.setOutputMarkupId(true);
    add(excludesTa);

    add(new HelpBubble("excludesHelp", helpMessage));

    //Excludes suggestions
    Model<CommonPathPattern> exclude = new Model<>();
    DropDownChoice<CommonPathPattern> excludesSuggest = new DropDownChoice<>(
            "excludesSuggest", exclude, includesExcludesSuggestions);
    if (!includesExcludesSuggestions.isEmpty()) {
        excludesSuggest.setDefaultModelObject(includesExcludesSuggestions.get(0));
    }
    excludesSuggest.add(new UpdatePatternsBehavior(exclude, excludesTa));
    excludesSuggest.setEnabled(isSystemAdmin());
    add(excludesSuggest);
}
 
Example 2
Project: MasterStats   File: BasePage.java   View source code 6 votes vote down vote up
/**
 * generates the navbar and mark the active page
 *
 * @param activePage page to be marked active (null for no active page)
 */
private void loadNavbar(final PageType activePage) {
    // add an entry for each page type
    add(new ListView<PageType>("navbar_left_elements", Arrays.asList(PageType.values())) {
        @Override
        protected void populateItem(final ListItem<PageType> item) {
            final PageType type = item.getModelObject();
            // create a link for the page type
            BookmarkablePageLink<String> link = new BookmarkablePageLink<>("navbar_left_element_link", type.getPageClass());
            link.add(new Label("navbar_left_element_text", type.getLinkText()));
            // if the type is same as active page, mark it as active
            if (type.equals(activePage)) link.add(new AttributeAppender("class", "active", " "));
            item.add(link);
        }
    });

    // create the summoner search region drop down menu
    // get all valid entries
    List<String> endpoints = Arrays.asList(RiotEndpoint.PLAYABLE_ENDPOINTS)
            .stream().map(RiotEndpoint::name).collect(Collectors.toList());
    // add the options to the drop down menu
    DropDownChoice<String> dropDownChoice = new DropDownChoice<>("navbar_form_regions_select",
            new PropertyModel<>(this, "selectedRegion"), endpoints, new StringChoiceRenderer());
    dropDownChoice.add(new AttributeModifier("name", "region"));
    add(dropDownChoice);
}
 
Example 3
Project: engerek   File: AssignmentCatalogPanel.java   View source code 6 votes vote down vote up
private void initViewSelector(WebMarkupContainer headerPanel){
    DropDownChoice<AssignmentViewType> viewSelect = new DropDownChoice(ID_VIEW_TYPE, viewModel,
            Model.ofList(viewTypeList != null && viewTypeList.size() > 0 ?
                    viewTypeList : createAssignableTypesList()),
            new EnumChoiceRenderer<AssignmentViewType>(this));
    viewSelect.add(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            if (AssignmentViewType.USER_TYPE.equals(viewSelect.getModelObject())){
                initUserViewSelectionPopup(createStringResource("AssignmentCatalogPanel.selectAssignmentsUserOwner"),
                        target);
            } else {
                searchModel.reset();
                AssignmentCatalogPanel.this.addOrReplaceSearchPanel(getHeaderPanel());
                AssignmentCatalogPanel.this.addOrReplaceLayout(target, getCatalogItemsPanelContainer(), getPageBase());
                target.add(getCatalogItemsPanelContainer());
                target.add(getHeaderPanel());
            }
        }
    });
    viewSelect.setOutputMarkupId(true);
    headerPanel.add(viewSelect);

}
 
Example 4
Project: engerek   File: OrgMemberPanel.java   View source code 6 votes vote down vote up
@Override
protected ObjectQuery createContentQuery() {
	String oid = getModelObject().getOid();

	DropDownChoice<String> searchScopeChoice = (DropDownChoice<String>) get(
			createComponentPath(ID_FORM, ID_SEARCH_SCOPE));
	String scope = searchScopeChoice.getModelObject();

	ObjectTypes searchType = getSearchType();
	S_FilterEntryOrEmpty q = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext());
	if (!searchType.equals(ObjectTypes.OBJECT)) {
		q = q.type(searchType.getClassDefinition());
	}
	ObjectQuery query;
	if (SEARCH_SCOPE_ONE.equals(scope)) {
		query = q.isDirectChildOf(oid).build();
	} else {
		query = q.isChildOf(oid).build();
	}
	if (LOGGER.isTraceEnabled()) {
		LOGGER.trace("Searching members of org {} with query:\n{}", oid, query.debugDump());
	}
	return query;
}
 
Example 5
Project: engerek   File: LoggingConfigPanel.java   View source code 6 votes vote down vote up
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);
}
 
Example 6
Project: engerek   File: RoleMemberPanel.java   View source code 6 votes vote down vote up
private <V> DropDownChoice<V> createDropDown(String id, IModel<V> defaultModel, final List<V> values,
		IChoiceRenderer<V> renderer) {
	DropDownChoice<V> listSelect = new DropDownChoice<V>(id, defaultModel,
			new AbstractReadOnlyModel<List<V>>() {
				private static final long serialVersionUID = 1L;

				@Override
				public List<V> getObject() {
					return values;
				}
			}, renderer);

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

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			refreshTable(target);
		}
	});

	return listSelect;
}
 
Example 7
Project: engerek   File: ObjectTypeSelectPanel.java   View source code 6 votes vote down vote up
private void initLayout(IModel<QName> model, final Class<O> superclass) {
	select = new DropDownChoice<>(ID_SELECT, model,
			new AbstractReadOnlyModel<List<QName>>() {
				private static final long serialVersionUID = 1L;

				@Override
	            public List<QName> getObject() {
					if (superclass == null || superclass == ObjectType.class) {
						return WebComponentUtil.createObjectTypeList();
					}
					if (superclass == FocusType.class) {
						return WebComponentUtil.createFocusTypeList();
					}
					if (superclass == AbstractRoleType.class) {
						return WebComponentUtil.createAbstractRoleTypeList();
					}
					throw new IllegalArgumentException("Unknown superclass "+superclass);
	            }
		}, new QNameChoiceRenderer());
	select.setNullValid(true);
	
	add(select);
}
 
Example 8
Project: vlo-curation   File: AllFacetValuesPanel.java   View source code 6 votes vote down vote up
private Form createOptionsForm(String id) {
    final Form options = new AjaxIndicatingForm(id);

    final DropDownChoice<SortParam<FieldValuesOrder>> sortSelect
            = new FieldValueOrderSelector("sort", new PropertyModel<SortParam<FieldValuesOrder>>(valuesProvider, "sort"));
    sortSelect.add(new UpdateOptionsFormBehavior(options));
    options.add(sortSelect);

    final TextField filterField = new TextField<>("filter", new PropertyModel(filterModel, "name"));
    filterField.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(valuesContainer);
        }
    });
    options.add(filterField);

    addOccurenceOptions(options);

    return options;
}
 
Example 9
Project: vlo-curation   File: SearchResultsHeaderPanel.java   View source code 6 votes vote down vote up
private Form createResultPageSizeForm(String id, final IPageableItems resultsView) {
    final Form resultPageSizeForm = new Form(id);

    final DropDownChoice<Long> pageSizeDropDown
            = new DropDownChoice<Long>("resultPageSize",
                    // bind to items per page property of pageable
                    new PropertyModel<Long>(resultsView, "itemsPerPage"),
                    ITEMS_PER_PAGE_OPTIONS);
    pageSizeDropDown.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            onChange(target);
        }
    });
    resultPageSizeForm.add(pageSizeDropDown);

    return resultPageSizeForm;
}
 
Example 10
Project: singular-server   File: SelecaoMenuItem.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    Form                form  = new Form<String>("form");
    Model<ModuleEntity> model = new Model<>(SingularSession.get().getCategoriaSelecionada());
    final DropDownChoice<ModuleEntity> select = new DropDownChoice<>("select", model, categorias,
            new ChoiceRenderer<>("name", "cod"));

    form.add(select);
    select.add(new BSSelectInitBehaviour());
    select.add(new FormComponentAjaxUpdateBehavior("change", (target, component) -> {
        final ModuleEntity categoriaSelecionada = (ModuleEntity) component.getDefaultModelObject();
        SingularSession.get().setCategoriaSelecionada(categoriaSelecionada);
        getPage().getPageParameters().set(MODULE_PARAM_NAME, categoriaSelecionada.getCod());
        final BoxConfigurationData boxConfigurationMetadataDTO = getDefaultMenuSelection(categoriaSelecionada);
        if (boxConfigurationMetadataDTO != null) {
            getPage().getPageParameters().set(MENU_PARAM_NAME, boxConfigurationMetadataDTO.getLabel());
        } else {
            getPage().getPageParameters().remove(MENU_PARAM_NAME);
        }
        setResponsePage(getPage().getClass(), getPage().getPageParameters());
    }));

    add(form);
}
 
Example 11
Project: Unicorn   File: ChartConfigurationPanel.java   View source code 6 votes vote down vote up
private Component addChartTypeSelect() {
	this.chartTypeSelect = new DropDownChoice<ChartTypeEnum>("chartTypeSelect", this.chartType, this.chartTypes);
	this.chartTypeSelect.setOutputMarkupId(true);

	this.chartTypeSelect.add(new AjaxFormComponentUpdatingBehavior("onchange") {

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			ChartConfigurationPanel.this.updateAttributes();
			ChartConfigurationPanel.this.updateSlider();
			target.add(ChartConfigurationPanel.this.attributeSelect);
			target.add(ChartConfigurationPanel.this.sliderContainer);
		}
	});
	return this.chartTypeSelect;
}
 
Example 12
Project: Unicorn   File: BPMNMonitoringPanel.java   View source code 6 votes vote down vote up
private void addProcessSelect(final Form<Void> layoutForm) {
	this.processNameList = new ArrayList<String>();
	for (final CorrelationProcess process : CorrelationProcess.findAll()) {
		this.processNameList.add(process.getName());
	}

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

		private static final long serialVersionUID = 1L;

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

	});

	layoutForm.add(this.processSelect);
}
 
Example 13
Project: Unicorn   File: UploadPanel.java   View source code 6 votes vote down vote up
private void addEventTypeDropDown() {
	final List<String> eventTypes = EapEventType.getAllTypeNames();
	if (!eventTypes.isEmpty()) {
		eventTypeName = eventTypes.get(0);
	}
	final DropDownChoice<String> eventTypeDropDownChoice = new DropDownChoice<String>("eventTypeDropDownChoice", new Model<String>(), eventTypes);
	eventTypeDropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			eventTypeName = eventTypeDropDownChoice.getModelObject();
		}
	});
	if (!eventTypes.isEmpty()) {
		eventTypeDropDownChoice.setModelObject(eventTypes.get(0));
	}
	eventTypeDropDownChoice.setOutputMarkupId(true);
	layoutForm.add(eventTypeDropDownChoice);
}
 
Example 14
Project: Unicorn   File: SimpleSimulationPanel.java   View source code 6 votes vote down vote up
private void addProcessSelect(final Form<Void> layoutForm) {
	this.processSelect = new DropDownChoice<String>("processSelect", new Model<String>(), this.processNameList);
	this.processSelect.setOutputMarkupId(true);
	this.processSelect.add(new AjaxFormComponentUpdatingBehavior("onchange") {

		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			final String processValue = SimpleSimulationPanel.this.processSelect.getValue();
			if (processValue != null && !processValue.isEmpty()) {
				final List<CorrelationProcess> processList = CorrelationProcess.findByName(SimpleSimulationPanel.this.processSelect.getChoices().get(Integer.parseInt(SimpleSimulationPanel.this.processSelect.getValue())));
				if (processList.size() > 0) {
					SimpleSimulationPanel.this.selectedProcess = processList.get(0);

					SimpleSimulationPanel.this.createEventTypeList(SimpleSimulationPanel.this.selectedProcess);
					target.add(SimpleSimulationPanel.this.eventTypeSelect);
				}
			}
			SimpleSimulationPanel.this.treeTableProvider.setCorrelationAttributes(SimpleSimulationPanel.this.selectedProcess.getCorrelationAttributes());
		}
	});

	layoutForm.add(this.processSelect);
}
 
Example 15
Project: Unicorn   File: DerivationTypeDropDownChoicePanel.java   View source code 6 votes vote down vote up
public DerivationTypeDropDownChoicePanel(final String id, final int entryId, final SimulationTreeTableProvider<Object> simulationTreeTableProvider) {
	super(id);
	final Form<Void> layoutForm = new Form<Void>("layoutForm");

	final DropDownChoice<DerivationType> derivationTypeDropDownChoice = new DropDownChoice<DerivationType>("derivationTypeDropDownChoice", Model.of(simulationTreeTableProvider.getDerivationTypeForEntry(entryId)), this.derivationTypes);
	derivationTypeDropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			simulationTreeTableProvider.setDerivationTypeForEntry(derivationTypeDropDownChoice.getModelObject(), entryId);

			if (DerivationTypeDropDownChoicePanel.this.treeTable != null) {
				target.add(DerivationTypeDropDownChoicePanel.this.treeTable);
			} else {
				target.add(DerivationTypeDropDownChoicePanel.this.getPage());
			}
		}
	});

	derivationTypeDropDownChoice.setEnabled(true);
	layoutForm.add(derivationTypeDropDownChoice);
	this.add(layoutForm);
}
 
Example 16
Project: Unicorn   File: BasicTransformationRuleEditorPanel.java   View source code 6 votes vote down vote up
private void buildTextFields() {
	this.transformationRuleNameTextField = new TextField<String>("transformationRuleNameTextField", new PropertyModel<String>(this, "transformationRuleName"));
	this.transformationRuleNameTextField.setOutputMarkupId(true);
	this.layoutForm.add(this.transformationRuleNameTextField);

	final List<String> eventTypes = EapEventType.getAllTypeNames();
	this.eventTypeDropDownChoice = new DropDownChoice<String>("eventTypeDropDownChoice", new PropertyModel<String>(this, "selectedEventTypeName"), eventTypes);
	this.eventTypeDropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			BasicTransformationRuleEditorPanel.this.updateOnChangeOfDropDownChoice(target);
		}
	});
	this.layoutForm.add(this.eventTypeDropDownChoice);

	this.transformationRuleTextArea = new TextArea<String>("transformationRuleTextArea", new PropertyModel<String>(this, "transformationRule"));
	this.transformationRuleTextArea.setOutputMarkupId(true);
	this.layoutForm.add(this.transformationRuleTextArea);
}
 
Example 17
Project: Unicorn   File: FilterExpressionPanel.java   View source code 6 votes vote down vote up
private void buildFilterExpressionOperatorDropDownChoice() {

		this.filterExpressionOperator = (FilterExpressionOperatorEnum) this.element.getValue();

		final DropDownChoice<FilterExpressionOperatorEnum> filterExpressionOperatorDropDownChoice = new DropDownChoice<FilterExpressionOperatorEnum>("filterExpressionOperatorDropDownChoice", new PropertyModel<FilterExpressionOperatorEnum>(this, "filterExpressionOperator"), Arrays.asList(FilterExpressionOperatorEnum.values()), new ChoiceRenderer<FilterExpressionOperatorEnum>() {
			private static final long serialVersionUID = 1L;

			@Override
			public Object getDisplayValue(final FilterExpressionOperatorEnum element) {
				return element.getValue();
			}
		});
		filterExpressionOperatorDropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
			private static final long serialVersionUID = -5452061293278720695L;

			@Override
			protected void onUpdate(final AjaxRequestTarget target) {
				FilterExpressionPanel.this.element.setValue(FilterExpressionPanel.this.filterExpressionOperator);
				FilterExpressionPanel.this.table.getSelectedElements().remove(FilterExpressionPanel.this.element);
				target.add(FilterExpressionPanel.this.table);
			}
		});
		filterExpressionOperatorDropDownChoice.setOutputMarkupId(true);
		this.layoutForm.add(filterExpressionOperatorDropDownChoice);
	}
 
Example 18
Project: Unicorn   File: FlexConditionInputPanel.java   View source code 6 votes vote down vote up
public FlexConditionInputPanel(final String id) {
	super(id);

	this.conditionAttributeSelect = new DropDownChoice<String>("conditionAttributeSelect", new PropertyModel<String>(this, "selectedConditionAttribute"), new ArrayList<String>());
	this.conditionAttributeSelect.setOutputMarkupId(true);
	this.conditionAttributeSelect.add(new AjaxFormComponentUpdatingBehavior("onChange") {

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			// collect all attributes
			final Set<Serializable> attributes = new HashSet<Serializable>();
			for (final EapEventType eventType : FlexConditionInputPanel.this.selectedEventTypes) {
				attributes.addAll(eventType.findAttributeValues(FlexConditionInputPanel.this.selectedConditionAttribute));
			}
		}
	});
	this.add(this.conditionAttributeSelect);

	this.conditionValueInput = new TextField("conditionValueInput", new PropertyModel<String>(this, "selectedConditionValue"));
	this.conditionValueInput.setOutputMarkupId(true);
	this.add(this.conditionValueInput);
}
 
Example 19
Project: Unicorn   File: DependenciesPanelTest.java   View source code 6 votes vote down vote up
public void testDropDowns() {
    // event type drop down
    DropDownChoice eventTypeDropDown = (DropDownChoice) tester.getComponentFromLastRenderedPage(formPath + ":eventTypeField");
    Assert.assertNotNull(eventTypeDropDown.getChoices());
    FormTester formTester = tester.newFormTester(formPath, false);
    formTester.select("eventTypeField", 0);
    Assert.assertEquals(eventType.getTypeName(), ((EapEventType) eventTypeDropDown.getChoices().get(0)).getTypeName());

    // attribute drop downs
    DropDownChoice baseDropDown = (DropDownChoice) tester.getComponentFromLastRenderedPage(formPath + ":baseAttributeField");
    Assert.assertEquals(2, baseDropDown.getChoices().size());
    Assert.assertEquals(attributes, baseDropDown.getChoices());
    DropDownChoice depDropDown = (DropDownChoice) tester.getComponentFromLastRenderedPage(formPath + ":dependentAttributeField");
    Assert.assertEquals(1, depDropDown.getChoices().size());
    Assert.assertEquals(depAttribute, depDropDown.getChoices().get(0));

    // shown type labels
    Label baseTypeLabel = (Label) tester.getComponentFromLastRenderedPage(formPath + ":selectedBaseAttributeType");
    Assert.assertEquals("String", baseTypeLabel.getDefaultModelObjectAsString());
    Label depTypeLabel = (Label) tester.getComponentFromLastRenderedPage(formPath + ":selectedDependentAttributeType");
    Assert.assertEquals("Integer", depTypeLabel.getDefaultModelObjectAsString());
}
 
Example 20
Project: openmeetings   File: PollResultsDialog.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	chartSimple = getString("1414");
	chartPie = getString("1415");
	add(name, question, count);
	chartType = new DropDownChoice<>("chartType", Model.of(chartSimple), Arrays.asList(chartSimple, chartPie));
	add(chartType.add(new AjaxFormComponentUpdatingBehavior("change") {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			redraw(target);
		}
	}));
	super.onInitialize();
}
 
Example 21
Project: openmeetings   File: PagingNavigatorPanel.java   View source code 6 votes vote down vote up
public PagingNavigatorPanel(String id, final DataView<?> dataView, List<Integer> numbers, int _entitiesPerPage) {
	super(id);
	setOutputMarkupId(true);
	this.entitiesPerPage = _entitiesPerPage;
	dataView.setItemsPerPage(entitiesPerPage);
	final Form<Void> f = new Form<>("pagingForm");
	f.add(new OmPagingNavigator("navigator", dataView).setOutputMarkupId(true))
		.add(new DropDownChoice<>("entitiesPerPage", new PropertyModel<Integer>(this, "entitiesPerPage"), numbers)
			.add(new AjaxFormComponentUpdatingBehavior("change") {
				private static final long serialVersionUID = 1L;

				@Override
				protected void onUpdate(AjaxRequestTarget target) {
					long newPage = dataView.getCurrentPage() * dataView.getItemsPerPage() / entitiesPerPage;
					dataView.setItemsPerPage(entitiesPerPage);
					dataView.setCurrentPage(newPage);
					target.add(f);
					PagingNavigatorPanel.this.onEvent(target);
				}
			}));
	add(f.setOutputMarkupId(true));
}
 
Example 22
Project: webanno   File: ImportDocumentsPanel.java   View source code 6 votes vote down vote up
public ImportDocumentsPanel(String aId, IModel<Project> aProject)
{
    super(aId);

    projectModel = aProject;
    
    Form<Void> form = new Form<>("form");
    add(form);
    
    format = Model.of();
    List<String> readableFormats = listReadableFormats();
    if (!readableFormats.isEmpty()) {
        format.setObject(readableFormats.get(0));
    }
    
    form.add(fileUpload = new FileUploadField("documents"));

    DropDownChoice<String> formats = new DropDownChoice<String>("format");
    formats.setModel(format);
    formats.setChoices(LambdaModel.of(this::listReadableFormats));
    form.add(formats);
    
    form.add(new LambdaAjaxButton<>("import", this::actionImport));
}
 
Example 23
Project: webanno   File: TagSetImportPanel.java   View source code 6 votes vote down vote up
public TagSetImportPanel(String aId, IModel<Project> aModel, IModel<TagSet> aTagSet)
{
    super(aId);
    
    setOutputMarkupId(true);
    setOutputMarkupPlaceholderTag(true);
    
    preferences = Model.of(new Preferences());
    selectedProject = aModel;
    selectedTagSet = aTagSet;
    
    Form<Preferences> form = new Form<>("form", CompoundPropertyModel.of(preferences));
    form.add(new DropDownChoice<>("format", LambdaModel.of(this::supportedFormats)));
    form.add(new CheckBox("overwrite"));
    form.add(fileUpload = new FileUploadField("content", new ListModel<>()));
    fileUpload.setRequired(true);
    form.add(new LambdaAjaxButton<>("import", this::actionImport));
    add(form);
}
 
Example 24
Project: webanno   File: ProjectDetailPanel.java   View source code 6 votes vote down vote up
private DropDownChoice<String> makeProjectTypeChoice()
{
    DropDownChoice<String> projectTypes = new DropDownChoice<String>("mode", projectService
            .listProjectTypes().stream().map(t -> t.id()).collect(Collectors.toList()))
    {
        private static final long serialVersionUID = -8268365384613932108L;

        @Override
        protected void onConfigure()
        {
            super.onConfigure();
            setEnabled(
                    projectModel.getObject() != null && projectModel.getObject().getId() == 0);
        }
    };

    projectTypes.setRequired(true);
    return projectTypes;

}
 
Example 25
Project: relax-dms   File: WorkflowPage.java   View source code 6 votes vote down vote up
private void createCustomWorkflow(boolean visible) {
    List<String> rules = workflowService.getCustomRules();
    if (!rules.isEmpty())
        selected = rules.get(0);
    
    DropDownChoice<String> workflows = new DropDownChoice<>("workflows", 
            new PropertyModel<String>(this, "selected"), rules);

    Environment env = new Environment();
    
    Form<?> form = new Form<Void>("form") {
        @Override
        protected void onSubmit() {
            env.setValue(true);
            env.setFireBy(user);
            env.setRule(selected);
            workflowService.insertAllFacts(documentService.getAllDocumentsMetadata(), env);
        }
    };

    addComponent(form, visible);
    form.add(workflows);
}
 
Example 26
Project: elpaaso-core   File: ReleaseFieldsetPanel.java   View source code 6 votes vote down vote up
private void initComponentsApplicationSelect(WebMarkupContainer selectApplicationContainer) {
    List<Application> appList = new ArrayList<>();
    if (showApplicationSelection) {
        if (app == null) {
            appList = (List<Application>) manageApplication.findMyApplications();
        } else {
            appList = Arrays.asList(app);
        }
    }
    ChoiceRenderer<Application> choiceRenderer = new ChoiceRenderer<Application>("label", "uid");
    applicationDropDownChoice = new DropDownChoice<Application>("application", appList, choiceRenderer);

    if (app != null) {
        applicationDropDownChoice.setEnabled(false);
    }

    // app required
    applicationDropDownChoice.setRequired(true);
    applicationDropDownChoice.add(new PropertyValidator<>());

    selectApplicationContainer.add(applicationDropDownChoice);
    selectApplicationContainer.add(new CacheActivatedImage("applicationHelp",new ResourceModel("image.help").getObject()));
}
 
Example 27
Project: elpaaso-core   File: CreateObjectsWithGUI.java   View source code 6 votes vote down vote up
public static void createRelationalDatabaseService(PaasWicketTester myTester, String name, String serviceName
        , LogicalRelationalServiceSqlDialectEnum sqlVersion,
                                                   int capacityMo) {

    selectService(myTester, LogicalRelationalService.class);

    FormTester creationForm = NavigationUtils.getParamsFormTester(myTester);
    creationForm.setValue("label", name);
    creationForm.setValue("serviceName", serviceName);
    int sqlIndex = sqlVersion.ordinal();

    myTester.assertVisible(paramsFormPath + ":sqlVersion");
    myTester.assertComponent(paramsFormPath + ":sqlVersion", DropDownChoice.class);
    creationForm.select("sqlVersion", sqlIndex);
    creationForm.setValue("capacityMo", String.valueOf(capacityMo));

    NavigationUtils.submitParamsForm(myTester);

}
 
Example 28
Project: elpaaso-core   File: CreateObjectsWithGUI.java   View source code 6 votes vote down vote up
public static void createQueueReceiveService(PaasWicketTester myTester, String name, String serviceName, String serviceVersion, String jndiQueuName
        , long msgMaxSizeKB, long maxNbMsgPerDay, long nbRetentionDay) {

    selectService(myTester, LogicalQueueReceiveService.class);
    FormTester creationForm = NavigationUtils.getParamsFormTester(myTester);
    creationForm.setValue("label", name);
    creationForm.setValue("serviceName", serviceName);
    creationForm.setValue("serviceVersion", serviceVersion);
    creationForm.setValue("jndiQueueName", jndiQueuName);
    myTester.assertComponent(paramsFormPath + ":msgMaxSizeKB", DropDownChoice.class);
    myTester.assertComponent(paramsFormPath + ":maxNbMsgPerDay", DropDownChoice.class);
    myTester.assertComponent(paramsFormPath + ":nbRetentionDay", DropDownChoice.class);

    selectItem(myTester, creationForm, msgMaxSizeKB, "msgMaxSizeKB");
    selectItem(myTester, creationForm, maxNbMsgPerDay, "maxNbMsgPerDay");
    selectItem(myTester, creationForm, nbRetentionDay, "nbRetentionDay");
    NavigationUtils.submitParamsForm(myTester);

}
 
Example 29
Project: elpaaso-core   File: ReleaseOverrideProfilePanelTest.java   View source code 6 votes vote down vote up
@Test
public void component_should_show_a_filtered_profiles_list() throws Exception {
	//Mock services with all existing profiles
	when(manageApplicationRelease.findAllMiddlewareProfil()).thenReturn(Arrays.asList(MiddlewareProfile.values()));
	//Fake user (ROLE_USER)
	PaasUser createPaasUserMock = CreateObjectsWithJava.createPaasUserMock("testuser", PaasRoleEnum.ROLE_USER);
	
	((PaasTestSession)tester.getSession()).setPaasUser(createPaasUserMock);
	
	//Construct profile versions expectations
	Set<MiddlewareProfile> expectedProfiles = MiddlewareProfile.filter(createPaasUserMock,Arrays.asList(MiddlewareProfile.values()));

	//When
	tester.startComponentInPage(ReleaseOverrideProfilePanel.class);
	
	//Grab listbox from last page
	DropDownChoice<MiddlewareProfile> choiceComponent = (DropDownChoice<MiddlewareProfile>) tester.getComponentFromLastRenderedPage("middlewareProfileContainer:middlewareProfileSelect");

	//Check that profiles are queried from elpaaso core services
	verify(manageApplicationRelease).findAllMiddlewareProfil();
	//Check that all expected profiles are displayed
	assertThat(choiceComponent.getChoices()).containsOnly(expectedProfiles.toArray());
}
 
Example 30
Project: elpaaso-core   File: ReleaseOverrideProfilePanelTest.java   View source code 6 votes vote down vote up
@Test
public void component_should_show_a_sorted_profiles_list() throws Exception {
	when(manageApplicationRelease.findAllMiddlewareProfil()).thenReturn(Arrays.asList(MiddlewareProfile.values()));
	//Fake user (ROLE_USER)
	PaasUser createPaasUserMock = CreateObjectsWithJava.createPaasUserMock("testuser", PaasRoleEnum.ROLE_ADMIN);
	((PaasTestSession)tester.getSession()).setPaasUser(createPaasUserMock);
	
	//When
	tester.startComponentInPage(ReleaseOverrideProfilePanel.class);
	
	//Grab listbox from last page
	DropDownChoice<MiddlewareProfile> choiceComponent = (DropDownChoice<MiddlewareProfile>) tester.getComponentFromLastRenderedPage("middlewareProfileContainer:middlewareProfileSelect");

	List<MiddlewareProfile> sortedList = new ArrayList<MiddlewareProfile>(choiceComponent.getChoices());
	Collections.sort(sortedList);
	
	assertThat(choiceComponent.getChoices()).isEqualTo(sortedList);
}
 
Example 31
Project: artifactory   File: WicketAddonsImpl.java   View source code 6 votes vote down vote up
@Override
public void createAndAddVcsConfigSection(Form form, RemoteRepoDescriptor repoDescriptor, boolean isCreate) {
    WebMarkupContainer vcsSection = new WebMarkupContainer("vcsSupportSection");
    vcsSection.add(new TitledBorderBehavior("fieldset-border", "Vcs"));
    vcsSection.add(new DisabledAddonBehavior(AddonType.VCS));
    vcsSection.add(new StyledCheckbox("enableVcsSupport").setTitle("Enable Vcs Support").setEnabled(false));
    vcsSection.add(new DisabledAddonHelpBubble("enableVcsSupport.help", VCS));

    DropDownChoice providerDropdown = new DropDownChoice("provider", Model.of(), Collections.emptyList());
    providerDropdown.setEnabled(false);
    providerDropdown.add(new DisabledAddonBehavior(AddonType.VCS));
    vcsSection.add(providerDropdown);
    vcsSection.add(new DisabledAddonHelpBubble("provider.help", VCS));

    WebMarkupContainer downloadUrlField = new WebMarkupContainer("downloadUrlField");
    downloadUrlField.setVisible(false);
    downloadUrlField.add(new TextField("downloadUrl").setEnabled(false).setVisible(false));
    downloadUrlField.add(new DisabledAddonHelpBubble("downloadUrl.help", VCS).setVisible(false));
    vcsSection.add(downloadUrlField);

    form.add(vcsSection);
}
 
Example 32
Project: artifactory   File: RepositoriesTabPanel.java   View source code 6 votes vote down vote up
private void addIncludesPatternFields(StringResourceModel helpMessage,
        final List<CommonPathPattern> includesExcludesSuggestions) {
    TextArea includesTa = new TextArea("includesPattern");
    includesTa.setEnabled(isSystemAdmin());
    includesTa.setOutputMarkupId(true);
    add(includesTa);

    add(new HelpBubble("includesHelp", helpMessage));

    Model<CommonPathPattern> include = new Model<>();
    DropDownChoice<CommonPathPattern> includesSuggest = new DropDownChoice<>(
            "includesSuggest", include, includesExcludesSuggestions);
    if (!includesExcludesSuggestions.isEmpty()) {
        includesSuggest.setDefaultModelObject(includesExcludesSuggestions.get(0));
    }
    includesSuggest.add(new UpdatePatternsBehavior(include, includesTa));
    if (parent.isCreate()) {
        includesSuggest.setDefaultModelObject(CommonPathPattern.ANY);
    }
    includesSuggest.setEnabled(isSystemAdmin());
    add(includesSuggest);
}
 
Example 33
Project: u-qasar.platform   File: UserEditPage.java   View source code 6 votes vote down vote up
private DataView<TeamMembership> getTeamListing() {
	return new DataView<TeamMembership>("teams", provider = new TeamProvider(user)) {
		@Override
		protected void populateItem(Item<TeamMembership> item) {
			final TeamMembership team = item.getModelObject();
			Check<TeamMembership> check = newDeleteCheck(item);
			List<Role> roles = new ArrayList<>(Arrays.asList(Role.teamAssignableRoles()));
			item.add(check);
			DropDownChoice<Role> roleSelector = new DropDownChoice<>("td.role",
					new PropertyModel<Role>(team, "role"), roles
			);
			roleSelector.setNullValid(false);
			item.add(roleSelector);
			BookmarkablePageLink<TeamEditPage> editTeamLink = new BookmarkablePageLink<>("link.edit.team", TeamEditPage.class, new PageParameters().add("id", team.getTeam().getId()));
			editTeamLink.add(new Label("td.teamname", new PropertyModel<>(team.getTeam(), "name")));
			item.add(editTeamLink);
			item.setOutputMarkupId(true);
		}
	};
}
 
Example 34
Project: u-qasar.platform   File: DropDownModal.java   View source code 6 votes vote down vote up
/**
 * Modal with a title and a DropDownChoice
 * @param id
 * @param headerModel header
 * @param types Options in DropDownChoice
 * @param showImmediately
 */
protected DropDownModal(final String id, final IModel<String> headerModel,
						List<Class> types, final boolean showImmediately) {
	super(id);
	show(showImmediately);
	header(headerModel);		

	List<String> ls = new ArrayList<>();
       for (Class type : types) {
           ls.add((type).getSimpleName());
       }

	metaDataTypes = new DropDownChoice<>("metaDataTypes", new Model(), ls);

	metaDataTypes.add(new AjaxEventBehavior("onchange") {
		@Override
		protected void onEvent(AjaxRequestTarget target) {
			typeSelected = metaDataTypes.getChoices().get(Integer.valueOf(metaDataTypes.getInput()));
		}
	});

	add(metaDataTypes).setEscapeModelStrings(false);
	setUseKeyboard(false);
}
 
Example 35
Project: midpoint   File: DropDownChoicePanel.java   View source code 6 votes vote down vote up
public DropDownChoicePanel(String id, IModel<T> model, IModel<? extends List<? extends T>> choices, IChoiceRenderer<T> renderer,
                            boolean allowNull) {
     super(id);

     DropDownChoice<T> input = new DropDownChoice<T>(ID_INPUT, model, choices, renderer) {

     	private static final long serialVersionUID = 1L;

@Override
         protected String getNullValidDisplayValue() {
             return getString("DropDownChoicePanel.notDefined");
         }
     };
     input.setNullValid(allowNull);
     add(input);
 }
 
Example 36
Project: midpoint   File: LoggingConfigPanel.java   View source code 6 votes vote down vote up
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);
}
 
Example 37
Project: midpoint   File: RoleMemberPanel.java   View source code 6 votes vote down vote up
private <V> DropDownChoice<V> createDropDown(String id, IModel<V> defaultModel, final List<V> values,
		IChoiceRenderer<V> renderer) {
	DropDownChoice<V> listSelect = new DropDownChoice<V>(id, defaultModel,
			new AbstractReadOnlyModel<List<V>>() {
				private static final long serialVersionUID = 1L;

				@Override
				public List<V> getObject() {
					return values;
				}
			}, renderer);

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

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			refreshTable(target);
		}
	});

	return listSelect;
}
 
Example 38
Project: midpoint   File: ObjectTypeSelectPanel.java   View source code 6 votes vote down vote up
private void initLayout(IModel<QName> model, final Class<O> superclass) {
	select = new DropDownChoice<>(ID_SELECT, model,
			new AbstractReadOnlyModel<List<QName>>() {
				private static final long serialVersionUID = 1L;

				@Override
	            public List<QName> getObject() {
					if (superclass == null || superclass == ObjectType.class) {
						return WebComponentUtil.createObjectTypeList();
					}
					if (superclass == FocusType.class) {
						return WebComponentUtil.createFocusTypeList();
					}
					if (superclass == AbstractRoleType.class) {
						return WebComponentUtil.createAbstractRoleTypeList();
					}
					throw new IllegalArgumentException("Unknown superclass "+superclass);
	            }
		}, new QNameChoiceRenderer());
	select.setNullValid(true);

	add(select);
}
 
Example 39
Project: syncope   File: SchemasITCase.java   View source code 6 votes vote down vote up
@Test
public void readPlainSchema() {
    browsingToPlainSchemas();
    TESTER.assertLabel(
            PLAIN_DATATABLE_PATH
            + ":tablePanel:groupForm:"
            + "checkgroup:dataTable:body:rows:1:cells:1:cell", "aLong");

    TESTER.executeAjaxEvent(
            PLAIN_DATATABLE_PATH + ":tablePanel:groupForm:checkgroup:dataTable:body:rows:1",
            Constants.ON_CLICK);

    TESTER.clickLink(
            "body:content:tabbedPanel:panel:accordionPanel:tabs:0:body:content:outerObjectsRepeater:1:outer:"
            + "container:content:togglePanelContainer:container:actions:actions:actionRepeater:0:action:action");

    TESTER.assertComponent(
            "body:content:tabbedPanel:"
            + "panel:accordionPanel:tabs:0:body:content:outerObjectsRepeater:0:outer:"
            + "form:content:kindForm:kind:dropDownChoiceField", DropDownChoice.class);
}
 
Example 40
Project: syncope   File: LogsITCase.java   View source code 6 votes vote down vote up
@Test
public void updateCoreLogs() {
    TESTER.clickLink("body:content:tabbedPanel:tabs-container:tabs:0:link");
    TESTER.assertComponent(CONTAINER_PATH, WebMarkupContainer.class);

    Component result = searchLog(KEY, CONTAINER_PATH, "io.swagger");
    assertNotNull(result);

    TESTER.getRequest().addParameter(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", "6");
    TESTER.assertComponent(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", DropDownChoice.class);
    TESTER.executeAjaxEvent(result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", "onchange");

    TESTER.assertInfoMessages("Operation executed successfully");
}