本文整理汇总了Java中org.apache.wicket.util.time.Duration类的典型用法代码示例。如果您正苦于以下问题:Java Duration类的具体用法?Java Duration怎么用?Java Duration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Duration类属于org.apache.wicket.util.time包,在下文中一共展示了Duration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRequest
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
public void onRequest() {
final File file = initFile();
IResourceStream resourceStream = new FileResourceStream(new File(file));
getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(
new ResourceStreamRequestHandler(resourceStream) {
@Override
public void respond(IRequestCycle requestCycle) {
try {
super.respond(requestCycle);
} finally {
if (removeFile) {
LOGGER.debug("Removing file '{}'.", new Object[]{file.getAbsolutePath()});
Files.remove(file);
}
}
}
}.setFileName(file.getName()).setContentDisposition(ContentDisposition.ATTACHMENT)
.setCacheDuration(Duration.ONE_SECOND));
}
示例2: onRequest
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
public void onRequest() {
IResourceStream resourceStream = getResourceStream();
if (resourceStream == null) {
return; // We hope the error was already processed and will be shown.
}
ResourceStreamRequestHandler reqHandler = new ResourceStreamRequestHandler(resourceStream) {
@Override
public void respond(IRequestCycle requestCycle) {
super.respond(requestCycle);
}
}.setContentDisposition(ContentDisposition.ATTACHMENT)
.setCacheDuration(Duration.ONE_SECOND);
if (StringUtils.isNotEmpty(getFileName())){
reqHandler.setFileName(getFileName());
}
getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(reqHandler);
}
示例3: AsyncDashboardPanel
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
public AsyncDashboardPanel(String id, IModel<String> title, String icon, IModel<V> callableParameterModel,
Duration durationSecs, String boxCssClasses, boolean noPadding) {
super(id, callableParameterModel, durationSecs);
initLayout(noPadding);
WebMarkupContainer dashboardTitle = (WebMarkupContainer) get(
createComponentPath(ID_DASHBOARD_PARENT, ID_DASHBOARD_TITLE));
Label label = (Label) dashboardTitle.get(ID_TITLE);
label.setDefaultModel(title);
if (boxCssClasses == null) {
boxCssClasses = GuiStyleConstants.CLASS_BOX_DEFAULT;
}
Component dashboardParent = get(ID_DASHBOARD_PARENT);
dashboardParent.add(new AttributeAppender("class", " " + boxCssClasses));
WebMarkupContainer iconI = new WebMarkupContainer(ID_ICON);
iconI.add(AttributeModifier.replace("class", icon));
dashboardTitle.add(iconI);
}
示例4: initLayout
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
@Override
protected void initLayout() {
final WebMarkupContainer table = new WebMarkupContainer(ID_TABLE);
table.setOutputMarkupId(true);
add(table);
table.add(new AjaxSelfUpdatingTimerBehavior(Duration.milliseconds(10000)));
Label cpuUsage = new Label(ID_CPU_USAGE, new PropertyModel<>(getModel(), SystemInfoDto.F_CPU_USAGE));
table.add(cpuUsage);
Label heapMemory = new Label(ID_HEAP_MEMORY, createMemoryModel(true));
table.add(heapMemory);
Label nonHeapMemory = new Label(ID_NON_HEAP_MEMORY, createMemoryModel(false));
table.add(nonHeapMemory);
Label threads = new Label(ID_THREADS, createThreadModel());
table.add(threads);
DateLabelComponent startTime = new DateLabelComponent(ID_START_TIME, createStartTimeModel(), DateLabelComponent.MEDIUM_MEDIUM_STYLE);
table.add(startTime);
Label uptime = new Label(ID_UPTIME, createUptimeModel());
table.add(uptime);
}
示例5: ConfigForm
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
public ConfigForm(String id, WebMarkupContainer listContainer, Configuration configuration) {
super(id, new CompoundPropertyModel<>(configuration));
setOutputMarkupId(true);
this.listContainer = listContainer;
valueS = new TextField<>("valueS");
valueN = new TextField<Long>("valueN") {
private static final long serialVersionUID = 1L;
@Override
protected String[] getInputTypes() {
return new String[] {"number"};
}
};
valueB = new CheckBox("valueB");
add(new DateLabel("updated"));
add(new Label("user.login"));
add(new TextArea<String>("comment"));
update(null);
// attach an ajax validation behavior to all form component's keydown
// event and throttle it down to once per second
add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND));
}
示例6: LdapForm
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
public LdapForm(String id, WebMarkupContainer listContainer, final LdapConfig ldapConfig) {
super(id, new CompoundPropertyModel<>(ldapConfig));
setOutputMarkupId(true);
this.listContainer = listContainer;
add(new CheckBox("active"));
add(new DateLabel("inserted"));
add(new Label("insertedby.login"));
add(new DateLabel("updated"));
add(new Label("updatedby.login"));
add(new CheckBox("addDomainToUserName"));
add(new TextField<String>("domain"));
add(new TextArea<String>("comment"));
// attach an ajax validation behavior to all form component's keydown
// event and throttle it down to once per second
add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND));
}
示例7: parse
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
public static Duration parse(Long time, DurationUnit durationUnit){
switch(durationUnit){
case DAYS:
return Duration.days(time);
case HOURS:
return Duration.hours(time);
case MILLISECONDS:
return Duration.milliseconds(time);
case MINUTES:
return Duration.minutes(time);
case SECONDS:
return Duration.seconds(time);
}
throw new WicketSpringBootException("Could not parse time with duration unit " + time + " " + durationUnit);
}
示例8: AclsPage
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
/**
* Creates an acls page and opens the permission target for editing.
*
* @param ptiToEdit Permission target to edit
*/
public AclsPage(final MutablePermissionTargetInfo ptiToEdit) {
// only admins can reach here
if (!authService.isAdmin()) {
throw new UnauthorizedInstantiationException(AclsPage.class);
}
// create the panel
final PermissionTargetListPanel panel = new PermissionTargetListPanel("permissionTargetList");
add(panel);
if (ptiToEdit != null) {
// use very short ajax timer to open the edit panel
add(new AbstractAjaxTimerBehavior(Duration.milliseconds(1)) {
@Override
protected void onTimer(AjaxRequestTarget target) {
stop(); // don't fire again
ModalHandler modalHandler = ModalHandler.getInstanceFor(AclsPage.this);
modalHandler.setModalPanel(panel.newUpdateItemPanel(ptiToEdit));
modalHandler.show(target);
}
});
}
}
示例9: SystemLogsViewPanel
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
/**
* Main constructor
*
* @param id The verbal ID of the panel
*/
public SystemLogsViewPanel(String id) {
super(id);
addLogComboBox();
addSystemLogsSize();
addSystemLogsLink();
addSystemLogsContent();
addLastUpdate();
// add the timer behavior to the page and make it update both components
add(new AbstractAjaxTimerBehavior(Duration.seconds(ConstantValues.logsViewRefreshRateSecs.getInt())) {
@Override
protected void onTimer(AjaxRequestTarget target) {
updateComponents(target, (!systemLogFile.exists()));
}
});
}
示例10: scheduleMessageFetch
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
private void scheduleMessageFetch() {
add(new AbstractAjaxTimerBehavior(Duration.seconds(5)) {
@Override
protected IAjaxCallDecorator getAjaxCallDecorator() {
return new NoAjaxIndicatorDecorator();
}
@Override
protected void onTimer(AjaxRequestTarget target) {
stop();
final Message message = artifactoryUpdatesService.getCachedMessage();
if (message != null && message != ArtifactoryUpdatesService.PROCESSING_MESSAGE) {
setupMessage(message);
target.add(ArtifactoryUpdatesPanel.this);
}
}
});
}
示例11: OnlineStatusPanel
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
OnlineStatusPanel(String id, RemoteRepoDescriptor remoteRepo) {
super(id);
setOutputMarkupId(true);
this.remoteRepository = remoteRepo;
isOffline = remoteRepo.isOffline() || centralConfigService.getDescriptor().isOfflineMode();
onlineStatusLabel = new LabeledValue("status", "Online Status: ", "");
onlineStatusLabel.setValue(getStatusText(remoteRepo, isOffline));
behavior = new AbstractAjaxRestartableTimerBehavior(Duration.seconds(getSecondsForNextRefresh()),
"ajaxRefresh") {
@Override
protected void onTimer(AjaxRequestTarget target) {
onlineStatusLabel.setValue(getStatusText(remoteRepository, isOffline));
this.setUpdateInterval(Duration.seconds(getSecondsForNextRefresh()));
target.add(OnlineStatusPanel.this);
}
};
// WebMarkupContainer statusLabel=new WebMarkupContainer("statusLabel");
// add(statusLabel);
onlineStatusLabel.setOutputMarkupId(true);
addOnlineInfo();
}
示例12: renderHead
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.renderOnDomReadyJavaScript("var refreshLabel");
response.renderOnDomReadyJavaScript("clearTimeout(refreshLabel)");
if (behavior != null && remoteRepository != null && onlineStatusLabel != null) {
onlineStatusLabel.setValue(getStatusText(remoteRepository, isOffline));
if (repositoryService.isRemoteAssumedOffline(remoteRepository.getKey())) {
response.renderOnLoadJavaScript("refreshLabel=GetCount(" + repositoryService.getRemoteNextOnlineCheck(
remoteRepository.getKey()) + ", 'statusLabel')");
if (behavior.isStopped()) {
behavior.setUpdateInterval(Duration.seconds(getSecondsForNextRefresh()));
behavior.start();
}
} else {
behavior.stop();
response.renderOnDomReadyJavaScript("clearTimeout(ajaxRefresh)");
response.renderOnDomReadyJavaScript("clearTimeout(refreshLabel)");
}
}
}
示例13: onTimer
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
@Override
protected void onTimer(AjaxRequestTarget target) {
// Try to get BintrayService package info.
// If still in process (no result from Bintray), wait, else show the corresponded panel and stop waiting.
BintrayInfoPanelBehavior bintrayInfoPanelBehavior = getBintrayInfoPanelBehavior();
long updateInterval = getUpdateInterval().getMilliseconds();
// Max time to wait is 1+2+4+8=15 seconds
long maxTimeToWait = TimeUnit.SECONDS.toMillis(16);
if (isPackageInProcess()) {
if (updateInterval < maxTimeToWait) {
// Check less frequently.
setUpdateInterval(Duration.milliseconds(updateInterval * 2));
} else {
bintrayInfoPanelBehavior = BintrayInfoPanelBehavior.packageRetrievalError;
stop();
}
} else {
stop();
}
// Change the panels only if real change occurred
if (currentBintrayInfoPanelBehavior != bintrayInfoPanelBehavior) {
currentBintrayInfoPanelBehavior = bintrayInfoPanelBehavior;
showInfoPanel(bintrayInfoPanelBehavior);
target.add(BintrayDynamicInfoPanel.this);
}
}
示例14: Timestamp
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
public Timestamp(String id) {
super(id);
// TODO Auto-generated constructor stub
// Server time Label
Label time = new Label("time", new Model() {
private static final long serialVersionUID = -4992940551255653329L;
@Override
public Serializable getObject() {
DateFormat dateFormat = new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
java.util.Date date = new java.util.Date();
return dateFormat.format(date);
}
});
time.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1)));
add(time);
}
示例15: StaticDataPanel
import org.apache.wicket.util.time.Duration; //导入依赖的package包/类
public StaticDataPanel(String id, String symbol) {
super(id);
// TODO Auto-generated constructor stub
StaticDataDAO sdd = new StaticDataDAO();
StaticData sd = sdd.getLastStaticDataAsObject(symbol);
add(new Label("range", sd.getRange()));
add(new Label("yearrange", sd.getYearRange()));
add(new Label("open", sd.getOpen()));
add(new Label("volavg", sd.getVolavg()));
add(new Label("mktcap", sd.getMktcap()));
add(new Label("pne", sd.getPne()));
add(new Label("divyield", sd.getDivyield()));
add(new Label("eps", sd.getEps()));
add(new Label("shares", sd.getShares()));
add(new Label("beta", sd.getBeta()));
add(new AjaxSelfUpdatingTimerBehavior(Duration.minutes(30)));
}