Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Evolveum/midpoint
- Loading branch information
Showing
46 changed files
with
1,503 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/refresh/AutoRefreshDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2010-2016 Evolveum | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.evolveum.midpoint.web.component.refresh; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* @author mederly | ||
*/ | ||
public class AutoRefreshDto implements Serializable { | ||
|
||
private long lastRefreshed = System.currentTimeMillis(); | ||
private int interval; // in milliseconds | ||
private boolean enabled = true; | ||
|
||
public AutoRefreshDto() { | ||
} | ||
|
||
public AutoRefreshDto(int refreshInterval) { | ||
this.interval = refreshInterval; | ||
} | ||
|
||
public int getInterval() { | ||
return interval; | ||
} | ||
|
||
public void setInterval(int interval) { | ||
this.interval = interval; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
public long getLastRefreshed() { | ||
return lastRefreshed; | ||
} | ||
|
||
public void setLastRefreshed(long lastRefreshed) { | ||
this.lastRefreshed = lastRefreshed; | ||
} | ||
|
||
public boolean shouldRefresh() { | ||
return isEnabled() && System.currentTimeMillis() - lastRefreshed > interval; | ||
} | ||
|
||
public int getRefreshingIn() { | ||
long delta = interval - (System.currentTimeMillis() - lastRefreshed); | ||
if (delta > 0) { | ||
return (int) (delta / 1000); | ||
} else { | ||
return 0; | ||
} | ||
} | ||
|
||
public void recordRefreshed() { | ||
lastRefreshed = System.currentTimeMillis(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...admin-gui/src/main/java/com/evolveum/midpoint/web/component/refresh/AutoRefreshPanel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!-- | ||
~ Copyright (c) 2010-2016 Evolveum | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
<!DOCTYPE html> | ||
<html xmlns:wicket="http://wicket.apache.org"> | ||
<body> | ||
<wicket:panel> | ||
<div wicket:id="start"/><div wicket:id="pause"/><div wicket:id="refreshNow"/><div wicket:id="status"/> | ||
</wicket:panel> | ||
</body> | ||
</html> |
103 changes: 103 additions & 0 deletions
103
...admin-gui/src/main/java/com/evolveum/midpoint/web/component/refresh/AutoRefreshPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright (c) 2010-2016 Evolveum | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.evolveum.midpoint.web.component.refresh; | ||
|
||
import com.evolveum.midpoint.gui.api.component.BasePanel; | ||
import com.evolveum.midpoint.web.component.data.column.LinkIconPanel; | ||
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; | ||
import com.evolveum.midpoint.web.page.admin.server.PageTaskEdit; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.model.AbstractReadOnlyModel; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.model.Model; | ||
|
||
/** | ||
* @author mederly | ||
*/ | ||
public class AutoRefreshPanel extends BasePanel<AutoRefreshDto> { | ||
|
||
private static final String ID_REFRESH_NOW = "refreshNow"; | ||
private static final String ID_START = "start"; | ||
private static final String ID_PAUSE = "pause"; | ||
private static final String ID_STATUS = "status"; | ||
|
||
public AutoRefreshPanel(String id, IModel<AutoRefreshDto> model, Refreshable refreshable) { | ||
super(id, model); | ||
initLayout(refreshable); | ||
} | ||
|
||
private void initLayout(final Refreshable refreshable) { | ||
|
||
final LinkIconPanel refreshNow = new LinkIconPanel(ID_REFRESH_NOW, new Model("fa fa-refresh"), createStringResource("autoRefreshPanel.refreshNow")) { | ||
@Override | ||
protected void onClickPerformed(AjaxRequestTarget target) { | ||
refreshable.refresh(target); | ||
} | ||
}; | ||
refreshNow.setRenderBodyOnly(true); | ||
add(refreshNow); | ||
|
||
final LinkIconPanel resumeRefreshing = new LinkIconPanel(ID_START, new Model("fa fa-play"), createStringResource("autoRefreshPanel.resumeRefreshing")) { | ||
@Override | ||
protected void onClickPerformed(AjaxRequestTarget target) { | ||
getModelObject().setEnabled(true); | ||
refreshable.refresh(target); | ||
refreshable.startRefreshing(); | ||
} | ||
}; | ||
resumeRefreshing.setRenderBodyOnly(true); | ||
resumeRefreshing.add(new VisibleEnableBehaviour() { | ||
@Override | ||
public boolean isVisible() { | ||
return !getModelObject().isEnabled(); | ||
} | ||
}); | ||
add(resumeRefreshing); | ||
|
||
final LinkIconPanel pauseRefreshing = new LinkIconPanel(ID_PAUSE, new Model("fa fa-pause"), createStringResource("autoRefreshPanel.pauseRefreshing")) { | ||
@Override | ||
protected void onClickPerformed(AjaxRequestTarget target) { | ||
getModelObject().setEnabled(false); | ||
refreshable.refresh(target); | ||
refreshable.stopRefreshing(); | ||
} | ||
}; | ||
pauseRefreshing.setRenderBodyOnly(true); | ||
pauseRefreshing.add(new VisibleEnableBehaviour() { | ||
@Override | ||
public boolean isVisible() { | ||
return getModelObject().isEnabled(); | ||
} | ||
}); | ||
add(pauseRefreshing); | ||
|
||
final Label status = new Label(ID_STATUS, new AbstractReadOnlyModel<String>() { | ||
@Override | ||
public String getObject() { | ||
AutoRefreshDto dto = getModelObject(); | ||
if (dto.isEnabled()) { | ||
return createStringResource("autoRefreshPanel.refreshingEach", dto.getInterval() / 1000).getString(); | ||
} else { | ||
return createStringResource("autoRefreshPanel.noRefreshing").getString(); | ||
} | ||
} | ||
}); | ||
status.setRenderBodyOnly(true); | ||
add(status); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/refresh/Refreshable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2010-2016 Evolveum | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.evolveum.midpoint.web.component.refresh; | ||
|
||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
|
||
/** | ||
* @author mederly | ||
*/ | ||
public interface Refreshable { | ||
void refresh(AjaxRequestTarget target); | ||
|
||
void startRefreshing(); | ||
|
||
void stopRefreshing(); | ||
} |
Oops, something went wrong.