portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r738308 - in /portals/jetspeed-2/applications/j2-admin/trunk/src: main/java/org/apache/jetspeed/portlets/profiler/ webapp/WEB-INF/
Date Wed, 28 Jan 2009 00:04:44 GMT
Author: ate
Date: Wed Jan 28 00:04:43 2009
New Revision: 738308

URL: http://svn.apache.org/viewvc?rev=738308&view=rev
Log:
JS2-880: Full Wicket implementation of the admin portlets
See: https://issues.apache.org/jira/browse/JS2-880

Niels van Kampenhout contributed a Wicket rewrite of the Profiler admin portlet,
see: https://issues.apache.org/jira/browse/JS2-880?focusedCommentId=12667338#action_12667338

Great work Niels, this really helps us getting the job done!

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$ActionPanel.html
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel$CriterionEditPanel.html
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel.html
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin.html
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin.java
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdminApplication.java
  (with props)
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$ActionPanel.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin%24ActionPanel.html?rev=738308&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$ActionPanel.html
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$ActionPanel.html
Wed Jan 28 00:04:43 2009
@@ -0,0 +1,21 @@
+<!-- 
+  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.
+-->
+<wicket:panel>
+    <a href="#" wicket:id="link">
+        <span wicket:id="label">link</span>
+    </a>
+</wicket:panel>

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$ActionPanel.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$ActionPanel.html
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$ActionPanel.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel$CriterionEditPanel.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin%24RuleEditPanel%24CriterionEditPanel.html?rev=738308&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel$CriterionEditPanel.html
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel$CriterionEditPanel.html
Wed Jan 28 00:04:43 2009
@@ -0,0 +1,81 @@
+<!-- 
+  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.
+-->
+<wicket:panel>
+
+    <div style="border:1px solid black; margin:4px; padding:4px;">
+
+	    <form wicket:id="criterionEditForm">
+	    
+	        <span wicket:id="feedbackPanel">feedback message</span>
+	    
+	        <table cellpadding="2">
+	            <tr>
+	                <td>
+	                    <span wicket:id="criterionNameLabel">Name</span>
+	                </td>
+	                <td>
+	                    <input wicket:id="criterionNameField"/>
+	                </td>
+	            </tr>
+	            <tr>
+	                <td>
+	                    <span wicket:id="criterionValueLabel">Name</span>
+	                </td>
+	                <td>
+	                    <input wicket:id="criterionValueField"/>
+	                </td>
+	            </tr>
+	            <tr>
+	                <td>
+	                    <span wicket:id="criterionResolverTypeLabel">ResolverType</span>
+	                </td>
+	                <td>
+	                    <select wicket:id="criterionResolverTypeField">
+	                        <option>option 1</option>
+	                        <option>option 2</option>
+	                    </select>
+	                </td>
+	            </tr>
+	            <tr>
+	                <td>
+	                    <span wicket:id="criterionFallbackLabel">Fallback</span>
+	                </td>
+	                <td>
+	                    <select wicket:id="criterionFallbackField">
+	                        <option>option 1</option>
+	                        <option>option 2</option>
+	                    </select>
+	                </td>
+	            </tr>
+	            <tr>
+	                <td>
+	                    <span wicket:id="criterionOrderLabel">Order</span>
+	                </td>
+	                <td>
+	                    <input wicket:id="criterionOrderField"/>
+	                </td>
+	            </tr>
+	        </table>
+	        
+	        <input type="submit" value="Save Criterion" wicket:id="saveCriterionButton"/>
+	        <input type="submit" value="Remove Criterion" wicket:id="removeCriterionButton"/>
+	    
+	    </form>
+
+    </div>
+
+</wicket:panel>
\ No newline at end of file

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel$CriterionEditPanel.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel$CriterionEditPanel.html
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel$CriterionEditPanel.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin%24RuleEditPanel.html?rev=738308&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel.html
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel.html
Wed Jan 28 00:04:43 2009
@@ -0,0 +1,64 @@
+<!-- 
+  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.
+-->
+<wicket:panel>
+    <div style="border:1px solid black; margin:4px; padding: 4px;">
+	    <form wicket:id="ruleEditForm">
+	        <span wicket:id="feedbackPanel">feedback message</span>
+	
+	        <table cellpadding="2">
+	            <tr>
+	                <td>
+	                    <span wicket:id="ruleIdLabel">rule id</span>
+	                </td>
+	                <td>
+	                    <input wicket:id="ruleIdField"/>
+	                </td>
+	            </tr>
+	            <tr>
+	                <td>
+	                    <span wicket:id="ruleTitleLabel">rule id</span>
+	                </td>
+	                <td>
+	                    <input wicket:id="ruleTitleField"/>
+	                </td>
+	            </tr>
+	            <tr>
+	                <td>
+	                    <span wicket:id="ruleClassLabel">rule class</span>
+	                </td>
+	                <td>
+				        <select wicket:id="ruleClassField">
+				            <option>option 1</option>
+				            <option>option 2</option>
+				        </select>                
+	                </td>
+	            </tr>
+	        </table>
+	        
+	        <span wicket:id="ruleCriteriaLabel">rule criteria</span>
+	        <table wicket:id="ruleCriteriaTable" cellpadding="2"></table>
+	
+	        <input type="submit" value="New Criterion" wicket:id="newCriterionButton"/>
+	        
+            <div wicket:id="criterionEditPanel">criterionEditPanel</div>
+	        
+	        <input type="submit" value="Save Rule" wicket:id="ruleSaveButton"/>
+	        <input type="submit" value="Remove Rule" wicket:id="ruleRemoveButton"/>
+	        
+	    </form>
+    </div>
+</wicket:panel>
\ No newline at end of file

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel.html
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin$RuleEditPanel.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin.html?rev=738308&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin.html
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin.html
Wed Jan 28 00:04:43 2009
@@ -0,0 +1,38 @@
+<!-- 
+  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" >
+
+    <table>
+        <tr>
+            <td>
+			    <form wicket:id="rulesForm">
+			        <table cellpadding="2" width="100%">
+			            <tr wicket:id="rules">
+			                <td><span wicket:id="ruleId"></span></td>
+			            </tr>
+			        </table>
+			        <div wicket:id="rulesPaging"></div>
+			        <input type="submit" value="New Rule" wicket:id="newRuleButton"/>
+			    </form>
+            </td>
+            <td>
+                <div wicket:id="ruleEditPanel">ruleEditPanel</div>
+            </td>
+        </tr>
+    </table>
+
+</html>

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

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin.java?rev=738308&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdmin.java
Wed Jan 28 00:04:43 2009
@@ -0,0 +1,492 @@
+/*
+ * 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.profiler;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.portlet.PortletRequest;
+
+import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.profiler.Profiler;
+import org.apache.jetspeed.profiler.ProfilerException;
+import org.apache.jetspeed.profiler.rules.ProfilingRule;
+import org.apache.jetspeed.profiler.rules.RuleCriterion;
+import org.apache.wicket.RequestContext;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.HeadersToolbar;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.NavigationToolbar;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.ChoiceRenderer;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.PageableListView;
+import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
+
+public class WicketProfilerAdmin extends WebPage {
+
+    List<ProfilingRule> rules;
+    protected ProfilingRule profilingRule;
+
+    public WicketProfilerAdmin() {
+
+        final RuleEditPanel ruleEditPanel = new RuleEditPanel("ruleEditPanel");
+
+        rules = new ArrayList<ProfilingRule>(getProfiler().getRules());
+
+        Form rulesForm = new Form("rulesForm");
+
+        // list of existing rules
+        PageableListView rulesList = new PageableListView("rules", new PropertyModel(this,
"rules"), 10) {
+
+            @Override
+            protected void populateItem(ListItem item) {
+                final ProfilingRule rule = (ProfilingRule) item.getModelObject();
+                
+                item.add(new ActionPanel("ruleId", new Model(rule), new Link("link", new
Model(rule)) {
+
+                    @Override
+                    public void onClick() {
+                        ProfilingRule rule = (ProfilingRule) getModelObject();
+                        setProfilingRule(rule);
+                        ruleEditPanel.setVisible(true);
+                        ruleEditPanel.hideCriterionEditPanel();
+                        ruleEditPanel.ruleIdFieldReadOnly(true);
+                    }
+                }, "id"));
+                
+            }
+
+        };
+        
+        rulesForm.add(rulesList);
+        rulesForm.add(new PagingNavigator("rulesPaging", rulesList));
+        add(rulesForm);
+
+        // button the create a new rule
+        Button newRuleButton = new Button("newRuleButton") {
+
+            @Override
+            public void onSubmit() {
+                System.out.println("newRuleButton.onSubmit");
+                Profiler profiler = getProfiler();
+                try
+                {
+                    Class defaultClass = profiler.getClass().getClassLoader().loadClass("org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule");
+                    setProfilingRule((ProfilingRule)defaultClass.newInstance());
+                    ruleEditPanel.setVisible(true);
+                    ruleEditPanel.hideCriterionEditPanel();
+                    ruleEditPanel.ruleIdFieldReadOnly(false);
+                }
+                catch (Exception e)
+                {
+                    System.out.println("Failed to CREATE NEW: rule = " + profilingRule.getId());
+                    // TODO add error message to feedback panel            
+                }
+            }
+            
+            
+            
+        };
+        rulesForm.add(newRuleButton);
+        
+        // form to edit new or selected rule
+        add(ruleEditPanel);
+        ruleEditPanel.setVisible(false);
+
+    }
+
+    public ProfilingRule getProfilingRule() {
+        return profilingRule;
+    }
+
+    public void setProfilingRule(ProfilingRule profilingRule) {
+        this.profilingRule = profilingRule;
+    }
+
+    protected PortletRequest getPortletRequest() {
+        return ((PortletRequestContext) RequestContext.get()).getPortletRequest();
+    }
+
+    protected Profiler getProfiler() {
+        return (Profiler) getPortletRequest().getAttribute(CommonPortletServices.CPS_PROFILER_COMPONENT);
+    }
+
+    
+    /**
+     * A panel containing a link with a label.
+     */
+    class ActionPanel extends Panel
+    {
+        public ActionPanel(String id, IModel model, Link link, String propertyExpression)
+        {
+            super(id, model);
+            link.add(new Label("label", new PropertyModel(model.getObject(), propertyExpression)));
+            add(link);
+        }
+    }    
+    
+    /**
+     * The form to edit the selected profiling rule.
+     *
+     */
+    protected class RuleEditPanel extends Panel {
+
+        private List<String> classNames = Arrays.asList(new String[] {
+                "org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule",
+                "org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule" });
+        protected RuleCriterion criterion;
+        protected CriterionEditPanel criterionEditPanel;
+        protected TextField ruleIdField;
+
+        public RuleEditPanel(String id) {
+            super(id);
+            
+            Form ruleEditForm = new Form("ruleEditForm");
+            
+            FeedbackPanel feedbackPanel = new FeedbackPanel("feedbackPanel");
+            ruleEditForm.add(feedbackPanel);
+            
+            ruleEditForm.add(new Label("ruleIdLabel", "Rule ID"));
+            ruleEditForm.add(new Label("ruleTitleLabel", "Rule Title"));
+            ruleEditForm.add(new Label("ruleClassLabel", "Rule Class"));
+            
+            ruleIdField = new TextField("ruleIdField", new PropertyModel(WicketProfilerAdmin.this,
"profilingRule.id"));
+            ruleIdField.setRequired(true);
+            TextField ruleTitleField = new TextField("ruleTitleField", new PropertyModel(WicketProfilerAdmin.this,
"profilingRule.title"));
+            
+            DropDownChoice ruleClassField = new DropDownChoice("ruleClassField", classNames);
+            ruleClassField.setModel(new PropertyModel(WicketProfilerAdmin.this, "profilingRule.classname"));
+            
+            Button ruleSaveButton = new Button("ruleSaveButton") {
+
+                @Override
+                public void onSubmit() {
+                    Profiler profiler = getProfiler();
+                    try {
+                        profiler.storeProfilingRule(profilingRule);
+                        if (!rules.contains(profilingRule)) {
+                            rules.add(profilingRule);
+                        }
+                    } catch (ProfilerException e) {
+                        System.out.println("Failed to UPDATE: rule = " + profilingRule.getId());
+                        e.printStackTrace();
+                        // TODO add error message to feedback panel
+                    }
+                }
+                
+            };
+
+            Button ruleRemoveButton = new Button("ruleRemoveButton") {
+
+                @Override
+                public void onSubmit() {
+                    Profiler profiler = getProfiler();
+                    try {
+                        if (rules.contains(profilingRule)) {
+                            rules.remove(profilingRule);
+                        }
+                        profiler.deleteProfilingRule(profilingRule);
+                        profilingRule = null;
+                        RuleEditPanel.this.setVisible(false);
+                    } catch (ProfilerException e) {
+                        System.out.println("Failed to REMOVE: rule = " + profilingRule.getId());
+                        e.printStackTrace();
+                        // TODO add error message to feedback panel
+                    }
+                }
+                
+            };
+            
+            ruleEditForm.add(ruleIdField);
+            ruleEditForm.add(ruleTitleField);
+            ruleEditForm.add(ruleClassField);
+            ruleEditForm.add(ruleSaveButton);
+            ruleEditForm.add(ruleRemoveButton);
+
+            
+            // the list of criteria for the selected rule
+            
+            ruleEditForm.add(new Label("ruleCriteriaLabel", "Rule Criteria"));
+            
+            SortableDataProvider dataProvider = new SortableDataProvider()
+            {
+                public int size()
+                {
+                    return profilingRule.getRuleCriteria().size();
+                }
+
+                public IModel model(Object object)
+                {
+                    RuleCriterion ruleCriterion = (RuleCriterion) object;
+                    return new Model(ruleCriterion);
+                }
+
+                public Iterator iterator(int first, int count)
+                {
+                    return new ArrayList(profilingRule.getRuleCriteria()).subList(first,
first + count).iterator();
+                }
+            };
+            IColumn[] columns = { new AbstractColumn(new Model("Name")) {
+
+                public void populateItem(Item cellItem, String componentId, IModel rowModel)
{
+                    //cellItem.add(new CriterionLink(componentId, rowModel));
+                    cellItem.add(new ActionPanel(componentId, rowModel, new Link("link",
rowModel) {
+                        public void onClick()
+                        {
+                            setCriterion((RuleCriterion) getModelObject());
+                            criterionEditPanel.setVisible(true);
+                        }
+                    }, "name"));
+                }
+                
+            }, 
+                    new PropertyColumn(new Model("Value"), "value"),
+                    new PropertyColumn(new Model("Resolver Type"), "type"),
+                    new PropertyColumn(new Model("Fallback Type"), "fallbackType"),
+                    new PropertyColumn(new Model("Order"), "fallbackOrder") };
+            
+            DataTable ruleCriteriaTable = new DataTable("ruleCriteriaTable", columns, dataProvider,
10);
+
+            ruleCriteriaTable.addTopToolbar(new HeadersToolbar(ruleCriteriaTable, dataProvider));
+            ruleCriteriaTable.addBottomToolbar(new NavigationToolbar(ruleCriteriaTable));
+            ruleEditForm.add(ruleCriteriaTable);
+
+            Button newCriterionButton = new Button("newCriterionButton") {
+
+                @Override
+                public void onSubmit() {
+                    Profiler profiler = getProfiler();
+                    try {
+                        criterion = profiler.createRuleCriterion();
+                        criterionEditPanel.setVisible(true);
+                    } catch (ClassNotFoundException e) {
+                        // TODO put message on feedback panel
+                        e.printStackTrace();
+                        System.out.println("Could not create new rule criterion: " + e.getMessage());
+                    }
+                }
+                
+            };
+            ruleEditForm.add(newCriterionButton);
+            
+            setCriterion(null);
+            criterionEditPanel = new CriterionEditPanel("criterionEditPanel");
+            ruleEditForm.add(criterionEditPanel);
+
+            criterionEditPanel.setVisible(false);
+            
+            add(ruleEditForm);
+            
+        }
+
+        public RuleCriterion getCriterion() {
+            return criterion;
+        }
+
+        public void setCriterion(RuleCriterion criterion) {
+            this.criterion = criterion;
+        }
+        
+        
+        protected void hideCriterionEditPanel() {
+            criterionEditPanel.setVisible(false);
+        }
+
+        protected void ruleIdFieldReadOnly(boolean readOnly) {
+            ruleIdField.setEnabled(!readOnly);
+        }
+        
+        /**
+         * Form to edit selected rule criterion.
+         *
+         */
+        protected class CriterionEditPanel extends Panel {
+
+            private static final String FALLBACK_CONTINUE = "Continue";
+            private static final String FALLBACK_STOP = "Stop";
+            private static final String FALLBACK_LOOP = "Loop";
+            
+            private List<String> resolvers = Arrays.asList(new String[] {
+                    "request",
+                    "session",
+                    "request.session",
+                    "hard.coded",
+                    "group.role.user",
+                    "user",
+                    "group",
+                    "role",
+                    "mediatype",
+                    "country",
+                    "language",
+                    "roles",
+                    "path",
+                    "page",
+                    "path.session",
+                    "user.attribute",
+                    "navigation",
+                    "ip",
+                    "hostname" });
+
+            private List<Integer> fallbackTypes = Arrays.asList(new Integer[] {
+                    new Integer(RuleCriterion.FALLBACK_CONTINUE), 
+                    new Integer(RuleCriterion.FALLBACK_STOP), 
+                    new Integer(RuleCriterion.FALLBACK_LOOP)
+            });
+
+            public CriterionEditPanel(String id) {
+                super(id);
+                
+                Form criterionEditForm = new Form("criterionEditForm");
+
+                FeedbackPanel feedbackPanel = new FeedbackPanel("feedbackPanel");
+                criterionEditForm.add(feedbackPanel);
+                
+                criterionEditForm.add(new Label("criterionNameLabel", "Name"));
+                criterionEditForm.add(new Label("criterionValueLabel", "Value"));
+                criterionEditForm.add(new Label("criterionResolverTypeLabel", "Resolver Type"));
+                criterionEditForm.add(new Label("criterionFallbackLabel", "Fallback"));
+                criterionEditForm.add(new Label("criterionOrderLabel", "Order"));
+                
+                TextField criterionNameField = new TextField("criterionNameField", new PropertyModel(RuleEditPanel.this,
"criterion.name"));
+                criterionNameField.setRequired(true);
+
+                TextField criterionValueField = new TextField("criterionValueField", new
PropertyModel(RuleEditPanel.this, "criterion.value"));
+
+                DropDownChoice criterionResolverTypeField = new DropDownChoice("criterionResolverTypeField",
resolvers);
+                criterionResolverTypeField.setModel(new PropertyModel(RuleEditPanel.this,
"criterion.type"));
+                criterionResolverTypeField.setRequired(true);
+                
+                DropDownChoice criterionFallbackField = new DropDownChoice("criterionFallbackField",
fallbackTypes, new FallbackTypeChoiceRenderer());
+                criterionFallbackField.setModel(new PropertyModel(RuleEditPanel.this, "criterion.fallbackType"));
+                criterionFallbackField.setRequired(true);
+                
+                TextField criterionOrderField = new TextField("criterionOrderField", new
PropertyModel(RuleEditPanel.this, "criterion.fallbackOrder"));
+                criterionOrderField.setRequired(true);
+                
+                criterionEditForm.add(criterionNameField);
+                criterionEditForm.add(criterionValueField);
+                criterionEditForm.add(criterionResolverTypeField);
+                criterionEditForm.add(criterionFallbackField);
+                criterionEditForm.add(criterionOrderField);
+
+                Button saveCriterionButton = new Button("saveCriterionButton") {
+
+                    @Override
+                    public void onSubmit() {
+                        if (criterion.getValue() != null)
+                        {
+                            String value = criterion.getValue();
+                            value = value.trim();
+                            if (value.equals(""))
+                            {
+                                criterion.setValue(null);
+                            }
+                        }
+                        if (!profilingRule.getRuleCriteria().contains(criterion)) {
+                            profilingRule.getRuleCriteria().add(criterion);
+                        }
+                        try {
+                            Profiler profiler = getProfiler();
+                            profiler.storeProfilingRule(profilingRule);
+                        }
+                        catch (ProfilerException e) {
+                            // TODO set feeback message
+                            e.printStackTrace();
+                            System.out.println("Could not save rule criterion " + criterion.getName()
+ ": " + e.getMessage());
+                        }
+                    }
+                    
+                };
+                
+                Button removeCriterionButton = new Button("removeCriterionButton") {
+
+                    @Override
+                    public void onSubmit() {
+                        if (profilingRule.getRuleCriteria().contains(criterion)) {
+                            profilingRule.getRuleCriteria().remove(criterion);
+                        }
+                        try {
+                            Profiler profiler = getProfiler();
+                            profiler.storeProfilingRule(profilingRule);
+                        }
+                        catch (ProfilerException e) {
+                            // TODO set feeback message
+                            e.printStackTrace();
+                            System.out.println("Could not save rule criterion " + criterion.getName()
+ ": " + e.getMessage());
+                        }
+                    }
+                    
+                };
+                
+                criterionEditForm.add(saveCriterionButton);
+                criterionEditForm.add(removeCriterionButton);
+                
+                add(criterionEditForm);
+            }
+
+            /**
+             * ChoiceRenderer for fallback types.
+             */
+            private final class FallbackTypeChoiceRenderer extends ChoiceRenderer
+            {
+                /**
+                 * Constructor.
+                 */
+                public FallbackTypeChoiceRenderer()
+                {
+                }
+
+                /**
+                 * @see org.apache.wicket.markup.html.form.IChoiceRenderer#getDisplayValue(Object)
+                 */
+                public Object getDisplayValue(Object object)
+                {
+                    Integer fallbackType = (Integer) object;
+                    switch (fallbackType)
+                    {
+                    case RuleCriterion.FALLBACK_CONTINUE:
+                        return FALLBACK_CONTINUE;
+                    case RuleCriterion.FALLBACK_LOOP:
+                        return FALLBACK_LOOP;
+                    default:
+                        return FALLBACK_STOP;
+                    }
+                }
+            }            
+        }
+
+    }
+}

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

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdminApplication.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdminApplication.java?rev=738308&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdminApplication.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/profiler/WicketProfilerAdminApplication.java
Wed Jan 28 00:04:43 2009
@@ -0,0 +1,12 @@
+package org.apache.jetspeed.portlets.profiler;
+
+import org.apache.jetspeed.portlets.wicket.AbstractAdminWebApplication;
+
+public class WicketProfilerAdminApplication extends AbstractAdminWebApplication {
+
+    @Override
+    public Class getHomePage() {
+        return WicketProfilerAdmin.class;
+    }
+
+}

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

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

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

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=738308&r1=738307&r2=738308&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 Wed Jan
28 00:04:43 2009
@@ -2168,7 +2168,35 @@
         <keywords>admin,security,roles,role</keywords>            
     </portlet-info>
    </portlet>
