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

The following examples show how to use org.apache.wicket.markup.html.form.DropDownChoice#setRequired() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KnowledgeBaseIriPanel.java    From inception with Apache License 2.0 6 votes vote down vote up
private DropDownChoice<Reification> selectReificationStrategy(String id, String property)
{
    DropDownChoice<Reification> reificationDropDownChoice = new BootstrapSelect<>(id,
        kbModel.bind(property), asList(Reification.values()));
    reificationDropDownChoice.setRequired(true);
    reificationDropDownChoice.setOutputMarkupPlaceholderTag(true);
    
    // The current reification implementation only really does something useful when the
    // Wikidata schema is used on the actual Wikidata knowledge base (or a mirror). 
    // Thus, we enable the option to activate reification only in this case.
    reificationDropDownChoice.add(visibleWhen(() -> 
            WIKIDATASCHEMA.equals(selectedSchemaProfile.getObject()) &&
            kbModel.getObject().getKb().isReadOnly() &&
            REMOTE.equals(kbModel.getObject().getKb().getType())));
    
    return reificationDropDownChoice;
}
 
Example 2
Source File: StatementGroupPanel.java    From inception with Apache License 2.0 6 votes vote down vote up
public NewStatementGroupFragment(String aId) {
    super(aId, "newStatementGroup", StatementGroupPanel.this, groupModel);
                
    IModel<KBProperty> property = Model.of();
    
    Form<KBProperty> form = new Form<>("form", property);
    DropDownChoice<KBProperty> type = new BootstrapSelect<>("property");
    type.setModel(property);
    type.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));            
    type.setChoices(getUnusedProperties());
    type.setRequired(true);
    type.setOutputMarkupId(true);
    form.add(type);
    focusComponent = type;
    
    form.add(new LambdaAjaxButton<>("create", this::actionNewProperty));
    form.add(new LambdaAjaxLink("cancel", this::actionCancelNewProperty));
    add(form);
}
 
Example 3
Source File: ActiveLearningSidebar.java    From inception with Apache License 2.0 6 votes vote down vote up
private Form<Void> createSessionControlForm()
{
    Form<Void> form = new Form<>(CID_SESSION_CONTROL_FORM);

    DropDownChoice<AnnotationLayer> layersDropdown = new BootstrapSelect<>(CID_SELECT_LAYER);
    layersDropdown.setModel(alStateModel.bind("layer"));
    layersDropdown.setChoices(LoadableDetachableModel.of(this::listLayersWithRecommenders));
    layersDropdown.setChoiceRenderer(new LambdaChoiceRenderer<>(AnnotationLayer::getUiName));
    layersDropdown.add(LambdaBehavior.onConfigure(it -> it.setEnabled(!alStateModel
        .getObject().isSessionActive())));
    layersDropdown.setOutputMarkupId(true);
    layersDropdown.setRequired(true);
    form.add(layersDropdown);
    
    form.add(new LambdaAjaxSubmitLink(CID_START_SESSION_BUTTON, this::actionStartSession)
            .add(visibleWhen(() -> !alStateModel.getObject().isSessionActive())));
    form.add(new LambdaAjaxLink(CID_STOP_SESSION_BUTTON, this::actionStopSession)
        .add(visibleWhen(() -> alStateModel.getObject().isSessionActive())));
    form.add(visibleWhen(() -> alStateModel.getObject().isDoExistRecommenders()));

    return form;
}
 
Example 4
Source File: SingleChoiceEditor.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * Construct drop down box to select single value.
 *
 * @param id         editor id.
 * @param markupProvider markup object.
 * @param model      model.
 * @param labelModel label model
 * @param attrValue  {@link org.yes.cart.domain.entity.AttrValue}
 * @param choices    list of strings {@link org.yes.cart.domain.misc.Pair}, that represent options to select one
 * @param readOnly  if true this component is read only
 */
