Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Apr 4, 2016
2 parents bbb069d + 45d664e commit 4cb652e
Show file tree
Hide file tree
Showing 46 changed files with 1,503 additions and 177 deletions.
31 changes: 4 additions & 27 deletions gui/admin-gui/pom.xml
Expand Up @@ -108,13 +108,13 @@
<groupId>org.webjars</groupId>
<artifactId>respond</artifactId>
<version>1.4.2</version>
<scope>runtime</scope> <!-- TODO: review if we need this dependency -->
<scope>runtime</scope> <!-- needed for javascripts for IE8 -->
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>html5shiv</artifactId>
<version>3.7.2</version>
<scope>runtime</scope> <!-- TODO: review if we need this dependency -->
<scope>runtime</scope> <!-- needed for javascripts for IE8 -->
</dependency>
<dependency>
<groupId>org.webjars</groupId>
Expand All @@ -138,12 +138,12 @@
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<scope>runtime</scope> <!-- TODO: review if we need this dependency -->
<scope>runtime</scope> <!-- used for loading js/css from webjars -->
</dependency>
<dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-extensions</artifactId>
<scope>runtime</scope> <!-- TODO: review if we need this dependency -->
<scope>runtime</scope> <!-- used to compile less files -->
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -498,29 +498,6 @@
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-datetime</artifactId>
</dependency>

<!-- Wicketstuff -->
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicketstuff-jwicket-ui-dragdrop</artifactId>
<version>6.11.0</version>
<scope>runtime</scope> <!-- TODO: review if we need this dependency -->
</dependency>

<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicketstuff-jwicket-ui-effects</artifactId>
<version>6.11.0</version>
<scope>runtime</scope> <!-- TODO: review if we need this dependency -->
</dependency>

<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicketstuff-jwicket-ui-tooltip</artifactId>
<version>6.11.0</version>
<scope>runtime</scope> <!-- TODO: review if we need this dependency -->
</dependency>


<dependency>
<groupId>org.ocpsoft.prettytime</groupId>
Expand Down
Expand Up @@ -97,6 +97,8 @@
import java.text.SimpleDateFormat;
import java.util.*;

import static com.evolveum.midpoint.gui.api.page.PageBase.createStringResourceStatic;

/**
* Utility class containing miscellaneous methods used mostly in Wicket components.
*
Expand Down Expand Up @@ -238,6 +240,15 @@ public static List<String> createTaskCategoryList() {
return categories;
}

public static IModel<String> createCategoryNameModel(final Component component, final IModel<String> categorySymbolModel) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return createStringResourceStatic(component, "pageTasks.category." + categorySymbolModel.getObject()).getString();
}
};
}

public static ObjectReferenceType createObjectRef(String oid, String name, QName type) {
ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(oid);
Expand Down
Expand Up @@ -33,7 +33,7 @@
<span wicket:id="summaryOrganization" class="summary-panel-organization">
</span>
</span>
<span class="summary-tag-box">
<span wicket:id="summaryTagBox" class="summary-tag-box">
<span wicket:id="firstSummaryTag"/>
<wicket:child />
</span>
Expand Down
Expand Up @@ -2,13 +2,12 @@

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.web.component.util.SummaryTag;
import com.evolveum.midpoint.web.component.util.SummaryTagSimple;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.model.PrismPropertyRealValueFromPrismObjectModel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.Image;
Expand All @@ -26,6 +25,7 @@ public abstract class AbstractSummaryPanel<O extends ObjectType> extends BasePan

protected static final String ID_BOX = "summaryBox";
protected static final String ID_ICON_BOX = "summaryIconBox";
protected static final String ID_TAG_BOX = "summaryTagBox";
protected static final String ID_ICON = "summaryIcon";
protected static final String ID_DISPLAY_NAME = "summaryDisplayName";
protected static final String ID_IDENTIFIER = "summaryIdentifier";
Expand All @@ -42,6 +42,7 @@ public abstract class AbstractSummaryPanel<O extends ObjectType> extends BasePan
protected static final String ICON_BOX_CSS_CLASS = "info-box-icon";

protected WebMarkupContainer box;
protected WebMarkupContainer tagBox;
protected WebMarkupContainer iconBox;

public AbstractSummaryPanel(String id, IModel<PrismObject<O>> model) {
Expand Down Expand Up @@ -128,17 +129,27 @@ public boolean isVisible() {
}
});
iconBox.add(img);

tagBox = new WebMarkupContainer(ID_TAG_BOX);
if (getTagBoxCssClass() != null) {
tagBox.add(new AttributeModifier("class", getTagBoxCssClass()));
}
box.add(tagBox);
}

public void addTag(SummaryTag<O> tag) {
box.add(tag);
protected String getTagBoxCssClass() {
return null;
}

public void addTag(Component tag) {
tagBox.add(tag);
}

public void addTag(SummaryTagSimple<O> tag) {
box.add(tag);
public Component getTag(String id) {
return tagBox.get(id);
}

protected abstract String getIconCssClass();
protected abstract String getIconCssClass();

protected abstract String getIconBoxAdditionalCssClass();

Expand Down
@@ -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();
}
}
@@ -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>
@@ -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);
}
}
@@ -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();
}

0 comments on commit 4cb652e

Please sign in to comment.