0001: package org.enhydra.jawe.base.panel;
0002:
0003: import java.awt.Component;
0004: import java.awt.event.ActionEvent;
0005: import java.awt.event.ActionListener;
0006: import java.awt.event.ItemEvent;
0007: import java.awt.event.ItemListener;
0008: import java.awt.event.KeyAdapter;
0009: import java.awt.event.KeyEvent;
0010: import java.lang.reflect.Method;
0011: import java.util.ArrayList;
0012: import java.util.Arrays;
0013: import java.util.HashSet;
0014: import java.util.Iterator;
0015: import java.util.List;
0016: import java.util.Set;
0017:
0018: import javax.swing.ImageIcon;
0019: import javax.swing.JLabel;
0020: import javax.swing.JList;
0021: import javax.swing.ListCellRenderer;
0022:
0023: import org.enhydra.jawe.JaWEManager;
0024: import org.enhydra.jawe.Settings;
0025: import org.enhydra.jawe.Utils;
0026: import org.enhydra.jawe.base.panel.panels.XMLActualParametersPanel;
0027: import org.enhydra.jawe.base.panel.panels.XMLBasicListPanel;
0028: import org.enhydra.jawe.base.panel.panels.XMLBasicPanel;
0029: import org.enhydra.jawe.base.panel.panels.XMLBasicTablePanel;
0030: import org.enhydra.jawe.base.panel.panels.XMLCheckboxPanel;
0031: import org.enhydra.jawe.base.panel.panels.XMLComboChoicePanel;
0032: import org.enhydra.jawe.base.panel.panels.XMLComboPanel;
0033: import org.enhydra.jawe.base.panel.panels.XMLDataTypesPanel;
0034: import org.enhydra.jawe.base.panel.panels.XMLGroupPanel;
0035: import org.enhydra.jawe.base.panel.panels.XMLLocationPanel;
0036: import org.enhydra.jawe.base.panel.panels.XMLMultiLineTextPanel;
0037: import org.enhydra.jawe.base.panel.panels.XMLPanel;
0038: import org.enhydra.jawe.base.panel.panels.XMLRadioPanel;
0039: import org.enhydra.jawe.base.panel.panels.XMLTabbedPanel;
0040: import org.enhydra.jawe.base.panel.panels.XMLTextPanel;
0041: import org.enhydra.shark.utilities.SequencedHashMap;
0042: import org.enhydra.shark.xpdl.XMLAttribute;
0043: import org.enhydra.shark.xpdl.XMLCollection;
0044: import org.enhydra.shark.xpdl.XMLCollectionElement;
0045: import org.enhydra.shark.xpdl.XMLComplexChoice;
0046: import org.enhydra.shark.xpdl.XMLComplexElement;
0047: import org.enhydra.shark.xpdl.XMLElement;
0048: import org.enhydra.shark.xpdl.XMLEmptyChoiceElement;
0049: import org.enhydra.shark.xpdl.XMLSimpleElement;
0050: import org.enhydra.shark.xpdl.XMLUtil;
0051: import org.enhydra.shark.xpdl.XPDLConstants;
0052: import org.enhydra.shark.xpdl.elements.*;
0053: import org.enhydra.shark.xpdl.elements.Package;
0054:
0055: /**
0056: * Used to generate panels for all XPDL entities.
0057: *
0058: * @author Zoran Milakovic
0059: * @author Sasa Bojanic
0060: */
0061: public class StandardPanelGenerator implements PanelGenerator {
0062:
0063: // public static final String
0064: // HIDE_COLLECTIONS_AND_COMPLEX_CHOICES="HideCollectionsAndComplexChoices";
0065:
0066: protected PanelContainer pc;
0067:
0068: // public String getLanguageDependentString (String nm) {
0069: // return pc.getPanelSettings().getLanguageDependentString(nm);
0070: // }
0071: //
0072: public StandardPanelGenerator() {
0073: }
0074:
0075: public void setPanelContainer(PanelContainer pc) {
0076: this .pc = pc;
0077: }
0078:
0079: public PanelContainer getPanelContainer() {
0080: return pc;
0081: }
0082:
0083: public XMLPanel getPanel(Activities el) {
0084: return generateStandardTablePanel(el, true, false);
0085: }
0086:
0087: public XMLPanel getPanel(Activity el) {
0088:
0089: List panels = new ArrayList();
0090: Set hidden = getHiddenElements("XMLGroupPanel", el);
0091: for (int i = 1;; i++) {
0092: try {
0093: XMLPanel p = getPanel(el, i, hidden);
0094: if (p != null) {
0095: panels.add(p);
0096: }
0097: } catch (Exception ex) {
0098: break;
0099: }
0100: }
0101:
0102: if (panels.size() > 1) {
0103: return new XMLTabbedPanel(getPanelContainer(), el, panels,
0104: JaWEManager.getInstance().getLabelGenerator()
0105: .getLabel(el), false);
0106: } else if (panels.size() == 1) {
0107: return (XMLPanel) panels.get(0);
0108: } else {
0109: return new XMLBasicPanel();
0110: }
0111:
0112: }
0113:
0114: protected XMLPanel getPanel(Activity el, int no, Set hidden) {
0115: XMLPanel p = null;
0116: switch (no) {
0117: case 1:
0118: List panelElements = new ArrayList();
0119: if (!hidden.contains(el.get("Id"))) {
0120: panelElements.add(el.get("Id"));
0121: }
0122: if (!hidden.contains(el.get("Name"))) {
0123: panelElements.add(el.get("Name"));
0124: }
0125: if (!hidden.contains(el.get("Performer"))) {
0126: int type = el.getActivityType();
0127: if (type == XPDLConstants.ACTIVITY_TYPE_NO
0128: || type == XPDLConstants.ACTIVITY_TYPE_TOOL) {
0129: panelElements.add(el.get("Performer"));
0130: }
0131: }
0132: if (!hidden.contains(el.getStartMode())) {
0133: panelElements.add(el.getStartMode());
0134: }
0135: if (!hidden.contains(el.getFinishMode())) {
0136: panelElements.add(el.getFinishMode());
0137: }
0138: if (!hidden.contains(el.getDeadlines())) {
0139: panelElements.add(el.getDeadlines());
0140: }
0141: if (!hidden.contains(el.get("Priority"))) {
0142: panelElements.add(el.get("Priority"));
0143: }
0144: if (!hidden.contains(el.get("Limit"))) {
0145: panelElements.add(el.get("Limit"));
0146: }
0147: if (!hidden.contains(el.get("Icon"))) {
0148: panelElements.add(el.get("Icon"));
0149: }
0150: if (!hidden.contains(el.get("Documentation"))) {
0151: panelElements.add(el.get("Documentation"));
0152: }
0153: if (!hidden.contains(el.get("Description"))) {
0154: panelElements.add(el.get("Description"));
0155: }
0156: if (panelElements.size() > 0) {
0157: p = new XMLGroupPanel(getPanelContainer(), el,
0158: panelElements, getPanelContainer()
0159: .getLanguageDependentString(
0160: "GeneralKey"), true, false,
0161: true);
0162: }
0163: break;
0164:
0165: case 2:
0166: if (!hidden.contains(el.getActivityTypes())) {
0167: int type = el.getActivityType();
0168: if (type == XPDLConstants.ACTIVITY_TYPE_TOOL) {
0169: Tools tools = el.getActivityTypes()
0170: .getImplementation()
0171: .getImplementationTypes().getTools();
0172: p = this .getPanel(tools);
0173: } else if (type == XPDLConstants.ACTIVITY_TYPE_SUBFLOW) {
0174: SubFlow sbflw = el.getActivityTypes()
0175: .getImplementation()
0176: .getImplementationTypes().getSubFlow();
0177: p = this .getPanel(sbflw);
0178: } else if (type == XPDLConstants.ACTIVITY_TYPE_BLOCK) {
0179: BlockActivity ba = el.getActivityTypes()
0180: .getBlockActivity();
0181: p = this .getPanel(ba);
0182: }
0183: }
0184: break;
0185:
0186: case 3:
0187: TransitionRestrictions trs = el.getTransitionRestrictions();
0188: if (!hidden.contains(trs) && trs.size() > 0) {
0189: TransitionRestriction tr = (TransitionRestriction) trs
0190: .get(0);
0191: p = getPanel(tr);
0192: }
0193: break;
0194:
0195: case 4:
0196: if (!hidden.contains(el.getSimulationInformation())) {
0197: p = this .getPanel(el.getSimulationInformation());
0198: }
0199: break;
0200:
0201: case 5:
0202: if (!hidden.contains(el.getExtendedAttributes())) {
0203: p = this .getPanel(el.getExtendedAttributes());
0204: }
0205: break;
0206:
0207: default:
0208: throw new RuntimeException();
0209:
0210: }
0211: return p;
0212: }
0213:
0214: public XMLPanel getPanel(ActivitySet el) {
0215: return generateStandardGroupPanel(el, true, false);
0216: }
0217:
0218: public XMLPanel getPanel(ActivitySets el) {
0219: return generateStandardTablePanel(el, true, false);
0220: }
0221:
0222: public XMLPanel getPanel(ActivityTypes el) {
0223: return generateStandardPanel(el);
0224: }
0225:
0226: public XMLPanel getPanel(ActualParameter el) {
0227: SequencedHashMap choices = XMLUtil.getPossibleVariables(XMLUtil
0228: .getWorkflowProcess(el));
0229: Object choosen = choices.get(el.toValue());
0230: if (choosen == null) {
0231: if (!el.toValue().equals("")) {
0232: choosen = el.toValue();
0233: }
0234: }
0235: SpecialChoiceElement cc = new SpecialChoiceElement(el, "",
0236: new ArrayList(choices.values()), choosen, true, "Id",
0237: el.toName(), el.isRequired());
0238: cc.setReadOnly(el.isReadOnly());
0239:
0240: return new XMLComboPanel(getPanelContainer(), cc, null, false,
0241: true, false, true, JaWEManager.getInstance()
0242: .getJaWEController().canModifyElement(el));
0243: }
0244:
0245: public XMLPanel getPanel(ActualParameters el) {
0246: return generateStandardTablePanel(el, true, false);
0247: }
0248:
0249: public XMLPanel getPanel(Application el) {
0250: return generateStandardGroupPanel(el, true, false);
0251: }
0252:
0253: public XMLPanel getPanel(Applications el) {
0254: return generateStandardPanel(el);
0255: }
0256:
0257: public XMLPanel getPanel(ApplicationTypes el) {
0258: return generateStandardPanel(el);
0259: }
0260:
0261: public XMLPanel getPanel(ArrayType el) {
0262: return generateStandardPanel(el);
0263: }
0264:
0265: public XMLPanel getPanel(Author el) {
0266: return generateStandardPanel(el);
0267: }
0268:
0269: public XMLPanel getPanel(Automatic el) {
0270: return new XMLBasicPanel();
0271: }
0272:
0273: public XMLPanel getPanel(BasicType el) {
0274: return this .getPanel((XMLAttribute) el.get("Type"));
0275: // return generateStandardPanel(el);
0276: }
0277:
0278: public XMLPanel getPanel(BlockActivity el) {
0279: return generateStandardPanel(el);
0280: }
0281:
0282: public XMLPanel getPanel(Codepage el) {
0283: return generateStandardPanel(el);
0284: }
0285:
0286: public XMLPanel getPanel(Condition el) {
0287: return generateStandardGroupPanel(el, true, false);
0288: }
0289:
0290: protected XMLPanel getPanel(Condition el, boolean hasTitle) {
0291: return generateStandardGroupPanel(el, hasTitle, false);
0292: }
0293:
0294: public XMLPanel getPanel(ConformanceClass el) {
0295: return generateStandardPanel(el.getGraphConformanceAttribute());
0296: }
0297:
0298: public XMLPanel getPanel(Cost el) {
0299: return generateStandardPanel(el);
0300: }
0301:
0302: public XMLPanel getPanel(CostUnit el) {
0303: return generateStandardPanel(el);
0304: }
0305:
0306: public XMLPanel getPanel(Countrykey el) {
0307: return generateStandardPanel(el);
0308: }
0309:
0310: public XMLPanel getPanel(Created el) {
0311: return generateStandardPanel(el);
0312: }
0313:
0314: public XMLPanel getPanel(DataField el) {
0315: Set hidden = getHiddenElements("XMLGroupPanel", el);
0316: List subpanels = new ArrayList();
0317: List groupsToShow = new ArrayList();
0318: if (!hidden.contains(el.get("Id"))) {
0319: subpanels
0320: .add(generateStandardTextPanel(el.get("Id"), true));
0321: }
0322: if (!hidden.contains(el.get("Length"))) {
0323: subpanels.add(generateStandardTextPanel(el.get("Length"),
0324: true));
0325: }
0326: if (subpanels.size() > 0) {
0327: groupsToShow.add(new XMLGroupPanel(getPanelContainer(), el,
0328: subpanels, "", true, false, true));
0329: }
0330: subpanels.clear();
0331: if (!hidden.contains(el.get("Name"))) {
0332: subpanels.add(generateStandardTextPanel(el.get("Name"),
0333: true));
0334: }
0335: if (!hidden.contains(el.get("IsArray"))) {
0336: XMLAttribute isa = (XMLAttribute) el.get("IsArray");
0337: // List choices=isa.getChoices();
0338: subpanels
0339: .add(new XMLCheckboxPanel(getPanelContainer(), isa,
0340: "", true, JaWEManager.getInstance()
0341: .getJaWEController()
0342: .canModifyElement(isa)));
0343: }
0344:
0345: if (subpanels.size() > 0) {
0346: groupsToShow.add(new XMLGroupPanel(getPanelContainer(), el,
0347: subpanels, "", true, false, true));
0348: }
0349:
0350: if (!hidden.contains(el.get("InitialValue"))) {
0351: groupsToShow.add(getPanel(el.get("InitialValue")));
0352: }
0353:
0354: if (!hidden.contains(el.getDataType())) {
0355: groupsToShow.add(getPanel(el.getDataType()));
0356: }
0357: if (!hidden.contains(el.get("Description"))) {
0358: groupsToShow.add(getPanel(el.get("Description")));
0359: }
0360: if (!hidden.contains(el.getExtendedAttributes())) {
0361: groupsToShow.add(getPanel(el.getExtendedAttributes()));
0362: }
0363: if (groupsToShow.size() == 6) {
0364: XMLGroupPanel g1 = new XMLGroupPanel(getPanelContainer(),
0365: el, new Object[] { groupsToShow.get(0),
0366: groupsToShow.get(1) }, "", false, false,
0367: true);
0368: return new XMLGroupPanel(getPanelContainer(), el,
0369: new Object[] { g1, groupsToShow.get(2),
0370: groupsToShow.get(3), groupsToShow.get(4),
0371: groupsToShow.get(5) }, "", true, false,
0372: true);
0373:
0374: }
0375: return new XMLGroupPanel(getPanelContainer(), el, groupsToShow,
0376: "", true, false, true);
0377: }
0378:
0379: public XMLPanel getPanel(DataFields el) {
0380: return generateStandardPanel(el);
0381: }
0382:
0383: public XMLPanel getPanel(DataType el) {
0384: return this .getPanel(el.getDataTypes());
0385: }
0386:
0387: public XMLPanel getPanel(DataTypes el) {
0388: return new XMLDataTypesPanel(getPanelContainer(), el, null,
0389: JaWEManager.getInstance().getLabelGenerator().getLabel(
0390: el), JaWEManager.getInstance()
0391: .getJaWEController().canModifyElement(el));
0392: }
0393:
0394: public XMLPanel getPanel(Deadline el) {
0395: return generateStandardPanel(el);
0396: }
0397:
0398: public XMLPanel getPanel(DeadlineCondition el) {
0399: return new XMLMultiLineTextPanel(getPanelContainer(), el, el
0400: .toName(), false, true,
0401: XMLMultiLineTextPanel.SIZE_LARGE, false, JaWEManager
0402: .getInstance().getJaWEController()
0403: .canModifyElement(el));
0404: }
0405:
0406: public XMLPanel getPanel(Deadlines el) {
0407: return generateStandardListPanel(el, true, false);
0408: }
0409:
0410: public XMLPanel getPanel(DeclaredType el) {
0411: XMLElement tdsel = el;
0412: while (!(tdsel instanceof TypeDeclarations)) {
0413: tdsel = tdsel.getParent();
0414: if (tdsel == null) {
0415: tdsel = XMLUtil.getPackage(el).getTypeDeclarations();
0416: break;
0417: }
0418: }
0419:
0420: TypeDeclarations tds = (TypeDeclarations) tdsel;
0421: List choices = tds.toElements();
0422: XMLElement choosen = tds.getTypeDeclaration(el.getId());
0423: // if (choosen==null) {
0424: // if (choices.size()>0) {
0425: // choosen=(XMLElement)choices.get(0);
0426: // getPanelContainer().setModified(true);
0427: // }
0428: // }
0429: // if we are editing existing TypeDeclaration, remove it from the choices
0430: if (el.getParent().getParent() instanceof TypeDeclaration) {
0431: choices.remove(el.getParent().getParent());
0432: }
0433: SpecialChoiceElement cc = new SpecialChoiceElement(el, "Id",
0434: choices, choosen, false, "Id", "SubType", el
0435: .isRequired());
0436: cc.setReadOnly(el.isReadOnly());
0437:
0438: return new XMLComboPanel(getPanelContainer(), cc, null, false,
0439: true, false, false, JaWEManager.getInstance()
0440: .getJaWEController().canModifyElement(el));
0441:
0442: }
0443:
0444: public XMLPanel getPanel(Description el) {
0445: return generateStandardMultiLineTextPanel(el, true,
0446: XMLMultiLineTextPanel.SIZE_SMALL, true);
0447: }
0448:
0449: public XMLPanel getPanel(Documentation el) {
0450: return new XMLLocationPanel(getPanelContainer(), el,
0451: JaWEManager.getInstance().getJaWEController()
0452: .canModifyElement(el));
0453: }
0454:
0455: public XMLPanel getPanel(Duration el) {
0456: return generateStandardPanel(el);
0457: }
0458:
0459: public XMLPanel getPanel(EnumerationType el) {
0460: return generateStandardListPanel(el, true, false);
0461: }
0462:
0463: public XMLPanel getPanel(EnumerationValue el) {
0464: return generateStandardPanel(el);
0465: }
0466:
0467: public XMLPanel getPanel(ExceptionName el) {
0468: return generateStandardPanel(el);
0469: }
0470:
0471: public XMLPanel getPanel(ExtendedAttributes el) {
0472: return generateStandardTablePanel(el, true, false);
0473: }
0474:
0475: public XMLPanel getPanel(ExtendedAttribute el) {
0476: return generateStandardGroupPanel(el, true, false);
0477: }
0478:
0479: public XMLPanel getPanel(ExternalPackage el) {
0480: return generateStandardGroupPanel(el, true, false);
0481: }
0482:
0483: public XMLPanel getPanel(ExternalPackages el) {
0484: return generateStandardListPanel(el, true, false);
0485: }
0486:
0487: public XMLPanel getPanel(ExternalReference el) {
0488: return generateStandardGroupPanel(el, true, false);
0489: }
0490:
0491: public XMLPanel getPanel(FinishMode el) {
0492: return getPanel(el.getStartFinishModes());
0493: }
0494:
0495: public XMLPanel getPanel(FormalParameter el) {
0496: return generateStandardPanel(el);
0497: }
0498:
0499: public XMLPanel getPanel(FormalParameters el) {
0500: return generateStandardPanel(el);
0501: }
0502:
0503: public XMLPanel getPanel(Icon el) {
0504: List choices = Utils.getActivityIconNamesList();
0505: String choosen = el.toValue();
0506: if (choices.size() == 0) {
0507: return new XMLLocationPanel(getPanelContainer(), el,
0508: JaWEManager.getInstance().getJaWEController()
0509: .canModifyElement(el));
0510: }
0511: if (!choices.contains(choosen)) {
0512: choices.add(choosen);
0513: }
0514: XMLComboPanel p = new XMLComboPanel(getPanelContainer(), el,
0515: JaWEManager.getInstance().getLabelGenerator().getLabel(
0516: el), choices, false, true, false, true,
0517: JaWEManager.getInstance().getJaWEController()
0518: .canModifyElement(el), false, false);
0519:
0520: p.getComboBox().setRenderer(cbr);
0521: return p;
0522: }
0523:
0524: public XMLPanel getPanel(Implementation el) {
0525: // XMLComplexChoice refMode=new XMLComplexChoice(null, "Type" , true ) {
0526: // protected void fillChoices() {
0527: // this.choices.add(new No(null));
0528: // this.choices.add(new Tools(null));
0529: // this.choices.add(new SubFlow(null));
0530: // }
0531: // };
0532: return generateStandardPanel(el);
0533: }
0534:
0535: public XMLPanel getPanel(ImplementationTypes el) {
0536: return generateStandardPanel(el);
0537: }
0538:
0539: public XMLPanel getPanel(InitialValue el) {
0540: return generateStandardMultiLineTextPanel(el, true,
0541: XMLMultiLineTextPanel.SIZE_MEDIUM, false);
0542: }
0543:
0544: public XMLPanel getPanel(Join el) {
0545: return generateStandardGroupPanel(el, true, false);
0546: }
0547:
0548: public XMLPanel getPanel(Length el) {
0549: return generateStandardPanel(el);
0550: }
0551:
0552: public XMLPanel getPanel(Limit el) {
0553: return generateStandardPanel(el);
0554: }
0555:
0556: public XMLPanel getPanel(ListType el) {
0557: return generateStandardPanel(el);
0558: }
0559:
0560: public XMLPanel getPanel(Manual el) {
0561: return generateStandardPanel(el);
0562: }
0563:
0564: public XMLPanel getPanel(Member el) {
0565: return generateStandardPanel(el);
0566: }
0567:
0568: public XMLPanel getPanel(Namespace el) {
0569: return generateStandardPanel(el);
0570: }
0571:
0572: public XMLPanel getPanel(Namespaces el) {
0573: return generateStandardTablePanel(el, true, false);
0574: }
0575:
0576: public XMLPanel getPanel(No el) {
0577: return generateStandardPanel(el);
0578: }
0579:
0580: public XMLPanel getPanel(Package el) {
0581: List panels = new ArrayList();
0582: Set hidden = getHiddenElements("XMLGroupPanel", el);
0583: for (int i = 1;; i++) {
0584: try {
0585: XMLPanel p = getPanel(el, i, hidden);
0586: if (p != null) {
0587: panels.add(p);
0588: }
0589: } catch (Exception ex) {
0590: break;
0591: }
0592: }
0593:
0594: if (panels.size() > 1) {
0595: return new XMLTabbedPanel(getPanelContainer(), el, panels,
0596: JaWEManager.getInstance().getLabelGenerator()
0597: .getLabel(el), false);
0598: } else if (panels.size() == 1) {
0599: return (XMLPanel) panels.get(0);
0600: } else {
0601: return new XMLBasicPanel();
0602: }
0603:
0604: }
0605:
0606: public XMLPanel getBasicPanel(Package el) {
0607: List panels = new ArrayList();
0608: Set hidden = getHiddenElements("XMLGroupPanel", el);
0609: for (int i = 1; i <= 3; i++) {
0610: try {
0611: XMLPanel p = getPanel(el, i, hidden);
0612: if (p != null) {
0613: panels.add(p);
0614: }
0615: } catch (Exception ex) {
0616: break;
0617: }
0618: }
0619:
0620: if (panels.size() > 1) {
0621: return new XMLTabbedPanel(getPanelContainer(), el, panels,
0622: JaWEManager.getInstance().getLabelGenerator()
0623: .getLabel(el), false);
0624: } else if (panels.size() == 1) {
0625: return (XMLPanel) panels.get(0);
0626: } else {
0627: return new XMLBasicPanel();
0628: }
0629:
0630: }
0631:
0632: protected XMLPanel getPanel(Package el, int no, Set hidden) {
0633: XMLPanel p = null;
0634: switch (no) {
0635:
0636: case 1:
0637: List panelElements = new ArrayList();
0638: if (!hidden.contains(el.get("Id"))) {
0639: panelElements.add(el.get("Id"));
0640: }
0641: if (!hidden.contains(el.get("Name"))) {
0642: panelElements.add(el.get("Name"));
0643: }
0644: if (!hidden.contains(el.getConformanceClass())) {
0645: panelElements.add(el.getConformanceClass());
0646: }
0647: if (!hidden.contains(el.getScript())) {
0648: panelElements.add(getPanel(el.getScript(), true));
0649: }
0650: if (!hidden.contains(el.getExtendedAttributes())) {
0651: panelElements.add(el.getExtendedAttributes());
0652: }
0653: if (panelElements.size() > 0) {
0654: p = new XMLGroupPanel(getPanelContainer(), el,
0655: panelElements, getPanelContainer()
0656: .getLanguageDependentString(
0657: "GeneralKey"), true, false,
0658: true);
0659: }
0660: break;
0661:
0662: case 2:
0663: if (!hidden.contains(el.getPackageHeader())) {
0664: p = this .getPanel(el.getPackageHeader());
0665: }
0666: break;
0667:
0668: case 3:
0669: if (!hidden.contains(el.getRedefinableHeader())) {
0670: p = this .getPanel(el.getRedefinableHeader());
0671: }
0672: break;
0673:
0674: case 4:
0675: if (!hidden.contains(el.getExternalPackages())) {
0676: p = this .getPanel(el.getExternalPackages());
0677: }
0678: break;
0679:
0680: case 5:
0681: if (!hidden.contains(el.getTypeDeclarations())) {
0682: p = this .getPanel(el.getTypeDeclarations());
0683: }
0684: break;
0685:
0686: case 6:
0687: if (!hidden.contains(el.getParticipants())) {
0688: p = this .getPanel(el.getParticipants());
0689: }
0690: break;
0691:
0692: case 7:
0693: if (!hidden.contains(el.getApplications())) {
0694: p = this .getPanel(el.getApplications());
0695: }
0696: break;
0697:
0698: case 8:
0699: if (!hidden.contains(el.getDataFields())) {
0700: p = this .getPanel(el.getDataFields());
0701: }
0702: break;
0703:
0704: case 9:
0705: if (!hidden.contains(el.getWorkflowProcesses())) {
0706: p = this .getPanel(el.getWorkflowProcesses());
0707: }
0708: break;
0709:
0710: case 10:
0711: if (!hidden.contains(el.getNamespaces())) {
0712: p = this .getPanel(el.getNamespaces());
0713: }
0714: break;
0715:
0716: default:
0717: throw new RuntimeException();
0718:
0719: }
0720: return p;
0721: }
0722:
0723: public XMLPanel getPanel(PackageHeader el) {
0724: return generateStandardPanel(el);
0725: }
0726:
0727: public XMLPanel getPanel(Participant el) {
0728: return generateStandardGroupPanel(el, true, false);
0729: }
0730:
0731: public XMLPanel getPanel(Participants el) {
0732: return generateStandardTablePanel(el, true, false);
0733: }
0734:
0735: public XMLPanel getPanel(ParticipantType el) {
0736: return new XMLRadioPanel(getPanelContainer(), el
0737: .getTypeAttribute(), getPanelContainer()
0738: .getLanguageDependentString(
0739: el.getTypeAttribute().toName() + "Key"), true,
0740: true, false, JaWEManager.getInstance()
0741: .getJaWEController().canModifyElement(el));
0742: }
0743:
0744: public XMLPanel getPanel(Performer el) {
0745: Activity act = XMLUtil.getActivity(el);
0746: int type = act.getActivityType();
0747: if (type == XPDLConstants.ACTIVITY_TYPE_NO
0748: || type == XPDLConstants.ACTIVITY_TYPE_TOOL) {
0749: SequencedHashMap choices = XMLUtil.getPossibleParticipants(
0750: XMLUtil.getWorkflowProcess(el), JaWEManager
0751: .getInstance().getXPDLHandler());
0752: Object choosen = choices.get(el.toValue());
0753: if (choosen == null) {
0754: if (!el.toValue().equals("")) {
0755: choosen = el.toValue();
0756: }
0757: }
0758: SpecialChoiceElement cc = new SpecialChoiceElement(el, "",
0759: new ArrayList(choices.values()), choosen, true,
0760: "Id", el.toName(), el.isRequired());
0761: cc.setReadOnly(el.isReadOnly());
0762:
0763: return new XMLComboPanel(getPanelContainer(), cc, null,
0764: false, true, false, true, JaWEManager.getInstance()
0765: .getJaWEController().canModifyElement(el));
0766:
0767: }
0768: return new XMLTextPanel(getPanelContainer(), el, false, false,
0769: JaWEManager.getInstance().getJaWEController()
0770: .canModifyElement(el));
0771: }
0772:
0773: public XMLPanel getPanel(Priority el) {
0774: return generateStandardPanel(el);
0775: }
0776:
0777: public XMLPanel getPanel(PriorityUnit el) {
0778: return generateStandardPanel(el);
0779: }
0780:
0781: public XMLPanel getPanel(ProcessHeader el) {
0782: return generateStandardPanel(el);
0783: }
0784:
0785: public XMLPanel getPanel(RecordType el) {
0786: return generateStandardListPanel(el, true, false);
0787: /*
0788: * XMLListPanel controlledPanel=new XMLListPanel(el,"",false,true,false) { public
0789: * boolean checkRequired () { if (el.isReadOnly() || (el.size()>0)) { return true; }
0790: * else {
0791: * XMLPanel.errorMessage(this.getDialog(),JaWEManager.getInstance().getLabelGenerator().getLabel(el),"",
0792: * getLanguageDependentString("ErrorTheListMustContainAtLeastOneElement"));
0793: * controlPanel.getComponent(1).requestFocus(); return false; } } };
0794: * controlPanel=new XMLListControlPanel(el,"",true,false,true); return new
0795: * XMLGroupPanel(el,new XMLPanel[]{
0796: * controlledPanel,controlPanel},JaWEManager.getInstance().getLabelGenerator().getLabel(el),XMLPanel.BOX_LAYOUT,
0797: * false,true);
0798: */
0799: }
0800:
0801: public XMLPanel getPanel(RedefinableHeader el) {
0802: // TODO
0803: return generateStandardPanel(el);
0804: }
0805:
0806: public XMLPanel getPanel(Responsible el) {
0807: SequencedHashMap choices = JaWEManager.getInstance()
0808: .getXPDLUtils().getPossibleResponsibles(
0809: (Responsibles) el.getParent(), el);
0810: Participant choosen = null;
0811: String pId = el.toValue();
0812: if (!pId.equals("")) {
0813: Iterator it = choices.values().iterator();
0814: while (it.hasNext()) {
0815: Participant p = (Participant) it.next();
0816: if (pId.equals(p.getId())) {
0817: choosen = p;
0818: break;
0819: }
0820: }
0821: }
0822: if (choosen != null) {
0823: choices.put(choosen.getId(), choosen);
0824: }
0825: // else if (choices.size()>0) {
0826: // choosen=(Participant)choices.getValue(0);
0827: // getPanelContainer().setModified(true);
0828: // } else {
0829: // getPanelContainer().setModified(true);
0830: // }
0831:
0832: SpecialChoiceElement cc = new SpecialChoiceElement(el, "",
0833: new ArrayList(choices.values()), choosen, false, "Id",
0834: el.toName(), el.isRequired());
0835: cc.setReadOnly(el.isReadOnly());
0836:
0837: return new XMLComboPanel(getPanelContainer(), cc, null, false,
0838: true, false, false, JaWEManager.getInstance()
0839: .getJaWEController().canModifyElement(el));
0840: }
0841:
0842: public XMLPanel getPanel(Responsibles el) {
0843: return generateStandardListPanel(el, true, false);
0844: }
0845:
0846: public XMLPanel getPanel(Route el) {
0847: return generateStandardPanel(el);
0848: }
0849:
0850: public XMLPanel getPanel(SchemaType el) {
0851: return generateStandardPanel(el);
0852: }
0853:
0854: public XMLPanel getPanel(Script el) {
0855: return generateStandardGroupPanel(el, false, false);
0856: }
0857:
0858: protected XMLPanel getPanel(Script el, boolean hasTitle) {
0859: return generateStandardGroupPanel(el, hasTitle, false);
0860: }
0861:
0862: public XMLPanel getPanel(SimulationInformation el) {
0863: return generateStandardPanel(el);
0864: }
0865:
0866: public XMLPanel getPanel(Split el) {
0867: return generateStandardGroupPanel(el, true, false);
0868: }
0869:
0870: public XMLPanel getPanel(StartFinishModes el) {
0871: return new XMLComboPanel(getPanelContainer(), el, null, false,
0872: true, false, false, JaWEManager.getInstance()
0873: .getJaWEController().canModifyElement(el));
0874: }
0875:
0876: public XMLPanel getPanel(StartMode el) {
0877: return getPanel(el.getStartFinishModes());
0878: }
0879:
0880: public XMLPanel getPanel(SubFlow el) {
0881: Set hidden = getHiddenElements("XMLGroupPanel", el);
0882: List panelElements = new ArrayList();
0883: SequencedHashMap choices = XMLUtil.getPossibleSubflowProcesses(
0884: el, JaWEManager.getInstance().getXPDLHandler());
0885: Object choosen = choices.get(el.getId());
0886: if (choosen == null) {
0887: if (!el.getId().equals("")) {
0888: choosen = el.getId();
0889: }
0890: // else {
0891: // if (choices.size()>0) {
0892: // choosen=choices.getValue(0);
0893: // getPanelContainer().setModified(true);
0894: // }
0895: // }
0896: }
0897: SpecialChoiceElement cc = new SpecialChoiceElement(
0898: el.get("Id"), "", new ArrayList(choices.values()),
0899: choosen, true, "Id", "WorkflowProcess", true);
0900: cc.setReadOnly(el.get("Id").isReadOnly());
0901:
0902: final XMLComboPanel cp = new XMLComboPanel(getPanelContainer(),
0903: cc, null, false, true, false, true, JaWEManager
0904: .getInstance().getJaWEController()
0905: .canModifyElement(el.get("Id")));
0906:
0907: if (!hidden.contains(el.get("Id"))) {
0908: panelElements.add(cp);
0909: }
0910: if (!hidden.contains(el.getExecutionAttribute())) {
0911: panelElements.add(el.getExecutionAttribute());
0912: }
0913:
0914: if (!hidden.contains(el.getActualParameters())) {
0915: FormalParameters fps = null;
0916: if (choosen instanceof WorkflowProcess) {
0917: fps = ((WorkflowProcess) choosen).getFormalParameters();
0918: }
0919: final XMLActualParametersPanel app = new XMLActualParametersPanel(
0920: getPanelContainer(), el.getActualParameters(), fps);
0921: panelElements.add(app);
0922: cp.getComboBox().addActionListener(new ActionListener() {
0923: public void actionPerformed(ActionEvent ae) {
0924: Object sel = cp.getSelectedItem();
0925: FormalParameters _fps = null;
0926: if (sel instanceof WorkflowProcess) {
0927: _fps = ((WorkflowProcess) sel)
0928: .getFormalParameters();
0929: }
0930: app.setFormalParameters(_fps);
0931: app.validate();
0932: }
0933: });
0934: cp.getComboBox().getEditor().getEditorComponent()
0935: .addKeyListener(new KeyAdapter() {
0936: public void keyPressed(KeyEvent e) {
0937: Object sel = cp.getSelectedItem();
0938: FormalParameters _fps = null;
0939: if (sel instanceof WorkflowProcess) {
0940: _fps = ((WorkflowProcess) sel)
0941: .getFormalParameters();
0942: }
0943: app.setFormalParameters(_fps);
0944: app.validate();
0945: }
0946: });
0947: cp.getComboBox().addItemListener(new ItemListener() {
0948: public void itemStateChanged(ItemEvent e) {
0949: Object sel = cp.getSelectedItem();
0950: FormalParameters _fps = null;
0951: if (sel instanceof WorkflowProcess) {
0952: _fps = ((WorkflowProcess) sel)
0953: .getFormalParameters();
0954: }
0955: app.setFormalParameters(_fps);
0956: app.validate();
0957: }
0958: });
0959:
0960: }
0961: if (panelElements.size() > 0) {
0962: return new XMLGroupPanel(getPanelContainer(), el,
0963: panelElements, getPanelContainer()
0964: .getLanguageDependentString(
0965: el.toName() + "Key"), true, false,
0966: true);
0967: }
0968: return null;
0969: }
0970:
0971: public XMLPanel getPanel(TimeEstimation el) {
0972: return generateStandardGroupPanel(el, false, false);
0973: }
0974:
0975: public XMLPanel getPanel(Tool el) {
0976: Set hidden = getHiddenElements("XMLGroupPanel", el);
0977: List panelElements = new ArrayList();
0978: SequencedHashMap choices = XMLUtil.getPossibleApplications(
0979: XMLUtil.getWorkflowProcess(el), JaWEManager
0980: .getInstance().getXPDLHandler());
0981: Object choosen = choices.get(el.getId());
0982: if (choosen == null) {
0983: if (!el.getId().equals("")) {
0984: choosen = el.getId();
0985: }
0986: // else {
0987: // if (choices.size()>0) {
0988: // choosen=choices.getValue(0);
0989: // getPanelContainer().setModified(true);
0990: // }
0991: // }
0992: }
0993: SpecialChoiceElement cc = new SpecialChoiceElement(
0994: el.get("Id"), "", new ArrayList(choices.values()),
0995: choosen, true, "Id", "Application", el.isRequired());
0996: cc.setReadOnly(el.get("Id").isReadOnly());
0997:
0998: final XMLComboPanel cp = new XMLComboPanel(getPanelContainer(),
0999: cc, null, false, true, false, false, JaWEManager
1000: .getInstance().getJaWEController()
1001: .canModifyElement(el.get("Id")));
1002:
1003: if (!hidden.contains(el.get("Id"))) {
1004: panelElements.add(cp);
1005: }
1006: if (!hidden.contains(el.getTypeAttribute())) {
1007: panelElements.add(el.getTypeAttribute());
1008: }
1009: if (!hidden.contains(el.getActualParameters())) {
1010: FormalParameters fps = null;
1011: if (choosen instanceof Application) {
1012: fps = ((Application) choosen).getApplicationTypes()
1013: .getFormalParameters();
1014: }
1015: final XMLActualParametersPanel app = new XMLActualParametersPanel(
1016: getPanelContainer(), el.getActualParameters(), fps);
1017: panelElements.add(app);
1018: ActionListener al = new ActionListener() {
1019: public void actionPerformed(ActionEvent ae) {
1020: Object sel = cp.getSelectedItem();
1021: FormalParameters _fps = null;
1022: if (sel instanceof Application) {
1023: _fps = ((Application) sel)
1024: .getApplicationTypes()
1025: .getFormalParameters();
1026: }
1027: app.setFormalParameters(_fps);
1028: }
1029: };
1030: cp.getComboBox().addActionListener(al);
1031: }
1032: if (!hidden.contains(el.get("Description"))) {
1033: panelElements.add(el.get("Description"));
1034: }
1035: if (!hidden.contains(el.getExtendedAttributes())) {
1036: panelElements.add(el.getExtendedAttributes());
1037: }
1038: if (panelElements.size() > 0) {
1039: return new XMLGroupPanel(getPanelContainer(), el,
1040: panelElements, getPanelContainer()
1041: .getLanguageDependentString(
1042: el.toName() + "Key"), true, false,
1043: true);
1044: }
1045: return null;
1046: }
1047:
1048: public XMLPanel getPanel(Tools el) {
1049: return generateStandardTablePanel(el, true, false);
1050: }
1051:
1052: public XMLPanel getPanel(Transition el) {
1053: Set hidden = getHiddenElements("XMLGroupPanel", el);
1054: List panelElements = new ArrayList();
1055: if (!hidden.contains(el.get("Id"))) {
1056: panelElements.add(el.get("Id"));
1057: }
1058: if (!hidden.contains(el.get("Name"))) {
1059: panelElements.add(el.get("Name"));
1060: }
1061: if (!hidden.contains(el.get("From"))) {
1062: panelElements.add(getPanelForFROMAttribute(el));
1063: }
1064: if (!hidden.contains(el.get("To"))) {
1065: panelElements.add(getPanelForTOAttribute(el));
1066: }
1067: if (!hidden.contains(el.getCondition())) {
1068: panelElements.add(el.getCondition());
1069: }
1070: if (!hidden.contains(el.get("Description"))) {
1071: panelElements.add(el.get("Description"));
1072: }
1073: if (!hidden.contains(el.getExtendedAttributes())) {
1074: panelElements.add(el.getExtendedAttributes());
1075: }
1076:
1077: if (panelElements.size() > 0) {
1078: return new XMLGroupPanel(getPanelContainer(), el,
1079: panelElements, JaWEManager.getInstance()
1080: .getLabelGenerator().getLabel(el), true,
1081: false, true);
1082: }
1083: return new XMLBasicPanel();
1084: }
1085:
1086: public XMLPanel getPanel(TransitionRef el) {
1087: // Activity act=XMLUtil.getActivity(el);
1088: // Set ogt=XMLUtil.getNonExceptionalOutgoingTransitions(act);
1089: // List ordrdl=XMLUtil.getOrderedOutgoingTransitions(act, ogt);
1090: // SequencedHashMap choices=new SequencedHashMap();
1091: // Iterator it=ordrdl.iterator();
1092: // while (it.hasNext()) {
1093: // Transition t=(Transition)it.next();
1094: // choices.put(t.getId(),t);
1095: // }
1096: // Transition choosen=null;
1097: // String tId=el.getId();
1098: // if (!tId.equals("")) {
1099: // it=choices.values().iterator();
1100: // while (it.hasNext()) {
1101: // Transition t=(Transition)it.next();
1102: // if (tId.equals(t.getId())) {
1103: // choosen=t;
1104: // break;
1105: // }
1106: // }
1107: // }
1108: // // filter choices: exclude already existing
1109: // it=((TransitionRefs)el.getParent()).toElements().iterator();
1110: // System.out.println("Choices="+choices.keySet());
1111: // while (it.hasNext()) {
1112: // TransitionRef tr=(TransitionRef)it.next();
1113: // choices.remove(tr.getId());
1114: // }
1115: // if (choosen!=null) {
1116: // choices.put(choosen.getId(),choosen);
1117: // }
1118: // // else if (choices.size()>0) {
1119: // // choosen=(Transition)choices.getValue(0);
1120: // // getPanelContainer().setModified(true);
1121: // // }
1122: //
1123: //
1124: // SpecialChoiceElement cc=new SpecialChoiceElement(
1125: // el,
1126: // "Id",
1127: // new ArrayList(choices.values()),
1128: // choosen,
1129: // false,
1130: // "Id",
1131: // el.toName(),
1132: // el.isRequired());
1133: // cc.setReadOnly(true);
1134: //
1135: // return new XMLComboPanel(getPanelContainer(),cc,null,true,false,false);
1136: return generateStandardPanel(el);
1137: }
1138:
1139: public XMLPanel getPanel(TransitionRefs el) {
1140: return generateStandardListPanel(el, true, false);
1141: }
1142:
1143: public XMLPanel getPanel(TransitionRestriction el) {
1144: return generateStandardPanel(el);
1145: }
1146:
1147: public XMLPanel getPanel(TransitionRestrictions el) {
1148: return generateStandardPanel(el);
1149: }
1150:
1151: public XMLPanel getPanel(Transitions el) {
1152: return generateStandardTablePanel(el, true, false);
1153: }
1154:
1155: public XMLPanel getPanel(TypeDeclaration el) {
1156:
1157: return generateStandardPanel(el);
1158: }
1159:
1160: public XMLPanel getPanel(TypeDeclarations el) {
1161: return generateStandardPanel(el);
1162: }
1163:
1164: public XMLPanel getPanel(UnionType el) {
1165: return generateStandardListPanel(el, true, false);
1166: }
1167:
1168: public XMLPanel getPanel(ValidFrom el) {
1169: return generateStandardPanel(el);
1170: }
1171:
1172: public XMLPanel getPanel(ValidTo el) {
1173: return generateStandardPanel(el);
1174: }
1175:
1176: public XMLPanel getPanel(Vendor el) {
1177: return generateStandardPanel(el);
1178: }
1179:
1180: public XMLPanel getPanel(Version el) {
1181: return generateStandardPanel(el);
1182: }
1183:
1184: public XMLPanel getPanel(WaitingTime el) {
1185: return generateStandardPanel(el);
1186: }
1187:
1188: public XMLPanel getPanel(WorkflowProcess el) {
1189: List panels = new ArrayList();
1190: Set hidden = getHiddenElements("XMLGroupPanel", el);
1191: for (int i = 1;; i++) {
1192: try {
1193: XMLPanel p = getPanel(el, i, hidden);
1194: if (p != null) {
1195: panels.add(p);
1196: }
1197: } catch (Exception ex) {
1198: break;
1199: }
1200: }
1201:
1202: if (panels.size() > 1) {
1203: return new XMLTabbedPanel(getPanelContainer(), el, panels,
1204: JaWEManager.getInstance().getLabelGenerator()
1205: .getLabel(el), false);
1206: } else if (panels.size() == 1) {
1207: return (XMLPanel) panels.get(0);
1208: } else {
1209: return new XMLBasicPanel();
1210: }
1211:
1212: }
1213:
1214: public XMLPanel getBasicPanel(WorkflowProcess el) {
1215: List panels = new ArrayList();
1216: Set hidden = getHiddenElements("XMLGroupPanel", el);
1217: for (int i = 1; i <= 3; i++) {
1218: try {
1219: XMLPanel p = getPanel(el, i, hidden);
1220: if (p != null) {
1221: panels.add(p);
1222: }
1223: } catch (Exception ex) {
1224: break;
1225: }
1226: }
1227:
1228: if (panels.size() > 1) {
1229: return new XMLTabbedPanel(getPanelContainer(), el, panels,
1230: JaWEManager.getInstance().getLabelGenerator()
1231: .getLabel(el), false);
1232: } else if (panels.size() == 1) {
1233: return (XMLPanel) panels.get(0);
1234: } else {
1235: return new XMLBasicPanel();
1236: }
1237:
1238: }
1239:
1240: public XMLPanel getPanel(WorkflowProcess el, int no, Set hidden) {
1241: XMLPanel p = null;
1242:
1243: switch (no) {
1244:
1245: case 1:
1246: List panelElements = new ArrayList();
1247: if (!hidden.contains(el.get("Id"))) {
1248: panelElements.add(el.get("Id"));
1249: }
1250: if (!hidden.contains(el.get("Name"))) {
1251: panelElements.add(el.get("Name"));
1252: }
1253: if (!hidden.contains(el.getAccessLevelAttribute())) {
1254: panelElements.add(el.getAccessLevelAttribute());
1255: }
1256: if (!hidden.contains(el.getExtendedAttributes())) {
1257: panelElements.add(el.getExtendedAttributes());
1258: }
1259: if (panelElements.size() > 0) {
1260: p = new XMLGroupPanel(getPanelContainer(), el,
1261: panelElements, getPanelContainer()
1262: .getLanguageDependentString(
1263: "GeneralKey"), true, false,
1264: true);
1265: }
1266: break;
1267:
1268: case 2:
1269: if (!hidden.contains(el.getProcessHeader())) {
1270: p = this .getPanel(el.getProcessHeader());
1271: }
1272: break;
1273:
1274: case 3:
1275: if (!hidden.contains(el.getRedefinableHeader())) {
1276: p = this .getPanel(el.getRedefinableHeader());
1277: }
1278: break;
1279:
1280: case 4:
1281: if (!hidden.contains(el.getParticipants())) {
1282: p = this .getPanel(el.getParticipants());
1283: }
1284: break;
1285:
1286: case 5:
1287: if (!hidden.contains(el.getApplications())) {
1288: p = this .getPanel(el.getApplications());
1289: }
1290: break;
1291:
1292: case 6:
1293: if (!hidden.contains(el.getDataFields())) {
1294: p = this .getPanel(el.getDataFields());
1295: }
1296: break;
1297:
1298: case 7:
1299: if (!hidden.contains(el.getFormalParameters())) {
1300: p = this .getPanel(el.getFormalParameters());
1301: }
1302: break;
1303:
1304: case 8:
1305: if (!hidden.contains(el.getActivities())) {
1306: p = this .getPanel(el.getActivities());
1307: }
1308: break;
1309:
1310: case 9:
1311: if (!hidden.contains(el.getTransitions())) {
1312: p = this .getPanel(el.getTransitions());
1313: }
1314: break;
1315:
1316: case 10:
1317: if (!hidden.contains(el.getActivitySets())) {
1318: p = this .getPanel(el.getActivitySets());
1319: }
1320: break;
1321:
1322: default:
1323: throw new RuntimeException();
1324:
1325: }
1326: return p;
1327: }
1328:
1329: public XMLPanel getPanel(WorkflowProcesses el) {
1330: return generateStandardPanel(el);
1331: }
1332:
1333: public XMLPanel getPanel(WorkingTime el) {
1334: return generateStandardPanel(el);
1335: }
1336:
1337: public XMLPanel getPanel(XPDLVersion el) {
1338: return generateStandardPanel(el);
1339: }
1340:
1341: public XMLPanel getPanel(XMLAttribute el) {
1342: if (el.getParent() instanceof ExternalPackage
1343: && el.toName().equals("href")) {
1344: return new XMLLocationPanel(getPanelContainer(), el,
1345: JaWEManager.getInstance().getJaWEController()
1346: .canModifyElement(el));
1347: }
1348: if (el.getParent() instanceof ExtendedAttribute) {
1349: if (el.toName().equals("Name")) {
1350: Set choices = JaWEManager.getInstance().getXPDLUtils()
1351: .getAllExtendedAttributeNames(
1352: (XMLComplexElement) el.getParent()
1353: .getParent().getParent(),
1354: JaWEManager.getInstance()
1355: .getXPDLHandler());
1356: String choosen = el.toValue();
1357: choices.add(choosen);
1358: return new XMLComboPanel(getPanelContainer(), el,
1359: new ArrayList(choices), false, true, false,
1360: true, JaWEManager.getInstance()
1361: .getJaWEController().canModifyElement(
1362: el));
1363: }
1364: XMLElement holder = el.getParent().getParent().getParent();
1365: if (XMLUtil.getWorkflowProcess(holder) != null
1366: && (holder instanceof Activity
1367: || holder instanceof Transition
1368: || holder instanceof Tool || holder instanceof WorkflowProcess)) {
1369: return new XMLMultiLineTextPanel(getPanelContainer(),
1370: el, "Value", false, true,
1371: XMLMultiLineTextPanel.SIZE_LARGE, false,
1372: JaWEManager.getInstance().getJaWEController()
1373: .canModifyElement(el));
1374: } else if (holder instanceof Application
1375: && ((Application) holder).getApplicationTypes()
1376: .getChoosen() instanceof FormalParameters) {
1377: return new XMLMultiLineTextPanel(getPanelContainer(),
1378: el, "Value", false, true,
1379: XMLMultiLineTextPanel.SIZE_LARGE, false,
1380: JaWEManager.getInstance().getJaWEController()
1381: .canModifyElement(el));
1382: } else {
1383: return new XMLMultiLineTextPanel(getPanelContainer(),
1384: el, "Value", false, true,
1385: XMLMultiLineTextPanel.SIZE_LARGE, false,
1386: JaWEManager.getInstance().getJaWEController()
1387: .canModifyElement(el));
1388: }
1389: }
1390: if (el.getParent() instanceof BlockActivity) {
1391: WorkflowProcess wp = XMLUtil.getWorkflowProcess(el);
1392: List choices = wp.getActivitySets().toElements();
1393: XMLElement choosen = wp.getActivitySet(el.toValue());
1394: // if (choosen==null && choices.size()>0) {
1395: // choosen=(XMLElement)choices.get(0);
1396: // getPanelContainer().setModified(true);
1397: // }
1398: SpecialChoiceElement cc = new SpecialChoiceElement(el, "",
1399: choices, choosen, true, "Id", "ActivitySet", el
1400: .isRequired());
1401: cc.setReadOnly(el.isReadOnly());
1402:
1403: return new XMLComboPanel(getPanelContainer(), cc, null,
1404: false, true, false, false, JaWEManager
1405: .getInstance().getJaWEController()
1406: .canModifyElement(el));
1407:
1408: }
1409: if (el.toName().equalsIgnoreCase("From")) {
1410: return getPanelForFROMAttribute((Transition) el.getParent());
1411: }
1412: if (el.toName().equalsIgnoreCase("To")) {
1413: return getPanelForTOAttribute((Transition) el.getParent());
1414: }
1415: if (el.toName().equalsIgnoreCase("ObjectClassFilter")) {
1416: return new XMLComboPanel(getPanelContainer(), el, null,
1417: true, true, false, true, true);
1418:
1419: }
1420: if (el.toName().equalsIgnoreCase("Password")) {
1421: return new XMLTextPanel(getPanelContainer(), el, false,
1422: true, true);
1423: }
1424: return generateStandardPanel(el);
1425: }
1426:
1427: public XMLPanel getPanel(XMLEmptyChoiceElement el) {
1428: return new XMLBasicPanel();
1429: }
1430:
1431: public XMLPanel getPanel(XMLComplexChoice el) {
1432: return generateStandardPanel(el);
1433: }
1434:
1435: public XMLPanel getPanel(XMLCollection el) {
1436: return generateStandardPanel(el);
1437: }
1438:
1439: public XMLPanel getPanel(XMLComplexElement el) {
1440: return generateStandardPanel(el);
1441: }
1442:
1443: public XMLPanel getPanel(XMLSimpleElement el) {
1444: return generateStandardPanel(el);
1445: }
1446:
1447: public XMLPanel getPanel(XMLElement el) {
1448:
1449: try {
1450: Class cl = el.getClass();
1451: Method m = null;
1452: try {
1453: m = this .getClass().getMethod("getPanel",
1454: new Class[] { cl });
1455: } catch (Exception ex) {
1456: if (!(cl == XMLSimpleElement.class
1457: || cl == XMLAttribute.class
1458: || cl == XMLComplexChoice.class
1459: || cl == XMLComplexElement.class
1460: || cl == XMLCollectionElement.class || cl == XMLCollection.class)) {
1461: if (XMLComplexChoice.class.isAssignableFrom(cl)) {
1462: cl = XMLComplexChoice.class;
1463: } else if (XMLAttribute.class.isAssignableFrom(cl)) {
1464: cl = XMLAttribute.class;
1465: } else if (XMLSimpleElement.class
1466: .isAssignableFrom(cl)) {
1467: cl = XMLSimpleElement.class;
1468: } else if (XMLComplexElement.class
1469: .isAssignableFrom(cl)) {
1470: cl = XMLComplexElement.class;
1471: } else if (XMLCollection.class.isAssignableFrom(cl)) {
1472: cl = XMLCollection.class;
1473: }
1474: }
1475: }
1476:
1477: m = this .getClass().getMethod("getPanel",
1478: new Class[] { cl });
1479: // System.err.println("calling "+m.toString());
1480: return (XMLPanel) m.invoke(this , new Object[] { el });
1481: } catch (Throwable e) {
1482: e.printStackTrace();
1483: }
1484:
1485: return generateStandardPanel(el);
1486: }
1487:
1488: protected XMLPanel getPanelForFROMAttribute(Transition transition) {
1489: SequencedHashMap choices = JaWEManager.getInstance()
1490: .getTransitionHandler().getPossibleSourceActivities(
1491: transition);
1492:
1493: // System.out.println("Choices="+choices);
1494: String tFrom = transition.getFrom();
1495:
1496: Activity current = ((Activities) ((XMLCollectionElement) transition
1497: .getParent().getParent()).get("Activities"))
1498: .getActivity(tFrom);
1499: if (current != null)
1500: choices.put(current.getId(), current);
1501:
1502: Activity choosen = null;
1503: if (!tFrom.equals("")) {
1504: choosen = (Activity) choices.get(tFrom);
1505: }
1506: // if (choosen==null && choices.size()>0) {
1507: // choosen=(Activity)choices.getValue(0);
1508: // getPanelContainer().setModified(true);
1509: // }
1510:
1511: XMLAttribute from = (XMLAttribute) transition.get("From");
1512: SpecialChoiceElement cc = new SpecialChoiceElement(from, "",
1513: new ArrayList(choices.values()), choosen, true, "Id",
1514: "From", from.isRequired());
1515: cc.setReadOnly(from.isReadOnly());
1516: return new XMLComboPanel(getPanelContainer(), cc, null, false,
1517: true, false, false, JaWEManager.getInstance()
1518: .getJaWEController().canModifyElement(from));
1519: }
1520:
1521: protected XMLPanel getPanelForTOAttribute(Transition transition) {
1522: SequencedHashMap choices = JaWEManager.getInstance()
1523: .getTransitionHandler().getPossibleTargetActivities(
1524: transition);
1525: String tTo = transition.getTo();
1526:
1527: Activity current = ((Activities) ((XMLCollectionElement) transition
1528: .getParent().getParent()).get("Activities"))
1529: .getActivity(tTo);
1530: if (current != null)
1531: choices.put(current.getId(), current);
1532:
1533: Activity choosen = null;
1534: if (!tTo.equals("")) {
1535: choosen = (Activity) choices.get(tTo);
1536: }
1537: // if (choosen==null && choices.size()>0) {
1538: // choosen=(Activity)choices.getValue(0);
1539: // getPanelContainer().setModified(true);
1540: // }
1541:
1542: XMLAttribute to = (XMLAttribute) transition.get("To");
1543: SpecialChoiceElement cc = new SpecialChoiceElement(to, "",
1544: new ArrayList(choices.values()), choosen, true, "Id",
1545: "To", to.isRequired());
1546: cc.setReadOnly(to.isReadOnly());
1547: return new XMLComboPanel(getPanelContainer(), cc, null, false,
1548: true, false, false, JaWEManager.getInstance()
1549: .getJaWEController().canModifyElement(to));
1550: }
1551:
1552: public XMLPanel generateStandardPanel(XMLElement el) {
1553: // new Throwable().printStackTrace();
1554: // System.err.println("generateStandardPanel, el = "+el);
1555: XMLPanel panel = null;
1556: if (el instanceof XMLSimpleElement) {
1557: panel = generateStandardTextPanel(el, false);
1558: } else if (el instanceof XMLAttribute) {
1559: List choices = ((XMLAttribute) el).getChoices();
1560: if (choices == null) {
1561: panel = generateStandardTextPanel(el, false);
1562: } else {
1563: panel = new XMLComboPanel(getPanelContainer(), el,
1564: null, false, true, false, false, JaWEManager
1565: .getInstance().getJaWEController()
1566: .canModifyElement(el));
1567: }
1568:
1569: } else if (el instanceof XMLComplexChoice) {
1570: panel = new XMLComboChoicePanel(getPanelContainer(), el,
1571: JaWEManager.getInstance().getJaWEController()
1572: .canModifyElement(el));
1573: } else if (el instanceof XMLComplexElement) {
1574: panel = generateStandardGroupPanel((XMLComplexElement) el,
1575: false, true);
1576: } else if (el instanceof XMLCollection) {
1577: panel = generateStandardTablePanel((XMLCollection) el,
1578: true, false);
1579: } else {
1580: panel = new XMLBasicPanel();
1581: }
1582: return panel;
1583: }
1584:
1585: protected XMLMultiLineTextPanel generateStandardMultiLineTextPanel(
1586:
1587: XMLElement el, boolean isVertical, int size, boolean wrapLines) {
1588: return new XMLMultiLineTextPanel(getPanelContainer(), el,
1589: isVertical, size, wrapLines, JaWEManager.getInstance()
1590: .getJaWEController().canModifyElement(el));
1591: }
1592:
1593: protected XMLTextPanel generateStandardTextPanel(XMLElement el,
1594: boolean isVertical) {
1595: return new XMLTextPanel(getPanelContainer(), el, isVertical,
1596: false, JaWEManager.getInstance().getJaWEController()
1597: .canModifyElement(el));
1598:
1599: }
1600:
1601: protected XMLBasicTablePanel generateStandardTablePanel(
1602: XMLCollection cl, boolean hasTitle, boolean hasEmptyBorder) {
1603: List elementsToShow = cl.toElements();
1604: Set hidden = getHiddenElements("XMLTablePanel", cl);
1605: elementsToShow.removeAll(hidden);
1606: List columnsToShow = getColumnsToShow("XMLTablePanel", cl);
1607: boolean miniDim = false;
1608: if (cl instanceof ExtendedAttributes) {
1609: miniDim = true;
1610: }
1611: return new XMLBasicTablePanel(
1612: (InlinePanel) getPanelContainer(), cl, columnsToShow,
1613: elementsToShow, JaWEManager.getInstance()
1614: .getLabelGenerator().getLabel(cl)
1615: + ", "
1616: + (cl.size() - hidden.size())
1617: + " "
1618: + getPanelContainer()
1619: .getLanguageDependentString(
1620: "ElementsKey"), true, false,
1621: false, miniDim, true, true);
1622: }
1623:
1624: protected XMLBasicListPanel generateStandardListPanel(
1625: XMLCollection cl, boolean hasTitle, boolean hasEmptyBorder) {
1626: List elementsToShow = cl.toElements();
1627: Set hidden = getHiddenElements("XMLListPanel", cl);
1628: elementsToShow.removeAll(hidden);
1629: return new XMLBasicListPanel((InlinePanel) getPanelContainer(),
1630: cl, elementsToShow, JaWEManager.getInstance()
1631: .getLabelGenerator().getLabel(cl)
1632: + ", "
1633: + (cl.size() - hidden.size())
1634: + " "
1635: + getPanelContainer()
1636: .getLanguageDependentString(
1637: "ElementsKey"), true, false,
1638: true, false);
1639: }
1640:
1641: protected XMLGroupPanel generateStandardGroupPanel(
1642: XMLComplexElement cel, boolean hasTitle,
1643: boolean hasEmptyBorder) {
1644: Set hidden = getHiddenElements("XMLGroupPanel", cel);
1645: List toShow = new ArrayList(cel.toElements());
1646: toShow.removeAll(hidden);
1647: if (cel instanceof Condition) {
1648: toShow.add(new XMLMultiLineTextPanel(getPanelContainer(),
1649: cel, "Xpression", false, true,
1650: XMLMultiLineTextPanel.SIZE_MEDIUM, false,
1651: JaWEManager.getInstance().getJaWEController()
1652: .canModifyElement(cel)));
1653: } else if (cel instanceof ExtendedAttribute) {
1654: XMLElement holder = cel.getParent().getParent();
1655: if (XMLUtil.getWorkflowProcess(holder) != null
1656: && (holder instanceof Activity
1657: || holder instanceof Transition
1658: || holder instanceof Application
1659: || holder instanceof Tool || holder instanceof WorkflowProcess)) {
1660: toShow.add(new XMLMultiLineTextPanel(
1661: getPanelContainer(), cel, "ComplexContent",
1662: false, true, XMLMultiLineTextPanel.SIZE_LARGE,
1663: false, JaWEManager.getInstance()
1664: .getJaWEController().canModifyElement(
1665: cel)));
1666: } else {
1667: toShow.add(new XMLMultiLineTextPanel(
1668: getPanelContainer(), cel, "ComplexContent",
1669: false, true, XMLMultiLineTextPanel.SIZE_LARGE,
1670: false, JaWEManager.getInstance()
1671: .getJaWEController().canModifyElement(
1672: cel)));
1673: }
1674: } else if (cel instanceof SchemaType) {
1675: toShow.add(new XMLMultiLineTextPanel(getPanelContainer(),
1676: cel, "ComplexContent", false, true,
1677: XMLMultiLineTextPanel.SIZE_LARGE, false,
1678: JaWEManager.getInstance().getJaWEController()
1679: .canModifyElement(cel)));
1680: }
1681: return new XMLGroupPanel(getPanelContainer(), cel, toShow,
1682: JaWEManager.getInstance().getLabelGenerator().getLabel(
1683: cel), true, hasTitle, hasEmptyBorder);
1684: }
1685:
1686: protected Set getHiddenElements(String panelName,
1687: XMLComplexElement cel) {
1688: Set hidden = new HashSet();
1689:
1690: String hstr = getPanelContainer().getSettings()
1691: .getSettingString(
1692: "HideSubElements." + panelName + "."
1693: + cel.toName());
1694:
1695: String[] hstra = Utils.tokenize(hstr, " ");
1696: if (hstra != null) {
1697: for (int i = 0; i < hstra.length; i++) {
1698: XMLElement el = cel.get(hstra[i]);
1699: if (el != null) {
1700: hidden.add(el);
1701: } else if (cel instanceof Package) {
1702: Package pkg = (Package) cel;
1703: if (hstra[i].equals(pkg.getNamespaces().toName())) {
1704: hidden.add(pkg.getNamespaces());
1705: }
1706: }
1707: }
1708: }
1709: // if
1710: // (getProperties().getProperty(HIDE_COLLECTIONS_AND_COMPLEX_CHOICES,"false").equals("true"))
1711: // {
1712: // List subEls=cel.toElements();
1713: // for (int i=0; i<subEls.size(); i++) {
1714: // XMLElement subEl=(XMLElement)subEls.get(i);
1715: // if (subEl instanceof XMLCollection || subEl instanceof XMLComplexChoice || subEl
1716: // instanceof DataType) {
1717: // hidden.add(subEl);
1718: // }
1719: // }
1720: // }
1721: return hidden;
1722: }
1723:
1724: protected Set getHiddenElements(String panelName, XMLCollection col) {
1725: Set hidden = new HashSet();
1726: String elAttr = getPanelContainer().getSettings()
1727: .getSettingString(
1728: "HideElements." + panelName + "."
1729: + col.toName());
1730: String[] els = Utils.tokenize(elAttr, " ");
1731: for (int k = 0; k < els.length; k++) {
1732: String key = els[k];
1733: String hstr = getPanelContainer().getSettings()
1734: .getSettingString(
1735: "HideElements." + panelName + "."
1736: + col.toName() + "." + key);
1737: String[] hstra = Utils.tokenize(hstr, " ");
1738: if (hstra != null) {
1739: for (int i = 0; i < hstra.length; i++) {
1740: if (hstra[i].equals("*")) {
1741: hidden.addAll(col.toElements());
1742: return hidden;
1743: }
1744: Iterator ci = col.toElements().iterator();
1745: while (ci.hasNext()) {
1746: XMLElement el = (XMLElement) ci.next();
1747: if (key.equals("")) {
1748: if (el.toValue().equals(hstra[i])) {
1749: hidden.add(el);
1750: }
1751: } else {
1752: if (el instanceof XMLComplexElement) {
1753: XMLElement sel = ((XMLComplexElement) el)
1754: .get(key);
1755: if (sel != null) {
1756: if (sel.toValue().equals(hstra[i])) {
1757: hidden.add(el);
1758: }
1759: }
1760: }
1761: }
1762: }
1763: }
1764: }
1765: }
1766: // System.out.println("There are "+hidden.size()+" hidden elements for panel
1767: // "+panelName+",
1768: // col="+col+", ks="+keyStarts+", colsize="+col.size());
1769: return hidden;
1770: }
1771:
1772: protected List getColumnsToShow(String panelName, XMLCollection col) {
1773: XMLElement el = col.generateNewElement();
1774: List toShow = new ArrayList();
1775: if (el instanceof XMLComplexElement) {
1776: String hstr = getPanelContainer().getSettings()
1777: .getSettingString(
1778: "ShowColumns." + panelName + "."
1779: + col.toName());
1780: // System.err.println("CTS for col "+col+" is "+hstr);
1781: String[] hstra = Utils.tokenize(hstr, " ");
1782: if (hstra.length > 0) {
1783: toShow.addAll(Arrays.asList(hstra));
1784: } else {
1785: toShow.addAll(((XMLComplexElement) el).toElementMap()
1786: .keySet());
1787: }
1788: // System.err.println("CTS list for col "+col+" is "+toShow);
1789: }
1790: return toShow;
1791: }
1792:
1793: public Settings getSettings() {
1794: return getPanelContainer().getSettings();
1795: }
1796:
1797: protected IconCBoxRenderer cbr = new IconCBoxRenderer();
1798:
1799: class IconCBoxRenderer extends JLabel implements ListCellRenderer {
1800:
1801: public IconCBoxRenderer() {
1802: setOpaque(true);
1803: }
1804:
1805: /*
1806: * This method finds the image and text corresponding to the selected value and
1807: * returns the label, set up to display the text and image.
1808: */
1809: public Component getListCellRendererComponent(JList list,
1810: Object value, int index, boolean isSelected,
1811: boolean cellHasFocus) {
1812: // Get the selected index. (The index param isn't
1813: // always valid, so just use the value.)
1814: String iconLoc = value.toString();
1815:
1816: if (isSelected) {
1817: setBackground(list.getSelectionBackground());
1818: setForeground(list.getSelectionForeground());
1819: } else {
1820: setBackground(list.getBackground());
1821: setForeground(list.getForeground());
1822: }
1823:
1824: // Set the icon and text. If icon was null, say so.
1825: ImageIcon icon = (ImageIcon) Utils
1826: .getOriginalActivityIconsMap().get(iconLoc);
1827: setIcon(icon);
1828: setText(iconLoc);
1829:
1830: return this;
1831: }
1832:
1833: }
1834:
1835: }
|