public SingleChoiceEditor(final String id,
                          final MarkupContainer markupProvider,
                          final IModel model,
                          final IModel<String> labelModel,
                          final IModel choices,
                          final AttrValueWithAttribute attrValue,
                          final boolean readOnly) {

    super(id, "singleChoiceEditor", markupProvider);

    final DropDownChoice<Pair<String, String>> dropDownChoice =
            new DropDownChoice<Pair<String, String>>(EDIT, model, choices);
    dropDownChoice.setLabel(labelModel);
    dropDownChoice.setEnabled(!readOnly);
    dropDownChoice.setRequired(attrValue.getAttribute().isMandatory());
    dropDownChoice.setChoiceRenderer(new PairChoiceRenderer());
    add(dropDownChoice);

}
 
Example 5
Source File: ProjectDetailPanel.java    From webanno with Apache License 2.0 6 votes vote down vote up
private DropDownChoice<String> makeProjectTypeChoice()
{
    List<String> types = projectService.listProjectTypes().stream().map(t -> t.id())
            .collect(Collectors.toList());

    DropDownChoice<String> projTypes = new BootstrapSelect<>("mode", types);
    projTypes.setRequired(true);
    projTypes.add(LambdaBehavior.onConfigure(_this -> {
        // If there is only a single project type and the project mode has not been set yet,
        // then we can simply select that and do not need to show the choice at all.
        Project project = projectModel.getObject();
        if (projectTypes.getChoices().size() == 1 && project.getMode() == null) {
            project.setMode(projectTypes.getChoices().get(0));
        }
        
        _this.setEnabled(
                nonNull(projectModel.getObject()) && isNull(projectModel.getObject().getId()));
        
        // If there is only a single project type, then we can simply select that and do not
        // need to show the choice at all.
        _this.setVisible(projTypes.getChoices().size() > 1);
    }));
    
    return projTypes;
}
 
Example 6
Source File: ScriptEditForm.java    From projectforge-webapp with GNU General Public License v3.0 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 7
Source File: TeamEventEditForm.java    From projectforge-webapp with GNU General Public License v3.0 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 8
Source File: AccessSettingsPanel.java    From inception with Apache License 2.0 5 votes vote down vote up
private DropDownChoice<RepositoryType> createTypeSelection(String id, String property)
{
    DropDownChoice<RepositoryType> typeChoice = new BootstrapSelect<>(id,
            kbModel.bind(property), asList(RepositoryType.values()),
            new EnumChoiceRenderer<>(this));
    typeChoice.setRequired(true);
    return typeChoice;
}
 
Example 9
Source File: QualifierEditor.java    From inception with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new fragement for editing a qualifier.<br>
 * The editor has two slightly different behaviors, depending on the value of
 * {@code isNewQualifier}:
 * <ul>
 * <li>{@code !isNewQualifier}: Save button commits changes, cancel button discards unsaved
 * changes, delete button removes the qualifier from the statement.</li>
 * <li>{@code isNewQualifier}: Save button commits changes (creates a new qualifier in the
 * statement), cancel button removes the qualifier from the UI, delete button is not visible
 * .</li>
 * </ul>
 *
 * @param aId
 *            markup ID
 * @param aQualifier
 *            qualifier model
 * @param isNewQualifier
 *            whether the qualifier being edited is new, meaning it has no corresponding
 *            qualifier in the KB backend
 */
public EditMode(String aId, IModel<KBQualifier> aQualifier, boolean isNewQualifier)
{
    super(aId, "editMode", QualifierEditor.this, aQualifier);

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

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

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

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

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

    add(form);
}
 
Example 10
Source File: AddAnalysisPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public AddAnalysisPanel() {
	super(FormPanel.CONTENT_ID);

	DropDownChoice<String> selectedTable = new DropDownChoice<String>("tableChoice", new PropertyModel<String>(this, "selectedTable"), new TablesModel());
	selectedTable.setOutputMarkupPlaceholderTag(true);
	selectedTable.setNullValid(false);		
	selectedTable.setRequired(true);
	selectedTable.setLabel(new StringResourceModel("Analysis.source", null));
		add(selectedTable);  		
}
 
