KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > editors > report > ReportOrderBy


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.editors.report;
20
21 import java.util.Iterator JavaDoc;
22
23 import javax.swing.JPanel JavaDoc;
24
25 import org.openharmonise.him.editors.report.rqom.*;
26
27
28 /**
29  *
30  * @author MATT TREANOR
31  * @version $Revision: 1.1 $
32  *
33  */

34 public class ReportOrderBy extends ReportMultiPanel {
35
36     /**
37      * @param query
38      * @param sTitle
39      */

40     public ReportOrderBy(ReportQuery query) {
41         super(query, "Order by");
42         this.setup();
43     }
44     /**
45      * Configures this component.
46      *
47      */

48     private void setup() {
49         Iterator JavaDoc itor = this.m_reportQuery.getOrderByAttributes().iterator();
50         int i = 0;
51         while (itor.hasNext()) {
52             i++;
53             Metadata metadata = (Metadata) itor.next();
54             String JavaDoc sText = "Select ";
55             if(i==1){
56                 sText += "first ";
57             } else if (i==2){
58                 sText += "second ";
59             }
60             sText += "property to order by";
61             OrderByPanel panel = new OrderByPanel(this.m_reportQuery, metadata, sText);
62             super.addValueComponent(panel);
63         }
64         this.setAllowedPanelMax(2);
65     }
66
67     /* (non-Javadoc)
68      * @see com.simulacramedia.contentmanager.editors.report.ReportMultiPanel#getNewValueComponent()
69      */

70     public JPanel JavaDoc getNewValueComponent() {
71         Metadata metadata = new Metadata(null, this.m_reportQuery);
72         this.m_reportQuery.addOrderByAttributes(metadata);
73         int i = m_reportQuery.getOrderByAttributes().size();
74         String JavaDoc sText = "Select ";
75         if(i==1){
76             sText += "first ";
77         } else if (i==2){
78             sText += "second ";
79         }
80         sText += "property to order by";
81         OrderByPanel panel = new OrderByPanel(this.m_reportQuery, metadata, sText);
82         return panel;
83     }
84
85     /* (non-Javadoc)
86      * @see com.simulacramedia.contentmanager.editors.report.ReportMultiPanel#removeValueComponent(javax.swing.JPanel)
87      */

88     public void removeValueComponent(JPanel JavaDoc valueComponent) {
89         OrderByPanel panel = (OrderByPanel) valueComponent;
90         this.m_reportQuery.removeOrderByAttributes(panel.getMetadata());
91     }
92     /* (non-Javadoc)
93      * @see com.simulacramedia.contentmanager.editors.report.ReportMultiPanel#getComponentCount()
94      */

95     public int getValueComponentCount() {
96         return m_reportQuery.getOrderByAttributes().size();
97     }
98
99 }
100
Popular Tags