Skip to content

Commit

Permalink
refactoring names of values
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Jul 9, 2018
1 parent 5ce2a57 commit 575b2d2
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 269 deletions.
@@ -0,0 +1,51 @@
<!--
~ Copyright (c) 2010-2017 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 wicket:id="items" class="main-form-panel">
<div wixket:id="search" class="row">
<!-- <div wicket:id="relationContainer" class="col-xs-6">
<label class="col-xs-2 prism-property" ><wicket:message key="AbstractRoleAssignmentPanel.relationLabel" /></label>
<div class="col-xs-3" wicket:id="relation" />
</div>
<div class="col-xs-3 pull-right">
<div class="btn btn-default pull-right" wicket:id="showAllAssignmentsButton" />
</div>-->
</div>

<div class="row" >
<div class="col-md-12" wicket:id="itemsTable" style="margin: 5px 0;"/>
</div>
<div>
<div class="btn btn-success btn-sm" wicket:id="newItemButton"/>
</div>
</div>
<div wicket:id="details">
<div wicket:id="itemsDetails">
<div wicket:id="itemDetails" />
</div>

<div class="row">
<div class="container-fluid prism-container">
<div class="btn btn-default" wicket:id="cancelButton"/>
<div class="btn btn-primary" wicket:id="doneButton"/>
</div>
</div>
</div>
</wicket:panel>
</html>
Expand Up @@ -17,7 +17,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand All @@ -40,16 +39,14 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.assignment.AssignmentPanel;
import com.evolveum.midpoint.web.component.data.BoxedTablePanel;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapperFactory;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.component.util.ContainerListDataProvider;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.session.AssignmentsTabStorage;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.web.session.PageStorage;
import com.evolveum.midpoint.web.session.UserProfileStorage.TableId;

