Commit 38cb82df authored by Arthur Bogaart's avatar Arthur Bogaart

HSTCONFIGEDIT-174: Simplified impl of LockInfo

 - Added top-level interface LockInfo instead of inner class
 - Lock info is now detachable, allowing it to calculate its properties only once (instead of instantiating a new LockData on every call to and of the three methods inside a LockInfo, which can be a lot since these are used in isVisible methods).
  - cleaned up code
parent 720b9aaa
......@@ -38,6 +38,7 @@ import org.hippoecm.frontend.plugins.standards.icon.HippoIcon;
import org.hippoecm.frontend.service.render.RenderPlugin;
import org.hippoecm.frontend.skin.Icon;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.domain.EditorBean;
import org.slf4j.Logger;
......@@ -83,7 +84,7 @@ public abstract class EditorPlugin<K extends EditorBean> extends RenderPlugin {
&& getLockInfo().getLockedBy() == null));
}
abstract protected HstContext.HstModelContext.LockInfo getLockInfo();
abstract protected HstLockInfo getLockInfo();
protected void setFocus(FormComponent fc) {
focus = fc;
......
/*
* Copyright 2008-2013 Hippo B.V. (http://www.onehippo.com)
*
* Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
*
* 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.
......@@ -22,20 +22,19 @@ import org.hippoecm.frontend.model.JcrNodeModel;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.EditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.ContainerItemPackageDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.domain.ContainerItemPackage;
public class CatalogEditorPlugin extends EditorPlugin<ContainerItemPackage> {
private static final long serialVersionUID = 1L;
public CatalogEditorPlugin(IPluginContext context, IPluginConfig config) {
super(context, config);
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.catalog.getLockInfo();
}
......
......@@ -32,7 +32,7 @@ import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.BasicEditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.common.Parameters;
import org.hippoecm.hst.plugins.frontend.editor.common.ParametersWidget;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.ContainerItemComponentDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.description.DescriptionPanel;
......@@ -144,7 +144,7 @@ public class ContainerItemComponentEditorPlugin extends BasicEditorPlugin<Contai
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.catalog.getLockInfo();
}
......
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
*
* Copyright 2012-2015 Hippo B.V. (http://www.onehippo.com)
*
* 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.
......@@ -22,24 +22,22 @@ import org.hippoecm.frontend.model.JcrNodeModel;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.BasicEditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.ContainerItemComponentDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.domain.ContainerItemComponent;
public class ContainerItemPackageEditorPlugin extends BasicEditorPlugin<ContainerItemComponent> {
private static final long serialVersionUID = 1L;
public ContainerItemPackageEditorPlugin(IPluginContext context, IPluginConfig config) {
super(context, config);
saveLink.setEnabled(false);
saveLink.setVisible(false);
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.catalog.getLockInfo();
}
......
......@@ -42,7 +42,7 @@ import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.BasicEditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.common.Parameters;
import org.hippoecm.hst.plugins.frontend.editor.common.ParametersWidget;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.ComponentDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.ContainerComponentDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
......@@ -142,7 +142,7 @@ public class ComponentEditorPlugin extends BasicEditorPlugin<Component> {
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.component.getLockInfo();
}
......
/*
* Copyright 2008-2013 Hippo B.V. (http://www.onehippo.com)
*
* Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
*
* 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.
......@@ -21,21 +21,19 @@ import org.hippoecm.frontend.model.JcrNodeModel;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.EditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.ComponentDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.domain.Component;
public class ComponentsEditorPlugin extends EditorPlugin<Component> {
private static final long serialVersionUID = 1L;
public ComponentsEditorPlugin(IPluginContext context, IPluginConfig config) {
super(context, config);
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.component.getLockInfo();
}
......
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
*
* Copyright 2012-2015 Hippo B.V. (http://www.onehippo.com)
*
* 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.
......@@ -27,7 +27,7 @@ import org.hippoecm.frontend.dialog.IDialogService.Dialog;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.BasicEditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.ContainerComponentDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.domain.ContainerComponent;
......@@ -36,18 +36,15 @@ import org.slf4j.LoggerFactory;
public class ContainerComponentEditorPlugin extends BasicEditorPlugin<ContainerComponent> {
private static final long serialVersionUID = 1L;
static final Logger log = LoggerFactory.getLogger(ContainerComponentEditorPlugin.class);
private static final String DEFAULT_CLASSNAME = "org.hippoecm.hst.pagecomposer.builtin.components.StandardContainerComponent";
public ContainerComponentEditorPlugin(IPluginContext context, IPluginConfig config) {
super(context, config);
getBean().setComponentClassName(DEFAULT_CLASSNAME);
// disable add button (child components are added to the container using the template composer)
addLink.setVisible(false);
......@@ -56,9 +53,9 @@ public class ContainerComponentEditorPlugin extends BasicEditorPlugin<ContainerC
fc.setOutputMarkupId(true);
fc.setEnabled(!getLockInfo().isLocked());
form.add(fc);
// Choose xType widget
List<String> xTypes = new ArrayList<String>();
List<String> xTypes = new ArrayList<>();
// FIXME get values from plugin configuration
xTypes.add("HST.vBox");
xTypes.add("HST.UnorderedList");
......@@ -67,14 +64,12 @@ public class ContainerComponentEditorPlugin extends BasicEditorPlugin<ContainerC
xTypes.add("HST.Span");
final String originalXType = getBean().getXType();
final DropDownChoice dc = new DropDownChoice("xType", xTypes);
final DropDownChoice<String> dc = new DropDownChoice<>("xType", xTypes);
dc.setNullValid(false);
dc.setRequired(true);
dc.setOutputMarkupId(true);
dc.setEnabled(!getLockInfo().isLocked());
dc.add(new AjaxFormComponentUpdatingBehavior("onChange") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
if (!getBean().getXType().equals(originalXType)) {
......@@ -83,11 +78,11 @@ public class ContainerComponentEditorPlugin extends BasicEditorPlugin<ContainerC
}
});
form.add(dc);
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.component.getLockInfo();
}
......
/*
* Copyright 2015 Hippo B.V. (http://www.onehippo.com)
*
* 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 org.hippoecm.hst.plugins.frontend.editor.context;
import java.util.Calendar;
import org.apache.wicket.model.IDetachable;
public interface HstLockInfo extends IDetachable {
boolean isLocked();
String getLockedBy();
Calendar getLockedOn();
}
/*
* Copyright 2008-2014 Hippo B.V. (http://www.onehippo.com)
*
* Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
*
* 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.
......@@ -25,7 +25,7 @@ import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.core.jcr.RuntimeRepositoryException;
import org.hippoecm.hst.plugins.frontend.editor.components.ComponentEditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.PageDAO;
import org.hippoecm.hst.plugins.frontend.editor.domain.Component;
......@@ -33,18 +33,18 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PageEditorPlugin extends ComponentEditorPlugin {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(PageEditorPlugin.class);
public PageEditorPlugin(IPluginContext context, IPluginConfig config) {
super(context, config);
//Pages shouldn't be able to add nested pages
addLink.setVisible(false);
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
try {
if (((JcrNodeModel) getModel()).getNode().getPath().contains("/hst:abstractpages")) {
return hstContext.abstractPage.getLockInfo();
......@@ -66,11 +66,6 @@ public class PageEditorPlugin extends ComponentEditorPlugin {
return new PageDAO(hstContext, hstContext.page.getNamespace());
}
// @Override
// protected Dialog newAddDialog() {
// return new AddPageDialog((PageDAO) dao, this, (JcrNodeModel) getModel());
// }
@Override
public List<String> getReferenceableComponents() {
List<String> refs = hstContext.page.getReferenceables();
......
/*
* Copyright 2008-2014 Hippo B.V. (http://www.onehippo.com)
*
* Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
*
* 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.
......@@ -24,7 +24,7 @@ import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.core.jcr.RuntimeRepositoryException;
import org.hippoecm.hst.plugins.frontend.editor.EditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.PageDAO;
import org.hippoecm.hst.plugins.frontend.editor.domain.Component;
import org.slf4j.Logger;
......@@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory;
public class PagesEditorPlugin extends EditorPlugin<Component> {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(PagesEditorPlugin.class);
public PagesEditorPlugin(IPluginContext context, IPluginConfig config) {
......@@ -40,7 +39,7 @@ public class PagesEditorPlugin extends EditorPlugin<Component> {
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
try {
if (((JcrNodeModel) getModel()).getNode().getPath().contains("/hst:abstractpages")) {
return hstContext.abstractPage.getLockInfo();
......
/*
* Copyright 2008-2013 Hippo B.V. (http://www.onehippo.com)
*
* Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
*
* 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.
......@@ -22,21 +22,19 @@ import org.hippoecm.frontend.model.JcrNodeModel;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.EditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.SitemapItemDAO;
import org.hippoecm.hst.plugins.frontend.editor.domain.SitemapItem;
public class SitemapEditorPlugin extends EditorPlugin<SitemapItem> {
private static final long serialVersionUID = 1L;
public SitemapEditorPlugin(IPluginContext context, IPluginConfig config) {
super(context, config);
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.sitemap.getLockInfo();
}
......
......@@ -45,7 +45,7 @@ import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.BasicEditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.common.Parameters;
import org.hippoecm.hst.plugins.frontend.editor.common.ParametersWidget;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.DescriptionDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.SitemapItemDAO;
......@@ -72,7 +72,7 @@ public class SitemapItemEditorPlugin extends BasicEditorPlugin<SitemapItem> {
public SitemapItemEditorPlugin(final IPluginContext context, final IPluginConfig config) {
super(context, config);
final HstContext.HstNamespaceContext.LockInfo lockInfo = hstContext.sitemap.getLockInfo();
final HstLockInfo lockInfo = hstContext.sitemap.getLockInfo();
FormComponent fc;
fc = new RequiredTextField("matcher");
fc.add(new UniqueSitemapItemValidator(this, hstContext.sitemap));
......@@ -162,7 +162,7 @@ public class SitemapItemEditorPlugin extends BasicEditorPlugin<SitemapItem> {
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.sitemap.getLockInfo();
}
......
/*
* Copyright 2008-2013 Hippo B.V. (http://www.onehippo.com)
*
* Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
*
* 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.
......@@ -22,24 +22,22 @@ import org.hippoecm.frontend.model.JcrNodeModel;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.BasicEditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.SitemenuItemDAO;
import org.hippoecm.hst.plugins.frontend.editor.domain.SitemenuItem;
public class SitemenuEditorPlugin extends BasicEditorPlugin<SitemenuItem> {
private static final long serialVersionUID = 1L;
public SitemenuEditorPlugin(IPluginContext context, IPluginConfig config) {
super(context, config);
saveLink.setEnabled(false);
saveLink.setVisible(false);
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.sitemenu.getLockInfo();
}
......
......@@ -16,8 +16,6 @@
package org.hippoecm.hst.plugins.frontend.editor.sitemenu;
import java.io.Serializable;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
......@@ -28,7 +26,6 @@ import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.validator.RangeValidator;
import org.apache.wicket.validation.validator.UrlValidator;
import org.hippoecm.frontend.dialog.AbstractDialog;
......@@ -41,7 +38,7 @@ import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.BasicEditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.common.Parameters;
import org.hippoecm.hst.plugins.frontend.editor.common.ParametersWidget;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.SitemenuItemDAO;
import org.hippoecm.hst.plugins.frontend.editor.dialogs.HstSitemapItemPickerDialog;
......@@ -51,8 +48,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SitemenuItemEditorPlugin extends BasicEditorPlugin<SitemenuItem> {
private static final long serialVersionUID = 1L;
static final Logger log = LoggerFactory.getLogger(SitemenuItemEditorPlugin.class);
......@@ -64,17 +59,15 @@ public class SitemenuItemEditorPlugin extends BasicEditorPlugin<SitemenuItem> {
TextField itemName = new TextField("name");
itemName.setOutputMarkupId(true);
itemName.setEnabled(!getLockInfo().isLocked());
itemName.add(new NodeUniqueValidator<SitemenuItem>(this));
itemName.add(new NodeUniqueValidator<>(this));
form.add(itemName);
IDialogFactory dialogFactory = new IDialogFactory() {
private static final long serialVersionUID = 1L;
public AbstractDialog createDialog() {
String path = getBean().getSitemapReference();
Model model = new Model(hstContext.sitemap.absolutePath(path));
IModel<String> model = Model.of(hstContext.sitemap.absolutePath(path));
return new HstSitemapItemPickerDialog(context, config, model) {
private static final long serialVersionUID = 1L;
@Override
protected void saveNode(Node node) {
......@@ -94,14 +87,7 @@ public class SitemenuItemEditorPlugin extends BasicEditorPlugin<SitemenuItem> {
}
};
DialogLink link = new DialogLink("path", new Model() {
private static final long serialVersionUID = 1L;
@Override
public Serializable getObject() {
return BROWSE_LABEL;
}
}, dialogFactory, getDialogService());
DialogLink link = new DialogLink("path", Model.of(BROWSE_LABEL), dialogFactory, getDialogService());
link.setOutputMarkupId(true);
link.setEnabled(!getLockInfo().isLocked());
form.add(link);
......@@ -111,15 +97,15 @@ public class SitemenuItemEditorPlugin extends BasicEditorPlugin<SitemenuItem> {
sitemapReference.setEnabled(!getLockInfo().isLocked());
form.add(sitemapReference);
TextField externalLink = new TextField("externalLink");
TextField<String> externalLink = new TextField<>("externalLink");
externalLink.setOutputMarkupId(true);
IValidator urlValidator = null;
UrlValidator urlValidator = null;
String urlValidatorClassName = config.getString("url.validator", UrlValidator.class.getName());
try {
Class<?> urlValidatorClass = Class.forName(urlValidatorClassName);
urlValidator = (IValidator) urlValidatorClass.newInstance();
urlValidator = (UrlValidator) urlValidatorClass.newInstance();
} catch (Exception e) {
log.warn("Invalid url validator class: '{}'. {}", urlValidatorClassName, e);
}
......@@ -149,7 +135,7 @@ public class SitemenuItemEditorPlugin extends BasicEditorPlugin<SitemenuItem> {
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.sitemenu.getLockInfo();
}
......
/*
* Copyright 2008-2013 Hippo B.V. (http://www.onehippo.com)
*
* Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
*
* 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.
......@@ -22,21 +22,19 @@ import org.hippoecm.frontend.model.JcrNodeModel;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.hst.plugins.frontend.editor.EditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.SitemenuDAO;
import org.hippoecm.hst.plugins.frontend.editor.domain.Sitemenu;
public class SitemenusEditorPlugin extends EditorPlugin<Sitemenu> {
private static final long serialVersionUID = 1L;
public SitemenusEditorPlugin(IPluginContext context, IPluginConfig config) {
super(context, config);
}
@Override
protected HstContext.HstModelContext.LockInfo getLockInfo() {
protected HstLockInfo getLockInfo() {
return hstContext.sitemenu.getLockInfo();
}
......
......@@ -33,7 +33,7 @@ import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.frontend.plugins.standards.icon.HippoIcon;
import org.hippoecm.frontend.skin.Icon;
import org.hippoecm.hst.plugins.frontend.editor.BasicEditorPlugin;
import org.hippoecm.hst.plugins.frontend.editor.context.HstContext;
import org.hippoecm.hst.plugins.frontend.editor.context.HstLockInfo;
import org.hippoecm.hst.plugins.frontend.editor.dao.EditorDAO;
import org.hippoecm.hst.plugins.frontend.editor.dao.TemplateDAO;
import org.hippoecm.hst.plugins.frontend.editor.description.DescriptionPanel;
......@@ -63,11 +63,11 @@ public class TemplateEditorPlugin extends BasicEditorPlugin<Template> {
form.add(new CombinedRequiredValidator(renderPathComponent, scriptEditor));
//Containers widget
ListView containers = new ListView("containers") {
ListView<String> containers = new ListView<String>("containers") {
@Override
protected void populateItem(final ListItem item) {
RequiredTextField rtf = new RequiredTextField("containerName", item.getModel());
protected void populateItem(final ListItem<String> item) {
RequiredTextField<String> rtf = new RequiredTextField<>("containerName", item.getModel());