001: package jimm.datavision.gui;
002:
003: import jimm.datavision.*;
004: import jimm.datavision.source.Column;
005: import jimm.datavision.gui.parameter.ParamEditWin;
006:
007: /**
008: * The classes in this file are leaf nodes for the {@link FieldPickerTree}.
009: *
010: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
011: */
012:
013: // ================================================================
014: public abstract class FPLeafInfo {
015: protected Object leaf;
016: protected Designer designer;
017:
018: FPLeafInfo(Draggable obj, Designer designer) {
019: leaf = obj;
020: this .designer = designer;
021: }
022:
023: public Object getLeaf() {
024: return leaf;
025: }
026:
027: public String toString() {
028: return (leaf instanceof Nameable) ? ((Nameable) leaf).getName()
029: : leaf.toString();
030: }
031:
032: public String dragString() {
033: return ((Draggable) leaf).dragString();
034: }
035:
036: abstract boolean isDeletable();
037:
038: // Only used for formulas, parameters, and user columns
039: void openEditor() {
040: }
041: }
042:
043: // ================================================================
044: class ColumnInfo extends FPLeafInfo {
045: ColumnInfo(Column c, Designer designer) {
046: super (c, designer);
047: }
048:
049: boolean isDeletable() {
050: return false;
051: }
052: }
053:
054: // ================================================================
055: class FormulaInfo extends FPLeafInfo {
056: protected Report report;
057:
058: FormulaInfo(Report r, Formula f, Designer designer) {
059: super (f, designer);
060: report = r;
061: }
062:
063: boolean isDeletable() {
064: return !report.containsReferenceTo((Formula) leaf);
065: }
066:
067: void openEditor() {
068: new FormulaWin(designer, report, (Formula) leaf);
069: }
070: }
071:
072: // ================================================================
073: class ParameterInfo extends FPLeafInfo {
074: protected Report report;
075:
076: ParameterInfo(Report r, Parameter p, Designer designer) {
077: super (p, designer);
078: report = r;
079: }
080:
081: boolean isDeletable() {
082: return !report.containsReferenceTo((Parameter) leaf);
083: }
084:
085: void openEditor() {
086: new ParamEditWin(designer, (Parameter) leaf);
087: }
088: }
089:
090: // ================================================================
091: class UserColumnInfo extends FPLeafInfo {
092: protected Report report;
093:
094: UserColumnInfo(Report r, UserColumn uc, Designer designer) {
095: super (uc, designer);
096: report = r;
097: }
098:
099: boolean isDeletable() {
100: return !report.containsReferenceTo((UserColumn) leaf);
101: }
102:
103: void openEditor() {
104: new UserColumnWin(designer, report, (UserColumn) leaf);
105: }
106: }
107:
108: // ================================================================
109: class SpecialInfo extends FPLeafInfo {
110: protected String specialString;
111: protected String dragString;
112:
113: SpecialInfo(String ss, String ds, Designer designer) {
114: super (null, designer);
115: specialString = ss;
116: dragString = ds;
117: }
118:
119: public String toString() {
120: return specialString;
121: }
122:
123: public String dragString() {
124: return dragString;
125: }
126:
127: boolean isDeletable() {
128: return false;
129: }
130: }
131:
132: // class AggregateInfo extends FPLeafInfo {
133: // AggregateInfo(AggregateField f, Designer designer) { super(f, designer); }
134: // public String toString() { return f.designLabel(); }
135: // boolean isDeletable() { return false; }
136: // }
|