You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ck...@apache.org on 2010/01/27 21:37:48 UTC

svn commit: r903822 [7/17] - in /myfaces/trinidad/trunk/trinidad-examples: ./ trinidad-components-showcase/ trinidad-components-showcase/src/ trinidad-components-showcase/src/main/ trinidad-components-showcase/src/main/java/ trinidad-components-showcas...

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/ReceivedEmailListBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/ReceivedEmailListBean.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/ReceivedEmailListBean.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/ReceivedEmailListBean.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,93 @@
+/*
+ * 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.myfaces.trinidaddemo.feature;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ *
+ */
+public class ReceivedEmailListBean {
+    private List<ReceivedEmail> list = new ArrayList<ReceivedEmail>();
+    private ReceivedEmail receivedEmail;
+    private TableBean tableBean = new TableBean();
+
+
+    public ReceivedEmailListBean(List<ReceivedEmail> list) {
+        this.list = list;
+    }
+
+    public ReceivedEmailListBean() {
+        list.add(new ReceivedEmail("jack@yahoo.com","subject1","2009.09.25 at 04:34:32","This is the content of the mail (Inbox) whitch you selected"));
+        list.add(new ReceivedEmail("john@yahoo.com","subject2","2009.09.25 at 04:34:32","content2"));
+        list.add(new ReceivedEmail("john@yahoo.com","subject2","2009.09.25 at 04:34:32","content3"));
+    }
+
+    public ReceivedEmail getReceivedEmail() {
+        return receivedEmail;
+    }
+
+    public void setReceivedEmail(ReceivedEmail receivedEmail) {
+        this.receivedEmail = receivedEmail;
+    }
+
+    public TableBean getTableBean() {
+        return tableBean;
+    }
+
+    public void setTableBean(TableBean tableBean) {
+        this.tableBean = tableBean;
+    }
+
+    public List<ReceivedEmail> getList() {
+        return list;
+    }
+
+    public void setList(List<ReceivedEmail> list) {
+        this.list = list;
+    }
+
+    public void openMail() {
+        tableBean.performReport();
+        List<Object> reportItems = tableBean.getReportItems();
+        if (reportItems.size() > 0) {
+            receivedEmail = (ReceivedEmail) reportItems.get(0);
+        } else {
+            receivedEmail = null;
+        }
+    }
+
+    public void deleteInboxEmail() {
+        tableBean.performReport();
+        List<Object> reportItems = tableBean.getReportItems();
+        for (Object reportItem : reportItems) {
+            if (list.contains((ReceivedEmail)reportItem)) {
+                list.remove(reportItem);
+            }
+        }
+        tableBean = new TableBean();
+    }
+
+    public static class ReceivedEmail extends Email{
+        public ReceivedEmail(String from, String subject, String date, String content) {
+            super(from, "Yourself", subject, date, content);
+        }
+    }
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/ReceivedEmailListBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/ReceivedEmailListBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/ReceivedEmailListBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/SentEmailListBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/SentEmailListBean.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/SentEmailListBean.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/SentEmailListBean.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,124 @@
+/*
+ * 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.myfaces.trinidaddemo.feature;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Calendar;
+import java.util.Locale;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+/**
+ *
+ */
+public class SentEmailListBean {
+    private List<SentEmail> list = new ArrayList<SentEmail>();
+    private TableBean tableBean = new TableBean();
+    private SentEmail sentEmail;
+
+
+    public SentEmailListBean(List list) {
+        this.list = list;
+    }
+
+    public SentEmailListBean() {
+        list.add(new SentEmail("jack@yahoo.com", "subject1", "2009.09.25 at 04:34:32", "This is the content of the mail (Sent) whitch you selected"));
+        list.add(new SentEmail("john@yahoo.com", "subject2", "2009.09.25 at 04:55:32", "content2"));
+        list.add(new SentEmail("john@yahoo.com", "subject2", "2009.09.25 at 04:10:32", "content3"));
+    }
+
+    public TableBean getTableBean() {
+        return tableBean;
+    }
+
+    public void setTableBean(TableBean tableBean) {
+        this.tableBean = tableBean;
+    }
+
+    public SentEmail getSentEmail() {
+        return sentEmail;
+    }
+
+    public void setSentEmail(SentEmail sentEmail) {
+        this.sentEmail = sentEmail;
+    }
+
+    public List<SentEmail> getList() {
+        return list;
+    }
+
+    public void setList(List<SentEmail> list) {
+        this.list = list;
+    }
+
+    public void openMail() {
+        tableBean.performReport();
+        List<Object> reportItems = tableBean.getReportItems();
+        if (reportItems.size() > 0) {
+            sentEmail = (SentEmail) reportItems.get(0);
+        } else {
+            sentEmail = null;
+        }
+    }
+
+    public void deleteSentEmail() {
+        tableBean.performReport();
+        List<Object> reportItems = tableBean.getReportItems();
+        for (Object reportItem : reportItems) {
+            if (list.contains((SentEmail) reportItem)) {
+                list.remove(reportItem);
+            }
+        }
+        tableBean = new TableBean();
+    }
+
+    public String newEmail() {
+        sentEmail = new SentEmail();
+        sentEmail.setFrom("Yourself");
+        Calendar now = Calendar.getInstance();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd 'at' hh:mm:ss", new Locale("de", "CH"));
+        sentEmail.setDate(formatter.format(now.getTime()));
+        return "goToNewMail";
+    }
+
+    public String save() {
+        if (!list.contains(sentEmail)) {
+            list.add(sentEmail);
+        }
+        sentEmail = null;
+        return "goToSent";
+    }
+
+    public String cancel() {
+        sentEmail = null;
+        return "goToSent";
+    }
+
+
+    public static class SentEmail extends Email {
+        public SentEmail(String to, String subject, String date, String content) {
+            super("Yourself", to, subject, date, content);
+        }
+
+        public SentEmail() {
+            super();
+        }
+    }
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/SentEmailListBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/SentEmailListBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/SentEmailListBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/TableBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/TableBean.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/TableBean.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/TableBean.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,74 @@
+/*
+ * 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.myfaces.trinidaddemo.feature;
+
+import org.apache.myfaces.trinidad.component.UIXCollection;
+import org.apache.myfaces.trinidad.component.UIXTable;
+import org.apache.myfaces.trinidad.component.UIXTree;
+import org.apache.myfaces.trinidad.model.RowKeySet;
+
+import javax.faces.component.UIComponent;
+import java.util.List;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+/**
+ *
+ */
+public class TableBean {
+    private UIComponent _table = null;
+    private List<Object> _selection;
+
+    @SuppressWarnings("unchecked")
+    public TableBean() {
+        _selection = Collections.EMPTY_LIST;
+    }
+
+    public UIComponent getTable() {
+        return _table;
+    }
+
+    public void setTable(UIComponent hgrid) {
+        _table = hgrid;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void performReport() {
+        UIXCollection table = (UIXCollection) _table;
+        final RowKeySet state;
+        if (table instanceof UIXTable)
+            state = ((UIXTable) table).getSelectedRowKeys();
+        else
+            state = ((UIXTree) table).getSelectedRowKeys();
+        Iterator<Object> selection = state.iterator();
+        Object oldKey = table.getRowKey();
+        _selection = new ArrayList<Object>();
+        while (selection.hasNext()) {
+            table.setRowKey(selection.next());
+            _selection.add(table.getRowData());
+        }
+        table.setRowKey(oldKey);
+    }
+
+    public List<Object> getReportItems() {
+        return _selection;
+    }
+
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/TableBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/TableBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/feature/TableBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ApplicationConfigurationBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ApplicationConfigurationBean.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ApplicationConfigurationBean.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ApplicationConfigurationBean.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,30 @@
+/**
+ * 
+ */
+package org.apache.myfaces.trinidaddemo.support;
+
+import java.io.Serializable;
+
+/**
+ * 
+ */
+public class ApplicationConfigurationBean implements Serializable {
+
+	private static final long serialVersionUID = -911848815332920525L;
+
+	private boolean jsBasedCodeFormatting;
+
+	/**
+	 * @return the jsBasedCodeFormatting
+	 */
+	public boolean isJsBasedCodeFormatting() {
+		return jsBasedCodeFormatting;
+	}
+
+	/**
+	 * @param jsBasedCodeFormatting the jsBasedCodeFormatting to set
+	 */
+	public void setJsBasedCodeFormatting(boolean jsBasedCodeFormatting) {
+		this.jsBasedCodeFormatting = jsBasedCodeFormatting;
+	}
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ApplicationConfigurationBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ApplicationConfigurationBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ApplicationConfigurationBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoCategoryId.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoCategoryId.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoCategoryId.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoCategoryId.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,35 @@
+/*
+ * 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.myfaces.trinidaddemo.support;
+
+/**
+ * Defines the unique identifiers of each demo category.
+ */
+public enum ComponentDemoCategoryId {
+    layout,
+    input,
+    panel,
+    output,
+    buttonsAndLinks,
+    select,
+    table,
+    showDetail,
+    navigation,
+    graphic;    
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoCategoryId.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoCategoryId.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoCategoryId.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoId.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoId.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoId.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoId.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,122 @@
+/*
+ * 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.myfaces.trinidaddemo.support;
+
+/**
+ * Defines the unique identifiers of each component that has a demo available. As a naming convention, the corresponding component 
+ * tag name is used.
+ */
+public enum ComponentDemoId {
+
+    //  Panel cathegory components
+    form,
+    group,
+    page,
+	panelAccordion,
+    panelBox,
+    panelButtonBar,
+    panelCaptionGroup,
+    panelChoice,
+    panelHeader,
+    panelLabelAndMessage,
+    panelList,
+    panelPage,
+    panelPageHeader,
+    panelPopup,
+    panelRadio,
+    panelSideBar,
+    panelTabbed,
+    panelTip,
+    
+    //  Layout cathegory components
+    panelBorderLayout,
+	panelFormLayout,
+	panelGroupLayout,
+    panelHorizontalLayout,
+    separator,
+    spacer,
+
+    //  Input cathegory components
+    inputColor,
+    inputDate,
+    inputFile,
+    inputHidden,
+    inputListOfValues,
+    inputNumberSpinbox,
+    inputText,
+
+    //  Output cathegory components
+    chart,
+    legend,
+    message,
+    messages,
+    outputDocument,
+    outputFormated,
+    outputLabel,
+    outputText,
+    progressIndicator,
+    statusIndicator,
+
+    //  Buttons & Links cathegory components
+    commnandButton,
+    commandLink,
+    goButton,
+    goLink,
+    resetButton,
+
+    //  Panel cathegory components
+    selectBooleanCheckbox,
+    selectBooleanRadio,
+    chooseColor,
+    chooseDate,
+    selectItem,
+    selectManyCheckbox,
+    selectManyListbox,
+    selectManyShuttle,
+    selectOneChoice,
+    selectOneListbox,
+    selectOneRadio,
+    selectOrderShuttle,
+    selectRangeChoiceBar,
+
+    //  Table cathegory components
+    column,
+    table,
+    treeTable,
+
+    //  Show Detail cathegory components
+    showDetail,
+    showDetailHeader,
+    showDetailItem,
+
+    //  Navigation cathegory components
+    breadCrumbs,
+    commandNavigationItem,
+    navigationTree,
+    navigationPane,
+    processChoiceBar,
+    singleStepButtonBar,
+    train,
+    tree,
+
+    //  Graphic cathegory components
+    icon,
+    image,
+    media;
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoId.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoId.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/ComponentDemoId.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemo.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemo.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemo.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,77 @@
+/*
+ * 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.myfaces.trinidaddemo.support;
+
+import java.util.List;
+
+/**
+ * Defines a component demo; a component demo groups together at least one or more variants of the same component.
+ */
+public interface IComponentDemo extends IComponentVariantDemo {
+	
+	/**
+	 * Returns the display name of this component demo.
+	 * 
+	 * @return the display name.
+	 */
+	String getDisplayName();
+	
+	/**
+	 * Returns a list containing all available demo variants of the corresponding component.
+	 * 
+	 * @return the list of available variants.
+	 */
+	List<IComponentVariantDemo> getVariants();
+	
+	/**
+	 * Returns the component variant demo identified by the given name.
+	 * 
+	 * @param name the name of the desired component variant demo.
+	 * @return the component variant demo identified by the given name, or null if it's not available.
+	 */
+	IComponentVariantDemo getVariant(String name);
+	
+	/**
+	 * Adds the specified component variant demo to this component demo.
+	 * 
+	 * @param variant the component variant demo to add.
+	 */
+	void addComponentDemoVariant(IComponentVariantDemo variant);
+	
+	/**
+	 * Sets this component demo's category to be the specified one.
+	 * 
+	 * @param category the new category of this component demo.
+	 */
+	void setCategory(IComponentDemoCategory category);
+	
+	/**
+	 * Returns a comma separated list of CSS styles classes to be applied to the columns of the component's demo dynamic part
+	 * 
+	 * @return  a comma separated list of CSS styles classes.
+	 */
+	String getColumnStyleClassNames();
+	
+	/**
+	 * Returns true if this component supports more than one variant, otherwise returns false.
+	 * 
+	 * @return true if this component supports more than one variant, false if not.
+	 */
+	boolean isSupportsMultipleVariants();
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoCategory.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoCategory.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoCategory.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoCategory.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,50 @@
+/*
+ * 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.myfaces.trinidaddemo.support;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * This interface defines a category that groups together one or more component demos.
+ */
+public interface IComponentDemoCategory extends Serializable  {
+	
+	/**
+	 * @return the name of this category.
+	 */
+	String getName();
+	
+	/**
+	 * @return the unique identifier of this category, unique across the whole application. 
+	 */
+	ComponentDemoCategoryId getId();
+
+	/**
+	 * Adds the specified component demo to this category.
+	 */
+	void addComponentDemo(IComponentDemo componentDemo);
+	
+	/**
+	 * Returns a list containing the component demos part of this category.
+	 * 
+	 * @return a list containing the component demos part of this category.
+	 */
+	List<IComponentDemo> getComponentDemos();
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoCategory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoCategory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoCategory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoVariantId.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoVariantId.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoVariantId.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoVariantId.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,25 @@
+/*
+ * 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.myfaces.trinidaddemo.support;
+
+/**
+ *
+ */
+public interface IComponentDemoVariantId {
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoVariantId.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoVariantId.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentDemoVariantId.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentVariantDemo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentVariantDemo.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentVariantDemo.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentVariantDemo.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,103 @@
+/*
+ * 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.myfaces.trinidaddemo.support;
+
+import java.io.Serializable;
+
+/**
+ * This interface defines a component variant demo.
+ */
+public interface IComponentVariantDemo extends Serializable {
+
+	/**
+	 * Returns the unique identifier of this component demo, unique across the whole application. 
+	 * 
+	 * @return the unique identifier of this component demo. 
+	 */
+	ComponentDemoId getId();
+	
+	/**
+	 * Returns the title to be shown at the top in the corresponding JSF page. 
+	 *  
+	 * @return the title or null if none is available.
+	 */
+	String getTitle();
+
+    /**
+     * Returns a short description about this component demo variant. Used as a value for  <meta name="description"/>
+     * 
+     * @return the short description.
+     */
+    String getDescription();    
+
+    /**
+     * Returns the path which can be used to navigate to this component variant demo.
+     * 
+     * @return the path.
+     */
+    String getDestination();
+	
+	/**
+	 * Returns the category this component demo belongs to.
+	 * 
+	 * @return the category or null if none is available.
+	 */
+	IComponentDemoCategory getCategory();
+	
+	/**
+	 * Returns  the name of this variant.
+	 * 
+	 * @return the name or null if none is available.
+	 */
+	IComponentDemoVariantId getVariantId();
+
+    /**
+     * @return
+     */
+    String getVariantDisplayName();
+
+    /**
+	 * Returns the path to the corresponding JSF page.
+	 *
+	 * @return the path or null if none is available.
+	 */
+	String getJsfResourcePath();
+
+    /**
+     * Returns the path to the corresponding JSF fragment which represents the summary of this demo.
+     *
+     * @return the resource path, or null if none exists
+     */
+    String getSummaryResourcePath();
+	
+	/**
+	 * If this component demo is a dynamic one, this method returns the path to the backing bean's java source file. 
+	 * 
+	 * @return the path to the backing bean's java source file.
+	 */
+	String getBackingBeanResourcePath();
+	
+	/**
+	 * Returns true of this component demo is a static one, e.g. there is no dynamic behavior associated with it and  
+	 * there is no backing bean defined for it.
+	 * 
+	 * @return true if this component demo is static, otherwise returns false.
+	 */
+	boolean isStatic();
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentVariantDemo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentVariantDemo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/IComponentVariantDemo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/PrettyUrlFilter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/PrettyUrlFilter.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/PrettyUrlFilter.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/PrettyUrlFilter.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,124 @@
+/*
+ * 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.myfaces.trinidaddemo.support;
+
+import org.apache.myfaces.trinidaddemo.NavigationHandlerBean;
+import org.apache.myfaces.trinidaddemo.ComponentDemoRegistry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.Filter;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletContext;
+import javax.servlet.FilterConfig;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.FactoryFinder;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+
+/**
+ *
+ */
+public class PrettyUrlFilter implements Filter {
+
+    private static final Log log = LogFactory.getLog(PrettyUrlFilter.class);
+
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+        String requestURI = getRequestURI(request);
+        IComponentVariantDemo resultingDemo = getComponentVariantDemo(requestURI);
+
+        FacesContext fc = getFacesContext(request, response);
+        NavigationHandlerBean navigationHandler = (NavigationHandlerBean) fc.getApplication().getELResolver().getValue(fc.getELContext(), null, "navigationHandler");
+
+        navigationHandler.setCurrentComponentVariantDemo(resultingDemo);
+
+        log.info("Forwarding request [" + requestURI + "] to view [" + "/pages/componentDemo.xhtml?id="+resultingDemo.getId()+"&variantId="+resultingDemo.getVariantId()+"]");
+        if (!response.isCommitted()) {
+            request.getRequestDispatcher("/faces/pages/componentDemo.xhtml").forward(request, response);
+        }       
+    }
+
+    /**
+     * @param request
+     * @return
+     */
+    private String getRequestURI(final ServletRequest request) {
+        String requestURI = ((HttpServletRequest) request).getRequestURI();
+        String contextPath = ((HttpServletRequest) request).getContextPath();
+        if (requestURI.startsWith(contextPath)) {
+            requestURI = requestURI.substring(contextPath.length());
+        }
+        
+        return requestURI;
+    }
+
+    /**
+     * @param requestURI
+     * @return
+     */
+    private IComponentVariantDemo getComponentVariantDemo(String requestURI) {
+        int idPathIndex = requestURI.lastIndexOf("/");
+        if (idPathIndex == -1) {
+            return null;
+        }
+
+        String idPath = requestURI.substring(idPathIndex + 1);
+        String[] values = idPath.split("-");
+
+        ComponentDemoId componentDemoId = ComponentDemoId.valueOf(values[0]);
+        String variantName = values[1] ;
+        
+        IComponentDemo componentDemo = ComponentDemoRegistry.getInstance().getComponentDemo(componentDemoId);
+        IComponentVariantDemo resultingDemo = componentDemo.getVariant(variantName);
+
+        return resultingDemo;
+    }        
+
+    /**
+     * @param request
+     * @param response
+     * @return
+     */
+    private FacesContext getFacesContext(final ServletRequest request, final ServletResponse response) {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        if (facesContext != null) {
+            return facesContext;
+        }
+
+        FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder
+                .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+        LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
+                .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+        Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+
+        ServletContext servletContext = ((HttpServletRequest) request).getSession().getServletContext();
+        facesContext = contextFactory.getFacesContext(servletContext, request, response, lifecycle);
+
+        return facesContext;
+    }
+
+    public void init(FilterConfig filterConfig) throws ServletException {}
+    public void destroy() {}
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/PrettyUrlFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/PrettyUrlFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/PrettyUrlFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentDemo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentDemo.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentDemo.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentDemo.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,211 @@
+/*
+ * 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.myfaces.trinidaddemo.support.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.trinidaddemo.support.IComponentDemo;
+import org.apache.myfaces.trinidaddemo.support.ComponentDemoId;
+import org.apache.myfaces.trinidaddemo.support.IComponentDemoVariantId;
+import org.apache.myfaces.trinidaddemo.support.IComponentDemoCategory;
+import org.apache.myfaces.trinidaddemo.support.IComponentVariantDemo;
+
+/**
+ * Base implementation of {@link IComponentDemo} interface. Extend this class and implement required methods for concrete 
+ * component demos.
+ */
+public abstract class AbstractComponentDemo implements IComponentDemo {
+
+    private static final String DEFAULT_VARIANT_NAME = "Default";
+
+	private ComponentDemoId id;
+	private String displayName;
+    private IComponentDemoVariantId variantId;
+    private String variantDisplayName;
+
+    private String title;
+
+    private enum VARIANTS implements IComponentDemoVariantId {
+        Default
+    }
+	
+	private IComponentDemoCategory category;
+	
+	private Map<String, IComponentVariantDemo> variantsByName;
+	private List<IComponentVariantDemo> variants;
+
+    /**
+     * Constructor.
+     * 
+     * @param id
+     * @param displayName
+     */
+    public AbstractComponentDemo(ComponentDemoId id, String displayName) {
+        this(id, displayName, VARIANTS.Default, DEFAULT_VARIANT_NAME);
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param id
+     * @param displayName
+     * @param variantId
+     */
+    public AbstractComponentDemo(ComponentDemoId id, String displayName, IComponentDemoVariantId variantId) {
+        this(id, displayName, variantId, variantId.toString());
+    }
+
+	/**
+	 * Constructor.
+	 * 
+	 * @param id the unique id of this component demo.
+	 * @param displayName the display name of this component demo.
+     * @param variantId the id of the variant this component demo represents.
+     * @param variantDisplayName the display name of the variant this component demo represents.
+	 */
+	public AbstractComponentDemo(ComponentDemoId id, String displayName,
+            IComponentDemoVariantId variantId, String variantDisplayName) {
+
+		this.id = id;
+		this.displayName = displayName;
+        this.variantId = variantId;
+        this.variantDisplayName = variantDisplayName;
+		
+		this.variantsByName = new HashMap<String, IComponentVariantDemo>();
+		this.variants = new ArrayList<IComponentVariantDemo>();
+		
+		//by default the component demo itself is a variant, might be the only one in the end
+		addComponentDemoVariant(this);
+
+        //determine the title to show at the top of the corresponding component demo page
+        if (DEFAULT_VARIANT_NAME.equals(DEFAULT_VARIANT_NAME)) {
+            title = getDisplayName();
+        }
+        else {
+            title = getDisplayName() + " - " + getVariantDisplayName();
+        }
+	}
+	
+	public ComponentDemoId getId() {
+		return id;
+	}
+
+    public String getDestination() {
+        StringBuilder url = new StringBuilder();
+        url.append("/component-demo/");
+        url.append(getId().toString());
+        url.append("-");
+        url.append(getVariantId());       
+
+        return url.toString();
+    }
+
+	public String getDisplayName() {
+		return displayName;
+	}
+	
+	public IComponentDemoVariantId getVariantId() {
+        return variantId;
+    }
+
+    public String getVariantDisplayName() {
+        return variantDisplayName;
+    }
+
+    public String getTitle() {
+		return title;
+	}
+
+    public String getDescription() {
+        return ComponentVariantDemoDescriptionProvider.getDescription(FacesContext.getCurrentInstance(), this);
+    }
+
+    public IComponentDemoCategory getCategory() {
+		return category;
+	}
+	
+	public void setCategory(IComponentDemoCategory category) {
+		this.category = category;
+	}
+	
+	public void addComponentDemoVariant(IComponentVariantDemo variant) {
+		if (variantsByName.get(variant.getVariantId()) != null) {
+			throw new IllegalArgumentException("Variant with name '"+variant.getVariantId()+"' already added to '"+getId()+"' demo!");
+		}
+		
+		variants.add(variant);
+		variantsByName.put(variant.getVariantId().toString(), variant);
+	}
+
+	public List<IComponentVariantDemo> getVariants() {
+		return variants;
+	}
+	
+	public IComponentVariantDemo getVariant(String name) {
+		return variantsByName.get(name);
+	}
+
+	public boolean isSupportsMultipleVariants() {
+		if (getVariants().size() > 1) {
+			return true;
+		}
+		
+		return false;
+	}
+	
+	public String getColumnStyleClassNames() {
+		if (isSupportsMultipleVariants()) {
+			return "column75percent2,column25percent2";
+		}
+		
+		return "column100percent";
+	}
+	
+	public String getBackingBeanResourcePath() {
+		return null;
+	}
+
+	public boolean isStatic() {
+		return getBackingBeanResourcePath() == null;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof AbstractComponentDemo) {
+			return getId() == ((AbstractComponentDemo)obj).getId();
+		}
+		
+		return false;
+	}
+
+	@Override
+	public int hashCode() {
+		return getId() != null ? getId().hashCode() : super.hashCode();
+	}
+
+	@Override
+	public String toString() {
+		return getDisplayName();
+	}
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentDemo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentDemo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentDemo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentVariantDemo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentVariantDemo.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentVariantDemo.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentVariantDemo.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,100 @@
+/*
+ * 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.myfaces.trinidaddemo.support.impl;
+
+import org.apache.myfaces.trinidaddemo.support.ComponentDemoId;
+import org.apache.myfaces.trinidaddemo.support.IComponentDemoCategory;
+import org.apache.myfaces.trinidaddemo.support.IComponentVariantDemo;
+import org.apache.myfaces.trinidaddemo.support.IComponentDemoVariantId;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * Base implementation of the {@link IComponentVariantDemo} interface. Extend this class and implement required methods for concrete 
+ * component variant demos.
+ */
+public abstract class AbstractComponentVariantDemo implements IComponentVariantDemo {
+	
+	private IComponentDemoVariantId variantId;
+    private String variantDisplayName;
+	
+	private AbstractComponentDemo componentDemo;
+	
+	/**
+	 * Constructor.
+	 * 
+	 * @param variantId the name of this component variant demo.
+     * @param variantDisplayName the display name of this component variant demo.
+	 * @param componentDemo the component demo owning this variant demo.
+	 */
+	public AbstractComponentVariantDemo(IComponentDemoVariantId variantId, String variantDisplayName,
+            AbstractComponentDemo componentDemo) {
+        
+		this.variantId = variantId;
+        this.variantDisplayName = variantDisplayName;
+		this.componentDemo = componentDemo;
+	}
+
+	public ComponentDemoId getId() {
+		return componentDemo.getId();
+	}
+
+    public IComponentDemoVariantId getVariantId() {
+		return variantId;
+	}
+
+    public String getVariantDisplayName() {
+        return variantDisplayName;
+    }
+
+    public IComponentDemoCategory getCategory() {
+		return componentDemo.getCategory();
+	}
+
+    public String getTitle() {
+		StringBuilder builder = new StringBuilder();
+		builder.append(componentDemo.getTitle());
+		builder.append(" - ");
+		builder.append(getVariantDisplayName());
+		
+		return builder.toString();
+	}
+
+    public String getDescription() {
+        return ComponentVariantDemoDescriptionProvider.getDescription(FacesContext.getCurrentInstance(), this);
+    }
+
+    public String getDestination() {
+        StringBuilder url = new StringBuilder();
+        url.append("/component-demo/");
+        url.append(getId().toString());
+        url.append("-");
+        url.append(getVariantId());
+
+        return url.toString();
+    }
+	
+	public String getBackingBeanResourcePath() {
+		return null;
+	}
+
+	public boolean isStatic() {
+		return getBackingBeanResourcePath() == null;
+	}
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentVariantDemo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentVariantDemo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/AbstractComponentVariantDemo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentDemoCategoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentDemoCategoryImpl.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentDemoCategoryImpl.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentDemoCategoryImpl.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,88 @@
+/*
+ * 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.myfaces.trinidaddemo.support.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.myfaces.trinidaddemo.support.ComponentDemoCategoryId;
+import org.apache.myfaces.trinidaddemo.support.IComponentDemo;
+import org.apache.myfaces.trinidaddemo.support.IComponentDemoCategory;
+
+/**
+ * Default implementation of the {@link IComponentDemoCategory} interface.
+ */
+public class ComponentDemoCategoryImpl implements IComponentDemoCategory {
+
+	private static final long serialVersionUID = -7340858926729979482L;
+
+	private ComponentDemoCategoryId id;
+	private String name;
+
+	private List<IComponentDemo> componentDemos;
+	
+	/**
+	 * Constructor. 
+	 * 
+	 * @param id the unique id of this category.
+	 * @param name the name of this category.
+	 */
+	public ComponentDemoCategoryImpl(ComponentDemoCategoryId id, String name) {
+		this.id = id;
+		this.name = name;
+
+		componentDemos = new ArrayList<IComponentDemo>();
+	}
+	
+	public void addComponentDemo(IComponentDemo componentDemo) {
+		componentDemo.setCategory(this);
+		componentDemos.add(componentDemo);
+	}
+
+	public List<IComponentDemo> getComponentDemos() {
+		return componentDemos;
+	}
+
+	public ComponentDemoCategoryId getId() {
+		return id;
+	}
+
+	public String getName() {
+		return name;
+	}
+  
+    @Override
+	public boolean equals(Object obj) {
+		if (obj instanceof ComponentDemoCategoryImpl) {
+			return getId() == ((ComponentDemoCategoryImpl)obj).getId();
+		}
+		
+		return false;
+	}
+
+	@Override
+	public int hashCode() {
+		return getId() != null ? getId().hashCode() : super.hashCode();
+	}
+
+	@Override
+	public String toString() {
+		return getName();
+	}
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentDemoCategoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentDemoCategoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentDemoCategoryImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoDescriptionProvider.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoDescriptionProvider.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoDescriptionProvider.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoDescriptionProvider.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,103 @@
+/*
+ * 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.myfaces.trinidaddemo.support.impl;
+
+import org.apache.myfaces.trinidaddemo.support.IComponentVariantDemo;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ *
+ */
+public class ComponentVariantDemoDescriptionProvider {
+
+    private static final Log log = LogFactory.getLog(ComponentVariantDemoDescriptionProvider.class);
+
+    /**
+     * @param facesContext
+     * @param componentVariantDemo
+     * @return
+     */
+    public static String getDescription(FacesContext facesContext, IComponentVariantDemo componentVariantDemo) {
+        StringBuilder description = new StringBuilder();
+
+        String summaryPath = componentVariantDemo.getSummaryResourcePath();
+        BufferedReader reader = null;
+
+        try {
+            URL summaryURL = getResourceURL(facesContext, summaryPath);
+            InputStream in = summaryURL.openStream();
+
+            reader = new BufferedReader(new InputStreamReader(in));             
+
+            try {
+                String line = reader.readLine();               
+
+                int index = 0;
+                while (line != null && index < 4) {
+                    line = line.trim();
+
+                    if (!line.contains("ui:composition") &&
+                       !line.contains("xmlns") &&
+                        line.length() != 0) {
+                            description.append(line);
+                            description.append(" ");
+                            index += 1;
+                    }
+
+                    line = reader.readLine();
+                }                
+            }
+            finally {
+                try {
+                    if (reader != null) {
+                        reader.close();
+                    }
+                }
+                catch (IOException exc) {
+                    log.error(exc);
+                }
+            }
+        }
+        catch (Exception exc) {
+            log.error(exc);
+        }
+
+        return description.toString();
+    }
+
+    /**
+     * @param facesContext
+     * @param path
+     * @return
+     * @throws MalformedURLException
+     */
+    public static URL getResourceURL(FacesContext facesContext, String path) throws MalformedURLException {
+        URL url = facesContext.getExternalContext().getResource(path);
+        return url;
+    }
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoDescriptionProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoDescriptionProvider.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoDescriptionProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoImpl.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoImpl.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoImpl.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,109 @@
+/*
+ * 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.myfaces.trinidaddemo.support.impl;
+
+import org.apache.myfaces.trinidaddemo.support.IComponentDemoVariantId;
+
+/**
+ *  Default implementation of the {@link org.apache.myfaces.trinidaddemo.support.impl.AbstractComponentVariantDemo}
+ */
+public class ComponentVariantDemoImpl extends AbstractComponentVariantDemo {
+
+    private String jsfResourcePath;
+    private String summaryResourcePath;
+    private String backingBeanResourcePath;
+
+    /**
+     * Constructor.
+     *
+     * @param variantId
+     * @param componentDemo
+     * @param jsfResourcePath
+     * @param summaryResourcePath
+     */
+    public ComponentVariantDemoImpl(IComponentDemoVariantId variantId,
+            AbstractComponentDemo componentDemo,
+            String jsfResourcePath, String summaryResourcePath) {
+        this(variantId, variantId.toString(), componentDemo, jsfResourcePath, summaryResourcePath);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param variantId
+     * @param componentDemo
+     * @param jsfResourcePath
+     * @param summaryResourcePath
+     * @param backingBeanResourcePath
+     */
+    public ComponentVariantDemoImpl(IComponentDemoVariantId variantId,
+            AbstractComponentDemo componentDemo,
+            String jsfResourcePath, String summaryResourcePath, String backingBeanResourcePath) {
+        this(variantId, variantId.toString(), componentDemo, jsfResourcePath, summaryResourcePath, backingBeanResourcePath);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param variantId
+     * @param variantDisplayName
+     * @param componentDemo
+     * @param jsfResourcePath
+     * @param summaryResourcePath
+     */
+    public ComponentVariantDemoImpl(IComponentDemoVariantId variantId, String variantDisplayName,
+            AbstractComponentDemo componentDemo,
+            String jsfResourcePath, String summaryResourcePath) {
+        this(variantId, variantDisplayName, componentDemo, jsfResourcePath, summaryResourcePath, null);
+    }   
+
+    /**
+     * Constructor,
+     *
+     * @param variantId
+     * @param variantDisplayName
+     * @param componentDemo
+     * @param jsfResourcePath
+     * @param summaryResourcePath
+     * @param backingBeanResourcePath
+     */
+    public ComponentVariantDemoImpl(IComponentDemoVariantId variantId, String variantDisplayName,
+            AbstractComponentDemo componentDemo,
+            String jsfResourcePath, String summaryResourcePath, String backingBeanResourcePath) {
+
+        super(variantId, variantDisplayName, componentDemo);
+
+        this.jsfResourcePath = jsfResourcePath;
+        this.summaryResourcePath = summaryResourcePath;
+        this.backingBeanResourcePath = backingBeanResourcePath;
+    }
+
+    public String getJsfResourcePath() {
+        return jsfResourcePath;
+    }
+
+    public String getSummaryResourcePath() {
+        return summaryResourcePath;
+    }
+
+    @Override
+    public String getBackingBeanResourcePath() {
+        return backingBeanResourcePath;
+    }
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/impl/ComponentVariantDemoImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/JsfHelper.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/JsfHelper.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/JsfHelper.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/JsfHelper.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,21 @@
+/**
+ * 
+ */
+package org.apache.myfaces.trinidaddemo.support.jsf;
+
+import javax.faces.context.FacesContext;
+
+/**
+ *
+ */
+public class JsfHelper {
+
+	/**
+	 * @param name
+	 * @return
+	 */
+	public static Object getBean(String name) {
+		FacesContext facesContext = FacesContext.getCurrentInstance();
+		return facesContext.getApplication().getELResolver().getValue(facesContext.getELContext(), null, name);
+	}
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/JsfHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/JsfHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/JsfHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSource.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSource.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSource.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSource.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,49 @@
+/*
+ * 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.myfaces.trinidaddemo.support.jsf;
+
+import org.apache.myfaces.trinidad.component.core.output.CoreOutputFormatted;
+import org.apache.myfaces.trinidad.bean.PropertyKey;
+import org.apache.myfaces.trinidad.bean.FacesBean;
+import org.apache.myfaces.trinidad.util.ComponentUtils;
+
+/**
+ *
+ */
+public class OutputSource extends CoreOutputFormatted {
+
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.trinidad.OutputSource";
+    public static final String RENDERER_TYPE = "org.apache.myfaces.trinidad.OutputSource";
+
+    static public final FacesBean.Type OUTPUT_SOURCE_TYPE = new FacesBean.Type(CoreOutputFormatted.TYPE);
+    
+    static public PropertyKey PATH_PREFIX_KEY = OUTPUT_SOURCE_TYPE.registerKey("pathPrefix", String.class);
+
+    public OutputSource() {
+        super(RENDERER_TYPE);
+    }
+
+    public String getPathPrefix() {
+        return ComponentUtils.resolveString(getProperty(PATH_PREFIX_KEY));
+    }
+
+    public void setPathPrefix(String pathPrefix) {
+        setProperty(PATH_PREFIX_KEY, pathPrefix);
+    }
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSource.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSourceRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSourceRenderer.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSourceRenderer.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSourceRenderer.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,159 @@
+/*
+ * 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.myfaces.trinidaddemo.support.jsf;
+
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.OutputFormattedRenderer;
+import org.apache.myfaces.trinidad.bean.FacesBean;
+import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidaddemo.support.ApplicationConfigurationBean;
+import org.apache.myfaces.trinidaddemo.support.util.HighlightXhtmlSource;
+import org.apache.myfaces.trinidaddemo.support.util.HighlightJavaSource;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.component.UIComponent;
+import javax.servlet.ServletContext;
+
+import com.uwyn.jhighlight.renderer.Renderer;
+
+import java.io.IOException;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.io.FileInputStream;
+
+/**
+ *
+ */
+public class OutputSourceRenderer extends OutputFormattedRenderer {
+
+    @Override
+    protected void encodeAll(FacesContext context, RenderingContext arc, UIComponent comp, FacesBean bean) throws IOException {
+    	if (canSkipRendering(context, arc, comp)) {
+            return;
+        }
+    	
+    	String path = (String)getValue(bean);
+        
+    	ResponseWriter rw = context.getResponseWriter();
+        rw.startElement("span", comp);
+
+        renderId(context, comp);
+        renderAllAttributes(context, arc, bean);
+    	
+        ApplicationConfigurationBean appConfig = (ApplicationConfigurationBean)JsfHelper.getBean("appConfig");
+        if (!appConfig.isJsBasedCodeFormatting()) {
+	        String sourceType = path.substring(path.lastIndexOf('.') + 1, path.length());
+	
+	        Renderer hlight;
+	
+	        if (sourceType.equals("xhtml")) {
+	            hlight = new HighlightXhtmlSource();
+	        }
+	        else if (sourceType.equals("java")) {
+	            hlight = new HighlightJavaSource();
+	        }
+	        else {
+	            hlight = null;
+	        } 
+	        
+	        renderSourceHighlighted(context, (OutputSource)comp, bean, hlight);
+        }
+        else {
+        	renderSourceHighlighted(context, (OutputSource)comp, bean);
+        }
+
+        rw.endElement("span");
+    }
+
+    /**
+     * @param context
+     * @param outputSource
+     * @param bean
+     * @param hlight
+     * @throws IOException
+     */
+    protected void renderSourceHighlighted(FacesContext context, OutputSource outputSource, FacesBean bean, Renderer hlight) throws IOException {
+        String sourceContent = readSource(context, outputSource, bean);
+
+        ResponseWriter rw = context.getResponseWriter();
+        rw.write(hlight.highlight(null, sourceContent, "UTF-8", true));
+    }
+    
+    /**
+     * @param context
+     * @param outputSource
+     * @param bean
+     * @throws IOException
+     */
+    protected void renderSourceHighlighted(FacesContext context, OutputSource outputSource, FacesBean bean) throws IOException {
+        String sourceContent = readSource(context, outputSource, bean);
+
+        ResponseWriter rw = context.getResponseWriter();
+
+        rw.write("<script type=\"syntaxhighlighter\" class=\"brush: "+super.getStyleUsage(bean)+"; auto-links: false; wrap-lines: true;\">");
+        rw.write(sourceContent);
+        rw.write("</script>");
+
+    }
+
+    /**
+     * @param context
+     * @param outputSource
+     * @param bean
+     * @return
+     */
+    protected String readSource(FacesContext context, OutputSource outputSource, FacesBean bean) {
+        String path = (String)getValue(bean);
+
+        String pathPrefix = outputSource.getPathPrefix();
+        if (pathPrefix == null) {
+            pathPrefix = "";
+        }
+
+        String realPath = ((ServletContext)context.getExternalContext().getContext()).getRealPath(pathPrefix + path);
+
+        String source = "";
+        InputStream in = null;
+
+        try {
+            in = new BufferedInputStream(new FileInputStream(realPath));
+            int ch;
+            while ((ch = in.read()) !=-1) {
+               source += ((char)ch);
+            }
+        }
+        catch (IOException e) {
+            e.printStackTrace();
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+        }
+        finally {
+            if (in != null)
+                try {
+                    in.close();
+                }
+                catch (IOException e) {
+                    e.printStackTrace();
+                }
+        }
+
+        return source;
+    }
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSourceRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSourceRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/jsf/OutputSourceRenderer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/util/EvalMapAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/util/EvalMapAdapter.java?rev=903822&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/util/EvalMapAdapter.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/util/EvalMapAdapter.java Wed Jan 27 20:37:29 2010
@@ -0,0 +1,75 @@
+/*
+ * 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.myfaces.trinidaddemo.support.util;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * An abstract adapter that exists as a convenience for creating evaluation Maps.
+ */
+public abstract class EvalMapAdapter implements Map<String, Object> {
+
+	public abstract Object get(Object key);
+	
+	public void clear() {
+		throw new UnsupportedOperationException();
+	}
+
+	public boolean containsKey(Object key) {
+		throw new UnsupportedOperationException();
+	}
+
+	public boolean containsValue(Object value) {
+		throw new UnsupportedOperationException();
+	}
+
+	public Set<java.util.Map.Entry<String, Object>> entrySet() {
+		throw new UnsupportedOperationException();
+	}
+
+	public boolean isEmpty() {
+		throw new UnsupportedOperationException();
+	}
+
+	public Set<String> keySet() {
+		throw new UnsupportedOperationException();
+	}
+
+	public Object put(String key, Object value) {
+		throw new UnsupportedOperationException();
+	}
+
+	public void putAll(Map<? extends String, ? extends Object> t) {
+		throw new UnsupportedOperationException();
+	}
+
+	public Object remove(Object key) {
+		throw new UnsupportedOperationException();
+	}
+
+	public int size() {
+		throw new UnsupportedOperationException();
+	}
+
+	public Collection<Object> values() {
+		throw new UnsupportedOperationException();
+	}
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/util/EvalMapAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/util/EvalMapAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/support/util/EvalMapAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain