List of usage examples for org.apache.wicket.util.time Duration NONE
Duration NONE
To view the source code for org.apache.wicket.util.time Duration NONE.
Click Source Link
From source file:au.org.theark.core.web.component.chart.JFreeChartImage.java
License:Open Source License
@Override protected IResource getImageResource() { DynamicImageResource resource = new DynamicImageResource() { private static final long serialVersionUID = 1L; @Override//from w w w . j ava2s .c o m protected byte[] getImageData(final Attributes attributes) { JFreeChart chart = (JFreeChart) getDefaultModelObject(); return toImageData(chart.createBufferedImage(width, height)); } @Override protected void configureResponse(final ResourceResponse response, final Attributes attributes) { super.configureResponse(response, attributes); response.setCacheDuration(Duration.NONE); response.setCacheScope(CacheScope.PRIVATE); } }; return resource; }
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
private void addComponents() { // Select the first message for initial display if (getConfig().messages.isEmpty()) { // No messages configured. Create a new message with id=1. getConfig().addMessageConfig(new MessageConfig(1)); }/*from w ww . ja va 2s . co m*/ currentMessage = getConfig().getMessageList().get(0); currentMessage.calcOffsets(getConfig().getMessageIdType().getByteSize()); currentMessageId = currentMessage.getMessageId(); // ******************************************************************************************* // *** Form for XML import final FileUploadField uploadField = new FileUploadField("upload-field", new ListModel<FileUpload>()); Form<?> uploadForm = new Form<Object>("upload-form") { @Override protected void onSubmit() { try { FileUpload upload = uploadField.getFileUpload(); if (upload != null) { handleOnUpload(upload.getInputStream()); } else { warn(new StringResourceModel("warn.noFileToUpload", this, null).getString()); } } catch (Exception e) { this.error(new StringResourceModel("import.error", this, null).getString() + " Exception: " + e.toString()); } } }; uploadForm.add(uploadField); SubmitLink importLink = new SubmitLink("import-link"); uploadForm.add(importLink); add(uploadForm); // ******************************************************************************************* // *** The message configuration currentMessageModel = new PropertyModel<MessageConfig>(this, "currentMessage"); editForm = new Form<MessageConfig>("edit-form", new CompoundPropertyModel<MessageConfig>(currentMessageModel)) { @Override protected void onError() { // Validation error - reset the message dropdown to the original value // Clear input causes the component to reload the model currentMessageIdDropdown.clearInput(); super.onError(); } }; editForm.add(new MessageFormValidator()); WebMarkupContainer tableContainer = new WebMarkupContainer("table-container"); messageIdTypeDropDown = getMessageIdTypeDropdown(); tableContainer.add(messageIdTypeDropDown); currentMessageIdDropdown = getCurrentMessageIdDropdown(); tableContainer.add(currentMessageIdDropdown); Button buttonNew = new Button("new"); buttonNew.add(new AjaxFormSubmitBehavior("onclick") { @Override protected void onSubmit(AjaxRequestTarget target) { handleNew(target); } @Override protected void onError(AjaxRequestTarget target) { handleError(target); } }); tableContainer.add(buttonNew); Button buttonCopy = new Button("copy"); buttonCopy.add(new AjaxFormSubmitBehavior("onclick") { @Override protected void onSubmit(AjaxRequestTarget target) { handleCopy(target); } @Override protected void onError(AjaxRequestTarget target) { handleError(target); } }); tableContainer.add(buttonCopy); Button deleteButton = new Button("delete"); deleteButton.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget target) { handleDelete(target); } }); tableContainer.add(deleteButton); messageTypeDropdown = getMessageTypeDropdown(); tableContainer.add(messageTypeDropdown); tableContainer.add(getQueueModeDropdown()); tableContainer.add(new CheckBox("usePersistance").setOutputMarkupId(true)); WebMarkupContainer listEditorContainer = new WebMarkupContainer("list-editor"); messageIdTextField = getMessageIdTextField(); listEditorContainer.add(messageIdTextField); messageAliasTextField = getMessageAliasTextField(); listEditorContainer.add(messageAliasTextField); // Create the list editor editor = new ListEditor<TagConfig>("tags", new PropertyModel<List<TagConfig>>(currentMessageModel, "tags")) { @Override protected void onPopulateItem(EditorListItem<TagConfig> item) { item.setModel(new CompoundPropertyModel<TagConfig>(item.getModelObject())); BinaryDataType dataType = item.getModelObject().getDataType(); boolean enable = dataType.isSpecial() ? false : true; // Offset is displayed only for information item.add(new Label("offset").setOutputMarkupId(true)); if (enable) { item.add(getIdTextField()); } else { // The static TextField has no validation. Validation would fail for special tags. item.add(getSpecialIdTextField().setEnabled(false)); } item.add(getAliasTextField().setVisible(enable)); item.add(getSizeTextField().setEnabled(dataType.isArrayAllowed())); item.add(getTagLengthTypeDropDown().setEnabled(dataType.supportsVariableLength())); item.add(getDataTypeDropdown()); // Create the edit links to be used in the list editor item.add(getInsertLink()); item.add(getDeleteLink()); item.add(getMoveUpLink().setVisible(item.getIndex() > 0)); item.add(getMoveDownLink().setVisible(item.getIndex() < getList().size() - 1)); } }; listEditorContainer.add(editor); Label noItemsLabel = new Label("no-items-label", new StringResourceModel("noitems", this, null)) { @Override public boolean isVisible() { return editor.getList().size() == 0; } }; listEditorContainer.add(noItemsLabel); listEditorContainer.add(new EditorSubmitLink("add-row-link") { @Override public void onSubmit() { editor.addItem(new TagConfig()); // Adjust the visibility of the edit links updateListEditor(editor); } }); listEditorContainer.setOutputMarkupId(true); tableContainer.add(listEditorContainer); editForm.add(tableContainer); // XML export SubmitLink exportLink = new SubmitLink("export-link", editForm) { @Override public void onSubmit() { ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(getResourceStream(), getFileName()); handler.setContentDisposition(ContentDisposition.ATTACHMENT); handler.setCacheDuration(Duration.NONE); getRequestCycle().scheduleRequestHandlerAfterCurrent(handler); } private String getFileName() { return String.format("MsgConfig_%s.xml", currentMessageModel.getObject().getMessageId()); } private IResourceStream getResourceStream() { String config = currentMessageModel.getObject().toXMLString(); return new StringResourceStream(config, "text/xml"); } }; editForm.add(exportLink); uploadForm.add(editForm); }
From source file:com.gmail.volodymyrdotsenko.jqxwicket.core.ajax.JQueryAjaxBehavior.java
License:Apache License
/** * Constructor//from ww w . ja va 2s. c o m * * @param source * {@link Behavior} to which the event - returned by * {@link #newEvent()} - will be broadcasted. */ public JQueryAjaxBehavior(IJQueryAjaxAware source) { this(source, Duration.NONE); }
From source file:com.gmail.volodymyrdotsenko.jqxwicket.core.ajax.JQueryAjaxBehavior.java
License:Apache License
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); if (this.duration != Duration.NONE) { attributes.setThrottlingSettings(new ThrottlingSettings("jquery-throttle", this.duration)); }//from w w w. ja v a 2 s. c o m }
From source file:com.googlecode.wicket.jquery.ui.ajax.JQueryAjaxBehavior.java
License:Apache License
/** * Constructor// www . j a v a 2s . c om * @param source {@link Component} to which the event - returned by {@link #newEvent(AjaxRequestTarget)} - will be broadcasted. */ public JQueryAjaxBehavior(Component source) { this(source, Duration.NONE); }
From source file:com.googlecode.wicket.jquery.ui.ajax.JQueryAjaxBehavior.java
License:Apache License
@Override protected IAjaxCallDecorator getAjaxCallDecorator() { if (this.duration != Duration.NONE) { return new AjaxCallThrottlingDecorator("throttle", this.duration); }//from w w w .ja v a 2s . c o m return super.getAjaxCallDecorator(); }
From source file:com.romeikat.datamessie.core.base.util.FileDownloadLink.java
License:Open Source License
public FileDownloadLink(final String id, final IModel<File> fileModel) { super(id, fileModel); setCacheDuration(Duration.NONE); setDeleteAfterDownload(true);/*from ww w.j a v a2s. c om*/ }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.licenses.components.LicenseEditForm.java
License:Apache License
@SuppressWarnings("serial") private void addBlueprintSelect() { IModel<License> selectedBlueprintModel = new Model<License>(); licenseChoice = new AjaxDropDownChoice<License>("blueprintSelect", selectedBlueprintModel, blueprintsModel, new ChoiceRenderer<License>("title")) { @Override/*from ww w.j a va 2 s .c om*/ protected void onSelectionChangeAjaxified(AjaxRequestTarget target, final License option) { if (option == null || option.getLicenseId() == 0) { form.getModelObject().setLicense(null); form.getModelObject().setPrice(BigDecimal.ZERO); saveButton.setVisibilityAllowed(false); priceInput.setEnabled(false); licenseDetails.setVisible(false); } else { priceInput.setEnabled(option.getLicenseType() == LicenseType.COMMERCIAL); licenseDetails.setVisible(true); licenseLink.setVisible(option.getLink() != null); if (option.getAttachmentFileName() != null) { ByteArrayResource res; res = new ByteArrayResource("", licenseFacade.getLicenseAttachmentContent(option.getLicenseId()), option.getAttachmentFileName()) { @Override public void configureResponse(final AbstractResource.ResourceResponse response, final IResource.Attributes attributes) { response.setCacheDuration(Duration.NONE); response.setFileName(option.getAttachmentFileName()); } }; ResourceLink<Void> newLink = new ResourceLink<Void>("fileDownload", res); newLink.add(new Label("fileName", option.getAttachmentFileName())); downloadLink.replaceWith(newLink); downloadLink = newLink; downloadLink.setVisible(true); } else { downloadLink.setVisible(false); } form.getModelObject().setLicense(option); saveButton.setVisibilityAllowed(true); } target.add(form); } }; licenseChoice.setNullValid(true); form.add(licenseChoice); }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.licenses.components.LicensePriceForm.java
License:Apache License
@SuppressWarnings("serial") private void addDropDownChoice(final IModel<List<License>> licenseChoices) { dropDownChoice = new AjaxDropDownChoice<License>("licenseSelect", new Model<License>(), licenseChoices, new ChoiceRenderer<License>("title")) { @Override//from w ww. ja v a 2 s.c o m protected void onSelectionChangeAjaxified(AjaxRequestTarget target, final License option) { if (option == null || option.getLicenseId() == 0) { //LicensePriceForm.this.form.setModelObject(null); //LicensePriceForm.this.form.clearInput(); clearForm(); } else { priceInput.setEnabled(option.getLicenseType() == LicenseType.COMMERCIAL); licenseDetails.setVisible(true); licenseLink.setVisible(option.getLink() != null); if (option.getAttachmentFileName() != null) { ByteArrayResource res; res = new ByteArrayResource("", licenseFacade.getLicenseAttachmentContent(option.getLicenseId()), option.getAttachmentFileName()) { @Override public void configureResponse(final AbstractResource.ResourceResponse response, final IResource.Attributes attributes) { response.setCacheDuration(Duration.NONE); response.setFileName(option.getAttachmentFileName()); } }; ResourceLink<Void> newLink = new ResourceLink<Void>("fileDownload", res); newLink.add(new Label("fileName", option.getAttachmentFileName())); downloadLink.replaceWith(newLink); downloadLink = newLink; downloadLink.setVisible(true); } else { downloadLink.setVisible(false); } LicensePriceForm.this.form.setModelObject(option); saveButton.setVisibilityAllowed(true); } target.add(LicensePriceForm.this); } }; dropDownChoice.setNullValid(true); form.add(dropDownChoice); }
From source file:de.alpharogroup.wicket.base.application.BaseWebApplication.java
License:Apache License
/** * Gets the elapsed duration since this application was initialized. * * @return the uptime/* w w w . j a va 2 s . c om*/ */ public Duration getUptime() { final DateTime startup = getStartupDate(); if (null != startup) { return Duration.elapsed(Time.valueOf(startup.toDate())); } return Duration.NONE; }