Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
boxed table panel, work in progress.
- Loading branch information
Showing
10 changed files
with
263 additions
and
24 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/BoxedPagingPanel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
30 changes: 30 additions & 0 deletions
30
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/BoxedPagingPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/BoxedTablePanel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
139 changes: 139 additions & 0 deletions
139
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/BoxedTablePanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters