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: engerek   File: OrgMemberPanel.java   Source Code and License 7 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 2
Project: artifactory   File: RepositoriesTabPanel.java   Source Code and License 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 3
Project: MasterStats   File: BasePage.java   Source Code and License 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 4
Project: engerek   File: AssignmentCatalogPanel.java   Source Code and License 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 5
Project: engerek   File: LoggingConfigPanel.java   Source Code and License 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: LoggingConfigPanel.java   Source Code and License 6 votes vote down vote up
private void initAudit(){
    CheckBox auditLog = WebComponentUtil.createAjaxCheckBox("auditLog", new PropertyModel<Boolean>(getModel(), "auditLog"));
    add(auditLog);

    CheckBox auditDetails = WebComponentUtil.createAjaxCheckBox("auditDetails", new PropertyModel<Boolean>(getModel(), "auditDetails"));
    add(auditDetails);

    DropDownChoice<String> auditAppender = new DropDownChoice<>("auditAppender", new PropertyModel<String>(
            getModel(), "auditAppender"), createAppendersListModel());
    auditAppender.setNullValid(true);
    auditAppender.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(auditAppender);
}
 
Example 7
Project: engerek   File: RoleMemberPanel.java   Source Code and License 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 8
Project: engerek   File: ObjectTypeSelectPanel.java   Source Code and License 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 9
Project: vlo-curation   File: AllFacetValuesPanel.java   Source Code and License 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 10
Project: vlo-curation   File: SearchResultsHeaderPanel.java   Source Code and License 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 11
Project: singular-server   File: SelecaoMenuItem.java   Source Code and License 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 12
Project: Unicorn   File: ChartConfigurationPanel.java   Source Code and License 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 13
Project: Unicorn   File: BPMNMonitoringPanel.java   Source Code and License 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 14
Project: Unicorn   File: UploadPanel.java   Source Code and License 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 15
Project: Unicorn   File: SimpleSimulationPanel.java   Source Code and License 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 16
Project: Unicorn   File: DerivationTypeDropDownChoicePanel.java   Source Code and License 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 17
Project: Unicorn   File: BasicTransformationRuleEditorPanel.java   Source Code and License 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 18
Project: Unicorn   File: FilterExpressionPanel.java   Source Code and License 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 19
Project: Unicorn   File: FlexConditionInputPanel.java   Source Code and License 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 20
Project: Unicorn   File: DependenciesPanelTest.java   Source Code and License 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 21
Project: openmeetings   File: PollResultsDialog.java   Source Code and License 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 22
Project: openmeetings   File: PagingNavigatorPanel.java   Source Code and License 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 23
Project: webanno   File: ImportDocumentsPanel.java   Source Code and License 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 24
Project: webanno   File: TagSetImportPanel.java   Source Code and License 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 25
Project: webanno   File: ProjectDetailPanel.java   Source Code and License 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 26
Project: relax-dms   File: WorkflowPage.java   Source Code and License 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 27
Project: elpaaso-core   File: ReleaseFieldsetPanel.java   Source Code and License 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 28
Project: elpaaso-core   File: CreateObjectsWithGUI.java   Source Code and License 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 29
Project: elpaaso-core   File: CreateObjectsWithGUI.java   Source Code and License 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 30
Project: elpaaso-core   File: ReleaseOverrideProfilePanelTest.java   Source Code and License 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 31
Project: elpaaso-core   File: ReleaseOverrideProfilePanelTest.java   Source Code and License 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 32
Project: artifactory   File: WicketAddonsImpl.java   Source Code and License 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 33
Project: artifactory   File: RepositoriesTabPanel.java   Source Code and License 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 34
Project: u-qasar.platform   File: UserEditPage.java   Source Code and License 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 35
Project: u-qasar.platform   File: DropDownModal.java   Source Code and License 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 36
Project: midpoint   File: DropDownChoicePanel.java   Source Code and License 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 37
Project: midpoint   File: LoggingConfigPanel.java   Source Code and License 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 38
Project: midpoint   File: RoleMemberPanel.java   Source Code and License 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 39
Project: midpoint   File: ObjectTypeSelectPanel.java   Source Code and License 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 40
Project: syncope   File: SchemasITCase.java   Source Code and License 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 41
Project: syncope   File: LogsITCase.java   Source Code and License 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");
}
 
