Skip to content

Commit

Permalink
boxed table panel, work in progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Sep 28, 2015
1 parent 0486678 commit e3cd481
Show file tree
Hide file tree
Showing 10 changed files with 263 additions and 24 deletions.
@@ -0,0 +1,38 @@
<!--
~ Copyright (c) 2010-2015 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>
<ul class="pagination">
<li wicket:id="first">
<a wicket:id="firstLink"><wicket:message key="NavigatorPanel.firstLink"/></a>
</li>
<li wicket:id="previous">
<a wicket:id="previousLink"><wicket:message key="NavigatorPanel.previousLink"/></a>
</li>
<li wicket:id="navigation">
<a wicket:id="pageLink"/>
</li>
<li wicket:id="next">
<a wicket:id="nextLink"><wicket:message key="NavigatorPanel.nextLink"/></a>
</li>
<li wicket:id="last">
<a wicket:id="lastLink"><wicket:message key="NavigatorPanel.lastLink"/></a>
</li>
</ul>
</wicket:panel>
</html>
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2010-2015 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.component.data;

import com.evolveum.midpoint.web.component.data.paging.NavigatorPanel;
import org.apache.wicket.markup.html.navigation.paging.IPageable;

/**
* @author Viliam Repan (lazyman)
*/
public class BoxedPagingPanel extends NavigatorPanel {

public BoxedPagingPanel(String id, IPageable pageable, boolean showPageListing) {
super(id, pageable, showPageListing);
}
}
@@ -0,0 +1,42 @@
<!--
~ Copyright (c) 2010-2015 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 class="box">
<div class="box-header" wicket:id="header"/>
<div class="box-body no-padding">
<table class="table table-striped table-hover table-bordered" wicket:id="table" about="table"/>
</div>
<div class="box-footer" wicket:id="footer"/>
</div>
</wicket:panel>

<wicket:fragment wicket:id="pagingFooter">
<div class="row">
<div class="col-md-6">
<div class="dataTables_info" wicket:id="count"/>
</div>
<div class="col-md-6">
<div class="dataTables_paginate paging_bootstrap" wicket:id="paging"/>
<wicket:remove>
<!-- todo [lazyman] add cog button with two menu items: "page size" and "column settings" -->
</wicket:remove>
</div>
</div>
</wicket:fragment>
</html>
@@ -0,0 +1,139 @@
/*
* Copyright (c) 2010-2015 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.component.data;

import com.evolveum.midpoint.web.component.data.paging.NavigatorPanel;
import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.navigation.paging.IPageable;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.data.DataViewBase;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.StringResourceModel;

import java.util.List;

/**
* @author Viliam Repan (lazyman)
*/
public class BoxedTablePanel<T> extends SimplePanel {

private static final String ID_HEADER = "header";
private static final String ID_FOOTER = "footer";
private static final String ID_TABLE = "table";

private static final String ID_PAGING_FOOTER = "pagingFooter";
private static final String ID_PAGING = "paging";
private static final String ID_COUNT = "count";

public BoxedTablePanel(String id,ISortableDataProvider provider, List<IColumn<T, String>> columns,
UserProfileStorage.TableId tableId, int pageSize) {
super(id);

initLayout(columns, provider, pageSize);
}

private void initLayout(List<IColumn<T, String>> columns, ISortableDataProvider provider, int pageSize) {
DataTable<T, String> table = new SelectableDataTable<>(ID_TABLE, columns, provider, pageSize);
add(table);

TableHeadersToolbar headersTop = new TableHeadersToolbar(table, provider);
headersTop.setOutputMarkupId(true);
table.addTopToolbar(headersTop);

add(createHeader(ID_HEADER));
add(createFooter(ID_FOOTER));
}

private DataTable getTable() {
return (DataTable) get(ID_TABLE);
}

protected WebMarkupContainer createHeader(String headerId) {
WebMarkupContainer header = new WebMarkupContainer(headerId);
header.setVisible(false);
return header;
}

protected WebMarkupContainer createFooter(String footerId) {
return new PagingFooter(footerId, ID_PAGING_FOOTER, this, getTable());
}

private static class PagingFooter extends Fragment {

public PagingFooter(String id, String markupId, MarkupContainer markupProvider, DataTable table) {
super(id, markupId, markupProvider);

initLayout(table);
}

private void initLayout(final DataTable table) {
BoxedPagingPanel nb2 = new BoxedPagingPanel(ID_PAGING, table, true);
add(nb2);

Label count = new Label(ID_COUNT, new AbstractReadOnlyModel<String>() {

@Override
public String getObject() {
return createCountString(table);
}
});
add(count);
}

private String createCountString(IPageable pageable) {
long from = 0;
long to = 0;
long count = 0;

if (pageable instanceof DataViewBase) {
DataViewBase view = (DataViewBase) pageable;

from = view.getFirstItemOffset() + 1;
to = from + view.getItemsPerPage() - 1;
long itemCount = view.getItemCount();
if (to > itemCount) {
to = itemCount;
}
count = itemCount;
} else if (pageable instanceof DataTable) {
DataTable table = (DataTable) pageable;

from = table.getCurrentPage() * table.getItemsPerPage() + 1;
to = from + table.getItemsPerPage() - 1;
long itemCount = table.getItemCount();
if (to > itemCount) {
to = itemCount;
}
count = itemCount;
}

if (count > 0) {
return new StringResourceModel("CountToolbar.label", PagingFooter.this, null,
new Object[]{from, to, count}).getString();
}

return new StringResourceModel("CountToolbar.noFound", PagingFooter.this, null).getString();
}
}
}
Expand Up @@ -17,16 +17,6 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<!--<div class="box">-->
<!--<div class="box-header"></div>-->
<!--<div class="box-body no-padding">-->
<!--<table class="table table-striped table-hover table-bordered" wicket:id="table" about="table"/>-->
<!--</div>-->
<!--<div class="box-footer">-->
<!--<div wicket:id="paging"/>-->
<!--</div>-->
<!--</div>-->

<table class="table table-striped table-condensed" wicket:id="table" about="table"/>
<div wicket:id="paging" />
</wicket:panel>
Expand Down
Expand Up @@ -54,7 +54,7 @@ public TablePanel(String id, ISortableDataProvider provider, List<IColumn<T, Str
}

public TablePanel(String id, ISortableDataProvider provider, List<IColumn<T, String>> columns,
UserProfileStorage.TableId tableId, long pageSize){
UserProfileStorage.TableId tableId, long pageSize) {
super(id);
Validate.notNull(provider, "Object type must not be null.");
Validate.notNull(columns, "Columns must not be null.");
Expand All @@ -64,13 +64,8 @@ public TablePanel(String id, ISortableDataProvider provider, List<IColumn<T, Str
initLayout(columns, provider, pageSize);
}

@Override
protected void onInitialize() {
super.onInitialize();
}

private void initLayout(List<IColumn<T, String>> columns, ISortableDataProvider provider, long pageSize) {
DataTable<T, String> table = new SelectableDataTable<>(ID_TABLE, columns, provider, (int)pageSize);
DataTable<T, String> table = new SelectableDataTable<>(ID_TABLE, columns, provider, (int) pageSize);

table.setOutputMarkupId(true);

Expand Down
Expand Up @@ -27,7 +27,7 @@
wicket:message="title:prismPropertyPanel.hasPendingModification">*</span>
<i wicket:id="help"/>
</div>
<div class="col-md-6" style="margin-top: 5px;" wicket:id="values">
<div class="col-md-6" wicket:id="values">
<div wicket:id="value"/>
</div>
</wicket:panel>
Expand Down
Expand Up @@ -39,6 +39,7 @@
import com.evolveum.midpoint.web.application.PageDescriptor;
import com.evolveum.midpoint.web.component.BasicSearchPanel;
import com.evolveum.midpoint.web.component.DropDownMultiChoice;
import com.evolveum.midpoint.web.component.data.BoxedTablePanel;
import com.evolveum.midpoint.web.component.data.ObjectDataProvider;
import com.evolveum.midpoint.web.component.data.TablePanel;
import com.evolveum.midpoint.web.component.data.column.*;
Expand Down Expand Up @@ -324,12 +325,16 @@ public UserListItemDto createDataObjectWrapper(PrismObject<UserType> obj) {
GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
provider.setOptions(options);

TablePanel table = new TablePanel(ID_TABLE, provider, columns,
UserProfileStorage.TableId.PAGE_USERS_PANEL, getItemsPerPage(UserProfileStorage.TableId.PAGE_USERS_PANEL));
BoxedTablePanel table = new BoxedTablePanel(ID_TABLE, provider, columns,
UserProfileStorage.TableId.PAGE_USERS_PANEL,
(int) getItemsPerPage(UserProfileStorage.TableId.PAGE_USERS_PANEL));

// TablePanel table = new TablePanel(ID_TABLE, provider, columns,
// UserProfileStorage.TableId.PAGE_USERS_PANEL, getItemsPerPage(UserProfileStorage.TableId.PAGE_USERS_PANEL));
table.setOutputMarkupId(true);

UsersStorage storage = getSessionStorage().getUsers();
table.setCurrentPage(storage.getUsersPaging());
// table.setCurrentPage(storage.getUsersPaging());

mainForm.add(table);
}
Expand Down
Expand Up @@ -2659,7 +2659,7 @@ PageAdmin.menu.profile=Profile
PageAdmin.menu.assignments=Assignments
PageAdmin.menu.credentials=Credentials
PageTemplate.version=Version:
PageTemplate.copy=<strong>Copyright &copy; 2010-2015 <a href="https://www.evolveum.com/">Evolveum</a> and partners.</strong> Thank you for using <a href="http://midpoint.evolveum.com">midPoint</a>
PageTemplate.copy=<strong>Copyright &copy; 2010-2015 <a href="https://www.evolveum.com/">Evolveum</a> and partners.</strong> Thank you for using <a href="http://midpoint.evolveum.com">midPoint</a>.
PageTemplate.toggleNavigation=Toggle navigation
PageTemplate.user=user
PageTemplate.couldntNavigateBreadcrumb=Couldn't navigate breadcrumb, reason: {0}
Expand Up @@ -99,9 +99,9 @@ table.table {
td, th {

&.cog {
width: 68px;
width: 50px;
vertical-align: bottom;
padding: 1px;
padding: 0px 1px 1px 1px;

ul.cog {

Expand Down

0 comments on commit e3cd481

Please sign in to comment.