001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.editors.report;
020:
021: import java.util.Iterator;
022:
023: import javax.swing.JPanel;
024:
025: import org.openharmonise.him.editors.report.rqom.*;
026:
027: /**
028: *
029: * @author MATT TREANOR
030: * @version $Revision: 1.1 $
031: *
032: */
033: public class ReportOrderBy extends ReportMultiPanel {
034:
035: /**
036: * @param query
037: * @param sTitle
038: */
039: public ReportOrderBy(ReportQuery query) {
040: super (query, "Order by");
041: this .setup();
042: }
043:
044: /**
045: * Configures this component.
046: *
047: */
048: private void setup() {
049: Iterator itor = this .m_reportQuery.getOrderByAttributes()
050: .iterator();
051: int i = 0;
052: while (itor.hasNext()) {
053: i++;
054: Metadata metadata = (Metadata) itor.next();
055: String sText = "Select ";
056: if (i == 1) {
057: sText += "first ";
058: } else if (i == 2) {
059: sText += "second ";
060: }
061: sText += "property to order by";
062: OrderByPanel panel = new OrderByPanel(this .m_reportQuery,
063: metadata, sText);
064: super .addValueComponent(panel);
065: }
066: this .setAllowedPanelMax(2);
067: }
068:
069: /* (non-Javadoc)
070: * @see com.simulacramedia.contentmanager.editors.report.ReportMultiPanel#getNewValueComponent()
071: */
072: public JPanel getNewValueComponent() {
073: Metadata metadata = new Metadata(null, this .m_reportQuery);
074: this .m_reportQuery.addOrderByAttributes(metadata);
075: int i = m_reportQuery.getOrderByAttributes().size();
076: String sText = "Select ";
077: if (i == 1) {
078: sText += "first ";
079: } else if (i == 2) {
080: sText += "second ";
081: }
082: sText += "property to order by";
083: OrderByPanel panel = new OrderByPanel(this .m_reportQuery,
084: metadata, sText);
085: return panel;
086: }
087:
088: /* (non-Javadoc)
089: * @see com.simulacramedia.contentmanager.editors.report.ReportMultiPanel#removeValueComponent(javax.swing.JPanel)
090: */
091: public void removeValueComponent(JPanel valueComponent) {
092: OrderByPanel panel = (OrderByPanel) valueComponent;
093: this .m_reportQuery.removeOrderByAttributes(panel.getMetadata());
094: }
095:
096: /* (non-Javadoc)
097: * @see com.simulacramedia.contentmanager.editors.report.ReportMultiPanel#getComponentCount()
098: */
099: public int getValueComponentCount() {
100: return m_reportQuery.getOrderByAttributes().size();
101: }
102:
103: }
|