Example 42
Project: wicket-crudifier   File: ObjectChoiceControlGroup.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("serial")
public ObjectChoiceControlGroup(String id, IModel<T> model) {
	super(id, model);
	
	IModel<List<? extends T>> modelList = new LoadableDetachableModel<List<? extends T>>() {
		private static final long serialVersionUID = -3995535290067544541L;

		@Override
		protected List<T> load() {
			if(entityProvider==null) throw new RuntimeException("no entity provider for '"+getPropertyName()+"'");
			return (List<T>) entityProvider.load();
		}
		
		
	};

	dropDown = new DropDownChoice<T>("input", getModel(), modelList){
		@Override
		public void error(IValidationError error) {
			MessageSource source = new MessageSource();
			Serializable message = error.getErrorMessage(source);
			
			super.error(message);
		}
	};
}
 
Example 43
Project: flex-ui   File: FormComponentsPage.java   Source Code and License 6 votes vote down vote up
public FormComponentsPage() {
    Form<Void> form = new Form<>("form");

    form.add(new DateTimePicker("date-time-picker", "y-MM-dd HH:mm"));
    form.add(new DateTimePicker("date-picker", "dd.MM.y").setPickTime(false));
    form.add(new DateTimePicker("time-picker", "HH:mm").setPickDate(false));

    form.add(new ButtonMultipleChoice<>("button-multiple-choice", Arrays.asList("Choice A", "Choice B",
            "Choice C", "Choice D")));

    form.add(new ButtonRadioChoice<>("button-radio-choice", Arrays.asList("Choice A", "Choice B", "Choice C",
            "Choice D")));

    form.add(new EnumDropDownChoice<>("enum-drop-down", Buttons.Type.class));
    form.add(new DropDownChoice<>("class-drop-down", Arrays.asList(ButtonMultipleChoice.class,
            ButtonRadioChoice.class, DropDownChoice.class), new ClassChoiceRenderer()));

    add(form);
}
 
Example 44
Project: gizmo-v3   File: PageDashboard.java   Source Code and License 6 votes vote down vote up
private void initRealizatorInput(WebMarkupContainer realizator) {
    DropDownChoice realizatorCombo = new DropDownChoice<User>(ID_REALIZATOR_COMBO,
            new PropertyModel<User>(filter, WorkFilterDto.F_REALIZATOR),
            GizmoUtils.createUsersModel(this), GizmoUtils.createUserChoiceRenderer()) {

        @Override
        protected String getNullValidKey() {
            return "PageDashboard.everyone";
        }
    };
    realizatorCombo.add(createMultipleVisibilityBehaviour(false));
    realizatorCombo.setNullValid(true);
    realizator.add(realizatorCombo);

    ListMultipleChoice realizatorMulti = new ListMultipleChoice<User>(ID_REALIZATOR_MULTI,
            new PropertyModel<List<User>>(filter, WorkFilterDto.F_REALIZATORS), GizmoUtils.createUsersModel(this),
            GizmoUtils.createUserChoiceRenderer());
    realizatorMulti.add(createMultipleVisibilityBehaviour(true));
    realizator.add(realizatorMulti);
}
 
Example 45
Project: midpoint   File: DropDownChoicePanel.java   Source Code and License 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 46
Project: midpoint   File: LoggingConfigPanel.java   Source Code and License 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 47
Project: midpoint   File: RoleMemberPanel.java   Source Code and License 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 48
Project: midpoint   File: ObjectTypeSelectPanel.java   Source Code and License 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 49
Project: oodt   File: TypeBrowser.java   Source Code and License 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 50
Project: projectforge-webapp   File: ScriptEditForm.java   Source Code and License 6 votes vote down vote up
private void addParameterSettings(final int idx)
{
  final FieldsetPanel fs = gridBuilder.newFieldset(getString("scripting.script.parameterName") + " " + idx);

  final String parameterType = "parameter" + idx + "Type";
  final String parameterName = "parameter" + idx + "Name";
  final MaxLengthTextField name = new MaxLengthTextField(fs.getTextFieldId(), new PropertyModel<String>(data, parameterName));
  WicketUtils.setSize(name, 20);
  fs.add(name);
  // DropDownChoice type
  final LabelValueChoiceRenderer<ScriptParameterType> typeChoiceRenderer = new LabelValueChoiceRenderer<ScriptParameterType>(this,
      ScriptParameterType.values());
  final DropDownChoice<ScriptParameterType> typeChoice = new DropDownChoice<ScriptParameterType>(fs.getDropDownChoiceId(),
      new PropertyModel<ScriptParameterType>(data, parameterType), typeChoiceRenderer.getValues(), typeChoiceRenderer);
  typeChoice.setNullValid(true);
  typeChoice.setRequired(false);
  fs.add(typeChoice);
}
 
Example 51
Project: projectforge-webapp   File: Kost1ListForm.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.projectforge.web.wicket.AbstractListForm#onOptionsPanelCreate(org.projectforge.web.wicket.flowlayout.FieldsetPanel, org.projectforge.web.wicket.flowlayout.DivPanel)
 */
@Override
protected void onOptionsPanelCreate(final FieldsetPanel optionsFieldsetPanel, final DivPanel optionsCheckBoxesPanel)
{
  // DropDownChoice listType
  final LabelValueChoiceRenderer<String> typeChoiceRenderer = new LabelValueChoiceRenderer<String>();
  typeChoiceRenderer.addValue("all", getString("filter.all"));
  typeChoiceRenderer.addValue("active", getString("fibu.kost.status.active"));
  typeChoiceRenderer.addValue("nonactive", getString("fibu.kost.status.nonactive"));
  typeChoiceRenderer.addValue("notEnded", getString("notEnded"));
  typeChoiceRenderer.addValue("ended", getString("ended"));
  final DropDownChoice<String> typeChoice = new DropDownChoice<String>(optionsFieldsetPanel.getDropDownChoiceId(), new PropertyModel<String>(this,
      "searchFilter.listType"), typeChoiceRenderer.getValues(), typeChoiceRenderer);
  typeChoice.setNullValid(false);
  optionsFieldsetPanel.add(typeChoice, true);
}
 
Example 52
Project: projectforge-webapp   File: UserEditForm.java   Source Code and License 6 votes vote down vote up
private static void addDateFormatCombobox(final GridBuilder gridBuilder, final PFUserDO user, final String labelKey,
    final String property, final String[] dateFormats, final boolean convertExcelFormat)
{
  final FieldsetPanel fs = gridBuilder.newFieldset(gridBuilder.getString(labelKey));
  final LabelValueChoiceRenderer<String> dateFormatChoiceRenderer = new LabelValueChoiceRenderer<String>();
  for (final String str : dateFormats) {
    String dateString = "???";
    final String pattern = convertExcelFormat == true ? str.replace('Y', 'y').replace('D', 'd') : str;
    try {
      final SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
      dateString = dateFormat.format(new Date());
    } catch (final Exception ex) {
      log.warn("Invalid date format in config.xml: " + pattern);
    }
    dateFormatChoiceRenderer.addValue(str, str + ": " + dateString);
  }
  final DropDownChoice<String> dateFormatChoice = new DropDownChoice<String>(fs.getDropDownChoiceId(), new PropertyModel<String>(user,
      property), dateFormatChoiceRenderer.getValues(), dateFormatChoiceRenderer);
  dateFormatChoice.setNullValid(true);
  fs.add(dateFormatChoice);
}
 
Example 53
Project: projectforge-webapp   File: TimesheetEditForm.java   Source Code and License 6 votes vote down vote up
/**
 * Used also by TimesheetMassUpdateForm.
 * @param timesheetDao
 * @param kost2List
 * @param data
 * @param kost2Choice
 * @return
 */
protected static LabelValueChoiceRenderer<Integer> getCost2LabelValueChoiceRenderer(final TimesheetDao timesheetDao,
    final List<Kost2DO> kost2List, final TimesheetDO data, final DropDownChoice<Integer> kost2Choice)
    {
  final LabelValueChoiceRenderer<Integer> kost2ChoiceRenderer = new LabelValueChoiceRenderer<Integer>();
  if (kost2List != null && kost2List.size() == 1) {
    // Es ist genau ein Eintrag. Deshalb selektieren wir diesen auch:
    final Integer kost2Id = kost2List.get(0).getId();
    timesheetDao.setKost2(data, kost2Id);
    if (kost2Choice != null) {
      kost2Choice.modelChanged();
    }
  }
  if (CollectionUtils.isEmpty(kost2List) == true) {
    data.setKost2(null); // No kost2 list given, therefore set also kost2 to null.
  } else {
    for (final Kost2DO kost2 : kost2List) {
      kost2ChoiceRenderer.addValue(kost2.getId(), KostFormatter.formatForSelection(kost2));
    }
  }
  return kost2ChoiceRenderer;
    }
 
