List of usage examples for org.apache.wicket.util.time Duration seconds
public static Duration seconds(final int seconds)
Duration
based on seconds. From source file:abid.password.wicket.pages.LoginPage.java
License:Apache License
public LoginPage() { LoginPanel loginPanel = new LoginPanel("loginPanel"); add(loginPanel);//w w w .j a v a 2 s .c o m LoadableDetachableModel<List<User>> usersModel = new LoadableDetachableModel<List<User>>() { private static final long serialVersionUID = 1L; @Override protected List<User> load() { return userService.getUsers(); } }; PageableListView<User> dataList = new PageableListView<User>("usersList", usersModel, 100) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<User> item) { final User data = item.getModelObject(); Label userLabel = new Label("userLabel", data.getUsername()); Label passLabel = new Label("passLabel", data.getPassword()); try { Password password = new MutablePasswordParser().parse(data.getPassword()); if (password instanceof MutablePassword) { MutablePassword mutablePassword = (MutablePassword) password; String evalatedPassword = mutablePassword.getEvaluatedPassword(); passLabel = new Label("passLabel", evalatedPassword); } } catch (Exception e) { log.error("Could not create the mutable password", e); } item.add(userLabel); item.add(passLabel); } }; int refreshTime = 3; final WebMarkupContainer usersContainer = new WebMarkupContainer("usersContainer"); usersContainer.setOutputMarkupId(true); usersContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(refreshTime))); usersContainer.add(dataList); String refreshInformation = String.format("Password refreshes every %s seconds.", refreshTime); String javascriptDisabledMsg = "Javascript is disabled you will need to refresh the page manually."; AjaxFallbackLabel refreshLabel = new AjaxFallbackLabel("refreshInformation", refreshInformation, javascriptDisabledMsg); add(usersContainer); add(refreshLabel); }
From source file:abid.password.wicket.pages.UsersPage.java
License:Apache License
public UsersPage() { LoadableDetachableModel<List<User>> usersModel = new LoadableDetachableModel<List<User>>() { private static final long serialVersionUID = 1L; @Override/*w ww. j ava 2 s .c o m*/ protected List<User> load() { return userService.getUsers(); } }; PageableListView<User> dataList = new PageableListView<User>("usersList", usersModel, 100) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<User> item) { final User data = item.getModelObject(); Label userLabel = new Label("userLabel", data.getUsername()); Label passLabel = new Label("passLabel", data.getPassword()); try { Password password = new MutablePasswordParser().parse(data.getPassword()); if (password instanceof MutablePassword) { MutablePassword mutablePassword = (MutablePassword) password; String evalatedPassword = mutablePassword.getEvaluatedPassword(); passLabel = new Label("passLabel", evalatedPassword); } } catch (Exception e) { log.error("Could not create the mutable password", e); } item.add(userLabel); item.add(passLabel); } }; int refreshTime = 3; final WebMarkupContainer dataContainer = new WebMarkupContainer("dataContainer"); dataContainer.setOutputMarkupId(true); dataContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(refreshTime))); dataContainer.add(dataList); String refreshInformation = String.format("Password refreshes every %s seconds.", refreshTime); String javascriptDisabledMsg = "Javascript is disabled you will need to refresh the page manually."; AjaxFallbackLabel refreshInfoLabel = new AjaxFallbackLabel("refreshInformation", refreshInformation, javascriptDisabledMsg); add(dataContainer); add(refreshInfoLabel); }
From source file:at.ac.tuwien.ifs.tita.ui.tasklist.stopwatch.AssignedTaskTimerPanel.java
License:Apache License
/** * Displays the Panel with all wicket elements. *//*from w ww .j ava 2 s . c o m*/ private void displayPanel() { taskTimerForm = new Form<Object>("timerTaskForm"); add(taskTimerForm); taskTimerForm.add(new Label("taskId", task.getId().toString())); taskTimerForm.add(new Label("taskDescription", task.getDescription())); startstop = new AjaxButton("startStopTimer", new Model<String>(), taskTimerForm) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form1) { if (!started) { owner.startTimerForIssue(task); started = true; this.getModel().setObject("Stop"); } else { owner.stopTimerForIssue(task, target); started = false; this.getModel().setObject("Start"); } this.setLabel(this.getModel()); target.addComponent(this); } }; taskTimerForm.add(startstop); taskTimerForm.add(new AjaxButton("closeTask", taskTimerForm) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form1) { started = false; // beh.stop(); owner.stopTimerForIssue(task, target); owner.closeTask(task, target); } }); lab = new Label("totalEffort", TiTATimeConverter.getDuration2String(effort != null ? effort : 0L)); taskTimerForm.add(lab); beh = new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1)); lab.add(beh); }
From source file:at.ac.tuwien.ifs.tita.ui.tasklist.stopwatch.GeneralTimerPanel.java
License:Apache License
/** * Displays the Panel with all wicket elements. *//*from ww w . j av a2 s . c o m*/ private void displayPanel() { taskTimerForm = new Form<Object>("timerTaskForm"); add(taskTimerForm); taskTimerForm.add(new Label("taskLabel", "Description")); description = new TextField<String>("taskDescription", new Model<String>("")); description.setType(String.class); duration = new TextField<String>("taskDuration", new Model<String>("00:00:00")); duration.setType(String.class); duration.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1))); duration.setOutputMarkupId(true); description.setOutputMarkupId(true); taskTimerForm.add(duration); taskTimerForm.add(description); startstop = new AjaxButton("startStopTimer", new Model<String>(), taskTimerForm) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form1) { if (!started) { owner.startGeneralTimerForTask(); description.getModel().setObject(""); started = true; this.getModel().setObject("Stop"); } else { owner.stopGeneralTimerForTask(); started = false; this.getModel().setObject("Start"); } this.setLabel(this.getModel()); target.addComponent(this); } }; taskTimerForm.add(startstop); taskTimerForm.add(new AjaxButton("saveEffort", taskTimerForm) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form1) { if (effort != null && !started) { owner.saveEffortForTiTATask(effort, target); description.setModelObject(""); duration.setModelObject("00:00:00"); } target.addComponent(description); target.addComponent(duration); } }); }
From source file:au.org.theark.study.web.component.managestudy.form.DetailForm.java
License:Open Source License
/** * Constructor/* w w w. jav a 2 s. c o m*/ * * @param id * @param crudVO * @param feedbackPanel * @param containerForm */ public DetailForm(String id, StudyCrudContainerVO crudVO, FeedbackPanel feedbackPanel, Container containerForm) { super(id, feedbackPanel, crudVO, containerForm); this.studyCrudVO = crudVO; this.containerForm = containerForm; AjaxFormValidatingBehavior.addToAllFormComponents(this, "onKeyup", Duration.seconds(2)); }
From source file:com.axway.ats.testexplorer.pages.model.BaseCopyPage.java
License:Apache License
private void startCurrentCopyThread() { // start the timer consoleUpdateTimer = new AjaxSelfUpdatingTimerBehavior(Duration.seconds(CONSOLE_UPDATE_INTERVAL)); consoleContainer.add(consoleUpdateTimer); // adding console update timer to thread and when the coping is done the timer will be stopped copyThread.addConsoleUpdateTimer(consoleUpdateTimer); copyThread.start();/* ww w . j ava 2 s.c o m*/ synchronized (copyJobThreads) { copyJobThreads.add(copyThread); } }
From source file:com.axway.ats.testexplorer.pages.model.BaseCopyPage.java
License:Apache License
private boolean checkForThreadCopingTheSameRun(String threadIdentifier) { synchronized (copyJobThreads) { for (CopyJobThread th : copyJobThreads) { if (th.isAlive() && th.getThreadIdentifier().equals(threadIdentifier)) { webConsole = th.getWebConsole(); // start the timer and attach it to the coping thread AjaxSelfUpdatingTimerBehavior consoleUpdateTimer = new AjaxSelfUpdatingTimerBehavior( Duration.seconds(CONSOLE_UPDATE_INTERVAL)); th.addConsoleUpdateTimer(consoleUpdateTimer); consoleContainer.add(consoleUpdateTimer); return true; }/*from w ww . jav a 2 s . co m*/ } } return false; }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.Index.java
License:Apache License
public Index() { final Behavior updater = new MultiUpdatingTimerBehavior(Duration.seconds(1));//AjaxSelfUpdatingTimerBehavior final Model<Integer> serverListSize = getServerListSizeModel(); final Label servers_count = new Label("servers_count", serverListSize); servers_count.setOutputMarkupId(true); add(servers_count);// w w w.j a v a 2 s . c o m final Label servers_down = new Label("servers_down", getServersDownModel()); servers_down.add(updater); add(servers_down); final Label totalBandwidth = new Label("totalBandwidth", getCacheStateSumModel("kbps")); totalBandwidth.add(updater); add(totalBandwidth); final Label totalBandwidthAvailable = new Label("totalBandwidthAvailable", getCacheStateSumModel("maxKbps")); totalBandwidthAvailable.add(updater); add(totalBandwidthAvailable); add(new Label("version", new Model<String>(getVersionStr()))); final Label source = new Label("source", getSourceModel()); source.add(updater); add(source); final Component[] updateList = new Component[] { servers_count }; //graph, final Label servers_available = new Label("servers_available", getServersAvailableModel()); servers_available.add(updater); add(servers_available); add(new CacheListPanel("serverList", updater, updateList)); add(new EventLogPanel("eventLog")); add(new DsListPanel("dsList", updater, updateList)); add(getTabbedPanel(updater)); }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.CacheDetailsPage.java
License:Apache License
public CacheDetailsPage(final String hostnameStr) { final Behavior updater = new MultiUpdatingTimerBehavior(Duration.seconds(1)); final Label hostname = new Label("hostname", hostnameStr); hostname.add(updater);//from ww w . j av a 2 s. c o m add(hostname); List<KeyValue> jsonValues = null; try { final CacheState atsState = CacheState.getState(hostnameStr); jsonValues = atsState.getModelList(); } catch (Exception e) { LOGGER.warn(e, e); jsonValues = new ArrayList<KeyValue>(); jsonValues.add(new KeyValue("Error", e.toString())); } final ListView<KeyValue> servers = new ListView<KeyValue>("params", jsonValues) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<KeyValue> item) { final KeyValue keyval = (KeyValue) item.getModelObject(); item.add(new Label("key", keyval.getKey())); final Label v = new Label("value", keyval); v.add(updater); item.add(v); } }; add(servers); }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.CacheListPanel.java
License:Apache License
public CacheListPanel(final String id, final Behavior updater, final Component[] updateList) { super(id);/*from w ww . j a v a 2 s .co m*/ final ModalWindow modal1; add(modal1 = new ModalWindow("modal1")); modal1.setInitialWidth(1000); // modal1.setCookieName("modal-1"); modal1.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; public Page createPage() { return new CacheDetailsPage(hostname); } }); this.updateList = updateList; final WebMarkupContainer container = new WebMarkupContainer("listpanel"); container.setOutputMarkupId(true); add(container); servers = createServerListView(updater, modal1); servers.setOutputMarkupId(true); container.setOutputMarkupId(true); container.add(servers); add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) { private static final long serialVersionUID = 1L; int serverCount = 0; @Override protected final void onTimer(final AjaxRequestTarget target) { // target.add(getComponent()); final int size = CacheState.getCacheStates().size(); if (serverCount != size) { serverCount = size; servers.setList(getServerList()); target.add(container); if (updateList != null) { for (Component c : updateList) { target.add(c); } } // target.add(graph); } } }); }