Skip to content

Commit

Permalink
MID-1931 more small code improvements and cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Suta committed Jun 25, 2014
1 parent c0e1bd3 commit c20f638
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 33 deletions.
Expand Up @@ -3,6 +3,7 @@
import com.evolveum.midpoint.web.component.AjaxSubmitButton;
import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.web.util.SearchFormEnterBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
Expand Down Expand Up @@ -55,12 +56,6 @@ protected void initLayout() {
Form form = new Form(ID_FORM);
popover.add(form);

TextField input = new TextField(ID_INPUT, createInputModel());
input.add(new RangeValidator(5, 50));
input.setLabel(createStringResource("PageSizePopover.title"));
input.setType(Integer.class);
form.add(input);

AjaxSubmitButton button = new AjaxSubmitButton(ID_BUTTON) {

@Override
Expand All @@ -77,6 +72,13 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
}
};
form.add(button);

TextField input = new TextField(ID_INPUT, createInputModel());
input.add(new RangeValidator(5, 50));
input.setLabel(createStringResource("PageSizePopover.title"));
input.add(new SearchFormEnterBehavior(button));
input.setType(Integer.class);
form.add(input);
}

private IModel<Integer> createInputModel() {
Expand Down
Expand Up @@ -45,7 +45,6 @@ public class TablePanel<T> extends Panel {

private IModel<Boolean> showPaging = new Model<Boolean>(true);
private IModel<Boolean> showCount = new Model<Boolean>(true);
private IModel<Boolean> showPagingSize = new Model<Boolean>(false);

private UserProfileStorage.TableId tableId;

Expand Down Expand Up @@ -100,8 +99,13 @@ protected void pageSizeChanged(AjaxRequestTarget target) {

@Override
protected boolean isPageSizePopupVisible() {
return showPagingSize.getObject();
if(tableId != null){
return true;
} else {
return false;
}
}

};
addVisibleBehaviour(count, showCount);
table.addBottomToolbar(count);
Expand Down Expand Up @@ -163,10 +167,6 @@ public void setCurrentPage(ObjectPaging paging) {
getDataTable().setCurrentPage(page);
}

public void setShowPagingSize(boolean show) {
this.showPagingSize.setObject(show);
}

public void setShowPaging(boolean showPaging) {
this.showPaging.setObject(showPaging);
this.showCount.setObject(showPaging);
Expand Down
Expand Up @@ -639,8 +639,4 @@ public void receiveNotifyMessage(AjaxRequestTarget target, NotifyMessage message

target.appendJavaScript(sb.toString());
}

public Integer getPagingSize(UserProfileStorage.TableId tableId){
return getSessionStorage().getUserProfile().getPagingSize(tableId);
}
}
Expand Up @@ -202,7 +202,6 @@ public void onClick(AjaxRequestTarget target) {
provider.setOptions(SelectorOptions.createCollection(GetOperationOptions.createRaw()));
provider.setQuery(ObjectQuery.createObjectQuery(createResourceQueryFilter()));
TablePanel accounts = new TablePanel(ID_ACCOUNTS, provider, createAccountsColumns(), UserProfileStorage.TableId.CONF_PAGE_ACCOUNTS);
accounts.setShowPagingSize(true);
accounts.add(new VisibleEnableBehaviour() {

@Override
Expand Down
Expand Up @@ -208,7 +208,6 @@ private void addOrReplaceTable(RepositoryObjectDataProvider provider) {
Form mainForm = (Form) get(ID_MAIN_FORM);

TablePanel table = new TablePanel(ID_TABLE, provider, initColumns(provider.getType()), UserProfileStorage.TableId.CONF_DEBUG_LIST_PANEL);
table.setShowPagingSize(true);
table.setOutputMarkupId(true);
mainForm.addOrReplace(table);
}
Expand Down
Expand Up @@ -184,7 +184,6 @@ protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
provider.setQuery(query);

TablePanel table = new TablePanel(ID_CREATED_REPORTS_TABLE, provider, initColumns(ajaxDownloadBehavior), UserProfileStorage.TableId.PAGE_CREATED_REPORTS_PANEL);
table.setShowPagingSize(true);
table.setShowPaging(true);
table.setOutputMarkupId(true);
mainForm.add(table);
Expand Down
Expand Up @@ -123,7 +123,6 @@ private void initLayout() {
provider.setSort("displayName", SortOrder.ASCENDING);
TablePanel objectTypes = new TablePanel<>("objectTypesTable", provider,
initObjectTypesColumns(), UserProfileStorage.TableId.PAGE_RESOURCE_PANEL);
objectTypes.setShowPagingSize(true);
objectTypes.setShowPaging(true);
objectTypes.setOutputMarkupId(true);
mainForm.add(objectTypes);
Expand Down
Expand Up @@ -144,7 +144,6 @@ private void initLayout() {

TablePanel resources = new TablePanel<>(ID_TABLE, initResourceDataProvider(), initResourceColumns(),
UserProfileStorage.TableId.PAGE_RESOURCES_PANEL);
resources.setShowPagingSize(true);
resources.setOutputMarkupId(true);
mainForm.add(resources);

Expand Down
Expand Up @@ -238,7 +238,6 @@ protected void addInlineMenuToDto(AccountContentDto dto) {

List<IColumn> columns = initColumns();
TablePanel table = new TablePanel(ID_TABLE, provider, columns, UserProfileStorage.TableId.PAGE_RESOURCE_ACCOUNTS_PANEL);
table.setShowPagingSize(true);
table.setOutputMarkupId(true);
mainForm.add(table);

Expand Down
Expand Up @@ -130,7 +130,6 @@ protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
List<IColumn<RoleType, String>> columns = initColumns();
TablePanel table = new TablePanel<>(ID_TABLE, provider, columns, UserProfileStorage.TableId.TABLE_ROLES);
table.setOutputMarkupId(true);
table.setShowPagingSize(true);
RolesStorage storage = getSessionStorage().getRoles();
table.setCurrentPage(storage.getRolesPaging());

Expand Down
Expand Up @@ -159,7 +159,6 @@ private void initLayout() {
provider.setQuery(createTaskQuery());
TablePanel<TaskDto> taskTable = new TablePanel<>(ID_TASK_TABLE, provider, taskColumns,
UserProfileStorage.TableId.PAGE_TASKS_PANEL);
taskTable.setShowPagingSize(true);
taskTable.setOutputMarkupId(true);
mainForm.add(taskTable);

Expand Down
Expand Up @@ -308,7 +308,6 @@ public UserListItemDto createDataObjectWrapper(PrismObject<UserType> obj) {
provider.setOptions(options);

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

UsersStorage storage = getSessionStorage().getUsers();
Expand Down
Expand Up @@ -331,7 +331,7 @@ public ObjectQuery getQuery() {
};
tableProvider.setOptions(WebModelUtils.createMinimalOptions());
List<IColumn<OrgTableDto, String>> tableColumns = createTableColumns();
TablePanel table = new TablePanel(ID_TABLE, tableProvider, tableColumns);
TablePanel table = new TablePanel(ID_TABLE, tableProvider, tableColumns, UserProfileStorage.TableId.TREE_TABLE_PANEL);
table.setOutputMarkupId(true);
form.add(table);
}
Expand Down
Expand Up @@ -93,7 +93,6 @@ private void initLayout() {
List<IColumn<WorkItemDto, String>> workItemColumns = initWorkItemColumns();
TablePanel<WorkItemDto> workItemTable = new TablePanel<>("workItemTable", new WorkItemDtoProvider(PageWorkItems.this, assigned),
workItemColumns, UserProfileStorage.TableId.PAGE_WORK_ITEMS);
workItemTable.setShowPagingSize(true);
workItemTable.setOutputMarkupId(true);
mainForm.add(workItemTable);

Expand Down
Expand Up @@ -34,11 +34,8 @@ public enum TableId{
TABLE_ROLES,
TABLE_USERS,
TREE_TABLE_PANEL,
RESOURCE_WIZARD_ATTRIBUTE_PANEL,
WF_WORK_ITEMS_PANEL,
CONF_PAGE_ACCOUNTS,
CONF_DEBUG_LIST_PANEL,
PAGE_REPORTS_PANEL,
PAGE_CREATED_REPORTS_PANEL,
PAGE_RESOURCE_PANEL,
PAGE_RESOURCES_PANEL,
Expand All @@ -53,11 +50,8 @@ public enum TableId{
put(TableId.TABLE_ROLES, null);
put(TableId.TABLE_USERS, null);
put(TableId.TREE_TABLE_PANEL, null);
put(TableId.RESOURCE_WIZARD_ATTRIBUTE_PANEL, null);
put(TableId.WF_WORK_ITEMS_PANEL, null);
put(TableId.CONF_PAGE_ACCOUNTS, null);
put(TableId.CONF_DEBUG_LIST_PANEL, null);
put(TableId.PAGE_REPORTS_PANEL, null);
put(TableId.PAGE_CREATED_REPORTS_PANEL, null);
put(TableId.PAGE_RESOURCE_PANEL, null);
put(TableId.PAGE_RESOURCES_PANEL, null);
Expand Down

0 comments on commit c20f638

Please sign in to comment.