Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Mar 30, 2016
2 parents 3ec8a86 + 83420d5 commit abacadc
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 9 deletions.
Expand Up @@ -120,8 +120,9 @@ public class AssignmentEditorPanel extends BasePanel<AssignmentEditorDto> {
private static final String ID_ERROR_ICON = "errorIcon";

private IModel<List<ACAttributeDto>> attributesModel;
private boolean isReadOnly;

public AssignmentEditorPanel(String id, IModel<AssignmentEditorDto> model) {
public AssignmentEditorPanel(String id, IModel<AssignmentEditorDto> model, boolean isReadOnly) {
super(id, model);

attributesModel = new LoadableModel<List<ACAttributeDto>>(false) {
Expand All @@ -130,6 +131,7 @@ protected List<ACAttributeDto> load() {
return loadAttributes();
}
};
this.isReadOnly = isReadOnly;

initLayout();
}
Expand Down Expand Up @@ -324,6 +326,7 @@ public void setObject(Date object) {
private void initBodyLayout(WebMarkupContainer body) {
TextArea description = new TextArea<>(ID_DESCRIPTION,
new PropertyModel<String>(getModel(), AssignmentEditorDto.F_DESCRIPTION));
description.setEnabled(!isReadOnly);
body.add(description);

WebMarkupContainer relationContainer = new WebMarkupContainer(ID_RELATION_CONTAINER);
Expand All @@ -349,6 +352,7 @@ public boolean isVisible() {
"AssignmentEditorPanel.member", "AssignmentEditorPanel.manager", null);
relation.setOutputMarkupId(true);
relation.setOutputMarkupPlaceholderTag(true);
relation.setPanelEnabled(!isReadOnly);
relation.add(new VisibleEnableBehaviour(){

@Override
Expand Down Expand Up @@ -401,14 +405,17 @@ public boolean isVisible() {
DropDownChoicePanel administrativeStatus = WebComponentUtil.createEnumPanel(ActivationStatusType.class, ID_ADMINISTRATIVE_STATUS,
new PropertyModel<ActivationStatusType>(getModel(), AssignmentEditorDto.F_ACTIVATION + "."
+ ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart()), this);
administrativeStatus.setEnabled(!isReadOnly);
activationBlock.add(administrativeStatus);

DateInput validFrom = new DateInput(ID_VALID_FROM, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(),
AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
validFrom.setEnabled(!isReadOnly);
activationBlock.add(validFrom);

DateInput validTo = new DateInput(ID_VALID_TO, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(),
AssignmentEditorDto.F_ACTIVATION + ".validTo")));
validTo.setEnabled(!isReadOnly);
activationBlock.add(validTo);
WebMarkupContainer targetContainer = new WebMarkupContainer(ID_TARGET_CONTAINER);
targetContainer.add(new VisibleEnableBehaviour() {
Expand Down Expand Up @@ -479,6 +486,7 @@ protected QName getSearchProperty() {
return OrgType.F_NAME;
}
};
tenantRef.setPanelEnabled(!isReadOnly);
tenantRefContainer.add(tenantRef);
tenantRefContainer.add(new VisibleEnableBehaviour(){

Expand Down Expand Up @@ -525,6 +533,7 @@ protected QName getSearchProperty() {
}
};
tenantRefContainer.add(tenantRef);
tenantRef.setEnabled(!isReadOnly);
tenantRefContainer.add(new VisibleEnableBehaviour(){

@Override
Expand Down Expand Up @@ -575,6 +584,7 @@ public boolean isVisible() {
return AssignmentEditorDtoType.ACCOUNT_CONSTRUCTION.equals(dto.getType());
}
});
attributes.setEnabled(isReadOnly);
constructionContainer.add(attributes);

ListView<ACAttributeDto> attribute = new ListView<ACAttributeDto>(ID_ATTRIBUTE, attributesModel){
Expand Down
Expand Up @@ -85,9 +85,14 @@ public class AssignmentTablePanel<T extends ObjectType> extends BasePanel<List<A

public AssignmentTablePanel(String id, IModel<String> label,
IModel<List<AssignmentEditorDto>> assignmentModel) {
this(id, label, assignmentModel, false);
}

public AssignmentTablePanel(String id, IModel<String> label,
IModel<List<AssignmentEditorDto>> assignmentModel, boolean isReadOnly) {
super(id, assignmentModel);

initLayout(label);
initLayout(label, isReadOnly);
}

public List<AssignmentType> getAssignmentTypeList() {
Expand All @@ -102,7 +107,7 @@ private IModel<List<AssignmentEditorDto>> getAssignmentModel() {
return getModel();
}

private void initLayout(IModel<String> labelText) {
private void initLayout(IModel<String> labelText, final boolean isReadOnly) {
final WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
assignments.setOutputMarkupId(true);
add(assignments);
Expand All @@ -117,7 +122,7 @@ private void initLayout(IModel<String> labelText) {

@Override
protected void populateItem(ListItem<AssignmentEditorDto> item) {
AssignmentEditorPanel editor = new AssignmentEditorPanel(ID_ROW, item.getModel());
AssignmentEditorPanel editor = new AssignmentEditorPanel(ID_ROW, item.getModel(), isReadOnly);
item.add(editor);
}
};
Expand Down
Expand Up @@ -131,4 +131,9 @@ private AttributeAppender prepareButtonCssClass(String cssClass){
* Override to provide custom action on change state event
* */
protected void onStateChanged(AjaxRequestTarget target, Boolean newValue){}

public void setPanelEnabled(boolean isEnabled){
get(ID_BUTTON_ONE).setEnabled(isEnabled);
get(ID_BUTTON_TWO).setEnabled(isEnabled);
}
}
Expand Up @@ -108,9 +108,8 @@ private void initLayout() {
WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
assignments.setOutputMarkupId(true);
add(assignments);

AssignmentTablePanel panel = new AssignmentTablePanel(ID_ASSIGNMENTS_PANEL,
createStringResource("FocusType.assignment"), assignmentsModel) {
createStringResource("FocusType.assignment"), assignmentsModel, ((ObjectWrapper)getObjectWrapperModel().getObject()).isReadonly()) {

@Override
protected void showAllAssignments(AjaxRequestTarget target) {
Expand Down
Expand Up @@ -81,7 +81,9 @@ public ID getItemDefinition() {
}

public boolean isVisible() {
if (item.getDefinition().isOperational()) { // TODO ...or use itemDefinition instead?
if (item.getDefinition().isEmphasized()){
return true;
} else if (item.getDefinition().isOperational()) { // TODO ...or use itemDefinition instead?
return false;
} else if (container != null) {
return container.isItemVisible(this);
Expand Down
Expand Up @@ -185,4 +185,9 @@ private void setToDefault(){
public Class<T> getObjectTypeClass(){
return ChooseTypePanel.this.getModelObject().getType();
}

public void setPanelEnabled(boolean isEnabled){
get(ID_LINK_CHOOSE).setEnabled(isEnabled);
get(ID_LINK_REMOVE).setEnabled(isEnabled);
}
}
Expand Up @@ -27,7 +27,7 @@ <h3>
</h3>

<p>
<wicket:message key="PageError.message" />
<div wicket:id="errorMessage" />
</p>

<p wicket:id="message" />
Expand Down
Expand Up @@ -49,6 +49,7 @@ public class PageError extends PageBase {
private static final String ID_CODE = "code";
private static final String ID_LABEL = "label";
private static final String ID_MESSAGE = "message";
private static final String ID_ERROR_MESSAGE = "errorMessage";
private static final String ID_BACK = "back";
private static final String ID_HOME = "home";

Expand All @@ -57,6 +58,7 @@ public class PageError extends PageBase {
private Integer code;
private String exClass;
private String exMessage;
protected String errorMessageKey;

public PageError() {
this(500);
Expand All @@ -83,6 +85,9 @@ public PageError(Integer code, Exception ex) {
Label codeLabel = new Label(ID_CODE, code);
add(codeLabel);

Label errorMessage = new Label(ID_ERROR_MESSAGE, createStringResource(getErrorMessageKey()));
add(errorMessage);

String errorLabel = "Unexpected error";
if (code != null) {
HttpStatus httpStatus = HttpStatus.valueOf(code);
Expand Down Expand Up @@ -176,4 +181,8 @@ private void homePerformed(AjaxRequestTarget target) {
private void backPerformed(AjaxRequestTarget target) {
redirectBack();
}

protected String getErrorMessageKey() {
return "PageError.message";
}
}
Expand Up @@ -11,4 +11,9 @@ public class PageError403 extends PageError {
public PageError403() {
super(403);
}

@Override
protected String getErrorMessageKey(){
return "PageError403.message";
}
}
Expand Up @@ -1566,6 +1566,7 @@ PageError404.title=Not found (404)
PageError401.title=Unauthorized (401)
PageError.button.back=Back
PageError.message=Unexpected error occurred, if necessary please contact system administrator.
PageError403.message=You don't have rights to see the required page, if necessary please contact system administrator.
PageError.title=Internal error (500)
PageFindUsers.title=Find users
PageForgetPassword.email=E-mail
Expand Down Expand Up @@ -3047,4 +3048,4 @@ ResourceContentResourcePanel.realSearch=(In fact) Searching by:
typedAssignablePanel.selectedOrgs=Orgs:
typedAssignablePanel.selectedResources=Resources:
typedAssignablePanel.selectedRoles=Roles
SearchPanel.insertFilterXml=Insert filter xml (SearchFilterType)
SearchPanel.insertFilterXml=Insert filter xml (SearchFilterType)

0 comments on commit abacadc

Please sign in to comment.