Skip to content

Commit

Permalink
resource assignment popup - kind&intent dropdown fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jun 26, 2018
1 parent fd52b18 commit 8c2625f
Showing 1 changed file with 23 additions and 37 deletions.
Expand Up @@ -57,7 +57,8 @@ public class ResourceTypeAssignmentPopupTabPanel extends AbstractAssignmentPopup
private static final String ID_INTENT = "intent";

private LoadableModel<List<String>> intentValues;
private String intentValue = "";
private String intentValue;
private ShadowKindType kindValue;

private static final String DOT_CLASS = ResourceTypeAssignmentPopupTabPanel.class.getName();
private static final Trace LOGGER = TraceManager.getTrace(ResourceTypeAssignmentPopupTabPanel.class);
Expand All @@ -75,8 +76,8 @@ protected void initParametersPanel(){
add(kindContainer);

DropDownChoicePanel<ShadowKindType> kindSelector = WebComponentUtil.createEnumPanel(ShadowKindType.class, ID_KIND,
WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), Model.of(ShadowKindType.ACCOUNT),
ResourceTypeAssignmentPopupTabPanel.this, false);
WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), Model.of(),
ResourceTypeAssignmentPopupTabPanel.this, true);
kindSelector.setOutputMarkupId(true);
kindSelector.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
Expand All @@ -103,24 +104,7 @@ public boolean isEnabled(){
add(intentContainer);

DropDownChoicePanel<String> intentSelector = new DropDownChoicePanel<String>(ID_INTENT,
new IModel<String>() {
private static final long serialVersionUID = 1L;

@Override
public String getObject() {
return intentValue;
}

@Override
public void setObject(String s) {
intentValue = s;
}

@Override
public void detach() {

}
}, intentValues);
Model.of(), intentValues, true);
intentSelector.getBaseFormComponent().add(new VisibleEnableBehaviour(){
private static final long serialVersionUID = 1L;

Expand All @@ -136,14 +120,6 @@ public boolean isEnabled(){

}

private DropDownChoicePanel getIntentDropDown(){
return (DropDownChoicePanel)get(ID_INTENT_CONTAINER).get(ID_INTENT);
}

private DropDownChoicePanel<ShadowKindType> getKindDropDown(){
return (DropDownChoicePanel<ShadowKindType>)get(ID_KIND_CONTAINER).get(ID_KIND);
}

private void initModels(){
intentValues = new LoadableModel<List<String>>(true) {
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -180,14 +156,6 @@ protected List<String> load() {
};
}

public String getIntentValue(){
return intentValue;
}

public ShadowKindType getKindValue(){
return getKindDropDown().getModel().getObject();
}

@Override
protected List<AssignmentType> getSelectedAssignmentsList(){
List<AssignmentType> assignmentList = new ArrayList<>();
Expand All @@ -201,6 +169,24 @@ protected List<AssignmentType> getSelectedAssignmentsList(){
return assignmentList;
}

public ShadowKindType getKindValue(){
DropDownChoicePanel<ShadowKindType> kindDropDown = getKindDropDown();
return kindDropDown.getModel() != null ? kindDropDown.getModel().getObject() : null;
}

public String getIntentValue(){
DropDownChoicePanel<String> intentDropDown = getIntentDropDown();
return intentDropDown.getModel() != null ? intentDropDown.getModel().getObject() : null;
}

private DropDownChoicePanel<String> getIntentDropDown(){
return (DropDownChoicePanel<String>)get(ID_INTENT_CONTAINER).get(ID_INTENT);
}

private DropDownChoicePanel<ShadowKindType> getKindDropDown(){
return (DropDownChoicePanel<ShadowKindType>)get(ID_KIND_CONTAINER).get(ID_KIND);
}

@Override
protected void onSelectionPerformed(AjaxRequestTarget target){
target.add(getObjectListPanel());
Expand Down

0 comments on commit 8c2625f

Please sign in to comment.