portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r771364 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets: prm/ prm/model/ prm/portlet/ wicket/component/editor/
Date Mon, 04 May 2009 17:16:12 GMT
Author: woonsan
Date: Mon May  4 17:16:12 2009
New Revision: 771364

URL: http://svn.apache.org/viewvc?rev=771364&view=rev
Log:
JS2-946: Improving portlet detail tab to allow to edit expirationCache value and localized
display name.

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DisplayNameBean.java
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/DisplayNameBeanModel.java
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.html
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.java
  (with props)
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/DetailsPanel.html
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/DetailsPanel.java

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DisplayNameBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DisplayNameBean.java?rev=771364&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DisplayNameBean.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DisplayNameBean.java
Mon May  4 17:16:12 2009
@@ -0,0 +1,55 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.portlets.prm;
+
+import java.util.Locale;
+
+import org.apache.jetspeed.om.portlet.DisplayName;
+import org.apache.wicket.IClusterable;
+
+public class DisplayNameBean  implements IClusterable
+{
+    private static final long serialVersionUID = 1L;
+    
+    private DisplayName displayName;
+    
+    public DisplayNameBean(DisplayName displayName)
+    {
+        this.displayName = displayName;
+    }
+    
+    public String getLocaleString()
+    {
+        return displayName.getLocale().toString();
+    }
+    
+    public Locale getLocale()
+    {
+        return displayName.getLocale();
+    }
+    
+    public String getDisplayName()
+    {
+        return displayName.getDisplayName();
+    }
+
+    public void setDisplayName(String dispName)
+    {
+        displayName.setDisplayName(dispName);
+    }
+    
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DisplayNameBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DisplayNameBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DisplayNameBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/DisplayNameBeanModel.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/DisplayNameBeanModel.java?rev=771364&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/DisplayNameBeanModel.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/DisplayNameBeanModel.java
Mon May  4 17:16:12 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.portlets.prm.model;
+
+import java.util.Locale;
+
+import org.apache.jetspeed.om.portlet.DisplayName;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.portlets.JetspeedServiceLocator;
+import org.apache.jetspeed.portlets.prm.DisplayNameBean;
+import org.apache.jetspeed.portlets.prm.PortletApplicationNodeBean;
+import org.apache.wicket.model.LoadableDetachableModel;
+
+public class DisplayNameBeanModel extends LoadableDetachableModel<DisplayNameBean>
+{
+    
+    private static final long serialVersionUID = 1L;
+    
+    private JetspeedServiceLocator locator;
+    private PortletApplicationNodeBean paNodeBean;
+    private Locale locale;
+
+    public DisplayNameBeanModel(JetspeedServiceLocator locator, PortletApplicationNodeBean
paNodeBean, DisplayNameBean displayNameBean)
+    {
+        super(displayNameBean);
+        this.locator = locator;
+        this.paNodeBean = paNodeBean;
+        this.locale = displayNameBean.getLocale();
+    }
+    
+    @Override
+    protected DisplayNameBean load()
+    {
+        PortletApplication app = locator.getPortletRegistry().getPortletApplication(paNodeBean.getApplicationName());
+        PortletDefinition def = app.getPortlet(paNodeBean.getName());
+        DisplayName displayName = def.getDisplayName(locale);
+        return new DisplayNameBean(displayName);
+    }
+    
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/DisplayNameBeanModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/DisplayNameBeanModel.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/DisplayNameBeanModel.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/DetailsPanel.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/DetailsPanel.html?rev=771364&r1=771363&r2=771364&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/DetailsPanel.html
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/DetailsPanel.html
Mon May  4 17:16:12 2009
@@ -21,6 +21,7 @@
 <head></head>
 <body>
 	<wicket:panel>
+	<form action="post" wicket:id="form">
 	<table style="border-collapse: collapse; width: 100%; margin-top: 8px; float: left;">
 		<thead>
 			<tr>
@@ -30,7 +31,7 @@
 		</thead>
 		<tr>
 			<td class="portlet-section-body">Expiration Cache</td>
-			<td class="portlet-section-body"><span wicket:id="expirationCache"></span></td>
+			<td class="portlet-section-body"><input type="text" wicket:id="expirationCache"
/></td>
 		</tr>
 		<tr>
 			<td class="portlet-section-body">Unique Name</td>
@@ -40,7 +41,18 @@
 			<td class="portlet-section-body">Class Name</td>
 			<td class="portlet-section-body"><span wicket:id="className"></span></td>
 		</tr>
+		<tr>
+		    <td class="portlet-section-body" colspan="2">
+                <span wicket:id="localizationEditor"/>
+            </td>
+        </tr>
+		<tr>
+            <td class="portlet-section-footer" colspan="2">
+                <input wicket:id="save" type="submit" value="Save"/> 
+            </td>
+        </tr>
 	</table>
+	</form>
 	</wicket:panel>
 </body>
 </html>
\ No newline at end of file

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/DetailsPanel.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/DetailsPanel.java?rev=771364&r1=771363&r2=771364&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/DetailsPanel.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/DetailsPanel.java
Mon May  4 17:16:12 2009
@@ -16,30 +16,215 @@
  */
 package org.apache.jetspeed.portlets.prm.portlet;
 
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.jetspeed.components.portletregistry.FailedToStorePortletDefinitionException;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.components.portletregistry.RegistryException;
+import org.apache.jetspeed.om.portlet.DisplayName;
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.portlets.JetspeedServiceLocator;
+import org.apache.jetspeed.portlets.prm.DisplayNameBean;
 import org.apache.jetspeed.portlets.prm.PortletApplicationNodeBean;
 import org.apache.jetspeed.portlets.wicket.AbstractAdminWebApplication;
+import org.apache.jetspeed.portlets.wicket.component.editor.LocalizedDisplayNameEditor;
 import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.markup.repeater.data.IDataProvider;
+import org.apache.wicket.markup.repeater.data.ListDataProvider;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.PropertyModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class DetailsPanel extends Panel
 {
     private static final long serialVersionUID = 1L;
     
+    static final Logger logger = LoggerFactory.getLogger(DetailsPanel.class);
+    
     private PortletApplicationNodeBean paNodeBean;
+    private Integer expirationCache;
+    private String newLocale, newDisplayName;
     
-    public DetailsPanel(String id, PortletApplicationNodeBean paNodeBean)
+    public DetailsPanel(String id, PortletApplicationNodeBean paNodeBeanParam)
     {
         super(id);
-        this.paNodeBean = paNodeBean;
+        this.paNodeBean = paNodeBeanParam;
         
         PortletApplication app = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry().getPortletApplication(this.paNodeBean.getApplicationName());
         PortletDefinition definition = app.getPortlet(this.paNodeBean.getName());
-        add(new Label("expirationCache", Integer.toString(definition.getExpirationCache())));
-        add(new Label("uniqueName", definition.getUniqueName()));
-        add(new Label("className", definition.getPortletClass()));
+        setExpirationCache(new Integer(definition.getExpirationCache()));
+        
+        Form form = new Form("form");
+        form.add(new TextField<Integer>("expirationCache", new PropertyModel<Integer>(this,
"expirationCache")));
+        form.add(new Label("uniqueName", definition.getUniqueName()));
+        form.add(new Label("className", definition.getPortletClass()));
+        
+        JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
+        
+        form.add(new LocalizedDisplayNameEditor("localizationEditor", locator, paNodeBean)
+        {
+
+            @Override
+            public IDataProvider<DisplayNameBean> getDataProvider()
+            {
+                PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
+                PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
+                PortletDefinition def = app.getPortlet(paNodeBean.getName());
+
+                List<DisplayNameBean> list = new LinkedList<DisplayNameBean>();
+
+                for (DisplayName displayName : def.getDisplayNames())
+                {
+                    list.add(new DisplayNameBean(displayName));
+                }
+
+                return new ListDataProvider<DisplayNameBean>(list);
+            }
+
+            @Override
+            public void delete(IModel<DisplayNameBean>[] fields)
+            {
+                try
+                {
+                    PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
+                    PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
+                    PortletDefinition def = app.getPortlet(paNodeBean.getName());
+                    
+                    for (Iterator<DisplayName> it = def.getDisplayNames().iterator();
it.hasNext(); )
+                    {
+                        DisplayName displayName = it.next();
+                        
+                        for (IModel<DisplayNameBean> displayNameBeanModel : fields)
+                        {
+                            if (displayNameBeanModel.getObject().getLocale().equals(displayName.getLocale()))
+                            {
+                                it.remove();
+                                break;
+                            }
+                        }
+                    }
+                    
+                    registry.savePortletDefinition(def);
+                }
+                catch (FailedToStorePortletDefinitionException e)
+                {
+                    logger.error("Failed to save portlet definition.", e);
+                }
+            }
+
+            @Override
+            protected Button saveButton(String componentId)
+            {
+                return new Button(componentId)
+                {
+
+                    @Override
+                    public void onSubmit()
+                    {
+                        PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
+                        PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
+                        PortletDefinition def = app.getPortlet(paNodeBean.getName());
+                        
+                        if (newLocale != null && newDisplayName != null)
+                        {
+                            Locale locale = new Locale(newLocale);
+                            DisplayName targetDisplayName = null;
+                            
+                            for (DisplayName displayName : def.getDisplayNames())
+                            {
+                                if (displayName.getLocale().equals(locale))
+                                {
+                                    targetDisplayName = displayName;
+                                    break;
+                                }
+                            }
+                            
+                            if (targetDisplayName == null)
+                            {
+                                targetDisplayName = def.addDisplayName(newLocale);
+                            }
+                            
+                            targetDisplayName.setDisplayName(newDisplayName);
+                            
+                            newLocale = null;
+                            newDisplayName = null;
+                        }
+
+                        try
+                        {
+                            registry.savePortletDefinition(def);
+                        }
+                        catch (RegistryException e)
+                        {
+                            logger.error("Failed to save portlet definition.", e);
+                        }
+                    }
+                };
+            }
+            
+        });
+        
+        form.add(new Button("save")
+        {
+            @Override
+            public void onSubmit()
+            {
+                try
+                {
+                    PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
+                    PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
+                    PortletDefinition def = app.getPortlet(paNodeBean.getName());
+                    def.setExpirationCache(getExpirationCache().intValue());
+                    registry.savePortletDefinition(def);
+                }
+                catch (FailedToStorePortletDefinitionException e)
+                {
+                    logger.error("Failed to store portlet definition.", e);
+                }
+            }
+        });
+        
+        add(form);
     }
 
+    public void setExpirationCache(Integer expirationCache)
+    {
+        this.expirationCache = expirationCache;
+    }
+    
+    public Integer getExpirationCache()
+    {
+        return expirationCache;
+    }
+    
+//    public void setNewLocale(String newLocale)
+//    {
+//        this.newLocale = newLocale;
+//    }
+//    
+//    public String getNewLocale()
+//    {
+//        return newLocale;
+//    }
+//    
+//    public void setNewDisplayName(String newDisplayName)
+//    {
+//        this.newDisplayName = newDisplayName;
+//    }
+//    
+//    public String getNewDisplayName()
+//    {
+//        return newDisplayName;
+//    }
+    
 }

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.html?rev=771364&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.html
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.html
Mon May  4 17:16:12 2009
@@ -0,0 +1,41 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
+<!-- 
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<html 
+	xmlns="http://www.w3.org/1999/xhtml" 
+	xmlns:wicket="http://wicket.sourceforge.net/" 
+	xml:lang="en" 
+	lang="en">
+<head></head>
+<body>
+	<wicket:extend>
+		<th class="portlet-section-subheader">Locale</th>
+		<th class="portlet-section-subheader">Display Name</th>
+		<wicket:fragment wicket:id="itemFragment">
+			<td class="portlet-section-body"><input type="text" wicket:id="locale" readonly="true"/></td>
+			<td class="portlet-section-body"><input type="text" wicket:id="displayName"/></td>
+		</wicket:fragment>
+		<wicket:fragment wicket:id="newFragment">
+		    <!-- FIXME:
+			<td style="border-top:1px dashed #000;"><input wicket:id="newLocale" style="margin-top:10px;"
type="text"/></td>
+			<td style="border-top:1px dashed #000;"><input wicket:id="newDisplayName" style="margin-top:10px;"
type="text"/></td>
+		    -->
+		</wicket:fragment>
+	</wicket:extend>
+</body>
+</html>
\ No newline at end of file

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.html
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.java?rev=771364&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.java
Mon May  4 17:16:12 2009
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.portlets.wicket.component.editor;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.jetspeed.portlets.JetspeedServiceLocator;
+import org.apache.jetspeed.portlets.prm.DisplayNameBean;
+import org.apache.jetspeed.portlets.prm.PortletApplicationNodeBean;
+import org.apache.jetspeed.portlets.prm.model.DisplayNameBeanModel;
+import org.apache.jetspeed.portlets.wicket.AbstractAdminWebApplication;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.panel.Fragment;
+import org.apache.wicket.markup.repeater.data.IDataProvider;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.PropertyModel;
+
+/**
+ * 
+ * @author Ruben Alexander de Gooijer
+ */
+public abstract class LocalizedDisplayNameEditor extends EditorTemplate<DisplayNameBean>
+{
+    private static final long serialVersionUID = 1L;
+    
+    protected JetspeedServiceLocator locator = null;
+    protected PortletApplicationNodeBean paNodeBean = null;
+
+    protected String newLocale, newDisplayName;
+    
+    public LocalizedDisplayNameEditor(String id, JetspeedServiceLocator locator, PortletApplicationNodeBean
paNodeBean)
+    {
+        super(id);
+        this.locator = locator;
+        this.paNodeBean = paNodeBean;
+    }
+
+    @Override
+    public int getColumnCount()
+    {
+        return 2;
+    }
+
+    @Override
+    public void buildItems(Fragment fragment, final DisplayNameBean displayNameBean)
+    {
+        JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
+        fragment.add(new TextField<String>("locale", new PropertyModel(new DisplayNameBeanModel(locator,
paNodeBean, displayNameBean), "localeString"))); 
+        fragment.add(new TextField<String>("displayName", new PropertyModel(new DisplayNameBeanModel(locator,
paNodeBean, displayNameBean), "displayName")));
+    }
+    
+    @Override
+    public void buildNew(Fragment fragment)
+    {
+        // FIXME:
+//        fragment.add(new TextField<String>("newLocale", new PropertyModel<String>(this,
"newLocale")));
+//        fragment.add(new TextField<String>("newDescription", new PropertyModel<String>(this,
"newDescription")));
+    }
+    
+    @Override
+    public Iterator<IModel<DisplayNameBean>> getItemModels()
+    {
+        IDataProvider<DisplayNameBean> dataProvider = getDataProvider();
+        List<IModel<DisplayNameBean>> list = new ArrayList<IModel<DisplayNameBean>>();
+        JetspeedServiceLocator locator = null;
+        PortletApplicationNodeBean paNodeBean = null;
+        String name = null;
+        
+        Iterator<? extends DisplayNameBean> it = dataProvider.iterator(0, dataProvider.size());
+        
+        while(it.hasNext()) 
+        {
+            DisplayNameBean displayNameBean = it.next();
+            list.add(new DisplayNameBeanModel(locator, paNodeBean, displayNameBean));
+        }
+        
+        return list.iterator();
+    }
+    
+    @Override
+    public IModel<DisplayNameBean> getNewRowModel(DisplayNameBean displayNameBean)
+    {
+        return new DisplayNameBeanModel(locator, paNodeBean, displayNameBean);
+    }
+    
+    public abstract IDataProvider<DisplayNameBean> getDataProvider();
+    
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDisplayNameEditor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message