Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MID-2862 Lock-out status should not be set to Locked
- Loading branch information
1 parent
6149ac9
commit 1d0eff1
Showing
6 changed files
with
157 additions
and
7 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
28 changes: 28 additions & 0 deletions
28
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/LockoutStatusPanel.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,28 @@ | ||
<!-- | ||
~ 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"> | ||
<wicket:panel> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div wicket:id="container"> | ||
<div class="col-md-11" wicket:id="label"></div> | ||
<div class="col-md-1 btn btn-primary btn-xs" wicket:id="button"></div> | ||
</div> | ||
</div> | ||
</div> | ||
</wicket:panel> | ||
</html> |
117 changes: 117 additions & 0 deletions
117
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/LockoutStatusPanel.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,117 @@ | ||
package com.evolveum.midpoint.web.component; | ||
|
||
import com.evolveum.midpoint.gui.api.page.PageBase; | ||
import com.evolveum.midpoint.gui.api.util.WebComponentUtil; | ||
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType; | ||
import org.apache.wicket.Component; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.markup.html.WebMarkupContainer; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.markup.html.panel.Panel; | ||
import org.apache.wicket.model.IModel; | ||
|
||
/** | ||
* Created by Kate on 12.04.2016. | ||
*/ | ||
public class LockoutStatusPanel extends Panel { | ||
private static final String ID_CONTAINER = "container"; | ||
private static final String ID_LABEL = "label"; | ||
private static final String ID_BUTTON = "button"; | ||
private static final String BUTTON_UNDO_LABEL = "Undo"; | ||
private static final String BUTTON_UNLOCK_LABEL = "Unlock"; | ||
private boolean isInitialState = true; | ||
private boolean isUndo = false; | ||
|
||
public LockoutStatusPanel(String id){ | ||
this(id, null); | ||
} | ||
|
||
public LockoutStatusPanel(String id, IModel<LockoutStatusType> model){ | ||
super(id); | ||
LockoutStatusType l = model.getObject(); | ||
isUndo = l != null && model.getObject().value() != null && | ||
model.getObject().equals(LockoutStatusType.LOCKED); | ||
initLayout(model); | ||
} | ||
|
||
private void initLayout(final IModel<LockoutStatusType> model){ | ||
WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER); | ||
add(container); | ||
|
||
Label label = new Label(ID_LABEL, new IModel<String>() { | ||
@Override | ||
public String getObject() { | ||
LockoutStatusType object = model != null ? model.getObject() : null; | ||
|
||
return object == null ? | ||
((PageBase)getPage()).createStringResource("LockoutStatusType.UNDEFINED").getString() | ||
: WebComponentUtil.createLocalizedModelForEnum(object, getLabel()).getObject(); | ||
} | ||
|
||
@Override | ||
public void setObject(String s) { | ||
} | ||
|
||
@Override | ||
public void detach() { | ||
|
||
} | ||
}); | ||
label.setOutputMarkupId(true); | ||
container.add(label); | ||
|
||
AjaxButton button = new AjaxButton(ID_BUTTON, getButtonModel()) { | ||
@Override | ||
public void onClick(AjaxRequestTarget ajaxRequestTarget) { | ||
if (!isInitialState){ | ||
model.setObject(LockoutStatusType.LOCKED); | ||
} else { | ||
model.setObject(LockoutStatusType.NORMAL); | ||
} | ||
isInitialState = !isInitialState; | ||
ajaxRequestTarget.add(getButton()); | ||
ajaxRequestTarget.add(getLabel()); | ||
} | ||
}; | ||
button.add(new VisibleEnableBehaviour(){ | ||
@Override | ||
public boolean isVisible(){ | ||
return isUndo; | ||
} | ||
}); | ||
button.setOutputMarkupId(true); | ||
container.add(button); | ||
} | ||
|
||
private IModel<String> getButtonModel(){ | ||
return new IModel<String>() { | ||
@Override | ||
public String getObject() { | ||
if (isInitialState){ | ||
return BUTTON_UNLOCK_LABEL; | ||
} else { | ||
return BUTTON_UNDO_LABEL; | ||
} | ||
} | ||
|
||
@Override | ||
public void setObject(String s) { | ||
|
||
} | ||
|
||
@Override | ||
public void detach() { | ||
|
||
} | ||
}; | ||
} | ||
|
||
private Component getButton(){ | ||
return get(ID_CONTAINER).get(ID_BUTTON); | ||
} | ||
|
||
private Component getLabel(){ | ||
return get(ID_CONTAINER).get(ID_LABEL); | ||
} | ||
} |
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