Example 11
Source File: NextRuntimePanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
  public void addWicketComponents() {    	        	    	
  	
      final DropDownChoice<String> exportChoice = new DropDownChoice<String>("exportType", new PropertyModel<String>(runtimeModel, "exportType"), typeList,
      		new ChoiceRenderer<String>() {
			@Override
			public Object getDisplayValue(String name) {
				if (name.equals(ReportConstants.ETL_FORMAT)) {
					return getString("Analysis.source");
				} else {
					return name;
				}
			}
});
      exportChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {
          @Override
          protected void onUpdate(AjaxRequestTarget target) {
              String format = (String) getFormComponent().getConvertedInput();
              if (ReportConstants.ETL_FORMAT.equals(format)) {
			System.out.println("***** ETL selected");
			//analysisPanel.setVisible(true);
		} else {
			System.out.println("***** " + format);
			//analysisPanel.setVisible(false);
		}
              //target.add(analysisPanel);
          }
      });
	
      exportChoice.setRequired(true);
      add(exportChoice);
      
      if (report.isAlarmType() || report.isIndicatorType() || report.isDisplayType()) {
      	exportChoice.setEnabled(false);
      } else {
      	exportChoice.setRequired(true);
      }
      
      
  }
 
Example 12
Source File: AddEmailUserPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public AddEmailUserPanel(String id) {
	super(id);

	DropDownChoice<String> choice = new DropDownChoice<String>("user", new PropertyModel<String>(this, "user"), new UsersModel());
	choice.setRequired(true);
	choice.setLabel(new Model<String>(getString("AclEntryPanel.user")));
	add(choice);
}
 
Example 13
Source File: AddEmailGroupPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public AddEmailGroupPanel(String id) {
	super(id);

	DropDownChoice<String> choice = new DropDownChoice<String>("group", new PropertyModel<String>(this, "group"), new GroupsModel());
	choice.setRequired(true);
	choice.setLabel(new Model<String>(getString("AclEntryPanel.group")));
	add(choice);
}
 
Example 14
Source File: DefineDrillEntityPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
public DefineDrillEntityPanel(String id, String type, final DrillDownEntity drillEntity, Entity entity) {
	super(id, new CompoundPropertyModel<DrillDownEntity>(drillEntity));
	
	this.type = type;
	
	final Label widgetLabel = new Label("entityLabel", getString(type));		
	add(widgetLabel);
	
	final DropDownChoice<Entity> entityChoice = new DropDownChoice<Entity>("entities", 
			new PropertyModel<Entity>(drillEntity, "entity"), new WidgetDropDownModel(), new EntityChoiceRenderer());
	entityChoice.setOutputMarkupPlaceholderTag(true);
	entityChoice.setOutputMarkupId(true);
	entityChoice.setRequired(true);
	add(entityChoice);
	
	final Label linkLabel = new Label("linkLabel", getString("ActionContributor.Drill.parameter"));
	linkLabel.setOutputMarkupId(true);
	linkLabel.setOutputMarkupPlaceholderTag(true);
	add(linkLabel);
	
	final DropDownChoice<String> paramChoice = new DropDownChoice<String>("parameters",
               new PropertyModel<String>(drillEntity, "linkParameter"), parameters, new ChoiceRenderer<String>());
       paramChoice.setRequired(true);
       paramChoice.setLabel(new Model<String>( getString("ActionContributor.Drill.parameter")));
       paramChoice.setOutputMarkupId(true);
       paramChoice.setOutputMarkupPlaceholderTag(true);
       add(paramChoice);
       
       final Label columnLabel = new Label("columnLabel",  getString("ActionContributor.Drill.column"));            
       columnLabel.setOutputMarkupId(true);
       columnLabel.setOutputMarkupPlaceholderTag(true);
	add(columnLabel);
                   
       final TextField<Integer> columnField = new TextField<Integer>("column");            
       columnField.setOutputMarkupId(true);
       columnField.setOutputMarkupPlaceholderTag(true);
       add(columnField);
       
       if (drillEntity.getIndex() == 0) {
       	if (entity instanceof Chart) {
       		columnLabel.setVisible(false);            	
       		columnField.setVisible(false);            		 
       	}
       } else {
       	if (DrillDownUtil.getLastDrillType(entity) == DrillDownEntity.CHART_TYPE) {
       		columnLabel.setVisible(false);            	
       		columnField.setVisible(false);            		   
       	} 
       }
       
       entityChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

           @Override
           protected void onUpdate(AjaxRequestTarget target) {
          	updateParameters(drillEntity);                     
              target.add(paramChoice);
           }

       }); 
       
}
 
