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.errorsview;
016:
017: import java.util.ArrayList;
018:
019: import javax.swing.table.AbstractTableModel;
020:
021: import com.metaboss.applications.designstudio.Application;
022: import com.metaboss.applications.designstudio.ModelErrorDescription;
023: import com.metaboss.sdlctools.models.ModelValidationException;
024:
025: /* Errors Table Model */
026:
027: public class ErrorsModel extends AbstractTableModel {
028: private ArrayList mList = new ArrayList();
029:
030: public void loadErrors(String pModelName) {
031: mList.clear();
032: int j = 0;
033: for (int i = 0; i < Application.sModelErrors.size(); i++) {
034: ModelErrorDescription lErrorDescription = (ModelErrorDescription) Application.sModelErrors
035: .get(i);
036: if (lErrorDescription != null
037: && lErrorDescription.getModelName().equals(
038: Application.getCurrentPackage()
039: .getFileName())) {
040: ModelValidationException lException = lErrorDescription
041: .getError();
042: if (lException != null) {
043: for (int k = 0; k < lException.getNumberOfErrors(); k++) {
044: String lID = lException
045: .getErrorModelElementRepositoryId(k);
046: if (Application.sErrorElement == null
047: || Application.sErrorElement
048: .equals(lID)) {
049: mList
050: .add(new ErrorInfo(
051: j,
052: k,
053: lException
054: .getErrorMessage(k),
055: lException
056: .getErrorExplanation(k),
057: lException
058: .getErrorModelElementRef(k),
059: lException
060: .getErrorModelElementRepositoryId(k)));
061: }
062: j++;
063: }
064: }
065: }
066: }
067: fireTableDataChanged();
068: }
069:
070: public void clearErrorrs() {
071: mList.clear();
072: fireTableDataChanged();
073: }
074:
075: public int getRowCount() {
076: return mList.size();
077: }
078:
079: public int getColumnCount() {
080: return 3;
081: }
082:
083: public Object getValueAt(int r, int c) {
084: ErrorInfo lErrorInfo = getErrorInfo(r);
085: if (lErrorInfo != null) {
086: switch (c) {
087: case 0:
088: return new Integer(lErrorInfo.mNumber + 1);
089: case 1:
090: return lErrorInfo.mDescription;
091: case 2:
092: return lErrorInfo.mRef;
093: }
094: }
095: return null;
096: }
097:
098: public String getColumnName(int c) {
099: switch (c) {
100: case 0:
101: return "N";
102: case 1:
103: return "Error";
104: case 2:
105: return "Element Ref";
106: }
107: return null;
108: }
109:
110: public boolean isCellEditable(int r, int c) {
111: return false;
112: }
113:
114: public void setValueAt(Object aValue, int r, int c) {
115: //???
116: }
117:
118: public ErrorInfo getErrorInfo(int pIndex) {
119: return (ErrorInfo) mList.get(pIndex);
120: }
121:
122: /* Auxilary classes */
123:
124: public class ErrorInfo {
125: public int mNumber = -1;
126: public int mIndex = -1;
127: public String mDescription = null;
128: public String mFullDescription = null;
129: public String mRef = null;
130: public String mMofID = null;
131:
132: public ErrorInfo(int pNumber, int pIndex, String pDescription,
133: String pFullDescription, String pRef, String pID) {
134: mNumber = pNumber;
135: mIndex = pIndex;
136: mDescription = pDescription;
137: mFullDescription = pFullDescription;
138: mRef = pRef;
139: mMofID = pID;
140: }
141: }
142: }
|