001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.applications.designstudio.userobjects;
016:
017: import java.awt.event.ActionEvent;
018: import java.util.ArrayList;
019:
020: import com.metaboss.applications.designstudio.Application;
021: import com.metaboss.applications.designstudio.BaseAction;
022: import com.metaboss.applications.designstudio.BasePropertiesDialog;
023: import com.metaboss.applications.designstudio.BaseUserObject;
024: import com.metaboss.applications.designstudio.components.SeparatorAction;
025: import com.metaboss.applications.designstudio.propertiesdialogs.ReportPropertiesDialog;
026: import com.metaboss.applications.designstudio.propertiesview.PropertiesTableModel;
027: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
028: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Report;
030: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.ReportClass;
031: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SystemImplementationModelPackage;
032:
033: /* Report user object */
034:
035: public class ReportUserObject extends BaseUserObject {
036: public static final int ADD_INPUTFIELD = 1;
037:
038: private Report mReport = null;
039: private AddNewInputFieldAction mAddNewInputFieldAction = new AddNewInputFieldAction();
040: private AddTopLevelOutputElementAction mAddTopLevelOutputElementAction = new AddTopLevelOutputElementAction();
041:
042: public ReportUserObject(Report pReport) {
043: super (pReport, Application.REPORT_ICON);
044: mReport = pReport;
045: }
046:
047: public ReportUserObject(Report pReport, String pCaption, int pMode) {
048: super (pReport, pCaption, pMode);
049: mReport = pReport;
050: }
051:
052: // create new Report
053: public static ReportUserObject addNewReport(Domain pDomain)
054: throws Exception {
055: return (ReportUserObject) new ReportUserObject(null)
056: .addNewObject(getObjectPackage(pDomain), pDomain
057: .getReports());
058: }
059:
060: public BaseUserObject createNewObject(MetaBossModelPackage pPackage) {
061: SystemImplementationModelPackage lSystemImplementationModelPackage = pPackage
062: .getEnterpriseModel().getSystemImplementationModel();
063: ReportClass lClass = lSystemImplementationModelPackage
064: .getReport();
065: return new ReportUserObject(lClass.createReport());
066: }
067:
068: // return object root node captions
069: public String getRootNodeName() {
070: return Application.getString("reports_node");
071: }
072:
073: public Report getReport() {
074: return mReport;
075: }
076:
077: // load object properties into grid control
078: public void loadObjectProperties(PropertiesTableModel pModel)
079: throws Exception {
080: super .loadObjectProperties(pModel);
081: if (pModel == null || mReport == null)
082: return;
083:
084: pModel.AddProperty("Output Levels", new Integer(mReport
085: .getOutputLevelsCount()));
086: pModel
087: .AddProperty("Paginal", boolToString(mReport
088: .isPaginal()));
089:
090: addModelElement(pModel, "Report Page Offset Datatype", mReport
091: .getReportPageOffsetDataType());
092: addModelElement(pModel, "Report Page Size Datatype", mReport
093: .getReportPageSizeDataType());
094: addModelElement(pModel, "Report Size Datatype", mReport
095: .getReportSizeDataType());
096: }
097:
098: // fill actions list
099: public void fillActionsList(ArrayList pList) {
100: switch (mMode) {
101: case ALL_ACTIONS:
102: super .fillActionsList(pList);
103: pList.add(new SeparatorAction());
104: pList.add(mAddNewInputFieldAction);
105: if (mReport != null
106: && mReport.getTopLevelOutputElement() == null)
107: pList.add(mAddTopLevelOutputElementAction);
108: break;
109: case ADD_INPUTFIELD:
110: pList.add(mAddNewInputFieldAction);
111: break;
112: }
113: }
114:
115: public BasePropertiesDialog getObjectEditor() {
116: return new ReportPropertiesDialog();
117: }
118:
119: private void addInputField() throws Exception {
120: ReportInputFieldUserObject.addNewReportInputField(mReport);
121: }
122:
123: private void addTopLevelOutputElement() throws Exception {
124: OutputElementUserObject.addNewOutputElement(mReport);
125: }
126:
127: /* Actions */
128:
129: public class AddNewInputFieldAction extends BaseAction {
130: public AddNewInputFieldAction() {
131: super ("Add New Input Field", Application
132: .getAddIcon(Application.FIELDS_ICON));
133: }
134:
135: public void actionPerformed(ActionEvent e) {
136: try {
137: addInputField();
138: } catch (Throwable t) {
139: Application.processError(t);
140: }
141: }
142: }
143:
144: public class AddTopLevelOutputElementAction extends BaseAction {
145: public AddTopLevelOutputElementAction() {
146: super ("Add Top Level Output Element", Application
147: .getAddIcon(Application.REPORTOUTPUTELEMENT_ICON));
148: }
149:
150: public void actionPerformed(ActionEvent e) {
151: try {
152: addTopLevelOutputElement();
153: } catch (Throwable t) {
154: Application.processError(t);
155: }
156: }
157: }
158: }
|