Example 15
Source File: ChartRuntimePanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public void addWicketComponents() {
	
	ChoiceRenderer<String> typeRenderer = new ChoiceRenderer<String>() {
    	
    	@Override
        public Object getDisplayValue(String chartType) {
            if (chartType == null) {
            	return ChartUtil.CHART_NONE;
            } else if (chartType.equals(ChartUtil.CHART_BAR)) {
            	return getString("chart.bar");
            } else if (chartType.equals(ChartUtil.CHART_NEGATIVE_BAR)) {
            	return getString("chart.negativebar");	
            } else if (chartType.equals(ChartUtil.CHART_BAR_COMBO)) {
            	return getString("chart.barcombo");	
            } else if (chartType.equals(ChartUtil.CHART_HORIZONTAL_BAR)) {
            	return getString("chart.horizontalbar");
            } else if (chartType.equals(ChartUtil.CHART_STACKED_BAR)) {
            	return getString("chart.stackedbar");
            } else if (chartType.equals(ChartUtil.CHART_STACKED_BAR_COMBO)) {
            	return getString("chart.stackedbarcombo");
            } else if (chartType.equals(ChartUtil.CHART_HORIZONTAL_STACKED_BAR)) {
            	return getString("chart.horizontalstackedbar");
            } else if (chartType.equals(ChartUtil.CHART_PIE)) {
            	return getString("chart.pie");
            } else if (chartType.equals(ChartUtil.CHART_LINE)) {
            	return getString("chart.line");
            } else if (chartType.equals(ChartUtil.CHART_AREA)) {
            	return getString("chart.area");	
            } else if (chartType.equals(ChartUtil.CHART_BUBBLE)) {
            	return getString("chart.bubble");		
            } else {
            	return ChartUtil.CHART_NONE;
            }
        }
        
    };
	
    DropDownChoice exportChoice = new DropDownChoice("chartType", new PropertyModel(runtimeModel, "chartType"), ChartUtil.CHART_TYPES, typeRenderer);
    exportChoice.setRequired(true);
    add(exportChoice);

    TextField<Integer> refreshText = new TextField<Integer>("refreshTime", new PropertyModel(runtimeModel, "refreshTime"));
    refreshText.add(new ZeroRangeValidator(10, 3600));
    refreshText.setRequired(true);
    add(refreshText);
    
    TextField<Integer> timeoutText = new TextField<Integer>("timeout", new PropertyModel(runtimeModel, "timeout"));
    timeoutText.add(new RangeValidator<Integer>(5, 600));
    timeoutText.setLabel(new Model<String>("Timeout"));
    timeoutText.setRequired(true);
    add(timeoutText);
}
 