/**
Expand All @@ -64,14 +61,15 @@ public abstract class MultivalueContainerListPanel<C extends Containerable> exte
private static final String ID_NEW_ITEM_BUTTON = "newItemButton";
private static final String ID_ITEMS_TABLE = "itemsTable";
public static final String ID_ITEMS_DETAILS = "itemsDetails";
public static final String ID_ITEM_DETAILS = "itemtDetails";
public static final String ID_ITEM_DETAILS = "itemDetails";
public static final String ID_SEARCH_ITEM_PANEL = "search";

public static final String ID_DETAILS = "details";

private final static String ID_DONE_BUTTON = "doneButton";
private final static String ID_CANCEL_BUTTON = "cancelButton";

private static final Trace LOGGER = TraceManager.getTrace(AssignmentPanel.class);
private static final Trace LOGGER = TraceManager.getTrace(MultivalueContainerListPanel.class);

protected boolean itemDetailsVisible;
private List<ContainerValueWrapper<C>> detailsPanelItemsList = new ArrayList<>();
Expand Down Expand Up @@ -100,12 +98,12 @@ private void initLayout() {
}

private void initListPanel() {
WebMarkupContainer assignmentsContainer = new WebMarkupContainer(ID_ITEMS);
assignmentsContainer.setOutputMarkupId(true);
add(assignmentsContainer);
WebMarkupContainer itemsContainer = new WebMarkupContainer(ID_ITEMS);
itemsContainer.setOutputMarkupId(true);
add(itemsContainer);

BoxedTablePanel<ContainerValueWrapper<C>> assignmentTable = initAssignmentTable();
assignmentsContainer.add(assignmentTable);
BoxedTablePanel<ContainerValueWrapper<C>> itemTable = initAssignmentTable();
itemsContainer.add(itemTable);

AjaxIconButton newObjectIcon = new AjaxIconButton(ID_NEW_ITEM_BUTTON, new Model<>("fa fa-plus"),
createStringResource("MainObjectListPanel.newObject")) {
Expand All @@ -114,7 +112,7 @@ private void initListPanel() {

@Override
public void onClick(AjaxRequestTarget target) {
newAssignmentClickPerformed(target);
newAssignmentPerformed(target);
}
};

Expand All @@ -126,11 +124,14 @@ public boolean isVisible() {
return enableActionNewObject();
}
});
assignmentsContainer.add(newObjectIcon);
itemsContainer.add(newObjectIcon);

WebMarkupContainer searchContainer = new WebMarkupContainer(ID_SEARCH_ITEM_PANEL);
itemsContainer.add(searchContainer);
createSearch(searchContainer);
createCustomLayout(itemsContainer);

createCustomLayout(assignmentsContainer);

assignmentsContainer.add(new VisibleEnableBehaviour() {
itemsContainer.add(new VisibleEnableBehaviour() {

private static final long serialVersionUID = 1L;

Expand All @@ -142,6 +143,8 @@ public boolean isVisible() {

}

protected abstract void createSearch(WebMarkupContainer searchContainer);

protected abstract boolean enableActionNewObject();

private BoxedTablePanel<ContainerValueWrapper<C>> initAssignmentTable() {
Expand All @@ -151,7 +154,7 @@ private BoxedTablePanel<ContainerValueWrapper<C>> initAssignmentTable() {

@Override
protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
getAssignmentsStorage().setPaging(paging);
getPageStorage().setPaging(paging);
}

@Override
Expand All @@ -176,7 +179,7 @@ containersProvider, columns, getTableId(), getItemsPerPage()) {
@Override
public int getItemsPerPage() {
return getPageBase().getSessionStorage().getUserProfile().getTables()
.get(UserProfileStorage.TableId.ASSIGNMENTS_TAB_TABLE);
.get(getTableId());
}

@Override
Expand All @@ -193,28 +196,24 @@ public String getObject() {

};
itemTable.setOutputMarkupId(true);
itemTable.setCurrentPage(getAssignmentsStorage().getPaging());
itemTable.setCurrentPage(getPageStorage().getPaging());
return itemTable;

}

protected List<ContainerValueWrapper<C>> postSearch(List<ContainerValueWrapper<C>> assignments) {
return assignments;
}
protected abstract List<ContainerValueWrapper<C>> postSearch(List<ContainerValueWrapper<C>> items);

protected AssignmentsTabStorage getAssignmentsStorage() {
return getPageBase().getSessionStorage().getAssignmentsTabStorage();
}
protected abstract PageStorage getPageStorage();

protected abstract ObjectQuery createQuery();

protected abstract List<IColumn<ContainerValueWrapper<C>, String>> createColumns();

protected abstract void newAssignmentClickPerformed(AjaxRequestTarget target);
protected abstract void newAssignmentPerformed(AjaxRequestTarget target);

protected abstract void createCustomLayout(WebMarkupContainer assignmentsContainer);
protected abstract void createCustomLayout(WebMarkupContainer itemsContainer);

protected abstract void createDetailsPanel(WebMarkupContainer assignmentsContainer);
protected abstract void createDetailsPanel(WebMarkupContainer itemsContainer);

private void initDetailsPanel() {
WebMarkupContainer details = new WebMarkupContainer(ID_DETAILS);
Expand Down Expand Up @@ -259,38 +258,33 @@ public void onClick(AjaxRequestTarget ajaxRequestTarget) {
details.add(cancelButton);
}

protected ContainerListDataProvider getAssignmentListProvider() {
return (ContainerListDataProvider) getAssignmentTable().getDataTable().getDataProvider();
}
// protected ContainerListDataProvider getAssignmentListProvider() {
// return (ContainerListDataProvider) getAssignmentTable().getDataTable().getDataProvider();
// }

protected BoxedTablePanel<ContainerValueWrapper<C>> getAssignmentTable() {
public BoxedTablePanel<ContainerValueWrapper<C>> getItemTable() {
return (BoxedTablePanel<ContainerValueWrapper<C>>) get(createComponentPath(ID_ITEMS, ID_ITEMS_TABLE));
}

protected abstract String getAuthirizationForRemoveAction();

protected abstract String getAuthirizationForAddAction();

protected abstract TableId getTableId();

protected abstract int getItemsPerPage();

protected void refreshTable(AjaxRequestTarget target) {
public void refreshTable(AjaxRequestTarget target) {
target.add(getItemContainer().addOrReplace(initAssignmentTable()));
}

protected ContainerValueWrapper<C> createNewAssignmentContainerValueWrapper(PrismContainerValue<C> newAssignment) {
protected ContainerValueWrapper<C> createNewItemContainerValueWrapper(PrismContainerValue<C> newItem) {
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
Task task = getPageBase().createSimpleTask("Creating new assignment");
ContainerValueWrapper<C> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newAssignment,
Task task = getPageBase().createSimpleTask("Creating new item");
ContainerValueWrapper<C> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newItem,
getModelObject().getObjectStatus(), ValueStatus.ADDED, getModelObject().getPath(), task);
valueWrapper.setShowEmpty(true, false);
getModelObject().getValues().add(valueWrapper);
return valueWrapper;
}

protected WebMarkupContainer getItemContainer() {
public WebMarkupContainer getItemContainer() {
return (WebMarkupContainer) get(ID_ITEMS);
}

}
Expand Up @@ -16,9 +16,12 @@

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<wicket:panel>
<div wicket:id="assignments"/>
</wicket:panel>
<!-- <wicket:panel>
<div wicket:id="assignments" class="main-form-panel">
<div wicket:id="items" class="main-form-panel">
<div class="row">
<div wicket:id="relationContainer" class="col-xs-6">
<label class="col-xs-2 prism-property" ><wicket:message key="AbstractRoleAssignmentPanel.relationLabel" /></label>
Expand All @@ -30,23 +33,23 @@
</div>
<div class="row" >
<div class="col-md-12" wicket:id="assignmentsTable" style="margin: 5px 0;"/>
<div class="col-md-12" wicket:id="itemsTable" style="margin: 5px 0;"/>
</div>
<div>
<div class="btn btn-success btn-sm" wicket:id="newAssignmentButton"/>
<div class="btn btn-success btn-sm" wicket:id="newItemButton"/>
</div>
</div>
<div wicket:id="details">
<div wicket:id="assignmentsDetails">
<div wicket:id="assignmentDetails" />
<div wicket:id="itemsDetails">
<div wicket:id="itemDetails" />
</div>
<div class="row">
<div class="container-fluid prism-container">
<div class="btn btn-default" wicket:id="cancelButton"/>
<div class="btn btn-primary" wicket:id="doneButton"/>
</div>
</div>
<div class="container-fluid prism-container">
<div class="btn btn-default" wicket:id="cancelButton"/>
<div class="btn btn-primary" wicket:id="doneButton"/>
</div>
</div>
</div>
</wicket:panel>
</wicket:panel> -->
</html>
Expand Up @@ -271,17 +271,17 @@ public boolean isVisible(){
};
}

protected void initPaging(){
getAssignmentsStorage().setPaging(ObjectPaging.createPaging(0, (int) getParentPage().getItemsPerPage(UserProfileStorage.TableId.ASSIGNMENTS_TAB_TABLE)));
protected void initCustomPaging(){
getAssignmentsTabStorage().setPaging(ObjectPaging.createPaging(0, (int) getParentPage().getItemsPerPage(UserProfileStorage.TableId.ASSIGNMENTS_TAB_TABLE)));
}

@Override
protected TableId getTableId() {
protected TableId getCustomTableId() {
return UserProfileStorage.TableId.ASSIGNMENTS_TAB_TABLE;
}

@Override
protected int getItemsPerPage() {
protected int getCustomItemsPerPage() {
return (int) getParentPage().getItemsPerPage(UserProfileStorage.TableId.ASSIGNMENTS_TAB_TABLE);
}

Expand Down
Expand Up @@ -18,18 +18,18 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<div wicket:id="assignments" class="main-form-panel">
<div wicket:id="items" class="main-form-panel">

<div class="row" >
<div class="col-md-12" wicket:id="assignmentsTable" style="margin: 5px 0;"/>
<div class="col-md-12" wicket:id="itemsTable" style="margin: 5px 0;"/>
</div>
<div>
<div class="btn btn-success btn-sm" wicket:id="newAssignmentButton"/>
<div class="btn btn-success btn-sm" wicket:id="newItemButton"/>
</div>
</div>
<div wicket:id="details">
<div wicket:id="assignmentsDetails">
<div wicket:id="assignmentDetails" />
<div wicket:id="itemsDetails">
<div wicket:id="itemDetails" />
</div>

<div class="row">
Expand Down

0 comments on commit 575b2d2

Please sign in to comment.