Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PortletDetailsView.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PortletDetailsView.java?rev=769206&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PortletDetailsView.java (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PortletDetailsView.java Tue Apr 28 00:04:31 2009 @@ -0,0 +1,152 @@ +/* + * 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.portlet; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.apache.jetspeed.portlets.AdminPortletWebPage; +import org.apache.jetspeed.portlets.prm.MetadataPanel; +import org.apache.jetspeed.portlets.prm.ApplicationsListApplication; +import org.apache.jetspeed.portlets.prm.PortletDefinitionBean; +import org.apache.jetspeed.portlets.prm.model.ApplicationModel; +import org.apache.jetspeed.portlets.prm.model.PortletModel; +import org.apache.portals.messaging.PortletMessaging; +import org.apache.wicket.extensions.markup.html.tabs.AbstractTab; +import org.apache.wicket.extensions.markup.html.tabs.ITab; +import org.apache.wicket.extensions.markup.html.tabs.TabbedPanel; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.model.Model; + +public class PortletDetailsView extends AdminPortletWebPage +{ + private Map<String, ITab> tabs; + private String title; + private boolean dirty = true; + private PortletModel portletDefinitionModel; + + public PortletDetailsView() + { + tabs = new HashMap<String, ITab>(); + + this.title = getPortletName(); + } + + @Override + protected void onBeforeRender() + { + PortletDefinitionBean portletDefinitionBean = (PortletDefinitionBean) PortletMessaging.consume(getPortletRequest(), + ApplicationsListApplication.PRM_TOPIC, ApplicationsListApplication.SELECTED_PORTLET_EVENT); + + if (portletDefinitionBean != null) + { + this.portletDefinitionModel = new PortletModel(new ApplicationModel(getServiceLocator(), portletDefinitionBean.getAppName()), + portletDefinitionBean.getName()); + this.title = getPortletName() + " - " + portletDefinitionBean.getName(); + this.dirty = true; + } + + if (dirty) + { + constructLayout(); + dirty = false; + } + + setTitle(title); + + super.onBeforeRender(); + } + + private void constructLayout() + { + if (portletDefinitionModel == null) + { + removeAll(); + add(new Label("status", "No application selected")); + add(new Label("tabs").setEnabled(false).setVisible(false)); + } + else + { + + if (get("status") != null) + { + remove("status"); + } + add(new Label("status", "")); + + ITab detailsTab = new AbstractTab(new Model("Details")) + { + + public Panel getPanel(String panelId) + { + return new DetailsPanel(panelId, portletDefinitionModel); + } + }; + tabs.put("details", detailsTab); + + ITab metadataTab = new AbstractTab(new Model("Metadata")) + { + + public Panel getPanel(String panelId) + { + return new MetadataPanel(panelId, portletDefinitionModel); + } + }; + tabs.put("metadata", metadataTab); + + ITab preferencesTab = new AbstractTab(new Model("Preferences")) + { + + public Panel getPanel(String panelId) + { + return new PreferencePanel(panelId, portletDefinitionModel); + } + }; + tabs.put("preferences", preferencesTab); + + ITab parametersTab = new AbstractTab(new Model("Parameters")) + { + + public Panel getPanel(String panelId) + { + return new ParameterPanel(panelId, portletDefinitionModel); + } + }; + tabs.put("parameters", parametersTab); + + TabbedPanel tabbedPanel = new TabbedPanel("tabs", Arrays.asList(tabs.values().toArray(new ITab[tabs.values().size()]))); + if (get("tabs") == null) + { + tabbedPanel.setSelectedTab(0); + } + else if (get("tabs") instanceof TabbedPanel) + { + TabbedPanel current = (TabbedPanel) get("tabs"); + remove(current); + + if (current.getTabs() == tabbedPanel.getTabs()) + { + tabbedPanel.setSelectedTab(current.getSelectedTab()); + } + } + + add(tabbedPanel); + } + } +}
Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PortletDetailsView.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PortletDetailsView.java ------------------------------------------------------------------------------ svn:keywords = Id Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.html URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.html?rev=769206&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.html (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.html Tue Apr 28 00:04:31 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">Name</th> + <th class="portlet-section-subheader">Value</th> + <wicket:fragment wicket:id="itemFragment"> + <td class="portlet-section-body"><input type="text" wicket:id="name"/></td> + <td class="portlet-section-body" wicket:id="values"> + <input type="text" wicket:id="value"/> + </td> + </wicket:fragment> + <wicket:fragment wicket:id="newFragment"> + <td style="border-top:1px dashed #000;"><input wicket:id="newName" style="margin-top:10px;" type="text"/></td> + <td style="border-top:1px dashed #000;"><input wicket:id="newValue" 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/prm/portlet/PreferencePanel.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.html ------------------------------------------------------------------------------ svn:keywords = Id Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.java?rev=769206&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.java (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.java Tue Apr 28 00:04:31 2009 @@ -0,0 +1,188 @@ +/* + * 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.portlet; + +import java.util.Iterator; + +import org.apache.jetspeed.components.portletregistry.RegistryException; +import org.apache.jetspeed.om.portlet.PortletDefinition; +import org.apache.jetspeed.om.portlet.Preference; +import org.apache.jetspeed.portlets.prm.model.PortletModel; +import org.apache.jetspeed.portlets.wicket.component.editor.EditorTemplate; +import org.apache.wicket.markup.html.form.Button; +import org.apache.wicket.markup.html.form.TextField; +import org.apache.wicket.markup.html.panel.Fragment; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.markup.repeater.RefreshingView; +import org.apache.wicket.markup.repeater.util.ModelIteratorAdapter; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.apache.wicket.model.PropertyModel; + +public class PreferencePanel extends EditorTemplate<Preference> +{ + private String newName, newValue; + + public PreferencePanel(String id, PortletModel model) + { + super(id, model); + } + + /** + * TODO: first fix the duplicated name fields + */ + @Override + protected Button saveButton(String componentId) + { + final PortletModel model = (PortletModel) getDefaultModel(); + return new Button(componentId) + { + + @Override + public void onSubmit() + { + if (newName != null && newValue != null) + { + PortletDefinition def = model.getObject(); + Preference pref = def.getPortletPreferences().addPreference(newName); + pref.addValue(newValue); + } + + try + { + model.getParent().getServiceLocator().getPortletRegistry().savePortletDefinition(model.getObject()); + } + catch (RegistryException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }; + } + + @Override + public void buildNew(Fragment fragment) + { + fragment.add(new TextField<String>("newName", new PropertyModel<String>(this, "newName"))); + fragment.add(new TextField<String>("newValue", new PropertyModel<String>(this, "newValue"))); + } + + @Override + public int getColumnCount() + { + return 3; + } + + @Override + public void buildItems(Fragment fragment, final Preference model) + { + fragment.add(new TextField<String>("name", new Model<String>() + { + + @Override + public String getObject() + { + return model.getName(); + } + + @Override + public void setObject(String object) + { + System.out.println("TODO set preference name: " + object); + } + })); + + RefreshingView<String> view = new RefreshingView<String>("values") + { + + @Override + protected Iterator<IModel<String>> getItemModels() + { + return new ModelIteratorAdapter<String>(model.getValues().iterator()) + { + + @Override + protected IModel<String> model(String object) + { + return new Model<String>(object); + } + + }; + } + + @Override + protected void populateItem(Item<String> item) + { + item.add(new TextField<String>("value", item.getModel())); + } + + }; + + fragment.add(view); + } + + @Override + public void delete(IModel<Preference>[] fields) + { + PortletModel model = (PortletModel) getDefaultModel(); + for (IModel<Preference> field : fields) + { + Iterator<Preference> it = model.getObject().getPortletPreferences().getPortletPreferences().iterator(); + while (it.hasNext()) + { + if (it.next().getName().equals(field.getObject().getName())) + { + it.remove(); + break; + } + } + } + + try + { + model.getParent().getServiceLocator().getPortletRegistry().savePortletDefinition(model.getObject()); + } + catch (RegistryException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public Iterator<IModel<Preference>> getItemModels() + { + PortletModel model = (PortletModel) getDefaultModel(); + return new ModelIteratorAdapter<Preference>(model.getObject().getPortletPreferences().getPortletPreferences().iterator()) + { + + @Override + protected IModel<Preference> model(Preference object) + { + return new Model<Preference>(object); + } + + }; + } + + @Override + public IModel<Preference> getNewRowModel(Preference object) + { + return new Model<Preference>(object); + } +} Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/PreferencePanel.java ------------------------------------------------------------------------------ svn:keywords = Id Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/SecurityPanel.html URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/SecurityPanel.html?rev=769206&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/SecurityPanel.html (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/SecurityPanel.html Tue Apr 28 00:04:31 2009 @@ -0,0 +1,42 @@ +<!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">Role Name</th> + <th class="portlet-section-subheader">Role Link</th> + <th class="portlet-section-subheader">Locale/Description</th> + <wicket:fragment wicket:id="itemFragment"> + <td class="portlet-section-body"><input type="text" wicket:id="roleName"/></td> + <td class="portlet-section-body"><input type="text" wicket:id="roleLink"/></td> + <td class="portlet-section-body"><span wicket:id="localizationEditor"/></td> + </wicket:fragment> + <wicket:fragment wicket:id="newFragment"> + <td style="border-top:1px dashed #000;"><input wicket:id="newRoleName" style="margin-top:10px;" type="text"/></td> + <td style="border-top:1px dashed #000;"><input wicket:id="newRoleLink" style="margin-top:10px;" type="text"/></td> + <td style="border-top:1px dashed #000;"><input wicket:id="newLocale" style="margin-top:10px;" type="text"/><input wicket:id="newDescription" 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/prm/portlet/SecurityPanel.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/SecurityPanel.html ------------------------------------------------------------------------------ svn:keywords = Id Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/AdminWicketPortlet.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/AdminWicketPortlet.java?rev=769206&r1=769205&r2=769206&view=diff ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/AdminWicketPortlet.java (original) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/AdminWicketPortlet.java Tue Apr 28 00:04:31 2009 @@ -41,6 +41,8 @@ { public static final String INIT_PARAMS = AdminWicketPortlet.class.getName() + ".initParams"; public static final String JETSPEED_PA_IDENTIFIER = "JetspeedPAName"; + public static final String PORTLET = "javax.portlet.Portlet"; + public static final String PORTLET_TITLE = "javax.portlet.Portlet.title"; protected String paName; protected Map<String, String> initParams = null; @@ -59,12 +61,19 @@ } paName = ((JetspeedPortletContext) config.getPortletContext()).getApplicationDefinition().getName(); } - + @Override protected void processRequest(PortletRequest request, PortletResponse response,String pageType) throws PortletException, IOException { request.setAttribute(JETSPEED_PA_IDENTIFIER, this.paName); - request.setAttribute(INIT_PARAMS, this.initParams); + request.setAttribute(INIT_PARAMS, this.initParams); + request.setAttribute(PORTLET, this); + + request.setAttribute(PORTLET_TITLE, getPortletName()); + if(request instanceof RenderRequest) { + request.setAttribute(PORTLET_TITLE, this.getTitle((RenderRequest) request)); + } + super.processRequest(request, response, pageType); } Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.html URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.html?rev=769206&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.html (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.html Tue Apr 28 00:04:31 2009 @@ -0,0 +1,57 @@ +<!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:panel> + <form action="post" wicket:id="form"> + <table style="border-collapse: collapse; width: 100%; margin-top: 8px; float: left;"> + <thead> + <tr> + <th class="portlet-section-subheader"></th> + <wicket:child/> + </tr> + </thead> + <tbody> + <tr wicket:id="data"> + <td class="portlet-section-body"><input type="checkbox" wicket:id="select"/></td> + <wicket:container wicket:id="items"/> + </tr> + </tbody> + <tfoot> + <tr> + <td style="border-top:1px dashed #000;"><img wicket:id="add" style="margin-top:10px;"/></td> + <wicket:container wicket:id="new"/> + </tr> + <tr> + <td class="portlet-section-footer" wicket:id="footer"> + <input wicket:id="save" type="submit" value="Save"/> + <input wicket:id="delete" type="submit" value="Delete"/> + </td> + </tr> + </tfoot> + </table> + </form> +</wicket:panel> +</body> +</html> Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.html ------------------------------------------------------------------------------ svn:keywords = Id Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java?rev=769206&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java Tue Apr 28 00:04:31 2009 @@ -0,0 +1,154 @@ +/* + * 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.wicket.component.JavascriptEventConfirmation; +import org.apache.wicket.AttributeModifier; +import org.apache.wicket.ResourceReference; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.form.Button; +import org.apache.wicket.markup.html.form.CheckBox; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.image.Image; +import org.apache.wicket.markup.html.panel.Fragment; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.markup.repeater.RefreshingView; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; + +/** + * + * @author Ruben Alexander de Gooijer + * + * @param <T> + */ +public abstract class EditorTemplate<T> extends Panel +{ + private List<SelectableModel<T>> rows; + + public static final String ITEMS_FRAGMENT_ID = "itemFragment"; + public static final String NEW_FRAGMENT_ID = "newFragment"; + + public EditorTemplate(String id, IModel<?> model) + { + super(id, model); + + rows = new ArrayList<SelectableModel<T>>(); + + RefreshingView<T> data = new RefreshingView<T>("data") { + @Override + protected Iterator<IModel<T>> getItemModels() + { + return EditorTemplate.this.getItemModels(); + } + + @Override + protected void populateItem(Item<T> item) + { + T object = item.getModelObject(); + + final SelectableModel<T> model = rowModel(object); + rows.add(model); + + Fragment fragment = new Fragment("items", ITEMS_FRAGMENT_ID, this); + EditorTemplate.this.buildItems(fragment, model.getObject()); + + //We cannot use the PropertyModel here. The SelectableObject might implement IModel + //this causes the PropertyModel to resolve the getChecked method to the object contained inside the SelectableObject, + //which should not happen. + item.add(new CheckBox("select", new IModel<Boolean>() { + public Boolean getObject() + { + return model.getSelected(); + } + + public void setObject(Boolean object) + { + model.setSelected(object); + } + + public void detach() + { + + } + })); + item.add(fragment); + } + }; + + Form form = new Form("form"); + + form.add(data); + + Fragment newFragment = new Fragment("new", NEW_FRAGMENT_ID, this); + buildNew(newFragment); + form.add(newFragment); + + form.add(new Image("add", new ResourceReference(EditorTemplate.class, "add.png"))); + + WebMarkupContainer footer = new WebMarkupContainer("footer"); + footer.add(saveButton("save")); + Button deleteBtn = deleteButton("delete"); + deleteBtn.add(new JavascriptEventConfirmation("onclick", "Are sure you want to delete the selected fields?")); + footer.add(deleteBtn); + footer.add(new AttributeModifier("colspan", true, new Model<Integer>(Integer.valueOf(getColumnCount())))); + + form.add(footer); + add(form); + } + + + + protected Button deleteButton(String componentId) + { + return new Button(componentId) { + @Override + public void onSubmit() { + List<IModel<T>> removeList = new ArrayList<IModel<T>>(); + for(SelectableModel<T> field : rows) { + if(field.getSelected()) { + removeList.add(field); + } + } + + delete(removeList.toArray(new IModel[removeList.size()])); + } + }; + } + + public final SelectableModel<T> rowModel(T object) + { + IModel<T> model = getNewRowModel(object); + return new SelectableModel<T>(model); + } + + public abstract int getColumnCount(); + + public abstract IModel<T> getNewRowModel(T object); + + public abstract Iterator<IModel<T>> getItemModels(); + public abstract void delete(IModel<T>[] fields); + protected abstract Button saveButton(String componentId); + + public abstract void buildItems(Fragment fragment, T model); + public abstract void buildNew(Fragment fragment); +} Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java ------------------------------------------------------------------------------ svn:keywords = Id Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.html URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.html?rev=769206&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.html (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.html Tue Apr 28 00:04:31 2009 @@ -0,0 +1,39 @@ +<!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">Description</th> + <wicket:fragment wicket:id="itemFragment"> + <td class="portlet-section-body"><input type="text" wicket:id="locale"/></td> + <td class="portlet-section-body"><input type="text" wicket:id="description"/></td> + </wicket:fragment> + <wicket:fragment wicket:id="newFragment"> + <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="newDescription" 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/LocalizedDescriptionEditor.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.html ------------------------------------------------------------------------------ svn:keywords = Id Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java?rev=769206&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java Tue Apr 28 00:04:31 2009 @@ -0,0 +1,96 @@ +/* + * 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.prm.model.DescriptionModel; +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.Model; +import org.apache.wicket.model.PropertyModel; + +/** + * + * @author Ruben Alexander de Gooijer + */ +public abstract class LocalizedDescriptionEditor extends EditorTemplate<DescriptionModel> +{ + protected String newLocale, newDescription; + + public LocalizedDescriptionEditor(String id, IModel<?> model) + { + super(id, model); + } + + @Override + public int getColumnCount() + { + return 2; + } + + @Override + public void buildItems(Fragment fragment, final DescriptionModel model) + { + fragment.add(new TextField<String>("locale", new Model<String>() { + @Override + public String getObject() + { + return model.getLang(); + } + + @Override + public void setObject(String object) + { + model.setLang(object); + } + })); + + fragment.add(new TextField<String>("description", new PropertyModel<String>(model, "description"))); + } + + @Override + public void buildNew(Fragment fragment) + { + 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<DescriptionModel>> getItemModels() + { + IDataProvider<DescriptionModel> dataProvider = getDataProvider(); + Iterator<? extends DescriptionModel> it = dataProvider.iterator(0, dataProvider.size()); + List<IModel<DescriptionModel>> list = new ArrayList<IModel<DescriptionModel>>(); + while(it.hasNext()) { + list.add(dataProvider.model(it.next())); + } + return list.iterator(); + } + + @Override + public IModel<DescriptionModel> getNewRowModel(DescriptionModel object) + { + return new Model<DescriptionModel>(object); + } + + public abstract IDataProvider<DescriptionModel> getDataProvider(); +} Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java ------------------------------------------------------------------------------ svn:keywords = Id Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/SelectableModel.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/SelectableModel.java?rev=769206&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/SelectableModel.java (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/SelectableModel.java Tue Apr 28 00:04:31 2009 @@ -0,0 +1,61 @@ +/* + * 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 org.apache.wicket.model.IModel; + +/** + * + * @author Ruben Alexander de Gooijer + * + * @param <T> + */ +public class SelectableModel<T> implements IModel<T> +{ + private Boolean selected = Boolean.FALSE; + private IModel<T> model; + + public SelectableModel(IModel<T> model) + { + this.model = model; + } + + public void setSelected(Boolean selected) + { + this.selected = selected; + } + + public Boolean getSelected() + { + return selected; + } + + public void setObject(T object) + { + this.model.setObject(object); + } + + public void detach() + { + this.model.detach(); + } + + public T getObject() + { + return model.getObject(); + } +} Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/SelectableModel.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/SelectableModel.java ------------------------------------------------------------------------------ svn:keywords = Id Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/add.png URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/add.png?rev=769206&view=auto ============================================================================== Binary file - no diff available. Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/add.png ------------------------------------------------------------------------------ svn:mime-type = image/png Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml?rev=769206&r1=769205&r2=769206&view=diff ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml (original) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml Tue Apr 28 00:04:31 2009 @@ -1432,39 +1432,6 @@ </portlet-info> </portlet> -<portlet id="RegistryApplicationsList"> - <description>The Portlet Registry Manager Application List displays a lost of portlet applications deployed to this portal registry. From here you deploy, undeploy, start, stop and edit portlet applications.</description> - <portlet-name>RegistryApplicationsList</portlet-name> - <display-name>Registry Applications List</display-name> - <portlet-class>org.apache.jetspeed.portlets.wicket.AdminWicketPortlet</portlet-class> - <init-param> - <name>editPage</name> - <value>/prm/edit</value> - </init-param> - <init-param> - <name>wicketFilterPath</name> - <value>/prm</value> - </init-param> - <supports> - <mime-type>text/html</mime-type> - <portlet-mode>EDIT</portlet-mode> - <portlet-mode>VIEW</portlet-mode> - <portlet-mode>HELP</portlet-mode> - </supports> - <supported-locale>en</supported-locale> - <portlet-info> - <title>Registry Applications List</title> - <short-title>Applications</short-title> - <keywords>admin,registry,list,applications,apps,portlets,PRM</keywords> - </portlet-info> - <portlet-preferences> - <preference> - <name>rows</name> - <value>10</value> - </preference> - </portlet-preferences> - </portlet> - <portlet id="PortalDataSerializer"> <description>The Portal Data Serializer imports and exports Jetspeed data from and to Jetspeed schema. From here you import and export users, groups, roles and other Jetspeed objects.</description> @@ -1673,7 +1640,94 @@ </preference> </portlet-preferences> </portlet> - + +<portlet id="RegistryApplicationsList"> + <description>The Portlet Registry Manager Application List displays a lost of portlet applications deployed to this portal registry. From here you deploy, undeploy, start, stop and edit portlet applications.</description> + <portlet-name>RegistryApplicationsList</portlet-name> + <display-name>Registry Applications List</display-name> + <portlet-class>org.apache.jetspeed.portlets.wicket.AdminWicketPortlet</portlet-class> + <init-param> + <name>editPage</name> + <value>/prm/edit</value> + </init-param> + <init-param> + <name>wicketFilterPath</name> + <value>/prm</value> + </init-param> + <supports> + <mime-type>text/html</mime-type> + <portlet-mode>EDIT</portlet-mode> + <portlet-mode>VIEW</portlet-mode> + <portlet-mode>HELP</portlet-mode> + </supports> + <supported-locale>en</supported-locale> + <portlet-info> + <title>Registry Applications List</title> + <short-title>Applications</short-title> + <keywords>admin,registry,list,applications,apps,portlets,PRM</keywords> + </portlet-info> + <portlet-preferences> + <preference> + <name>rows</name> + <value>10</value> + </preference> + </portlet-preferences> + </portlet> + + <portlet id="ApplicationDetails"> + <description>Application Details List</description> + <portlet-name>ApplicationDetails</portlet-name> + <display-name>Application Details</display-name> + <portlet-class>org.apache.jetspeed.portlets.wicket.AdminWicketPortlet</portlet-class> + <init-param> + <name>editPage</name> + <value>/pad/edit</value> + </init-param> + <init-param> + <name>wicketFilterPath</name> + <value>/pad</value> + </init-param> + <supports> + <mime-type>text/html</mime-type> + <portlet-mode>EDIT</portlet-mode> + <portlet-mode>VIEW</portlet-mode> + <portlet-mode>HELP</portlet-mode> + </supports> + <supported-locale>en</supported-locale> + <portlet-info> + <title>Application Details</title> + <short-title>Applications</short-title> + <keywords>admin,registry,list,applications,apps,portlets,PRM</keywords> + </portlet-info> + </portlet> + + <portlet id="WicketPortletDetails"> + <description>Portlet Details Manager</description> + <portlet-name>PortletDetailsManager</portlet-name> + <display-name>Portlet Details Manager</display-name> + <portlet-class>org.apache.jetspeed.portlets.wicket.AdminWicketPortlet</portlet-class> + <init-param> + <name>editPage</name> + <value>/pdm/edit</value> + </init-param> + <init-param> + <name>wicketFilterPath</name> + <value>/pdm</value> + </init-param> + <supports> + <mime-type>text/html</mime-type> + <portlet-mode>EDIT</portlet-mode> + <portlet-mode>VIEW</portlet-mode> + <portlet-mode>HELP</portlet-mode> + </supports> + <supported-locale>en</supported-locale> + <portlet-info> + <title>Portlet Details</title> + <short-title>Applications</short-title> + <keywords>admin,registry,list,portlet,details,apps,portlets,PRM</keywords> + </portlet-info> + </portlet> + <custom-portlet-mode> <description>a Custom Edit_defaults Mode</description> <portlet-mode>edit_defaults</portlet-mode> Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml?rev=769206&r1=769205&r2=769206&view=diff ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml (original) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml Tue Apr 28 00:04:31 2009 @@ -94,6 +94,33 @@ <param-value>org.apache.jetspeed.portlets.prm.ApplicationsListApplication</param-value> </init-param> </filter> + + <filter> + <filter-name>PortletDetailsManager</filter-name> + <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> + <init-param> + <param-name>applicationClassName</param-name> + <param-value>org.apache.jetspeed.portlets.prm.portlet.PortletDetailsApplication</param-value> + </init-param> + </filter> + + <filter> + <filter-name>PortletApplicationDetailsManager</filter-name> + <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> + <init-param> + <param-name>applicationClassName</param-name> + <param-value>org.apache.jetspeed.portlets.prm.application.ApplicationDetailsApplication</param-value> + </init-param> + </filter> + + <filter> + <filter-name>RPADPortlet</filter-name> + <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> + <init-param> + <param-name>applicationClassName</param-name> + <param-value>org.apache.jetspeed.portlets.rpad.RPADApplication</param-value> + </init-param> + </filter> <filter-mapping> <filter-name>PortalSiteManagerApplication</filter-name> @@ -137,15 +164,20 @@ <dispatcher>INCLUDE</dispatcher> </filter-mapping> - <filter> - <filter-name>RPADPortlet</filter-name> - <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> - <init-param> - <param-name>applicationClassName</param-name> - <param-value>org.apache.jetspeed.portlets.rpad.RPADApplication</param-value> - </init-param> - </filter> - + <filter-mapping> + <filter-name>PortletApplicationDetailsManager</filter-name> + <url-pattern>/pad/*</url-pattern> + <dispatcher>REQUEST</dispatcher> + <dispatcher>INCLUDE</dispatcher> + </filter-mapping> + + <filter-mapping> + <filter-name>PortletDetailsManager</filter-name> + <url-pattern>/pdm/*</url-pattern> + <dispatcher>REQUEST</dispatcher> + <dispatcher>INCLUDE</dispatcher> + </filter-mapping> + <filter-mapping> <filter-name>RPADPortlet</filter-name> <url-pattern>/rpad/*</url-pattern> --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscr...@portals.apache.org For additional commands, e-mail: jetspeed-dev-h...@portals.apache.org