Skip to content

Commit

Permalink
fixed logging/basic configuration url problems
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed May 9, 2015
1 parent 70d1662 commit 00af232
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 73 deletions.
Expand Up @@ -22,7 +22,7 @@ public LabeledBookmarkableLink(String id, MenuItem menuItem) {
@Override
protected void initLayout() {
MenuItem item = getModel().getObject();
BookmarkablePageLink link = new BookmarkablePageLink(ID_LINK, item.getPage());
BookmarkablePageLink link = new BookmarkablePageLink(ID_LINK, item.getPage(), item.getPageParameters());
add(link);

Label label = new Label(ID_LABEL, item.getName());
Expand Down
@@ -1,8 +1,10 @@
package com.evolveum.midpoint.web.component.menu.top;

import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.github.sommeri.less4j.core.ast.Page;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;

import java.io.Serializable;

Expand All @@ -15,21 +17,32 @@ public class MenuItem implements Serializable {
private VisibleEnableBehaviour visibleEnable;
private Class<? extends WebPage> page;
private boolean menuHeader;
private PageParameters pageParameters;

public MenuItem(IModel<String> name) {
this(name, false, null, null);
}

public MenuItem(IModel<String> name, Class<? extends WebPage> page) {
this(name, false, page, null);
this(name, false, page, null, null);
}

public MenuItem(IModel<String> name, Class<? extends WebPage> page, PageParameters pageParameters) {
this(name, false, page, null, pageParameters);
}

public MenuItem(IModel<String> name, boolean menuHeader, Class<? extends WebPage> page,
VisibleEnableBehaviour visibleEnable) {
this(name, menuHeader, page, visibleEnable, null);
}

public MenuItem(IModel<String> name, boolean menuHeader, Class<? extends WebPage> page,
VisibleEnableBehaviour visibleEnable, PageParameters pageParameters) {
this.name = name;
this.menuHeader = menuHeader;
this.page = page;
this.visibleEnable = visibleEnable;
this.pageParameters = pageParameters;
}

public IModel<String> getName() {
Expand All @@ -51,4 +64,8 @@ public boolean isMenuHeader() {
public boolean isDivider() {
return getPage() == null;
}

public PageParameters getPageParameters() {
return pageParameters;
}
}
Expand Up @@ -22,7 +22,8 @@ public MenuLinkPanel(String id, IModel<MenuItem> item) {
private void initLayout(IModel<MenuItem> item) {
MenuItem menuItem = item.getObject();

BookmarkablePageLink menuItemLink = new BookmarkablePageLink(ID_MENU_ITEM_LINK, menuItem.getPage());
BookmarkablePageLink menuItemLink = new BookmarkablePageLink(ID_MENU_ITEM_LINK,
menuItem.getPage(), menuItem.getPageParameters());
add(menuItemLink);

Label menuItemLabel = new Label(ID_MENU_ITEM_LABEL, menuItem.getName());
Expand Down
Expand Up @@ -166,8 +166,15 @@ private MenuBarItem createConfigurationItems() {
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.repositoryObjects"), PageDebugList.class));
configuration.addMenuItem(new MenuItem(null));
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.configuration"), true, null, null));
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.basic"), PageSystemConfiguration.class));
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.logging"), PageSystemConfigurationLogging.class));

PageParameters params = new PageParameters();
params.add(PageSystemConfiguration.SELECTED_TAB_INDEX, PageSystemConfiguration.CONFIGURATION_TAB_BASIC);
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.basic"), PageSystemConfiguration.class, params));

params = new PageParameters();
params.add(PageSystemConfiguration.SELECTED_TAB_INDEX, PageSystemConfiguration.CONFIGURATION_TAB_LOGGING);
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.logging"), PageSystemConfiguration.class, params));

// configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.security"), PageDashboard.class));
configuration.addMenuItem(new MenuItem(null));
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.development"), true, null, null));
Expand Down
Expand Up @@ -27,7 +27,4 @@ public class PageAdminConfiguration extends PageAdmin {
public static final String AUTH_CONFIGURATION_ALL = AuthorizationConstants.NS_AUTHORIZATION + "#configurationAll";
public static final String AUTH_CONFIGURATION_ALL_LABEL = "PageAdminConfiguration.auth.configurationAll.label";
public static final String AUTH_CONFIGURATION_ALL_DESCRIPTION = "PageAdminConfiguration.auth.configurationAll.description";

protected static final int CONFIGURATION_TAB_BASIC = 0;
protected static final int CONFIGURATION_TAB_LOGGING = 1;
}
Expand Up @@ -48,6 +48,8 @@
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.string.StringValue;

import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration;
Expand All @@ -68,6 +70,11 @@
description = "PageSystemConfiguration.auth.configSystemConfiguration.description")})
public class PageSystemConfiguration extends PageAdminConfiguration {

public static final String SELECTED_TAB_INDEX = "tab";

public static final String CONFIGURATION_TAB_BASIC = "basic";
public static final String CONFIGURATION_TAB_LOGGING = "logging";

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

private static final String DOT_CLASS = PageSystemConfiguration.class.getName() + ".";
Expand All @@ -86,8 +93,9 @@ public class PageSystemConfiguration extends PageAdminConfiguration {

private LoadableModel<SystemConfigurationDto> model;

public PageSystemConfiguration() {
private boolean initialized;

public PageSystemConfiguration() {
model = new LoadableModel<SystemConfigurationDto>(false) {

@Override
Expand Down Expand Up @@ -152,13 +160,38 @@ public WebMarkupContainer getPanel(String panelId) {

TabbedPanel tabPanel = new TabbedPanel(ID_TAB_PANEL, tabs);
tabPanel.setOutputMarkupId(true);
tabPanel.setSelectedTab(getTabIndex());

mainForm.add(tabPanel);

initButtons(mainForm);
}

@Override
protected void onBeforeRender() {
super.onBeforeRender();

if (!initialized) {
PageParameters params = getPageParameters();
StringValue val = params.get(SELECTED_TAB_INDEX);
String value = CONFIGURATION_TAB_BASIC;
if (val != null && !val.isNull()) {
value = val.toString();
}

int index;
switch (value) {
case CONFIGURATION_TAB_LOGGING:
index = 1;
break;
case CONFIGURATION_TAB_BASIC:
default:
index = 0;
}
getTabPanel().setSelectedTab(index);

initialized = true;
}
}

private void initButtons(Form mainForm) {
AjaxSubmitButton save = new AjaxSubmitButton(ID_SAVE, createStringResource("PageBase.button.save")) {

Expand Down Expand Up @@ -246,8 +279,8 @@ private LoggingConfigurationType createLoggingConfiguration(LoggingDto dto) {
return configuration;
}

public TabbedPanel getTabPanel(){
return (TabbedPanel)get(ID_MAIN_FORM + ":" + ID_TAB_PANEL);
private TabbedPanel getTabPanel() {
return (TabbedPanel) get(createComponentPath(ID_MAIN_FORM, ID_TAB_PANEL));
}

private ClassLoggerConfigurationType createCustomClassLogger(String name, LoggingLevelType level, String appender) {
Expand Down Expand Up @@ -364,7 +397,7 @@ private void savePerformed(AjaxRequestTarget target) {

showResultInSession(result);
target.add(getFeedbackPanel());
resetPerformed();
resetPerformed(target);
}

private void saveObjectPolicies(SystemConfigurationType systemConfig){
Expand Down Expand Up @@ -498,23 +531,13 @@ private SystemConfigurationType saveLogging(AjaxRequestTarget target, SystemConf
return config;
}

private void resetPerformed() {
private void resetPerformed(AjaxRequestTarget target) {
model.reset();

setResponsePage(new PageSystemConfiguration(){

@Override
public int getTabIndex(){
return PageSystemConfiguration.this.getTabPanel().getSelectedTab();
}
});
target.add(this);
}

private void cancelPerformed(AjaxRequestTarget target) {
resetPerformed();
}

public int getTabIndex(){
return CONFIGURATION_TAB_BASIC;
resetPerformed(target);
}
}

This file was deleted.

0 comments on commit 00af232

Please sign in to comment.