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 github.com:Evolveum/midpoint
- Loading branch information
Showing
17 changed files
with
364 additions
and
82 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
88 changes: 88 additions & 0 deletions
88
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/DateLabelComponent.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,88 @@ | ||
/* | ||
* 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; | ||
|
||
import com.evolveum.midpoint.gui.api.util.WebComponentUtil; | ||
import org.apache.wicket.datetime.DateConverter; | ||
import org.apache.wicket.datetime.PatternDateConverter; | ||
import org.apache.wicket.datetime.markup.html.basic.DateLabel; | ||
import org.apache.wicket.model.IModel; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* Created by honchar | ||
* Component for displaying date value as a label | ||
* By default (if no converter is set) the date is formatted | ||
* according to the client's locale, timezone (not implemented yet), | ||
* with applying long style for date and long style for time. | ||
*/ | ||
public class DateLabelComponent extends DateLabel { | ||
|
||
public static final String SHORT_SHORT_STYLE = "SS"; //short style for date, short style for time | ||
public static final String MEDIUM_MEDIUM_STYLE = "MM"; //medium style for date, medium style for time | ||
public static final String LONG_LONG_STYLE = "LL"; //long style for date, long style for time | ||
public static final String FULL_FULL_STYLE = "FF"; //full style for date, full style for time | ||
public static final String SHORT_MEDIUM_STYLE = "SM"; //short style for date, medium style for time | ||
public static final String SHORT_LONG_STYLE = "SL"; //short style for date, long style for time | ||
public static final String SHORT_FULL_STYLE = "SF"; //short style for date, full style for time | ||
public static final String SHORT_NOTIME_STYLE = "S-"; //short style for date, no time | ||
public static final String MEDIUM_SHORT_STYLE = "MS"; //medium style for date, short style for time | ||
public static final String MEDIUM_LONG_STYLE = "ML"; //medium style for date, long style for time | ||
public static final String MEDIUM_FULL_STYLE = "MF"; //medium style for date, full style for time | ||
public static final String MEDIUM_NOTIME_STYLE = "M-"; //medium style for date, no time | ||
public static final String LONG_SHORT_STYLE = "LS"; //long style for date, short style for time | ||
public static final String LONG_MEDIUM_STYLE = "LM"; //long style for date, medium style for time | ||
public static final String LONG_FULL_STYLE = "LF"; //long style for date, full style for time | ||
public static final String LONG_NOTIME_STYLE = "L-"; //long style for date, no time | ||
public static final String FULL_SHORT_STYLE = "FS"; //full style for date, short style for time | ||
public static final String FULL_MEDIUM_STYLE = "FM"; //full style for date, medium style for time | ||
public static final String FULL_LONG_STYLE = "FL"; //full style for date, long style for time | ||
public static final String FULL_NOTIME_STYLE = "F-"; //full style for date, no time | ||
public static final String NODATE_SHORT_STYLE = "-S"; //no date, short style for time | ||
public static final String NODATE_MEDIUM_STYLE = "-M"; //no date, medium style for time | ||
public static final String NODATE_LONG_STYLE = "-L"; //no date, long style for time | ||
public static final String NODATE_FULL_STYLE = "-F"; //no date, full style for time | ||
|
||
public DateLabelComponent(String id, IModel<Date> model){ | ||
this(id, model, (DateConverter) null); | ||
} | ||
|
||
public DateLabelComponent(String id, IModel<Date> model, DateConverter converter){ | ||
this(id, model, converter, null, "", ""); | ||
} | ||
|
||
public DateLabelComponent(String id, IModel<Date> model, String style){ | ||
this(id, model, null, style, "", ""); | ||
} | ||
|
||
public DateLabelComponent(String id, IModel<Date> model, DateConverter converter, String style, | ||
String beforeDateText, String afterDateText){ | ||
super(id, model, converter == null ? | ||
new PatternDateConverter(WebComponentUtil.getLocalizedDatePattern(style == null ? LONG_LONG_STYLE : style), true ) : converter); | ||
|
||
setBefore(beforeDateText); | ||
setAfter(afterDateText); | ||
} | ||
|
||
public void setBeforeTextOnDateNull(String nullDateText){ | ||
if (getModel().getObject() == null){ | ||
setBefore(nullDateText); | ||
} | ||
} | ||
} | ||
|
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
19 changes: 19 additions & 0 deletions
19
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/util/SummaryTagSimple.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,19 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- | ||
~ Copyright (c) 2015 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. | ||
--> | ||
<wicket:panel xmlns:wicket="http://wicket.apache.org"> | ||
<span class="summary-tag"><span class="summary-tag-icon"><span wicket:id="summaryTagIcon"/></span> <span wicket:id="summaryTagLabel"/><wicket:child /></span> | ||
</wicket:panel> |
137 changes: 137 additions & 0 deletions
137
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/util/SummaryTagSimple.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,137 @@ | ||
/* | ||
* 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.util; | ||
|
||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; | ||
import org.apache.wicket.AttributeModifier; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.markup.html.panel.Panel; | ||
import org.apache.wicket.model.AbstractReadOnlyModel; | ||
import org.apache.wicket.model.IModel; | ||
|
||
/** | ||
* The same as SummaryTag, but based on PrismObject model, not ObjectWrapper one. | ||
* TODO fix somehow | ||
* | ||
* @author semancik | ||
* @author mederly | ||
*/ | ||
public abstract class SummaryTagSimple<O extends ObjectType> extends Panel { | ||
|
||
private static final String ID_TAG_ICON = "summaryTagIcon"; | ||
private static final String ID_TAG_LABEL = "summaryTagLabel"; | ||
|
||
private boolean initialized = false; | ||
private String iconCssClass; | ||
private String label; | ||
private String color = null; | ||
private boolean hideTag = false; | ||
|
||
public SummaryTagSimple(String id, final IModel<PrismObject<O>> model) { | ||
super(id, model); | ||
|
||
Label tagIcon = new Label(ID_TAG_ICON, ""); | ||
tagIcon.add(new AttributeModifier("class", new SummaryTagModel<String>(model) { | ||
@Override | ||
protected String getValue() { | ||
return getIconCssClass(); | ||
} | ||
})); | ||
add(tagIcon); | ||
|
||
add(new Label(ID_TAG_LABEL, new SummaryTagModel<String>(model) { | ||
@Override | ||
protected String getValue() { | ||
return getLabel(); | ||
} | ||
})); | ||
|
||
add(new AttributeModifier("style", new SummaryTagModel<String>(model) { | ||
@Override | ||
protected String getValue() { | ||
if (getColor() == null) { | ||
return null; | ||
} | ||
return "color: " + getColor(); | ||
} | ||
})); | ||
|
||
add(new VisibleEnableBehaviour(){ | ||
@Override | ||
public boolean isVisible(){ | ||
if (!initialized) { | ||
initialize(model.getObject()); | ||
} | ||
return !isHideTag(); | ||
} | ||
}); | ||
} | ||
|
||
public String getIconCssClass() { | ||
return iconCssClass; | ||
} | ||
|
||
public void setIconCssClass(String iconCssClass) { | ||
this.iconCssClass = iconCssClass; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public String getColor() { | ||
return color; | ||
} | ||
|
||
public void setColor(String color) { | ||
this.color = color; | ||
} | ||
|
||
public boolean isHideTag() { | ||
return hideTag; | ||
} | ||
|
||
public void setHideTag(boolean hideTag) { | ||
this.hideTag = hideTag; | ||
} | ||
|
||
protected abstract void initialize(PrismObject<O> object); | ||
|
||
abstract class SummaryTagModel<T> extends AbstractReadOnlyModel<T> { | ||
|
||
IModel<PrismObject<O>> objectModel; | ||
|
||
public SummaryTagModel(IModel<PrismObject<O>> objectModel) { | ||
this.objectModel = objectModel; | ||
} | ||
|
||
@Override | ||
public T getObject() { | ||
if (!initialized) { | ||
initialize(objectModel.getObject()); | ||
} | ||
return getValue(); | ||
} | ||
|
||
protected abstract T getValue(); | ||
|
||
} | ||
} |
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
Oops, something went wrong.