List of usage examples for org.apache.wicket.util.time Duration milliseconds
public static Duration milliseconds(final long milliseconds)
Duration based on milliseconds. From source file:com.doculibre.constellio.wicket.components.form.LoggingTextArea.java
License:Open Source License
private void initComponents(long refreshDelayMillis) { add(new AjaxSelfUpdatingTimerBehavior(Duration.milliseconds(refreshDelayMillis))); add(new SimpleAttributeModifier("readonly", "readonly")); }
From source file:com.evolveum.midpoint.web.component.progress.ProgressReporter.java
License:Apache License
private void startRefreshingProgressPanel(AjaxRequestTarget target) { if (refreshingBehavior == null) { // i.e. refreshing behavior has not been set yet refreshingBehavior = new AjaxSelfUpdatingTimerBehavior(Duration.milliseconds(refreshInterval)) { @Override/*www.ja v a 2s . co m*/ protected void onPostProcessTarget(AjaxRequestTarget target) { super.onPostProcessTarget(target); if (asyncOperationResult != null) { // by checking this we know that async operation has been finished asyncOperationResult.recomputeStatus(); // because we set it to in-progress stopRefreshingProgressPanel(); // TODO this is a bit of heuristics - we give user a chance to retry the operation if the error is fatal (RETHINK/REVISE THIS "POLICY") if (asyncOperationResult.isFatalError()) { saveButton.setVisible(true); // enable re-saving after fixing (potential) error target.add(saveButton); } abortButton.setVisible(false); target.add(abortButton); parentPage.finishProcessing(target, asyncOperationResult); asyncOperationResult = null; } } @Override public boolean isEnabled(Component component) { return component != null; } }; progressPanel.add(refreshingBehavior); target.add(progressPanel); } }
From source file:com.evolveum.midpoint.web.component.refresh.RemovableAjaxTimerBehavior.java
License:Apache License
public RemovableAjaxTimerBehavior(@NotNull Component parent, long updateInterval) { super(Duration.milliseconds(updateInterval)); this.updateInterval = updateInterval; this.parent = parent; }
From source file:com.evolveum.midpoint.web.component.search.SearchPanel.java
License:Apache License
private void initLayout() { moreDialogModel = new LoadableModel<MoreDialogDto>(false) { @Override// w ww.java2 s . co m protected MoreDialogDto load() { MoreDialogDto dto = new MoreDialogDto(); dto.setProperties(createPropertiesList()); return dto; } }; Form form = new Form(ID_FORM); add(form); ListView items = new ListView<SearchItem>(ID_ITEMS, new PropertyModel<List<SearchItem>>(getModel(), Search.F_ITEMS)) { @Override protected void populateItem(ListItem<SearchItem> item) { SearchItemPanel searchItem = new SearchItemPanel(ID_ITEM, item.getModel()); item.add(searchItem); } }; items.add(createAdvancedVisibleBehaviour(false)); form.add(items); WebMarkupContainer moreGroup = new WebMarkupContainer(ID_MORE_GROUP); moreGroup.add(createAdvancedVisibleBehaviour(false)); form.add(moreGroup); AjaxLink more = new AjaxLink(ID_MORE) { @Override public void onClick(AjaxRequestTarget target) { Component button = SearchPanel.this.get(createComponentPath(ID_FORM, ID_MORE_GROUP, ID_MORE)); Component popover = SearchPanel.this.get(createComponentPath(ID_POPOVER)); togglePopover(target, button, popover, 14); } }; more.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { Search search = getModelObject(); return !search.getAvailableDefinitions().isEmpty(); } }); more.setOutputMarkupId(true); moreGroup.add(more); WebMarkupContainer searchContainer = new WebMarkupContainer(ID_SEARCH_CONTAINER); searchContainer.setOutputMarkupId(true); form.add(searchContainer); AjaxSubmitButton searchSimple = new AjaxSubmitButton(ID_SEARCH_SIMPLE) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(form); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { searchPerformed(target); } }; searchSimple.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { Search search = getModelObject(); if (!search.isShowAdvanced()) { return true; } PrismContext ctx = getPageBase().getPrismContext(); return search.isAdvancedQueryValid(ctx); } @Override public boolean isVisible() { return !getModelObject().isShowAdvanced() || !queryPlagroundAccessible; } }); searchSimple.setOutputMarkupId(true); searchContainer.add(searchSimple); WebMarkupContainer searchDropdown = new WebMarkupContainer(ID_SEARCH_DROPDOWN); searchDropdown.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return getModelObject().isShowAdvanced() && queryPlagroundAccessible; } }); searchContainer.add(searchDropdown); AjaxSubmitButton searchButtonBeforeDropdown = new AjaxSubmitButton(ID_SEARCH_BUTTON_BEFORE_DROPDOWN) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(form); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { searchPerformed(target); } }; searchButtonBeforeDropdown.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { Search search = getModelObject(); if (!search.isShowAdvanced()) { return true; } PrismContext ctx = getPageBase().getPrismContext(); return search.isAdvancedQueryValid(ctx); } }); searchDropdown.add(searchButtonBeforeDropdown); List<InlineMenuItem> searchItems = new ArrayList<>(); InlineMenuItem searchItem = new InlineMenuItem(createStringResource("SearchPanel.search"), new InlineMenuItemAction() { @Override public void onClick(AjaxRequestTarget target) { PrismContext ctx = getPageBase().getPrismContext(); if (getModelObject().isAdvancedQueryValid(ctx)) { searchPerformed(target); } } }); searchItems.add(searchItem); searchItem = new InlineMenuItem(createStringResource("SearchPanel.debug"), new InlineMenuItemAction() { @Override public void onClick(AjaxRequestTarget target) { debugPerformed(); } }); searchItems.add(searchItem); ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, Model.ofList(searchItems)) { @Override protected void populateItem(ListItem<InlineMenuItem> item) { WebMarkupContainer menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, item.getModel()); menuItemBody.setRenderBodyOnly(true); item.add(menuItemBody); } }; searchDropdown.add(li); AjaxButton advanced = new AjaxButton(ID_ADVANCED, createAdvancedModel()) { @Override public void onClick(AjaxRequestTarget target) { advancedPerformed(target); } }; advanced.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return advancedSearch; } }); form.add(advanced); initPopover(); WebMarkupContainer advancedGroup = new WebMarkupContainer(ID_ADVANCED_GROUP); advancedGroup.add(createAdvancedVisibleBehaviour(true)); advancedGroup.add(AttributeAppender.append("class", createAdvancedGroupStyle())); advancedGroup.setOutputMarkupId(true); form.add(advancedGroup); Label advancedCheck = new Label(ID_ADVANCED_CHECK); advancedCheck.add(AttributeAppender.append("class", createAdvancedGroupLabelStyle())); advancedGroup.add(advancedCheck); final TextArea advancedArea = new TextArea(ID_ADVANCED_AREA, new PropertyModel(getModel(), Search.F_ADVANCED_QUERY)); advancedArea.add(new AjaxFormComponentUpdatingBehavior("keyup") { @Override protected void onUpdate(AjaxRequestTarget target) { updateAdvancedArea(advancedArea, target); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setThrottlingSettings( new ThrottlingSettings(ID_ADVANCED_AREA, Duration.milliseconds(500), true)); } }); advancedGroup.add(advancedArea); Label advancedError = new Label(ID_ADVANCED_ERROR, new PropertyModel<String>(getModel(), Search.F_ADVANCED_ERROR)); advancedError.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { Search search = getModelObject(); if (!search.isShowAdvanced()) { return false; } return StringUtils.isNotEmpty(search.getAdvancedError()); } }); advancedGroup.add(advancedError); }
From source file:com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails.java
License:Apache License
@Override protected void onConfigure() { super.onConfigure(); if (saveOnConfigure) { saveOnConfigure = false;//from w w w . j av a 2s . co m add(new AbstractAjaxTimerBehavior(Duration.milliseconds(100)) { @Override protected void onTimer(AjaxRequestTarget target) { stop(target); savePerformed(target); } }); } }
From source file:com.mycompany.RunAwayTextPage.java
License:Apache License
private AjaxEventBehavior getRollEvent() { return new AjaxEventBehavior("onMouseOver") { @Override//from ww w .ja va2 s. c o m protected void onEvent(AjaxRequestTarget target) { Component comp = this.getComponent(); comp.remove(this); comp.add(new AbstractAjaxTimerBehavior(Duration.milliseconds(20)) { @Override protected void onTimer(AjaxRequestTarget target) { Component comp = this.getComponent(); comp.setDefaultModel(new Model<String>(view.get(part))); part++; if (view.size() <= part) { stop(); part = 0; comp.remove(this); comp.add(getRollEvent()); } target.add(comp); } }); target.add(comp); } }; }
From source file:com.senacor.wbs.web.chat.ChatPanel.java
License:Apache License
public ChatPanel(String id) { super(id);//from w w w . j ava 2 s.c o m setOutputMarkupId(true); add(new Form("chatForm") { { final Vector<String> nachrichten = new Vector<String>(); final TextArea textArea = new TextArea("nachrichten", new Model(nachrichten)) { @Override protected void onBeforeRender() { nachrichten.addAll(receiveMessages()); } }; textArea.add(new AjaxSelfUpdatingTimerBehavior(Duration.milliseconds(15000))); textArea.setEnabled(false); textArea.setOutputMarkupId(true); add(textArea); final TextField textField = new TextField("neueNachricht", new Model("deine Nachricht")); textField.setOutputMarkupId(true); add(textField); add(new AjaxButton("senden") { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { nachrichten.add(textField.getInput()); target.addComponent(textArea); textField.setModel(new Model("")); textField.clearInput(); target.addComponent(textField); } }); } }); }
From source file:com.servoy.j2db.server.headlessclient.RequestCycleSettings.java
License:Open Source License
/** * You should always use {@link #restoreTimeout()} with a try-finally after using this method. *///w w w . j av a 2 s . c om public void overrideTimeout(long duration) { alternateTimeout.set(Duration.milliseconds(duration)); }
From source file:de.webplatz.addons.HelpLink.java
License:Open Source License
/** * Add animation.// ww w .j av a 2 s . c o m * * @return HelpLink */ public final HelpLink withAnimation() { this.popconfig.withAnimation(true); this.popconfig.withDelay(Duration.milliseconds(POPOVER_DURATION)); return this; }
From source file:eu.esdihumboldt.hale.server.webapp.components.JobPanel.java
License:Open Source License
/** * Create a job panel./*from w ww. j av a 2s. com*/ * * @param id the component ID * @param jobFamily the job family, may be <code>null</code> if all jobs * should be shown * @param hideNoJobs if the message stating that there are no jobs running * should be hidden * * @see IJobManager#find(Object) */ public JobPanel(String id, final Serializable jobFamily, final boolean hideNoJobs) { super(id); setOutputMarkupId(true); // update panel add(timer = new StoppableAjaxSelfUpdatingTimer(Duration.milliseconds(1500))); // TODO add option to stop? // job list final IModel<? extends List<Job>> jobModel = new LoadableDetachableModel<List<Job>>() { private static final long serialVersionUID = 7277175702043541004L; @Override protected List<Job> load() { return Arrays.asList(Job.getJobManager().find(jobFamily)); } }; final ListView<Job> jobList = new ListView<Job>("jobs", jobModel) { private static final long serialVersionUID = -6740090246572869212L; /** * @see ListView#populateItem(ListItem) */ @Override protected void populateItem(final ListItem<Job> item) { // final boolean odd = item.getIndex() % 2 == 1; // if (odd) { // item.add(AttributeModifier.replace("class", "odd")); // } // name item.add(new Label("name", item.getModelObject().getName())); final IModel<eu.esdihumboldt.hale.server.progress.Progress> progressModel = new LoadableDetachableModel<eu.esdihumboldt.hale.server.progress.Progress>() { private static final long serialVersionUID = 2666038645533292585L; @Override protected eu.esdihumboldt.hale.server.progress.Progress load() { ProgressService ps = OsgiUtils.getService(ProgressService.class); if (ps == null) { return null; } return ps.getJobProgress(item.getModelObject()); } }; // progress Progress progress = new JobProgress("progress", progressModel); item.add(progress); // task name String task = progressModel.getObject().getSubTask(); if (task == null || task.isEmpty()) { task = progressModel.getObject().getTaskName(); } item.add(new Label("task", task)); } }; add(jobList); add(new WebMarkupContainer("nojobs") { private static final long serialVersionUID = -7752350858497246457L; @Override public boolean isVisible() { return !hideNoJobs && jobModel.getObject().isEmpty(); } }); }