/* * Copyright (c) 2010-2016 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.util; import org.apache.commons.lang.StringUtils; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.StringResourceModel; import com.evolveum.midpoint.gui.api.page.PageBase; /** * @author lazyman */ @Deprecated public abstract class BaseDeprecatedPanel<T> extends Panel { private IModel<T> model; private boolean initialized; public BaseDeprecatedPanel(String id, IModel<T> model) { super(id); this.model = model; } @Override protected void onBeforeRender() { super.onBeforeRender(); if (initialized) { return; } initLayout(); initialized = true; } protected IModel<T> getModel() { return model; } public String getString(String resourceKey, Object... objects) { return createStringResource(resourceKey, objects).getString(); } public StringResourceModel createStringResource(String resourceKey, Object... objects) { return PageBase.createStringResourceStatic(this, resourceKey, objects); // return new StringResourceModel(resourceKey, this, null, resourceKey, objects); } public StringResourceModel createStringResource(Enum e) { String resourceKey = e.getDeclaringClass().getSimpleName() + "." + e.name(); return createStringResource(resourceKey); } public PageBase getPageBase() { return (PageBase) getPage(); } protected void initLayout() { } protected String createComponentPath(String... components) { return StringUtils.join(components, ":"); } }