Example 54
Project: projectforge-webapp   File: WicketUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Sets attribute size (only for TextFields) and style="length: width"; The width value is size + 0.5 em and for drop down choices size +
 * 2em;
 * @param component
 * @param size
 * @param important If true then "!important" is appended to the width style (true is default).
 * @return This for chaining.
 */
public static FormComponent< ? > setSize(final FormComponent< ? > component, final int size, final boolean important)
{
  if (component instanceof TextField) {
    component.add(AttributeModifier.replace("size", String.valueOf(size)));
  }
  final StringBuffer buf = new StringBuffer(20);
  buf.append("width: ");
  if (component instanceof DropDownChoice) {
    buf.append(size + 2).append("em");
  } else {
    buf.append(size).append(".5em");
  }
  if (important == true) {
    buf.append(" !important;");
  }
  buf.append(";");
  component.add(AttributeModifier.append("style", buf.toString()));
  return component;
}
 
Example 55
Project: projectforge-webapp   File: DateTimePanel.java   Source Code and License 6 votes vote down vote up
/**
 * @param id
 * @param label Only for displaying the field's name on validation messages.
 * @param model
 * @param precision
 * @param settings.tabIndex Use tabIndex as html tab index of date field, hours and minutes.
 */
public DateTimePanel(final String id, final IModel<Date> model, final DateTimePanelSettings settings, final DatePrecision precision)
{
  super(id, model);
  this.settings = settings;
  setType(settings.targetType);
  dateHolder = new DateHolder(model.getObject(), precision);
  final PropertyModel<Date> dateFieldModel = new PropertyModel<Date>(this, "date");
  add(datePanel = new DatePanel("date", dateFieldModel, settings));
  datePanel.setRequired(settings.required);
  hourOfDayDropDownChoice = new DropDownChoice<Integer>("hourOfDay", new PropertyModel<Integer>(this, "hourOfDay"),
      getHourOfDayRenderer().getValues(), getHourOfDayRenderer());
  hourOfDayDropDownChoice.setNullValid(!settings.required);
  hourOfDayDropDownChoice.setRequired(settings.required);
  add(hourOfDayDropDownChoice);
  minuteDropDownChoice = new DropDownChoice<Integer>("minute", new PropertyModel<Integer>(this, "minute"), getMinutesRenderer(
      dateHolder.getPrecision()).getValues(), getMinutesRenderer(dateHolder.getPrecision()));
  minuteDropDownChoice.setNullValid(!settings.required);
  minuteDropDownChoice.setRequired(settings.required);
  add(minuteDropDownChoice);
  if (settings.tabIndex != null) {
    datePanel.dateField.add(AttributeModifier.replace("tabindex", String.valueOf(settings.tabIndex)));
    hourOfDayDropDownChoice.add(AttributeModifier.replace("tabindex", String.valueOf(settings.tabIndex + 1)));
    minuteDropDownChoice.add(AttributeModifier.replace("tabindex", String.valueOf(settings.tabIndex + 2)));
  }
}
 
Example 56
Project: projectforge-webapp   File: TeamEventEditForm.java   Source Code and License 6 votes vote down vote up
/**
 * if has access: create drop down with teamCals else create label
 * 
 * @param fieldSet
 */
private void initTeamCalPicker(final FieldsetPanel fieldSet)
{
  if (access == false) {
    final TeamCalDO calendar = data.getCalendar();
    final Label teamCalTitle = new Label(fieldSet.newChildId(), calendar != null ? new PropertyModel<String>(data.getCalendar(), "title")
        : "");
    fieldSet.add(teamCalTitle);
  } else {
    final List<TeamCalDO> list = teamCalDao.getAllCalendarsWithFullAccess();
    calendarsWithFullAccess = list.toArray(new TeamCalDO[0]);
    final LabelValueChoiceRenderer<TeamCalDO> calChoiceRenderer = new LabelValueChoiceRenderer<TeamCalDO>();
    for (final TeamCalDO cal : list) {
      calChoiceRenderer.addValue(cal, cal.getTitle());
    }
    final DropDownChoice<TeamCalDO> calDropDownChoice = new DropDownChoice<TeamCalDO>(fieldSet.getDropDownChoiceId(),
        new PropertyModel<TeamCalDO>(data, "calendar"), calChoiceRenderer.getValues(), calChoiceRenderer);
    calDropDownChoice.setNullValid(false);
    calDropDownChoice.setRequired(true);
    fieldSet.add(calDropDownChoice);
  }
}
 