Example 16
Source File: AbstractListForm.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("serial")
private void addExtendedFilter()
{
  gridBuilder.newSplitPanel(GridSize.COL66);
  extendedFilter = gridBuilder.getRowPanel();
  extendedFilter.setMarkupId("extendedFilter");
  if (searchFilter.isUseModificationFilter() == false) {
    extendedFilter.add(AttributeModifier.append("style", "display: none;"));
  }
  {
    final FieldsetPanel fieldset = gridBuilder.newFieldset(getString("search.periodOfModification"));
    fieldset.add(new HiddenInputPanel(fieldset.newChildId(), new HiddenField<Boolean>(InputPanel.WICKET_ID, new PropertyModel<Boolean>(
        searchFilter, "useModificationFilter"))).setHtmlId("useModificationFilter"));

    startDateTimePanel = new DateTimePanel(fieldset.newChildId(), new PropertyModel<Date>(searchFilter, "startTimeOfModification"),
        (DateTimePanelSettings) DateTimePanelSettings.get().withSelectProperty("startDateOfModification").withSelectPeriodMode(true),
        DatePrecision.MINUTE);
    fieldset.add(startDateTimePanel);
    fieldset.setLabelFor(startDateTimePanel);
    stopDateTimePanel = new DateTimePanel(fieldset.newChildId(), new PropertyModel<Date>(searchFilter, "stopTimeOfModification"),
        (DateTimePanelSettings) DateTimePanelSettings.get().withSelectProperty("stopDateOfModification").withSelectPeriodMode(true),
        DatePrecision.MINUTE);
    stopDateTimePanel.setRequired(false);
    fieldset.add(stopDateTimePanel);
    final HtmlCommentPanel comment = new HtmlCommentPanel(fieldset.newChildId(), new DatesAsUTCModel() {
      @Override
      public Date getStartTime()
      {
        return searchFilter.getStartTimeOfModification();
      }

      @Override
      public Date getStopTime()
      {
        return searchFilter.getStopTimeOfModification();
      }
    });
    fieldset.add(comment);
    // DropDownChoice for convenient selection of time periods.
    final LabelValueChoiceRenderer<String> timePeriodChoiceRenderer = new LabelValueChoiceRenderer<String>();
    timePeriodChoiceRenderer.addValue("lastMinute", getString("search.lastMinute"));
    timePeriodChoiceRenderer.addValue("lastMinutes:10", PFUserContext.getLocalizedMessage("search.lastMinutes", 10));
    timePeriodChoiceRenderer.addValue("lastMinutes:30", PFUserContext.getLocalizedMessage("search.lastMinutes", 30));
    timePeriodChoiceRenderer.addValue("lastHour", getString("search.lastHour"));
    timePeriodChoiceRenderer.addValue("lastHours:4", PFUserContext.getLocalizedMessage("search.lastHours", 4));
    timePeriodChoiceRenderer.addValue("today", getString("search.today"));
    timePeriodChoiceRenderer.addValue("sinceYesterday", getString("search.sinceYesterday"));
    timePeriodChoiceRenderer.addValue("lastDays:3", PFUserContext.getLocalizedMessage("search.lastDays", 3));
    timePeriodChoiceRenderer.addValue("lastDays:7", PFUserContext.getLocalizedMessage("search.lastDays", 7));
    timePeriodChoiceRenderer.addValue("lastDays:14", PFUserContext.getLocalizedMessage("search.lastDays", 14));
    timePeriodChoiceRenderer.addValue("lastDays:30", PFUserContext.getLocalizedMessage("search.lastDays", 30));
    timePeriodChoiceRenderer.addValue("lastDays:60", PFUserContext.getLocalizedMessage("search.lastDays", 60));
    timePeriodChoiceRenderer.addValue("lastDays:90", PFUserContext.getLocalizedMessage("search.lastDays", 90));
    final DropDownChoice<String> modificationSinceChoice = new DropDownChoice<String>(fieldset.getDropDownChoiceId(),
        new PropertyModel<String>(this, "modificationSince"), timePeriodChoiceRenderer.getValues(), timePeriodChoiceRenderer);
    modificationSinceChoice.setNullValid(true);
    modificationSinceChoice.setRequired(false);
    fieldset.add(modificationSinceChoice, true);
  }

  {
    gridBuilder.newSplitPanel(GridSize.COL33);
    final FieldsetPanel fs = gridBuilder.newFieldset(getString("modifiedBy"), getString("user"));

    final UserSelectPanel userSelectPanel = new UserSelectPanel(fs.newChildId(), new Model<PFUserDO>() {
      @Override
      public PFUserDO getObject()
      {
        return userGroupCache.getUser(searchFilter.getModifiedByUserId());
      }

      @Override
      public void setObject(final PFUserDO object)
      {
        if (object == null) {
          searchFilter.setModifiedByUserId(null);
        } else {
          searchFilter.setModifiedByUserId(object.getId());
        }
      }
    }, parentPage, "modifiedByUserId");
    fs.add(userSelectPanel);
    userSelectPanel.setDefaultFormProcessing(false);
    userSelectPanel.init().withAutoSubmit(true);
  }
  gridBuilder.setCurrentLevel(0); // Go back to main row panel.
}
 
