public static void putPageParameters( final ISelectCallerPage callerPage, final Object dataObject, final Object filterObject, final PageParameters pageParameters, final String[] bookmarkableProperties) { if (bookmarkableProperties == null) { return; } // final String pre = prefix != null ? prefix + "." : ""; for (final String propertyString : bookmarkableProperties) { final InitialPageParameterHolder paramHolder = new InitialPageParameterHolder(propertyString); final Object bean; if (paramHolder.isFilterParameter() == true) { bean = filterObject; } else { bean = dataObject; } try { final Object value = BeanHelper.getProperty(bean, paramHolder.property); WicketUtils.putPageParameter(pageParameters, paramHolder.prefix + paramHolder.alias, value); } catch (final Exception ex) { log.warn( "Couldn't put page parameter '" + paramHolder.property + "' of bean '" + bean + "'. Ignoring this parameter."); } } }
@Override public void renderHead(final IHeaderResponse response) { super.renderHead(response); response.render( JavaScriptReferenceHeaderItem.forReference( Application.get().getJavaScriptLibrarySettings().getJQueryReference())); response.render( StringHeaderItem.forString(WicketUtils.getCssForFavicon(getUrl("/favicon.ico")))); if (WebConfiguration.isDevelopmentMode() == true) { response.render( CssReferenceHeaderItem.forUrl( "mobile/jquery.mobile/jquery.mobile-" + JQUERY_MOBILE_VERSION + ".css")); } else { response.render( CssReferenceHeaderItem.forUrl( "mobile/jquery.mobile/jquery.mobile-" + JQUERY_MOBILE_VERSION + ".min.css")); } response.render(CssReferenceHeaderItem.forUrl("mobile/projectforge.css")); response.render(JavaScriptReferenceHeaderItem.forUrl("mobile/jquery.mobile/myconfig.js")); if (WebConfiguration.isDevelopmentMode() == true) { // response.renderJavaScriptReference("mobile/jquery.mobile/myconfig.js"); response.render( JavaScriptReferenceHeaderItem.forUrl( "mobile/jquery.mobile/jquery.mobile-" + JQUERY_MOBILE_VERSION + ".js")); } else { // response.renderJavaScriptReference("mobile/jquery.mobile/myconfig.js"); response.render( JavaScriptReferenceHeaderItem.forUrl( "mobile/jquery.mobile/jquery.mobile-" + JQUERY_MOBILE_VERSION + ".min.js")); } }
/** @return */ public static ContextImage getInvisibleDummyImage( final String id, final RequestCycle requestCylce) { final ContextImage image = new ContextImage(id, WicketUtils.getImageUrl(requestCylce, WebConstants.IMAGE_SPACER)); image.setVisible(false); return image; }
/** @see org.projectforge.web.wicket.AbstractSelectPanel#onBeforeRender() */ @SuppressWarnings("serial") @Override protected void onBeforeRender() { super.onBeforeRender(); final TaskDO task = getModelObject(); final Integer taskId = task != null ? task.getId() : null; if (currentTaskId == taskId) { return; } currentTaskId = taskId; if (showPath == true && task != null) { ancestorRepeater.removeAll(); final TaskNode taskNode = taskTree.getTaskNodeById(task.getId()); final List<Integer> ancestorIds = taskNode.getAncestorIds(); final ListIterator<Integer> it = ancestorIds.listIterator(ancestorIds.size()); while (it.hasPrevious() == true) { final Integer ancestorId = it.previous(); final TaskDO ancestorTask = taskTree.getTaskById(ancestorId); if (ancestorTask.getParentTask() == null) { // Don't show root node: continue; } final WebMarkupContainer cont = new WebMarkupContainer(ancestorRepeater.newChildId()); ancestorRepeater.add(cont); final SubmitLink selectTaskLink = new SubmitLink("ancestorTaskLink") { @Override public void onSubmit() { caller.select(selectProperty, ancestorTask.getId()); } }; selectTaskLink.setDefaultFormProcessing(false); cont.add(selectTaskLink); WicketUtils.addTooltip( selectTaskLink, getString("task.selectPanel.selectAncestorTask.tooltip")); selectTaskLink.add(new Label("name", ancestorTask.getTitle())); } ancestorRepeater.setVisible(true); } else { ancestorRepeater.setVisible(false); } }
@SuppressWarnings("serial") private MyButtonPanel(final String id, final String i18nKey) { button = new Button(SingleButtonPanel.WICKET_ID, new Model<String>()) { @Override public final void onSubmit() { MyButtonPanel.this.onSubmit(); } /** @see org.apache.wicket.Component#isVisible() */ @Override public boolean isVisible() { return MyButtonPanel.this.isVisible(); } }; buttonPanel = new SingleButtonPanel( id, button, getString("system.admin.button." + i18nKey), SingleButtonPanel.GREY); WicketUtils.addTooltip(button, getString("system.admin.button." + i18nKey + ".tooltip")); }
/** @see WicketUtils#getUrl(org.apache.wicket.Response, String, boolean) */ public String getUrl(final String path, final boolean encodeUrl) { return WicketUtils.getUrl(getRequestCycle(), path, encodeUrl); }
/** @see WicketUtils#getImageUrl(org.apache.wicket.Response, String) */ public String getImageUrl(final String subpath) { return WicketUtils.getImageUrl(getRequestCycle(), subpath); }
@SuppressWarnings("serial") @Override protected void init() { super.init(); /* GRID16 - BLOCK */ gridBuilder.newGridPanel(); { // Number final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.kunde.nummer")); final MinMaxNumberField<Integer> number = new MinMaxNumberField<Integer>( InputPanel.WICKET_ID, new PropertyModel<Integer>(data, "id"), 0, KundeDO.MAX_ID) { @SuppressWarnings({"unchecked", "rawtypes"}) @Override public IConverter getConverter(final Class type) { return new IntegerConverter(3); } }; WicketUtils.setSize(number, 7); fs.add(number); if (isNew() == true) { WicketUtils.setFocus(number); } } { // Name final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.kunde.name")); final RequiredMaxLengthTextField name = new RequiredMaxLengthTextField( InputPanel.WICKET_ID, new PropertyModel<String>(data, "name")); fs.add(name); if (isNew() == false) { WicketUtils.setFocus(name); } } if (Registry.instance().getKontoCache().isEmpty() == false) { // Show this field only if DATEV accounts does exist. final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.konto")); final KontoSelectPanel kontoSelectPanel = new KontoSelectPanel( fs.newChildId(), new PropertyModel<KontoDO>(data, "konto"), null, "kontoId"); kontoSelectPanel .setKontoNumberRanges(AccountingConfig.getInstance().getDebitorsAccountNumberRanges()) .init(); fs.addHelpIcon(getString("fibu.kunde.konto.tooltip")); fs.add(kontoSelectPanel); } { // Identifier final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.kunde.identifier")); fs.add( new MaxLengthTextField( InputPanel.WICKET_ID, new PropertyModel<String>(data, "identifier"))); } { // Identifier final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.kunde.division")); fs.add( new MaxLengthTextField( InputPanel.WICKET_ID, new PropertyModel<String>(data, "division"))); } { // Identifier final FieldsetPanel fs = gridBuilder.newFieldset(getString("description")); fs.add( new MaxLengthTextArea( TextAreaPanel.WICKET_ID, new PropertyModel<String>(data, "description"))); } { // Status drop down box: final FieldsetPanel fs = gridBuilder.newFieldset(getString("status")); final LabelValueChoiceRenderer<KundeStatus> statusChoiceRenderer = new LabelValueChoiceRenderer<KundeStatus>(fs, KundeStatus.values()); final DropDownChoice<KundeStatus> statusChoice = new DropDownChoice<KundeStatus>( fs.getDropDownChoiceId(), new PropertyModel<KundeStatus>(data, "status"), statusChoiceRenderer.getValues(), statusChoiceRenderer); statusChoice.setNullValid(false).setRequired(true); fs.add(statusChoice); } }
/** * At least one parameter should be given for setting the fill the bean with all book-markable * properties (absent properties will be set to zero). If the given bean is an instance of {@link * ISelectCallerPage} then the select/unselect methods are used, otherwise the properties will set * directly of the given bean. * * @param bean * @param parameters * @param prefix * @param bookmarkableProperties */ public static void evaluatePageParameters( final ISelectCallerPage callerPage, final Object dataObject, final Object filter, final PageParameters parameters, final String[] bookmarkableProperties) { if (bookmarkableProperties == null) { return; } // First check if any parameter is given: boolean useParameters = false; for (final String str : bookmarkableProperties) { final InitialPageParameterHolder paramHolder = new InitialPageParameterHolder(str); if (hasParameter(parameters, paramHolder.prefix + paramHolder.property) == true || hasParameter(parameters, paramHolder.prefix + paramHolder.alias) == true) { useParameters = true; break; } } if (useParameters == false) { // No book-markable parameters found. return; } for (final String str : bookmarkableProperties) { final InitialPageParameterHolder paramHolder = new InitialPageParameterHolder(str); String key = null; if (hasParameter(parameters, paramHolder.prefix + paramHolder.property) == true) { key = paramHolder.property; } else if (hasParameter(parameters, paramHolder.prefix + paramHolder.alias) == true) { key = paramHolder.alias; } if (paramHolder.isCallerPageParameter() == true) { if (callerPage == null) { log.warn("PageParameter '" + str + "' ignored, ISelectCallerPage isn't given."); } else if (key == null) { callerPage.unselect(paramHolder.property); } else { callerPage.select( paramHolder.property, parameters.get(paramHolder.prefix + key).toString()); } } else { try { final Object bean; if (paramHolder.isFilterParameter() == true) { // Use filter object bean = filter; if (bean == null) { log.warn("PageParameter '" + str + "' ignored, filter isn't given."); continue; } } else { bean = dataObject; if (bean == null) { log.warn("PageParameter '" + str + "' ignored, dataObject isn't given."); continue; } } final Method method = BeanHelper.determineGetter(bean.getClass(), paramHolder.property); if (key == null) { BeanHelper.setProperty( bean, paramHolder.property, ClassHelper.getDefaultType(method.getReturnType())); } else { final Object value = WicketUtils.getPageParameter( parameters, paramHolder.prefix + key, method.getReturnType()); BeanHelper.setProperty(bean, paramHolder.property, value); } } catch (final Exception ex) { log.warn("Property '" + key + "' not found. Ignoring URL parameter."); } } } }
private void initAutoCompletePanels() { userselectContainer = new WebMarkupContainer("userselectContainer") { private static final long serialVersionUID = -4871020567729661148L; /** @see org.apache.wicket.Component#isVisible() */ @Override public boolean isVisible() { // only show if we are in ajax select task mode return ajaxTaskSelectMode == true; } }; add(userselectContainer); userselectContainer.setOutputMarkupId(true); userselectContainer.setOutputMarkupPlaceholderTag(true); final TaskSelectAutoCompleteFormComponent searchTaskInput = new TaskSelectAutoCompleteFormComponent("searchTaskInput") { private static final long serialVersionUID = -7741009167252308262L; /** * @see * org.projectforge.web.task.TaskSelectAutoCompleteFormComponent#onModelChanged(org.apache.wicket.ajax.AjaxRequestTarget) */ @Override protected void onModelSelected(final AjaxRequestTarget target, final TaskDO taskDo) { ajaxTaskSelectMode = false; target.appendJavaScript("hideAllTooltips();"); TaskSelectPanel.this.setModelObject(taskDo); TaskSelectPanel.this.onModelSelected(target, taskDo); } }; searchTaskInput.setAutocompleteOnlyTaskBookableForTimesheets( autocompleteOnlyTaskBookableForTimesheets); userselectContainer.add(searchTaskInput); // opener link final WebMarkupContainer searchTaskInputOpen = new WebMarkupContainer("searchTaskInputOpen"); WicketUtils.addTooltip(searchTaskInputOpen, getString("quickselect")); searchTaskInputOpen.add( new AjaxEventBehavior("click") { private static final long serialVersionUID = -938527474172868488L; @Override protected void onEvent(final AjaxRequestTarget target) { ajaxTaskSelectMode = true; target.appendJavaScript("hideAllTooltips();"); target.add(divContainer); target.add(userselectContainer); target.focusComponent(searchTaskInput); } }); // close link final WebMarkupContainer searchTaskInputClose = new WebMarkupContainer("searchTaskInputClose"); divContainer.add(searchTaskInputClose); searchTaskInputClose.add( new AjaxEventBehavior("click") { private static final long serialVersionUID = -4334830387094758960L; @Override protected void onEvent(final AjaxRequestTarget target) { ajaxTaskSelectMode = false; target.appendJavaScript("hideAllTooltips();"); target.add(divContainer); target.add(userselectContainer); } }); userselectContainer.add(searchTaskInputClose); divContainer.add(searchTaskInputOpen); }
@Override @SuppressWarnings("serial") public TaskSelectPanel init() { super.init(); ancestorRepeater = new RepeatingView("ancestorTasks"); divContainer.add(ancestorRepeater); final SubmitLink taskLink = new SubmitLink("taskLink") { @Override public void onSubmit() { final TaskDO task = getModelObject(); if (task == null) { return; } final PageParameters pageParams = new PageParameters(); pageParams.add(AbstractEditPage.PARAMETER_KEY_ID, String.valueOf(task.getId())); final TaskEditPage editPage = new TaskEditPage(pageParams); editPage.setReturnToPage((AbstractSecuredPage) getPage()); setResponsePage(editPage); } }; taskLink.setDefaultFormProcessing(false); divContainer.add(taskLink); // auto complete panels initAutoCompletePanels(); WicketUtils.addTooltip(taskLink, getString("task.selectPanel.displayTask.tooltip")); taskLink.add( new Label( "name", new Model<String>() { /** @see org.apache.wicket.model.Model#getObject() */ @Override public String getObject() { final TaskDO task = getModelObject(); return task != null ? task.getTitle() : ""; } })); final SubmitLink selectButton = new SubmitLink("select") { @Override public void onSubmit() { final TaskTreePage taskTreePage = new TaskTreePage(caller, selectProperty); if (getModelObject() != null) { taskTreePage.setHighlightedRowId( getModelObject().getId()); // Preselect node for highlighting. } setResponsePage(taskTreePage); }; }; selectButton.setDefaultFormProcessing(false); divContainer.add(selectButton); selectButton.add(new IconPanel("selectHelp", IconType.TASK, getString("tooltip.selectTask"))); final SubmitLink unselectButton = new SubmitLink("unselect") { @Override public void onSubmit() { caller.unselect(selectProperty); } @Override public boolean isVisible() { return isRequired() == false && getModelObject() != null; } }; unselectButton.setDefaultFormProcessing(false); divContainer.add(unselectButton); unselectButton.add( new IconPanel("unselectHelp", IconType.REMOVE_SIGN, getString("tooltip.unselectTask")) .setColor(CSSColor.RED)); // DropDownChoice favorites final FavoritesChoicePanel<TaskDO, TaskFavorite> favoritesPanel = new FavoritesChoicePanel<TaskDO, TaskFavorite>( "favorites", UserPrefArea.TASK_FAVORITE, tabIndex, "full text") { @Override protected void select(final TaskFavorite favorite) { if (favorite.getTask() != null) { TaskSelectPanel.this.selectTask(favorite.getTask()); } } @Override protected TaskDO getCurrentObject() { return TaskSelectPanel.this.getModelObject(); } @Override protected TaskFavorite newFavoriteInstance(final TaskDO currentObject) { final TaskFavorite favorite = new TaskFavorite(); favorite.setTask(currentObject); return favorite; } }; divContainer.add(favoritesPanel); favoritesPanel.init(); if (showFavorites == false) { favoritesPanel.setVisible(false); } return this; }
/** @see org.apache.wicket.Component#onBeforeRender() */ @SuppressWarnings("serial") protected void redraw( final TemplateEntry activeTemplateEntry, final List<TeamCalDO> selectedCalendars) { columnRepeater.removeAll(); final int counter = selectedCalendars.size(); int rowsPerColumn = counter / 3; if (counter % 3 > 0) { ++rowsPerColumn; // Need one more row. } int rowCounter = 0; WebMarkupContainer columnContainer; RepeatingView rowRepeater = null; for (final TeamCalDO calendar : selectedCalendars) { if (rowCounter++ % rowsPerColumn == 0) { // Start new column: columnContainer = new WebMarkupContainer(columnRepeater.newChildId()); columnContainer.add(AttributeModifier.append("class", GridSize.COL33.getClassAttrValue())); columnRepeater.add(columnContainer); rowRepeater = new RepeatingView("rowRepeater"); columnContainer.add(rowRepeater); } final WebMarkupContainer container = new WebMarkupContainer(rowRepeater.newChildId()); rowRepeater.add(container); final IModel<Boolean> model = Model.of(activeTemplateEntry.isVisible(calendar.getId()) == true); final CheckBoxPanel checkBoxPanel = new CheckBoxPanel("isVisible", model, ""); checkBoxPanel .getCheckBox() .add( new AjaxFormComponentUpdatingBehavior("onChange") { private static final long serialVersionUID = 3523446385818267608L; @Override protected void onUpdate(final AjaxRequestTarget target) { final Boolean newSelection = checkBoxPanel.getCheckBox().getConvertedInput(); final TemplateCalendarProperties properties = activeTemplateEntry.getCalendarProperties(calendar.getId()); if (newSelection != properties.isVisible()) { properties.setVisible(newSelection); activeTemplateEntry.setDirty(); } } }); container.add(checkBoxPanel); WicketUtils.addTooltip( checkBoxPanel.getCheckBox(), getString("plugins.teamcal.filterDialog.calendarIsVisible.tooltip")); container.add(new Label("name", calendar.getTitle())); final ColorPickerPanel picker = new ColorPickerPanel("colorPicker", activeTemplateEntry.getColorCode(calendar.getId())) { @Override protected void onColorUpdate(final String selectedColor) { final TemplateCalendarProperties props = activeTemplateEntry.getCalendarProperties(calendar.getId()); if (props != null) { props.setColorCode(selectedColor); } else { log.warn( "TeamCalendarProperties not found: calendar.id='" + calendar.getId() + "' + for active template '" + activeTemplateEntry.getName() + "'."); } } }; container.add(picker); } }
@Override protected void init() { super.init(); // GRID 50% - BLOCK gridBuilder.newSplitPanel(GridSize.COL50); { // Number final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.number")); fs.add(new DivTextPanel(fs.newChildId(), "C-")); numberField = new MinMaxNumberField<Integer>( InputPanel.WICKET_ID, new PropertyModel<Integer>(data, "number"), 0, 99999999); numberField.setMaxLength(8); WicketUtils.setSize(numberField, 6); fs.add(numberField); if (NumberHelper.greaterZero(getData().getNumber()) == false) { fs.addHelpIcon(getString("fibu.tooltip.nummerWirdAutomatischVergeben")); } } { // Date final FieldsetPanel fs = gridBuilder.newFieldset(getString("date")); datePanel = new DatePanel( fs.newChildId(), new PropertyModel<Date>(data, "date"), DatePanelSettings.get().withTargetType(java.sql.Date.class)); fs.add(datePanel); } { // Title final FieldsetPanel fs = gridBuilder.newFieldset(getString("title")); fs.add(createAutocompleteTextField("title")) .getField() .setRequired(true) .add(WicketUtils.setFocus()); } { // Contract type final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.type")); final List<ContractType> contractTypes = ConfigXml.getInstance().getContractTypes(); final LabelValueChoiceRenderer<ContractType> typeChoiceRenderer = new LabelValueChoiceRenderer<ContractType>(contractTypes); final DropDownChoice<ContractType> typeChoice = new DropDownChoice<ContractType>( fs.getDropDownChoiceId(), new PropertyModel<ContractType>(data, "type"), typeChoiceRenderer.getValues(), typeChoiceRenderer); typeChoice.setNullValid(false); fs.add(typeChoice); } { // Status final FieldsetPanel fs = gridBuilder.newFieldset(getString("status")); // DropDownChoice for convenient selection of time periods. final LabelValueChoiceRenderer<String> statusChoiceRenderer = new LabelValueChoiceRenderer<String>(); for (final ContractStatus status : ContractStatus.values()) { statusChoiceRenderer.addValue(status.name(), getString(status.getI18nKey())); } final DropDownChoice<String> statusChoice = new DropDownChoice<String>( fs.getDropDownChoiceId(), new PropertyModel<String>(data, "status"), statusChoiceRenderer.getValues(), statusChoiceRenderer); statusChoice.setNullValid(false); fs.add(statusChoice); } gridBuilder.newSplitPanel(GridSize.COL50); { // Reference final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.common.reference")); fs.add( new MaxLengthTextField( InputPanel.WICKET_ID, new PropertyModel<String>(data, "reference"))); } { // Resubmission date final FieldsetPanel fs = gridBuilder.newFieldset(getString("resubmissionOnDate")); resubmissionDatePanel = new DatePanel( fs.newChildId(), new PropertyModel<Date>(data, "resubmissionOnDate"), DatePanelSettings.get().withTargetType(java.sql.Date.class)); fs.add(resubmissionDatePanel); } { // Due date final FieldsetPanel fs = gridBuilder.newFieldset(getString("dueDate")); dueDatePanel = new DatePanel( fs.newChildId(), new PropertyModel<Date>(data, "dueDate"), DatePanelSettings.get().withTargetType(java.sql.Date.class)); fs.add(dueDatePanel); } { // Signing date final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.signing"), getString("date")); signingDatePanel = new DatePanel( fs.newChildId(), new PropertyModel<Date>(data, "signingDate"), DatePanelSettings.get().withTargetType(java.sql.Date.class)); fs.add(signingDatePanel); } { // Validity final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.validity")); validFromDatePanel = new DatePanel( fs.newChildId(), new PropertyModel<Date>(data, "validFrom"), DatePanelSettings.get().withTargetType(java.sql.Date.class)); fs.add(validFromDatePanel); fs.add(new DivTextPanel(fs.newChildId(), "-")); validUntilDatePanel = new DatePanel( fs.newChildId(), new PropertyModel<Date>(data, "validUntil"), DatePanelSettings.get().withTargetType(java.sql.Date.class)); fs.add(validUntilDatePanel); } gridBuilder.newSplitPanel(GridSize.COL50); { // CocontractorA final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.coContractorA")); fs.add(createAutocompleteTextField("coContractorA")); } { // CopersonA final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.contractPersonA")); fs.add(createAutocompleteTextField("contractPersonA")); } { // SignerA final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.signerA")); fs.add(createAutocompleteTextField("signerA")); } /* GRID8 */ gridBuilder.newSplitPanel(GridSize.COL50); { // CocontractorB final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.coContractorB")); fs.add(createAutocompleteTextField("coContractorB")); } { // CopersonB final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.contractPersonB")); fs.add(createAutocompleteTextField("contractPersonB")); } { // SignerB final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.signerB")); fs.add(createAutocompleteTextField("signerB")); } /* GRID16 */ gridBuilder.newGridPanel(); { // Text with JIRA support final FieldsetPanel fs = gridBuilder.newFieldset(getString("text")); final IModel<String> model = new PropertyModel<String>(data, "text"); fs.add(new MaxLengthTextArea(TextAreaPanel.WICKET_ID, model)); fs.addJIRAField(model); } { // Filing final FieldsetPanel fs = gridBuilder.newFieldset(getString("filing")); fs.add( new MaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<String>(data, "filing"))); } addCloneButton(); }