Skip to content

Commit

Permalink
GUI support for assignment/inducement focusType field. (MID-3448)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Oct 8, 2016
1 parent d97ad17 commit a815274
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 1 deletion.
@@ -0,0 +1,22 @@
<!--
~ Copyright (c) 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>
<select wicket:id="select" class="form-control input-sm"></select>
</wicket:panel>
</html>
@@ -0,0 +1,78 @@
/**
* Copyright (c) 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.gui.api.component.objecttypeselect;

import java.util.List;

import javax.xml.namespace.QName;

import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.web.component.input.QNameChoiceRenderer;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

/**
* @author semancik
*
*/
public class ObjectTypeSelectPanel<O extends ObjectType> extends BasePanel<QName> {
private static final long serialVersionUID = 1L;

private static final String ID_SELECT = "select";

private DropDownChoice<QName> select;

public ObjectTypeSelectPanel(String id, IModel<QName> model, Class<O> superclass) {
super(id, model);
initLayout(model, superclass);
}

private void initLayout(IModel<QName> model, final Class<O> superclass) {
select = new DropDownChoice<>(ID_SELECT, model,
new AbstractReadOnlyModel<List<QName>>() {
private static final long serialVersionUID = 1L;

@Override
public List<QName> getObject() {
if (superclass == null || superclass == ObjectType.class) {
return WebComponentUtil.createObjectTypeList();
}
if (superclass == FocusType.class) {
return WebComponentUtil.createFocusTypeList();
}
if (superclass == AbstractRoleType.class) {
return WebComponentUtil.createAbstractRoleTypeList();
}
throw new IllegalArgumentException("Unknown superclass "+superclass);
}
}, new QNameChoiceRenderer());
select.setNullValid(true);

add(select);
}

public void addInput(Behavior behavior) {
select.add(behavior);
}

}
Expand Up @@ -20,6 +20,8 @@
import java.util.Collection;
import java.util.List;

import javax.xml.namespace.QName;

import org.apache.commons.lang.Validate;

import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition;
Expand Down Expand Up @@ -79,6 +81,7 @@ public class AssignmentEditorDto extends SelectableBean implements Comparable<As
public static final String F_DESCRIPTION = "description";
public static final String F_ACTIVATION = "activation";
public static final String F_RELATION = "relation";
public static final String F_FOCUS_TYPE = "focusType";
public static final String F_TENANT_REF = "tenantRef";
public static final String F_ORG_REF = "orgRef";
public static final String F_ALT_NAME = "altName";
Expand Down Expand Up @@ -536,6 +539,10 @@ public PrismContainerValue<AssignmentType> getNewValue(PrismContext prismContext
public String getDescription() {
return newAssignment.getDescription();
}

public QName getFocusType() {
return newAssignment.getFocusType();
}

public String getRelation() {
ObjectReferenceType ref = newAssignment.getTargetRef();
Expand All @@ -550,6 +557,10 @@ public void setDescription(String description) {
newAssignment.setDescription(description);
}

public void setFocusType(QName focusType) {
newAssignment.setFocusType(focusType);
}

public Boolean isOrgUnitManager() {
return isOrgUnitManager;
}
Expand Down
Expand Up @@ -79,6 +79,21 @@
</div>
</div>
</div>

<div>
<div class="row prism-property">
<div class="col-xs-4">
<span><wicket:message key="AssignmentEditorPanel.focusType"/></span>
</div>
<div class="col-xs-8">
<div class="row">
<div class="col-xs-9">
<span wicket:id="focusType"/>
</div>
</div>
</div>
</div>
</div>

<div>
<div class="row prism-property" wicket:id="tenantRefContainer">
Expand Down
Expand Up @@ -20,6 +20,7 @@
import com.evolveum.midpoint.common.refinery.RefinedResourceSchema;
import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.objecttypeselect.ObjectTypeSelectPanel;
import com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
Expand Down Expand Up @@ -108,6 +109,7 @@ public class AssignmentEditorPanel extends BasePanel<AssignmentEditorDto> {
private static final String ID_BODY = "body";
private static final String ID_DESCRIPTION = "description";
private static final String ID_RELATION_CONTAINER = "relationContainer";
private static final String ID_FOCUS_TYPE = "focusType";
private static final String ID_RELATION = "relation";
private static final String ID_RELATION_LABEL = "relationLabel";
private static final String ID_ADMINISTRATIVE_STATUS = "administrativeStatus";
Expand Down Expand Up @@ -358,7 +360,7 @@ public void setObject(Date object) {
}

private void initBodyLayout(WebMarkupContainer body) {
TextArea description = new TextArea<>(ID_DESCRIPTION,
TextArea<String> description = new TextArea<>(ID_DESCRIPTION,
new PropertyModel<String>(getModel(), AssignmentEditorDto.F_DESCRIPTION));
description.setEnabled(getModel().getObject().isEditable());
body.add(description);
Expand All @@ -381,6 +383,10 @@ public boolean isVisible() {
}
});
body.add(relationContainer);

ObjectTypeSelectPanel<FocusType> focusType = new ObjectTypeSelectPanel<>(ID_FOCUS_TYPE,
new PropertyModel<QName>(getModel(), AssignmentEditorDto.F_FOCUS_TYPE), FocusType.class);
body.add(focusType);

TwoStateBooleanPanel relation = new TwoStateBooleanPanel(ID_RELATION,
new PropertyModel<Boolean>(getModel(), AssignmentEditorDto.F_IS_ORG_UNIT_MANAGER),
Expand Down
Expand Up @@ -342,6 +342,7 @@ public List<QName> getObject() {
parentPage.addEditingEnabledBehavior(editorObjectClass);
editor.add(editorObjectClass);

// TODO: switch to ObjectTypeSelectPanel
DropDownChoice editorFocus = new DropDownChoice<>(ID_EDITOR_FOCUS, new PropertyModel<QName>(syncDtoModel,
ResourceSynchronizationDto.F_SELECTED + ".focusType"),
new AbstractReadOnlyModel<List<QName>>() {
Expand Down
Expand Up @@ -40,6 +40,7 @@ AssignmentEditorPanel.description=Description
AssignmentEditorPanel.enabledFrom={0}, from {1,date,medium}
AssignmentEditorPanel.enabledFromTo={0}, from {1,date,medium} to {2,date,medium}
AssignmentEditorPanel.enabledTo={0}, to {1,date,medium}
AssignmentEditorPanel.focusType=Focus type
AssignmentEditorPanel.hideEmpty=Hide empty
AssignmentEditorPanel.loadError=Error loading object
AssignmentEditorPanel.manager=Manager
Expand Down
Expand Up @@ -40,6 +40,7 @@ AssignmentEditorPanel.description=Description
AssignmentEditorPanel.enabledFrom={0}, from {1,date,medium}
AssignmentEditorPanel.enabledFromTo={0}, from {1,date,medium} to {2,date,medium}
AssignmentEditorPanel.enabledTo={0}, to {1,date,medium}
AssignmentEditorPanel.focusType=Focus type
AssignmentEditorPanel.hideEmpty=Hide empty
AssignmentEditorPanel.loadError=Error loading object
AssignmentEditorPanel.manager=Manager
Expand Down

0 comments on commit a815274

Please sign in to comment.