Example 17
Source File: CalendarForm.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("serial")
@Override
protected void init()
{
  super.init();
  gridBuilder.newSplitPanel(GridSize.SPAN8);
  fieldset = gridBuilder.newFieldset(getString("label.options"));
  final CalendarPageSupport calendarPageSupport = createCalendarPageSupport();
  calendarPageSupport.addUserSelectPanel(fieldset, new PropertyModel<PFUserDO>(this, "timesheetsUser"), true);
  currentDatePanel = new JodaDatePanel(fieldset.newChildId(), new PropertyModel<DateMidnight>(filter, "startDate")).setAutosubmit(true);
  currentDatePanel.getDateField().setOutputMarkupId(true);
  fieldset.add(currentDatePanel);

  final DropDownChoice<Integer> firstHourDropDownChoice = new DropDownChoice<Integer>(fieldset.getDropDownChoiceId(),
      new PropertyModel<Integer>(filter, "firstHour"), DateTimePanel.getHourOfDayRenderer().getValues(),
      DateTimePanel.getHourOfDayRenderer()) {
    /**
     * @see org.apache.wicket.markup.html.form.DropDownChoice#wantOnSelectionChangedNotifications()
     */
    @Override
    protected boolean wantOnSelectionChangedNotifications()
    {
      return true;
    }
  };
  firstHourDropDownChoice.setNullValid(false);
  firstHourDropDownChoice.setRequired(true);
  WicketUtils.addTooltip(firstHourDropDownChoice, getString("calendar.option.firstHour.tooltip"));
  fieldset.add(firstHourDropDownChoice);

  final DivPanel checkBoxPanel = fieldset.addNewCheckBoxButtonDiv();

  calendarPageSupport.addOptions(checkBoxPanel, true, filter);
  checkBoxPanel.add(new CheckBoxButton(checkBoxPanel.newChildId(), new PropertyModel<Boolean>(filter, "slot30"),
      getString("calendar.option.slot30"), true).setTooltip(getString("calendar.option.slot30.tooltip")));

  buttonGroupPanel = new ButtonGroupPanel(fieldset.newChildId());
  fieldset.add(buttonGroupPanel);
  {
    final IconButtonPanel refreshButtonPanel = new IconButtonPanel(buttonGroupPanel.newChildId(), IconType.REFRESH,
        getRefreshIconTooltip()) {
      /**
       * @see org.projectforge.web.wicket.flowlayout.IconButtonPanel#onSubmit()
       */
      @Override
      protected void onSubmit()
      {
        parentPage.refresh();
        setResponsePage(getPage().getClass(), getPage().getPageParameters());
      }
    };
    buttonGroupPanel.addButton(refreshButtonPanel);
    setDefaultButton(refreshButtonPanel.getButton());
  }
  gridBuilder.newSplitPanel(GridSize.SPAN4);
  final FieldsetPanel fs = gridBuilder.newFieldset(getString("timesheet.duration")).suppressLabelForWarning();
  final DivTextPanel durationPanel = new DivTextPanel(fs.newChildId(), new Label(DivTextPanel.WICKET_ID, new Model<String>() {
    @Override
    public String getObject()
    {
      return parentPage.calendarPanel.getTotalTimesheetDuration();
    }
  }));
  durationLabel = durationPanel.getLabel4Ajax();
  fs.add(durationPanel);
  onAfterInit(gridBuilder);
}
 
Example 18
Source File: MetricSelectDropDownPanel.java    From inception with Apache License 2.0 4 votes vote down vote up
public MetricSelectDropDownPanel(String aId)
{
    super(aId);

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

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

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

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

    add(dropdown);

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

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

            }
            else {

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

    link.setOutputMarkupId(true);
    add(link);
}