Skip to content

Commit

Permalink
Merge Objects gui implementing
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar authored and semancik committed Oct 21, 2016
1 parent b975205 commit 4582ce6
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 19 deletions.
Expand Up @@ -17,9 +17,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>
<form wicket:id="mainForm" class="form-inline">
<div wicket:id="mergePanel"/>
</form>
</wicket:extend>
</body>
</html>
Expand Up @@ -30,13 +30,14 @@ public class PageMergeObjects<F extends FocusType> extends PageBase {
private static final String ID_MERGE_PANEL = "mergePanel";
private F mergeObject;
private F mergeWithObject;

private Class<F> type;
public PageMergeObjects(){
}

public PageMergeObjects(F mergeObject, F mergeWithObject){
public PageMergeObjects(F mergeObject, F mergeWithObject, Class<F> type){
this.mergeObject = mergeObject;
this.mergeWithObject = mergeWithObject;
this.type = type;
initLayout();
}

Expand All @@ -47,7 +48,7 @@ private void initLayout(){
warningMessage.setOutputMarkupId(true);
add(warningMessage);
} else {
MergeObjectsPanel mergePanel = new MergeObjectsPanel(ID_MERGE_PANEL, mergeObject, mergeWithObject);
MergeObjectsPanel mergePanel = new MergeObjectsPanel(ID_MERGE_PANEL, mergeObject, mergeWithObject, type);
mergePanel.setOutputMarkupId(true);
add(mergePanel);
}
Expand Down
Expand Up @@ -431,7 +431,7 @@ private void deleteConfirmedPerformed(AjaxRequestTarget target) {
getTable().clearCache();
}

private void mergePerformed(AjaxRequestTarget target, UserType selectedUser) {
private void mergePerformed(AjaxRequestTarget target, final UserType selectedUser) {
List<QName> supportedTypes = new ArrayList<>();
supportedTypes.add(UserType.COMPLEX_TYPE);
ObjectBrowserPanel panel = new ObjectBrowserPanel(
Expand All @@ -440,9 +440,9 @@ private void mergePerformed(AjaxRequestTarget target, UserType selectedUser) {
private static final long serialVersionUID = 1L;

@Override
protected void addPerformed(AjaxRequestTarget target, QName type, List selected) {
super.addPerformed(target, type, selected);
// mergeConfirmedPerformed(selectedUser, );
protected void onSelectPerformed(AjaxRequestTarget target, ObjectType user) {
hideMainPopup(target);
mergeConfirmedPerformed(selectedUser, (UserType) user, target);
}

};
Expand All @@ -451,6 +451,7 @@ protected void addPerformed(AjaxRequestTarget target, QName type, List selected)
}

private void mergeConfirmedPerformed(UserType mergeObject, UserType mergeWithObject, AjaxRequestTarget target) {
setResponsePage(new PageMergeObjects(mergeObject, mergeWithObject, UserType.class));
}

private void unlockPerformed(AjaxRequestTarget target, UserType selectedUser) {
Expand Down
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ 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.
-->

<wicket:panel xmlns:wicket="http://wicket.apache.org">
<div wicket:id="objectName" class="form-control input-sm" />
<div wicket:id="objectFullName" class="form-control input-sm" />
<div wicket:id="objectAssignmentsCount" class="form-control input-sm" />
<div wicket:id="objectProjectionsCount" class="form-control input-sm" />
</wicket:panel>
@@ -0,0 +1,81 @@
/**
* 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.page.admin.users.component;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismReference;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;

import java.util.ArrayList;
import java.util.List;

/**
* Created by honchar.
*/
public class MergeObjectDetailsPanel<F extends FocusType> extends BasePanel<F> {
private static final String ID_OBJECT_NAME = "objectName";
private static final String ID_OBJECT_FULLNAME = "objectFullName";
private static final String ID_OBJECT_ASSIGNMENTS_COUNT = "objectAssignmentsCount";
private static final String ID_OBJECT_PROJECTIONS_COUNT = "objectProjectionsCount";

private F mergeObject;

public MergeObjectDetailsPanel(String id, F mergeObject, Class<F> type){
super(id);
this.mergeObject = mergeObject;
initLayout(type);
}

private void initLayout(Class<F> type){
setOutputMarkupId(true);
Label nameLabel = new Label(ID_OBJECT_NAME, mergeObject.getName());
add(nameLabel);

Label fullNameLabel;
if (UserType.class.equals(type)){
fullNameLabel = new Label(ID_OBJECT_FULLNAME, ((UserType) mergeObject).getFullName());
} else {
fullNameLabel = new Label(ID_OBJECT_FULLNAME, ((AbstractRoleType) mergeObject).getDisplayName());
}
add(fullNameLabel);

Label assignmentsCount = new Label(ID_OBJECT_ASSIGNMENTS_COUNT, getAssignmentsCount());
add(assignmentsCount);

Label projectionsCount = new Label(ID_OBJECT_PROJECTIONS_COUNT, getProjectionsCount());
add(projectionsCount);

}

private int getProjectionsCount(){
if (mergeObject == null){
return 0;
}
List<ObjectReferenceType> referenceTypes = mergeObject.getLinkRef();
return referenceTypes == null ? 0 : referenceTypes.size();
}

private int getAssignmentsCount(){
return mergeObject != null ?
(mergeObject.getAssignment() != null ? mergeObject.getAssignment().size() : 0)
: 0;
}
}
@@ -1,10 +1,47 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ 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.
-->

</body>
</html>
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<!--<form wicket:id="mainForm" class="form-horizontal">-->
<div class="row">
<!--<select wicket:id="mergeType"/>-->
<!---->
<!--<div wicket:id="infoHelperButton"/>-->
</div>
<div class="row">
<div wicket:id="mergeObjectDetailsPanel" class="col-md-3"/>
<div class="icon">
<i class="fa fa-plus" style="font-size: 30px;"></i>
</div>
<div class="col-md-1 fa fa-plus"/>
<div wicket:id="mergeWithObjectDetailsPanel" class="col-md-3"/>
<div class="icon">
<i class="fa fa-arrow-right" style="font-size: 30px;"></i>
</div>
<!--<div wicket:id="mergeResultObjectDetailsPanel" class="col-md-3"/>-->
</div>
<wicket:child/>

<!--<div class="main-button-bar">-->
<!--<span class="button-group">-->
<!--<a class="btn btn-default" wicket:id="back"/>-->
<!--</span>-->
<!--<a class="btn btn-primary" wicket:id="switchDirection"/>-->
<!--<a class="btn btn-primary" wicket:id="merge"/>-->
<!--</div>-->
<!--</form>-->
</wicket:panel>
Expand Up @@ -22,11 +22,40 @@
* Created by honchar.
*/
public class MergeObjectsPanel<F extends FocusType> extends BasePanel{
private static final String ID_MERGE_OBJECT_DETAILS_PANEL = "mergeObjectDetailsPanel";
private static final String ID_MERGE_WITH_OBJECT_DETAILS_PANEL = "mergeWithObjectDetailsPanel";
private static final String ID_MERGE_RESULT_OBJECT_DETAILS_PANEL = "mergeResultObjectDetailsPanel";
private static final String ID_PLUS_ICON = "mergeObjectDetailsPanel";
private static final String ID_EQUAL_ICON = "mergeObjectDetailsPanel";

private F mergeObject;
private F mergeWithObject;
private Class<F> type;

public MergeObjectsPanel(String id){
super(id);
}

public MergeObjectsPanel(String id, F mergeObject, F mergeWithObject){
public MergeObjectsPanel(String id, F mergeObject, F mergeWithObject, Class<F> type){
super(id);
this.mergeObject = mergeObject;
this.mergeWithObject = mergeWithObject;
this.type = type;
initLayout();
}

private void initLayout(){
MergeObjectDetailsPanel mergeObjectPanel = new MergeObjectDetailsPanel(ID_MERGE_OBJECT_DETAILS_PANEL,
mergeObject, type);
mergeObjectPanel.setOutputMarkupId(true);
add(mergeObjectPanel);

MergeObjectDetailsPanel mergeWithObjectPanel = new MergeObjectDetailsPanel(ID_MERGE_WITH_OBJECT_DETAILS_PANEL,
mergeWithObject, type);
mergeWithObjectPanel.setOutputMarkupId(true);
add(mergeWithObjectPanel);



}
}

0 comments on commit 4582ce6

Please sign in to comment.