-   <custom-portlet-mode>
+
+    <portlet>
+        <description>wicket profiler admin</description>
+        <portlet-name>WicketProfilerAdmin</portlet-name>
+        <display-name>Wicket Profiler Admin</display-name>
+        <portlet-class>org.apache.jetspeed.portlets.wicket.AdminWicketPortlet</portlet-class>
+        <init-param>
+            <name>wicketFilterPath</name>
+            <value>/profileradmin</value>
+        </init-param>
+        <init-param>
+            <name>serviceComponentNames</name>
+            <value>cps:UserManager,cps:JetspeedPrincipalManagerProvider,cps:RoleManager,cps:GroupManager,cps:Profiler,cps:AuditActivity</value>
+        </init-param>
+        <supports>
+            <mime-type>*/*</mime-type>
+            <portlet-mode>VIEW</portlet-mode>
+        </supports>
+        <supported-locale>en</supported-locale>
+        <!--<resource-bundle>org.apache.jetspeed.portlets.security.JetspeedPrincipalManagementUsers</resource-bundle>
-->
+        <portlet-info>
+            <title>Wicket Profiler Admin</title>
+            <short-title>ProfilerAdmin</short-title>
+            <keywords>admin,profiler</keywords>            
+        </portlet-info>
+    </portlet>
+    
+    
+    <custom-portlet-mode>
         <description>a Custom Edit_defaults Mode</description>            
         <portlet-mode>edit_defaults</portlet-mode>
     </custom-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=738308&r1=738307&r2=738308&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 Wed Jan 28 00:04:43
2009
@@ -114,7 +114,16 @@
         <param-value>org.apache.jetspeed.portlets.security.users.WicketUserDetailsApplication</param-value>
       </init-param>
     </filter>
-    
+
+  <filter>
+    <filter-name>WicketProfilerAdminApplication</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.profiler.WicketProfilerAdminApplication</param-value>
+    </init-param>
+  </filter>
+
     <filter>
       <filter-name>PortalSiteManagerApplication</filter-name>
       <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
@@ -151,7 +160,14 @@
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
     </filter-mapping>
-    
+
+  <filter-mapping>
+    <filter-name>WicketProfilerAdminApplication</filter-name>
+    <url-pattern>/profileradmin/*</url-pattern>
+    <dispatcher>REQUEST</dispatcher>
+    <dispatcher>INCLUDE</dispatcher>
+  </filter-mapping>
+  
     <listener>
       <listener-class>org.apache.jetspeed.webapp.logging.Log4JConfigurator</listener-class>
     </listener>



---------------------------------------------------------------------
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