Example 57
Project: Jouve-Project   File: AddEditFacetPanel.java   Source Code and License 6 votes vote down vote up
private void addFieldFacetFields(WebMarkupContainer container) {
	WebMarkupContainer fieldFacetFieldsContainer = new WebMarkupContainer("fieldFacetFields") {
		@Override
		public boolean isVisible() {
			CollectionFacet facet = facetModel.getObject();
			if(facet!=null){
				return facet.isFieldFacet();
			}
			else {
				return false;
			}
		}
	};
	container.add(fieldFacetFieldsContainer);
	
	DropDownChoice facetField = 
		new DropDownChoice(
				"facetField", 
				indexFieldOptionsModel, 
				indexFieldRenderer);
	fieldFacetFieldsContainer.add(facetField);
}
 
Example 58
Project: Jouve-Project   File: AddEditFacetPanel.java   Source Code and License 6 votes vote down vote up
private void addCloudKeywordFields(WebMarkupContainer container) {
	WebMarkupContainer cloudKeywordFacetFieldsContainer = new WebMarkupContainer("cloudKeywordFacetFields") {
		@Override
		public boolean isVisible() {
			CollectionFacet facet = facetModel.getObject();
			if(facet!=null){
				return facet.isCloudKeywordFacet();
			}
			else {
				return false;
			}
		}
	};
	container.add(cloudKeywordFacetFieldsContainer);
	
	DropDownChoice facetField = 
		new DropDownChoice(
				"facetField", 
				indexFieldOptionsModel, 
				indexFieldRenderer);
	cloudKeywordFacetFieldsContainer.add(facetField);
}
 
Example 59
Project: Jouve-Project   File: AdvancedSearchOptionsPanel.java   Source Code and License 6 votes vote down vote up
public AdvancedSearchOptionsPanel(String id, IModel theCollectionModel) {
	super(id);
	this.collectionModel = new ReloadableEntityModel<RecordCollection>(
			theCollectionModel);

	AjaxCheckBox enabledCheckbox = getEnabledCheckbox();
	add(enabledCheckbox);

	ListView enabledRules = getEnabledRulesListView();
	add(enabledRules);

	DropDownChoice initialRulesNumberDropdownChoice = getInitialRulesNumberDropdownChoice();
	add(initialRulesNumberDropdownChoice);

	add(new WebMarkupContainer("enabledRulesHeader") {

		@Override
		public boolean isVisible() {
			RecordCollection collection = collectionModel.getObject();
			return collection.isAdvancedSearchEnabled();
		}
	});
}
 
Example 60
Project: nextreports-server   File: HourlyJobPanel.java   Source Code and License 6 votes vote down vote up
public HourlyJobPanel(String id, SchedulerJob schedulerJob) {
    super(id);
    this.schedulerJob = schedulerJob;

    hourLabel = new Label("hourLabel", getString("JobPanel.everyHour"));
    add(hourLabel);

    hourText = new TextField<Integer>("hourText", new PropertyModel<Integer>(schedulerJob, "time.gap"));
    hourText.setLabel(new Model<String>(getString("JobPanel.everyHour")));
    hourText.add(new RangeValidator<Integer>(1, 23));
    add(hourText);

    add(minuteLabel = new Label("minuteLabel", getString("JobPanel.minute")));
    add(minuteChoice = new DropDownChoice<Integer>("minuteChoice", new PropertyModel<Integer>(schedulerJob, "time.minute"), getMinutes()));
    add(hLabel = new Label("hLabel", getString("hours")));
    add(hoursPanel = new IntervalFieldPanel("hoursPanel", new PropertyModel(schedulerJob, "time.hours"), SelectIntervalPanel.HOUR_ENTITY,TimeValues.INTERVAL_TYPE));
    add(dLabel = new Label("dLabel", getString("days")));
    add(daysPanel = new IntervalFieldPanel("daysPanel", new PropertyModel(schedulerJob, "time.days"), SelectIntervalPanel.DAY_ENTITY, null));
    add(mLabel = new Label("mLabel", getString("months")));
    add(monthsPanel = new IntervalFieldPanel("monthsPanel", new PropertyModel(schedulerJob, "time.months"), SelectIntervalPanel.MONTH_ENTITY, null));

    setAdvancedType(false);
}