0001: /*
0002: * JFolder, Copyright 2001-2006 Gary Steinmetz
0003: *
0004: * Distributable under LGPL license.
0005: * See terms of license at gnu.org.
0006: */
0007:
0008: package org.jfolder.console.base;
0009:
0010: //base classes
0011: import java.io.IOException;
0012: import java.util.ArrayList;
0013: import java.util.HashMap;
0014: import javax.servlet.ServletException;
0015:
0016: //project specific classes
0017: import org.jfolder.common.UnexpectedSystemException;
0018: import org.jfolder.common.tagging.ConceptRollupTag;
0019: import org.jfolder.common.tagging.ConceptTag;
0020: import org.jfolder.common.tagging.ConceptTagCharacteristic;
0021: import org.jfolder.common.tagging.ConceptTagPreferences;
0022: import org.jfolder.common.tagging.ConceptTagSetHolder;
0023: import org.jfolder.common.tagging.RootConceptTagHolder;
0024: import org.jfolder.common.utils.misc.CommonSeparators;
0025: import org.jfolder.common.utils.misc.MiscHelper;
0026: import org.jfolder.common.utils.web.ParameterSet;
0027: import org.jfolder.common.web.template.ConsoleParameterContext;
0028: import org.jfolder.common.web.template.PageSetupContext;
0029: import org.jfolder.common.web.template.SubmitActionContext;
0030: import org.jfolder.common.web.template.SubmitActionParameters;
0031: import org.jfolder.console.config.ConsoleConfig;
0032: import org.jfolder.console.config.ConsoleConfigTagHelper;
0033: import org.jfolder.console.config.ConsoleConfigTagPreferencesHelper;
0034: import org.jfolder.security.model.UserHolder;
0035: import org.jfolder.security.model.UserIdentity;
0036: import org.jfolder.services.console.ConsoleService;
0037: import org.jfolder.services.console.ConsoleServiceCallerFactory;
0038:
0039: //other classes
0040:
0041: public abstract class BaseRcthStudioServlet extends BaseConsoleServlet {
0042:
0043: //
0044: public final static int AREA__TOP = 0;
0045: public final static int AREA__LEFT = 1;
0046: public final static int AREA__CENTER = 2;
0047: public final static int AREA__RIGHT = 3;
0048: //
0049: public final static int AREA__MINIMUM_SIZE = ConsoleConfigTagHelper.AREA__MINIMUM_SIZE;
0050:
0051: public BaseRcthStudioServlet() {
0052: }
0053:
0054: protected boolean checkAccess(ConsolePageSession inCps)
0055: throws IOException, ServletException {
0056:
0057: boolean outValue = false;
0058:
0059: outValue = inCps.isDeveloper();
0060:
0061: return outValue;
0062: }
0063:
0064: public final ConsolePageContext process(ConsolePageSession inCps,
0065: UserHolder inUser, ParameterSet inPs,
0066: SubmitActionContext inSac) throws IOException,
0067: ServletException {
0068:
0069: ConsolePageContext outValue = null;
0070:
0071: BaseRcthStudioSettings brss = BaseRcthStudioSettings
0072: .newInstance();
0073: outValue = subProcess(inCps, inUser, inPs, inSac, brss);
0074:
0075: postProcess(outValue, inCps, inUser, inPs, inSac, brss);
0076:
0077: return outValue;
0078: }
0079:
0080: public abstract ConsolePageContext subProcess(
0081: ConsolePageSession inCps, UserHolder inUser,
0082: ParameterSet inPs, SubmitActionContext inSac,
0083: BaseRcthStudioSettings inBrss) throws IOException,
0084: ServletException;
0085:
0086: private void postProcess(ConsolePageContext inCpc,
0087: ConsolePageSession inCps, UserHolder inUser,
0088: ParameterSet inPs, SubmitActionContext inSac,
0089: BaseRcthStudioSettings inBrss) {
0090: //
0091:
0092: //
0093: //
0094: //
0095: if (inBrss.isUpdatedHighlightHandlePresent()) {
0096: //
0097: String uhh = inBrss.getUpdatedHighlightHandle();
0098: inCpc.setHighlightHandle(uhh);
0099: //
0100: //
0101: //
0102: RootConceptTagHolder localRcth = inCps
0103: .getCurrentApplicationRootHolder();
0104: ConceptTagPreferences localCtp = localRcth.getPreferences();
0105: //
0106: PageSetupContext localPsc = inCps.getPageSetupContext();
0107: localPsc.setHighlightHandleUpdated(true);
0108: //
0109: String localCs[] = inSac.getCommonStems();
0110: for (int i = 0; i < localCs.length; i++) {
0111: ArrayList nextStemHighlight = MiscHelper.parseHandle(
0112: localCs[i],
0113: CommonSeparators.TOGGLE_LINK_SEPARATOR);
0114: //
0115: ArrayList hhParts = MiscHelper.parseHandle(uhh,
0116: localCtp.getHandleConjunction());
0117: //
0118: MiscHelper.println("BasRtchStuServ cs.len = "
0119: + localCs.length);
0120: MiscHelper.println("BasRtchStuServ localCs = "
0121: + localCs[i]);
0122: MiscHelper.println("BasRtchStuServ uhh = " + uhh);
0123: //
0124: nextStemHighlight.addAll(hhParts);
0125: //
0126: for (int j = (nextStemHighlight.size() - 1); j >= 0; j--) {
0127: //
0128: String nextTreeLocation = MiscHelper
0129: .reassembleHandle(
0130: nextStemHighlight,
0131: CommonSeparators.TOGGLE_LINK_SEPARATOR);
0132:
0133: //
0134: if (!inCpc.isTreeComponentPresent(nextTreeLocation)) {
0135: //MiscHelper.println(
0136: // "BasRtchStuServ nextTreeLoc = "
0137: // + nextTreeLocation);
0138: inCpc.addTreeComponent(nextTreeLocation);
0139: }
0140:
0141: nextStemHighlight.remove(j);
0142: }
0143: }
0144: }
0145:
0146: //
0147: //
0148: //
0149: if (inBrss.isRcthChangePresent()) {
0150: //
0151: RootConceptTagHolder localRcth = inCps
0152: .getCurrentApplicationRootHolder();
0153: ConceptTagPreferences localCtp = localRcth.getPreferences();
0154: String hc = localCtp.getHandleConjunction();
0155: //
0156: //
0157: //
0158: if (inBrss.isRcthChangeCreate()) {
0159: adjustTreeBranches(inCpc, inBrss.getRcthChangeHandle(),
0160: inSac.getCommonStems(), false, localCtp);
0161: } else if (inBrss.isRcthChangeDelete()) {
0162: adjustTreeBranches(inCpc, inBrss.getRcthChangeHandle(),
0163: inSac.getCommonStems(), true, localCtp);
0164: } else if (inBrss.isRcthChangeUpdate()) {
0165: //
0166: adjustTreeBranches(inCpc, inBrss.getRcthChangeHandle(),
0167: inSac.getCommonStems(), true, localCtp);
0168: //
0169: adjustTreeBranches(inCpc, inBrss.getRcthChangeHandle(),
0170: inSac.getCommonStems(), false, localCtp);
0171: } else {
0172: throw UnexpectedSystemException.unknownState();
0173: }
0174: //
0175: //
0176: //
0177: //
0178: //
0179: ConceptTagCharacteristic parCtchar = inBrss
0180: .getRcthChangeParent();
0181: String conName = parCtchar.getConstraintName();
0182: //
0183: if (localCtp.getUnconstrainedSymbol().equals(conName)) {
0184: //
0185: for (int i = 0; i < parCtchar.getValueLength(); i++) {
0186: //
0187: int p = i - 1;
0188: //
0189: if (i != 0) {
0190: if (parCtchar.isStatic(p, null)
0191: && parCtchar.isStatic(i, null)) {
0192: //
0193: String updatedValue = parCtchar
0194: .getValueAsString(p, null)
0195: + parCtchar.getValueAsString(i,
0196: null);
0197: //
0198: parCtchar.removeValueWithLocalFiles(i);
0199: parCtchar.removeValueWithLocalFiles(p);
0200: parCtchar.addValue(p, updatedValue);
0201: //
0202: String mergeHandle = inBrss
0203: .getRcthChangeParentHandle()
0204: + hc + i;
0205: adjustTreeBranches(inCpc, mergeHandle,
0206: inSac.getCommonStems(), true,
0207: localCtp);
0208: //
0209: i--;
0210: }
0211: }
0212: }
0213: }
0214: }
0215: //if (currentTreeHandle != null) {
0216: // RootConceptTagHolder localRcth =
0217: // inCs.getCurrentApplicationRootHolder();
0218: // ConceptTagPreferences localCtp = localRcth.getPreferences();
0219: // //
0220: // if (currentTreeDeleteNotAdd != null) {
0221: // inCpc.adjustNumericHandleWithCommonStems(
0222: // currentTreeHandle, inSac.getCommonStems(),
0223: // currentTreeDeleteNotAdd.booleanValue(), localCtp);
0224: // }
0225: // else {
0226: // inCpc.adjustNumericHandleWithCommonStems(
0227: // currentTreeHandle, inSac.getCommonStems(),
0228: // false, localCtp);
0229: // inCpc.adjustNumericHandleWithCommonStems(
0230: // currentTreeHandle, inSac.getCommonStems(),
0231: // true, localCtp);
0232: // }
0233: //}
0234: }
0235:
0236: private void adjustTreeBranches(ConsolePageContext inCpc,
0237: String inHandle, String inCommonStems[],
0238: boolean inDeleteNotAdd, ConceptTagPreferences inCtp) {
0239: //
0240: inCpc.adjustNumericHandleWithCommonStems(inHandle,
0241: inCommonStems, inDeleteNotAdd, inCtp);
0242: }
0243:
0244: protected boolean commonActions(ConsolePageSession inCps,
0245: UserHolder inUser, ParameterSet inPs,
0246: SubmitActionContext inSac, BaseRcthStudioSettings inBrss) {
0247:
0248: boolean outValue = true;
0249:
0250: if (inSac.isAction(SubmitActionParameters.DO_NOTHING)) {
0251: } else if (inSac.isAction(SubmitActionParameters.COPY)) {
0252: //
0253: //
0254: accountForRcthTextChanges(inCps, inPs);
0255: //
0256: //
0257: //
0258: //ConsolePageSession localCps = getConsolePageSession();
0259: //
0260: String parentCode = inSac
0261: .getParameter(ConsoleParameterContext.FIRST_INPUT);
0262: int copyIndex = Integer
0263: .parseInt(inSac
0264: .getParameter(ConsoleParameterContext.SECOND_INPUT));
0265: //
0266: inCps.setCopyHolder(parentCode, copyIndex);
0267: //
0268: //
0269: //
0270: inCps.validateCurrentApplicationRootHolder();
0271: //
0272: //
0273: } else if (inSac.isAction(SubmitActionParameters.PASTE)) {
0274: //
0275: //
0276: accountForRcthTextChanges(inCps, inPs);
0277: //
0278: //
0279: //
0280: String parentCode = inSac
0281: .getParameter(ConsoleParameterContext.FIRST_INPUT);
0282: int copyIndex = Integer
0283: .parseInt(inSac
0284: .getParameter(ConsoleParameterContext.SECOND_INPUT));
0285: //
0286: RootConceptTagHolder localRcth = inCps
0287: .getCurrentApplicationRootHolder();
0288: ConceptTagCharacteristic localCtchar = localRcth
0289: .getCharacteristic(parentCode);
0290: //
0291: if (inSac.isSubAction(SubmitActionParameters.REPLACE)) {
0292: //
0293: localCtchar.removeValueWithLocalFiles(copyIndex);
0294: //
0295: inCps.enableCopyHolderAsPasteInsert(parentCode,
0296: copyIndex);
0297: } else if (inSac.isSubAction(SubmitActionParameters.ADD)) {
0298: //
0299: inCps.enableCopyHolderAsPasteInsert(parentCode,
0300: copyIndex);
0301: } else {
0302: throw UnexpectedSystemException.unknownState();
0303: }
0304: //
0305: //
0306: inCps.validateCurrentApplicationRootHolder();
0307: //
0308: //
0309: } else if (inSac.isAction(SubmitActionParameters.REFRESH)) {
0310: //
0311: //
0312: accountForRcthTextChanges(inCps, inPs);
0313: //
0314: inCps.validateCurrentApplicationRootHolder();
0315: //
0316: //
0317: } else if (inSac
0318: .isAction(SubmitActionParameters.SHOW_RCTH_TEXT)) {
0319: //
0320: //
0321: RootConceptTagHolder localRcth = inCps
0322: .getCurrentApplicationRootHolder();
0323: byte content[] = MiscHelper.fromStringToBytes(localRcth
0324: .getXMLRepresentation());
0325: //
0326: inBrss.setRcthBinaryOutput("content.xml", "text/xml",
0327: content);
0328: } else if (inSac
0329: .isAction(SubmitActionParameters.SHOW_RCTH_ROLLUP)) {
0330: //
0331: //
0332: RootConceptTagHolder localRcth = inCps
0333: .getCurrentApplicationRootHolder();
0334: byte content[] = ConceptRollupTag.getRollupFromList(
0335: localRcth, null);
0336: inBrss.setRcthBinaryOutput("content.zip",
0337: "application/download", content);
0338: } else if (inSac
0339: .isAction(SubmitActionParameters.SHOW_CONSOLE_CONFIG_RCTH_TEXT)) {
0340: //
0341: //
0342: RootConceptTagHolder localRcth = inCps.getConsoleConfig();
0343: byte content[] = MiscHelper.fromStringToBytes(localRcth
0344: .getXMLRepresentation());
0345: //
0346: inBrss.setRcthBinaryOutput("config.xml", "text/xml",
0347: content);
0348: } else if (inSac
0349: .isAction(SubmitActionParameters.SHOW_CONSOLE_CONFIG_RCTH_ROLLUP)) {
0350: //
0351: //
0352: RootConceptTagHolder localRcth = inCps.getConsoleConfig();
0353: byte content[] = ConceptRollupTag.getRollupFromList(
0354: localRcth, null);
0355: inBrss.setRcthBinaryOutput("config.zip",
0356: "application/download", content);
0357: } else if (inSac.isAction(SubmitActionParameters.MOVE)) {
0358: inBrss.setUpdatedHighlightHandle(inSac
0359: .getParameter(ConsoleParameterContext.FIRST_INPUT));
0360: accountForRcthTextChanges(inCps, inPs);
0361: inCps.validateCurrentApplicationRootHolder();
0362: } else if (inSac.isAction(SubmitActionParameters.DELETE)) {
0363: //
0364: //
0365: //
0366: accountForRcthTextChanges(inCps, inPs);
0367: //
0368: //
0369: String parentCode = inSac
0370: .getParameter(ConsoleParameterContext.FIRST_INPUT);
0371: int deleteIndex = Integer
0372: .parseInt(inSac
0373: .getParameter(ConsoleParameterContext.SECOND_INPUT));
0374: //
0375: RootConceptTagHolder localRcth = inCps
0376: .getCurrentApplicationRootHolder();
0377: ConceptTagCharacteristic localCtchar = localRcth
0378: .getCharacteristic(parentCode);
0379: //
0380: localCtchar.removeValueWithLocalFiles(deleteIndex);
0381: inCps.validateCurrentApplicationRootHolder();
0382: //
0383: ConceptTagPreferences localCtp = localRcth.getPreferences();
0384: String hc = localCtp.getHandleConjunction();
0385: //
0386: //
0387: //
0388: inBrss.registerRcthDelete(parentCode,
0389: (parentCode + hc + deleteIndex), localCtchar,
0390: deleteIndex);
0391: //
0392: //currentTreeHandle =
0393: // parentCode + localCtp.getHandleConjunction() + deleteIndex;
0394: //currentTreeDeleteNotAdd = new Boolean(true);
0395: } else if (inSac.isAction(SubmitActionParameters.ADD,
0396: SubmitActionParameters.COMPOUND)) {
0397: //
0398: //
0399: accountForRcthTextChanges(inCps, inPs);
0400: //
0401: //
0402: String parentCode = inSac
0403: .getParameter(ConsoleParameterContext.FIRST_INPUT);
0404: int addIndex = Integer
0405: .parseInt(inSac
0406: .getParameter(ConsoleParameterContext.SECOND_INPUT));
0407: //
0408: //
0409: RootConceptTagHolder localRcth = inCps
0410: .getCurrentApplicationRootHolder();
0411: ConceptTagCharacteristic localCtchar = localRcth
0412: .getCharacteristic(parentCode);
0413: //
0414: ConceptTagPreferences localCtp = localRcth.getPreferences();
0415: String hc = localCtp.getHandleConjunction();
0416: //
0417: localCtchar.createRegisteredHolder(addIndex, false);
0418: //boolean localValidate = localCtp//
0419: //localRcth
0420: inCps.validateCurrentApplicationRootHolder();
0421: //
0422: //
0423: //
0424: inBrss
0425: .registerRcthCreate(parentCode,
0426: (parentCode + hc + addIndex), localCtchar,
0427: addIndex);
0428: //currentTreeHandle =
0429: // parentCode + localCtp.getHandleConjunction() + addIndex;
0430: //currentTreeDeleteNotAdd = new Boolean(false);
0431: //outValue.adjustNumericHandleWithCommonStems(
0432: // fullHandle, inSac.getCommonStems(), false, localCtp);
0433: } else if (inSac.isAction(SubmitActionParameters.REPLACE,
0434: SubmitActionParameters.COMPOUND)) {
0435: //
0436: //
0437: accountForRcthTextChanges(inCps, inPs);
0438: //
0439: //
0440: String parentCode = inSac
0441: .getParameter(ConsoleParameterContext.FIRST_INPUT);
0442: int addIndex = Integer
0443: .parseInt(inSac
0444: .getParameter(ConsoleParameterContext.SECOND_INPUT));
0445: //
0446: //
0447: RootConceptTagHolder localRcth = inCps
0448: .getCurrentApplicationRootHolder();
0449: ConceptTagCharacteristic localCtchar = localRcth
0450: .getCharacteristic(parentCode);
0451: //
0452: ConceptTagPreferences localCtp = localRcth.getPreferences();
0453: String hc = localCtp.getHandleConjunction();
0454: //
0455: //
0456: localCtchar.replaceValueAndRemoveLocalFilesWithHolder(
0457: addIndex, false);
0458: //boolean localValidate = localCtp//
0459: //localRcth
0460: inCps.validateCurrentApplicationRootHolder();
0461: //
0462: //
0463: //
0464: inBrss
0465: .registerRcthUpdate(parentCode,
0466: (parentCode + hc + addIndex), localCtchar,
0467: addIndex);
0468: //
0469: //currentTreeHandle =
0470: // parentCode + localCtp.getHandleConjunction() + addIndex;
0471: //currentTreeDeleteNotAdd = null;
0472: //outValue.adjustNumericHandleWithCommonStems(
0473: // fullHandle, inSac.getCommonStems(), false, localCtp);
0474: } else if (inSac.isAction(SubmitActionParameters.ADD,
0475: SubmitActionParameters.CONCEPT_TAG)) {
0476: //
0477: //
0478: accountForRcthTextChanges(inCps, inPs);
0479: //
0480: //
0481: String parentCode = inSac
0482: .getParameter(ConsoleParameterContext.FIRST_INPUT);
0483: int addIndex = Integer
0484: .parseInt(inSac
0485: .getParameter(ConsoleParameterContext.SECOND_INPUT));
0486: //
0487: String ctNs = inSac
0488: .getParameter(ConsoleParameterContext.THIRD_INPUT);
0489: if (ctNs.length() == 0) {
0490: ctNs = null;
0491: }
0492: String ctName = inSac
0493: .getParameter(ConsoleParameterContext.FOURTH_INPUT);
0494: //
0495: RootConceptTagHolder localRcth = inCps
0496: .getCurrentApplicationRootHolder();
0497: ConceptTagCharacteristic localCtchar = localRcth
0498: .getCharacteristic(parentCode);
0499: //
0500: ConceptTagPreferences localCtp = localRcth.getPreferences();
0501: String hc = localCtp.getHandleConjunction();
0502: //
0503: ConceptTagSetHolder ctsh = localCtp.getSetHolder();
0504: Class ctClass = ctsh.getConceptTagClass(ctNs, ctName);
0505: ConceptTag ct = (ConceptTag) MiscHelper
0506: .newInstance(ctClass);
0507: //
0508: localCtchar.addValue(addIndex, ct, false);
0509: //boolean localValidate = localCtp//
0510: //localRcth
0511: inCps.validateCurrentApplicationRootHolder();
0512: //
0513: //
0514: //
0515: inBrss
0516: .registerRcthCreate(parentCode,
0517: (parentCode + hc + addIndex), localCtchar,
0518: addIndex);
0519: //currentTreeHandle =
0520: // parentCode + localCtp.getHandleConjunction() + addIndex;
0521: //currentTreeDeleteNotAdd = new Boolean(false);
0522: //outValue.adjustNumericHandleWithCommonStems(
0523: // fullHandle, inSac.getCommonStems(), false, localCtp);
0524: } else if (inSac.isAction(SubmitActionParameters.REPLACE,
0525: SubmitActionParameters.CONCEPT_TAG)) {
0526: //
0527: //
0528: accountForRcthTextChanges(inCps, inPs);
0529: //
0530: //
0531: String parentCode = inSac
0532: .getParameter(ConsoleParameterContext.FIRST_INPUT);
0533: int addIndex = Integer
0534: .parseInt(inSac
0535: .getParameter(ConsoleParameterContext.SECOND_INPUT));
0536: //
0537: String ctNs = inSac
0538: .getParameter(ConsoleParameterContext.THIRD_INPUT);
0539: if (ctNs.length() == 0) {
0540: ctNs = null;
0541: }
0542: String ctName = inSac
0543: .getParameter(ConsoleParameterContext.FOURTH_INPUT);
0544: //
0545: RootConceptTagHolder localRcth = inCps
0546: .getCurrentApplicationRootHolder();
0547: ConceptTagCharacteristic localCtchar = localRcth
0548: .getCharacteristic(parentCode);
0549: //
0550: ConceptTagPreferences localCtp = localRcth.getPreferences();
0551: String hc = localCtp.getHandleConjunction();
0552: //
0553: ConceptTagSetHolder ctsh = localCtp.getSetHolder();
0554: Class ctClass = ctsh.getConceptTagClass(ctNs, ctName);
0555: ConceptTag ct = (ConceptTag) MiscHelper
0556: .newInstance(ctClass);
0557: //
0558: localCtchar.replaceValueAndRemoveLocalFiles(addIndex, ct,
0559: false);
0560: //boolean localValidate = localCtp//
0561: //localRcth
0562: inCps.validateCurrentApplicationRootHolder();
0563: //
0564: //
0565: //
0566: inBrss
0567: .registerRcthUpdate(parentCode,
0568: (parentCode + hc + addIndex), localCtchar,
0569: addIndex);
0570: //
0571: //currentTreeHandle =
0572: // parentCode + localCtp.getHandleConjunction() + addIndex;
0573: //currentTreeDeleteNotAdd = null;
0574: //outValue.adjustNumericHandleWithCommonStems(
0575: // fullHandle, inSac.getCommonStems(), false, localCtp);
0576: } else if (inSac.isAction(SubmitActionParameters.ADD,
0577: SubmitActionParameters.TEXT)) {
0578: //
0579: //
0580: accountForRcthTextChanges(inCps, inPs);
0581: //
0582: //
0583: String parentCode = inSac
0584: .getParameter(ConsoleParameterContext.FIRST_INPUT);
0585: int addIndex = Integer
0586: .parseInt(inSac
0587: .getParameter(ConsoleParameterContext.SECOND_INPUT));
0588: //
0589: String value = inSac
0590: .getParameter(ConsoleParameterContext.THIRD_INPUT);
0591: value = MiscHelper.normalizeCarriageReturns(value);
0592: //
0593: RootConceptTagHolder localRcth = inCps
0594: .getCurrentApplicationRootHolder();
0595: ConceptTagCharacteristic localCtchar = localRcth
0596: .getCharacteristic(parentCode);
0597: //
0598: ConceptTagPreferences localCtp = localRcth.getPreferences();
0599: String hc = localCtp.getHandleConjunction();
0600: //
0601: //
0602: localCtchar.addValue(addIndex, value);
0603: inCps.validateCurrentApplicationRootHolder();
0604: //
0605: //
0606: //
0607: inBrss
0608: .registerRcthCreate(parentCode,
0609: (parentCode + hc + addIndex), localCtchar,
0610: addIndex);
0611: //
0612: //currentTreeHandle =
0613: // parentCode + localCtp.getHandleConjunction() + addIndex;
0614: //currentTreeDeleteNotAdd = new Boolean(false);
0615: //outValue.adjustNumericHandleWithCommonStems(
0616: // fullHandle, inSac.getCommonStems(), false, localCtp);
0617: } else if (inSac.isAction(SubmitActionParameters.REPLACE,
0618: SubmitActionParameters.TEXT)) {
0619: //
0620: //
0621: accountForRcthTextChanges(inCps, inPs);
0622: //
0623: //
0624: String parentCode = inSac
0625: .getParameter(ConsoleParameterContext.FIRST_INPUT);
0626: int addIndex = Integer
0627: .parseInt(inSac
0628: .getParameter(ConsoleParameterContext.SECOND_INPUT));
0629: //
0630: String value = inSac
0631: .getParameter(ConsoleParameterContext.THIRD_INPUT);
0632: value = MiscHelper.normalizeCarriageReturns(value);
0633: //
0634: RootConceptTagHolder localRcth = inCps
0635: .getCurrentApplicationRootHolder();
0636: ConceptTagCharacteristic localCtchar = localRcth
0637: .getCharacteristic(parentCode);
0638: //
0639: ConceptTagPreferences localCtp = localRcth.getPreferences();
0640: String hc = localCtp.getHandleConjunction();
0641: //
0642: //
0643: localCtchar
0644: .replaceValueAndRemoveLocalFiles(addIndex, value);
0645: inCps.validateCurrentApplicationRootHolder();
0646: //
0647: //
0648: //
0649: inBrss
0650: .registerRcthUpdate(parentCode,
0651: (parentCode + hc + addIndex), localCtchar,
0652: addIndex);
0653: //
0654: //currentTreeHandle =
0655: // parentCode + localCtp.getHandleConjunction() + addIndex;
0656: //currentTreeDeleteNotAdd = null;
0657: //outValue.adjustNumericHandleWithCommonStems(
0658: // fullHandle, inSac.getCommonStems(), false, localCtp);
0659: } else if (inSac
0660: .isAction(SubmitActionParameters.DELETE_CONSOLE_CONFIG)) {
0661: //
0662: accountForRcthTextChanges(inCps, inPs);
0663: //
0664: //
0665: ConsoleService cs = ConsoleServiceCallerFactory
0666: .getConsoleService();
0667: UserIdentity ui = inCps.getUserHolder().getUserIdentity();
0668: RootConceptTagHolder localRcth = inCps
0669: .getCurrentApplicationRootHolder();
0670: String prefHan = localRcth.getPreferences()
0671: .getPreferencesHandle();
0672: cs.resetConsoleConfig(ui, prefHan);
0673: //
0674: inCps.resetConsoleConfig();
0675: } else if (inSac
0676: .isAction(SubmitActionParameters.UPDATE_CONSOLE_CONFIG)) {
0677: //
0678: //
0679: accountForRcthTextChanges(inCps, inPs);
0680: //
0681: int section = Integer.parseInt(inSac
0682: .getParameter(ConsoleParameterContext.FIRST_INPUT));
0683: int index = Integer
0684: .parseInt(inSac
0685: .getParameter(ConsoleParameterContext.SECOND_INPUT));
0686: //
0687: //RootConceptTagHolder localRcth =
0688: // inCs.getCurrentApplicationRootHolder();
0689: //ConceptTagPreferences localCtp = localRcth.getPreferences();
0690: RootConceptTagHolder ccRcth = inCps.getConsoleConfig();
0691: ConsoleConfig cc = (ConsoleConfig) ccRcth
0692: .getFirstChildConceptTag();
0693:
0694: if (inSac.isSubAction(SubmitActionParameters.REMOVE_PANE)) {
0695: //
0696: if (section == AREA__LEFT) {
0697: //cc.removeLeftSectionPane(index);
0698: ConsoleConfigTagHelper.removeLeftSectionPane(cc,
0699: index);
0700: } else if (section == AREA__CENTER) {
0701: //cc.removeCenterSectionPane(index);
0702: ConsoleConfigTagHelper.removeCenterSectionPane(cc,
0703: index);
0704: } else if (section == AREA__RIGHT) {
0705: //cc.removeRightSectionPane(index);
0706: ConsoleConfigTagHelper.removeRightSectionPane(cc,
0707: index);
0708: } else {
0709: throw new UnexpectedSystemException(
0710: "Unknown Section '" + section + "'");
0711: }
0712: } else if (inSac
0713: .isSubAction(SubmitActionParameters.CREATE_PANE)) {
0714: //
0715: String context = inSac
0716: .getParameter(ConsoleParameterContext.THIRD_INPUT);
0717: //
0718: if (section == AREA__LEFT) {
0719: //cc.removeLeftSectionPane(index);
0720: //
0721: HashMap nextProps = new HashMap();
0722: nextProps
0723: .put(
0724: ConsoleConfigTagPreferencesHelper.PROP_NAME__HEIGHT,
0725: cc
0726: .getMainProperty(ConsoleConfigTagPreferencesHelper.PROP_NAME__HEIGHT));
0727: nextProps
0728: .put(
0729: ConsoleConfigTagPreferencesHelper.PROP_NAME__WIDTH,
0730: (AREA__MINIMUM_SIZE + ""));
0731: //
0732: ConsoleConfigTagHelper.createLeftSectionPane(cc,
0733: index, context, nextProps);
0734: } else if (section == AREA__CENTER) {
0735: //cc.removeCenterSectionPane(index);
0736: //
0737: HashMap nextProps = new HashMap();
0738: nextProps
0739: .put(
0740: ConsoleConfigTagPreferencesHelper.PROP_NAME__WIDTH,
0741: cc
0742: .getMainProperty(ConsoleConfigTagPreferencesHelper.PROP_NAME__WIDTH));
0743: nextProps
0744: .put(
0745: ConsoleConfigTagPreferencesHelper.PROP_NAME__HEIGHT,
0746: (AREA__MINIMUM_SIZE + ""));
0747: //
0748: ConsoleConfigTagHelper.createCenterSectionPane(cc,
0749: index, context, nextProps);
0750: } else if (section == AREA__RIGHT) {
0751: //cc.removeRightSectionPane(index);
0752: //
0753: HashMap nextProps = new HashMap();
0754: nextProps
0755: .put(
0756: ConsoleConfigTagPreferencesHelper.PROP_NAME__HEIGHT,
0757: cc
0758: .getMainProperty(ConsoleConfigTagPreferencesHelper.PROP_NAME__HEIGHT));
0759: nextProps
0760: .put(
0761: ConsoleConfigTagPreferencesHelper.PROP_NAME__WIDTH,
0762: (AREA__MINIMUM_SIZE + ""));
0763: //
0764: ConsoleConfigTagHelper.createRightSectionPane(cc,
0765: index, context, nextProps);
0766: } else {
0767: throw new UnexpectedSystemException(
0768: "Unknown Section '" + section + "'");
0769: }
0770: }
0771: //////////
0772: else if (inSac
0773: .isSubAction(SubmitActionParameters.STRETCH_PANE_HORIZONTALLY)) {
0774: //
0775: if (section == AREA__LEFT) {
0776: //cc.removeLeftSectionPane(index);
0777: ConsoleConfigTagHelper
0778: .adjustLeftSectionPaneHorizontally(cc,
0779: index, AREA__MINIMUM_SIZE);
0780: } else if (section == AREA__CENTER) {
0781: //cc.removeCenterSectionPane(index);
0782: ConsoleConfigTagHelper
0783: .adjustCenterSectionPaneHorizontally(cc,
0784: index, AREA__MINIMUM_SIZE);
0785: } else if (section == AREA__RIGHT) {
0786: //cc.removeRightSectionPane(index);
0787: ConsoleConfigTagHelper
0788: .adjustRightSectionPaneHorizontally(cc,
0789: index, AREA__MINIMUM_SIZE);
0790: } else {
0791: throw new UnexpectedSystemException(
0792: "Unknown Section '" + section + "'");
0793: }
0794:
0795: } else if (inSac
0796: .isSubAction(SubmitActionParameters.STRETCH_PANE_VERTICALLY)) {
0797: //
0798: if (section == AREA__LEFT) {
0799: //cc.removeLeftSectionPane(index);
0800: ConsoleConfigTagHelper
0801: .adjustLeftSectionPaneVertically(cc, index,
0802: AREA__MINIMUM_SIZE);
0803: } else if (section == AREA__CENTER) {
0804: //cc.removeCenterSectionPane(index);
0805: ConsoleConfigTagHelper
0806: .adjustCenterSectionPaneVertically(cc,
0807: index, AREA__MINIMUM_SIZE);
0808: } else if (section == AREA__RIGHT) {
0809: //cc.removeRightSectionPane(index);
0810: ConsoleConfigTagHelper
0811: .adjustRightSectionPaneVertically(cc,
0812: index, AREA__MINIMUM_SIZE);
0813: } else {
0814: throw new UnexpectedSystemException(
0815: "Unknown Section '" + section + "'");
0816: }
0817: }
0818: //////////
0819: else if (inSac
0820: .isSubAction(SubmitActionParameters.SHRINK_PANE_HORIZONTALLY)) {
0821: //
0822: if (section == AREA__LEFT) {
0823: //cc.removeLeftSectionPane(index);
0824: ConsoleConfigTagHelper
0825: .adjustLeftSectionPaneHorizontally(cc,
0826: index, -AREA__MINIMUM_SIZE);
0827: } else if (section == AREA__CENTER) {
0828: //cc.removeCenterSectionPane(index);
0829: ConsoleConfigTagHelper
0830: .adjustCenterSectionPaneHorizontally(cc,
0831: index, -AREA__MINIMUM_SIZE);
0832: } else if (section == AREA__RIGHT) {
0833: //cc.removeRightSectionPane(index);
0834: ConsoleConfigTagHelper
0835: .adjustRightSectionPaneHorizontally(cc,
0836: index, -AREA__MINIMUM_SIZE);
0837: } else {
0838: throw new UnexpectedSystemException(
0839: "Unknown Section '" + section + "'");
0840: }
0841:
0842: } else if (inSac
0843: .isSubAction(SubmitActionParameters.SHRINK_PANE_VERTICALLY)) {
0844: //
0845: if (section == AREA__LEFT) {
0846: //cc.removeLeftSectionPane(index);
0847: ConsoleConfigTagHelper
0848: .adjustLeftSectionPaneVertically(cc, index,
0849: -AREA__MINIMUM_SIZE);
0850: } else if (section == AREA__CENTER) {
0851: //cc.removeCenterSectionPane(index);
0852: ConsoleConfigTagHelper
0853: .adjustCenterSectionPaneVertically(cc,
0854: index, -AREA__MINIMUM_SIZE);
0855: } else if (section == AREA__RIGHT) {
0856: //cc.removeRightSectionPane(index);
0857: ConsoleConfigTagHelper
0858: .adjustRightSectionPaneVertically(cc,
0859: index, -AREA__MINIMUM_SIZE);
0860: } else {
0861: throw new UnexpectedSystemException(
0862: "Unknown Section '" + section + "'");
0863: }
0864: }
0865: //////////
0866: else if (inSac
0867: .isSubAction(SubmitActionParameters.MOVE_TO_LEFT_SECTION)) {
0868: //
0869: if (section == AREA__CENTER) {
0870:
0871: HashMap centerProps = getAllCenterSectionPaneProperties(
0872: cc, index);
0873: String contextName = cc
0874: .getCenterSectionPaneContext(index);
0875:
0876: ConsoleConfigTagHelper.removeCenterSectionPane(cc,
0877: index);
0878:
0879: ConsoleConfigTagHelper.createLeftSectionPane(cc, 0,
0880: contextName, centerProps);
0881: } else if (section == AREA__RIGHT) {
0882:
0883: HashMap rightProps = getAllRightSectionPaneProperties(
0884: cc, index);
0885: String contextName = cc
0886: .getRightSectionPaneContext(index);
0887:
0888: ConsoleConfigTagHelper.removeRightSectionPane(cc,
0889: index);
0890:
0891: ConsoleConfigTagHelper.createLeftSectionPane(cc, 0,
0892: contextName, rightProps);
0893: } else {
0894: throw new UnexpectedSystemException(
0895: "Unknown Section '" + section + "'");
0896: }
0897: } else if (inSac
0898: .isSubAction(SubmitActionParameters.MOVE_TO_CENTER_SECTION)) {
0899: //
0900: if (section == AREA__LEFT) {
0901:
0902: HashMap leftProps = getAllLeftSectionPaneProperties(
0903: cc, index);
0904: String contextName = cc
0905: .getLeftSectionPaneContext(index);
0906:
0907: ConsoleConfigTagHelper.removeLeftSectionPane(cc,
0908: index);
0909:
0910: int centerCount = cc.getCenterSectionPaneCount();
0911: //if (centerCount > 0) {
0912: ConsoleConfigTagHelper.createCenterSectionPane(cc,
0913: (centerCount), contextName, leftProps);
0914: //}
0915: //else {
0916: // ConsoleConfigTagHelper.createCenterSectionPane(
0917: // cc, 0, contextName, leftProps);
0918: //}
0919: } else if (section == AREA__RIGHT) {
0920:
0921: HashMap rightProps = getAllRightSectionPaneProperties(
0922: cc, index);
0923: String contextName = cc
0924: .getRightSectionPaneContext(index);
0925:
0926: ConsoleConfigTagHelper.removeRightSectionPane(cc,
0927: index);
0928:
0929: int centerCount = cc.getCenterSectionPaneCount();
0930: //if (centerCount > 0) {
0931: ConsoleConfigTagHelper.createCenterSectionPane(cc,
0932: (centerCount), contextName, rightProps);
0933: //}
0934: //else {
0935: // ConsoleConfigTagHelper.createCenterSectionPane(
0936: // cc, 0, contextName, rightProps);
0937: //}
0938: } else {
0939: throw new UnexpectedSystemException(
0940: "Unknown Section '" + section + "'");
0941: }
0942: } else if (inSac
0943: .isSubAction(SubmitActionParameters.MOVE_TO_RIGHT_SECTION)) {
0944: //
0945: if (section == AREA__CENTER) {
0946:
0947: HashMap centerProps = getAllCenterSectionPaneProperties(
0948: cc, index);
0949: String contextName = cc
0950: .getCenterSectionPaneContext(index);
0951:
0952: ConsoleConfigTagHelper.removeCenterSectionPane(cc,
0953: index);
0954:
0955: int rightCount = cc.getRightSectionPaneCount();
0956: if (rightCount > 0) {
0957: ConsoleConfigTagHelper.createRightSectionPane(
0958: cc, (rightCount - 1), contextName,
0959: centerProps);
0960: } else {
0961: ConsoleConfigTagHelper.createRightSectionPane(
0962: cc, 0, contextName, centerProps);
0963: }
0964: } else if (section == AREA__LEFT) {
0965:
0966: HashMap leftProps = getAllLeftSectionPaneProperties(
0967: cc, index);
0968: String contextName = cc
0969: .getLeftSectionPaneContext(index);
0970:
0971: ConsoleConfigTagHelper.removeLeftSectionPane(cc,
0972: index);
0973:
0974: int rightCount = cc.getRightSectionPaneCount();
0975: if (rightCount > 0) {
0976: ConsoleConfigTagHelper.createRightSectionPane(
0977: cc, (rightCount - 1), contextName,
0978: leftProps);
0979: } else {
0980: ConsoleConfigTagHelper.createRightSectionPane(
0981: cc, 0, contextName, leftProps);
0982: }
0983: } else {
0984: throw new UnexpectedSystemException(
0985: "Unknown Section '" + section + "'");
0986: }
0987: }
0988: //////////
0989: else if (inSac.isSubAction(SubmitActionParameters.SWAP_UP)) {
0990: //
0991: if (section == AREA__CENTER) {
0992:
0993: HashMap centerProps = getAllCenterSectionPaneProperties(
0994: cc, index);
0995: String contextName = cc
0996: .getCenterSectionPaneContext(index);
0997:
0998: ConsoleConfigTagHelper.removeCenterSectionPane(cc,
0999: index);
1000: ConsoleConfigTagHelper.createCenterSectionPane(cc,
1001: (index - 1), contextName, centerProps);
1002:
1003: } else {
1004: throw new UnexpectedSystemException(
1005: "Unknown Section '" + section + "'");
1006: }
1007: } else if (inSac
1008: .isSubAction(SubmitActionParameters.SWAP_DOWN)) {
1009: //
1010: if (section == AREA__CENTER) {
1011:
1012: HashMap centerProps = getAllCenterSectionPaneProperties(
1013: cc, index);
1014: String contextName = cc
1015: .getCenterSectionPaneContext(index);
1016:
1017: ConsoleConfigTagHelper.removeCenterSectionPane(cc,
1018: index);
1019: ConsoleConfigTagHelper.createCenterSectionPane(cc,
1020: (index + 1), contextName, centerProps);
1021:
1022: } else {
1023: throw new UnexpectedSystemException(
1024: "Unknown Section '" + section + "'");
1025: }
1026: } else if (inSac
1027: .isSubAction(SubmitActionParameters.SWAP_LEFT)) {
1028: //
1029: if (section == AREA__LEFT) {
1030:
1031: HashMap leftProps = getAllLeftSectionPaneProperties(
1032: cc, index);
1033: String contextName = cc
1034: .getLeftSectionPaneContext(index);
1035:
1036: ConsoleConfigTagHelper.removeLeftSectionPane(cc,
1037: index);
1038: ConsoleConfigTagHelper.createLeftSectionPane(cc,
1039: (index - 1), contextName, leftProps);
1040:
1041: } else if (section == AREA__RIGHT) {
1042:
1043: HashMap rightProps = getAllRightSectionPaneProperties(
1044: cc, index);
1045: String contextName = cc
1046: .getRightSectionPaneContext(index);
1047:
1048: ConsoleConfigTagHelper.removeRightSectionPane(cc,
1049: index);
1050: ConsoleConfigTagHelper.createRightSectionPane(cc,
1051: (index - 1), contextName, rightProps);
1052:
1053: } else {
1054: throw new UnexpectedSystemException(
1055: "Unknown Section '" + section + "'");
1056: }
1057: } else if (inSac
1058: .isSubAction(SubmitActionParameters.SWAP_RIGHT)) {
1059: //
1060: if (section == AREA__LEFT) {
1061:
1062: HashMap leftProps = getAllLeftSectionPaneProperties(
1063: cc, index);
1064: String contextName = cc
1065: .getLeftSectionPaneContext(index);
1066:
1067: ConsoleConfigTagHelper.removeLeftSectionPane(cc,
1068: index);
1069: ConsoleConfigTagHelper.createLeftSectionPane(cc,
1070: (index + 1), contextName, leftProps);
1071:
1072: } else if (section == AREA__RIGHT) {
1073:
1074: HashMap rightProps = getAllRightSectionPaneProperties(
1075: cc, index);
1076: String contextName = cc
1077: .getRightSectionPaneContext(index);
1078:
1079: ConsoleConfigTagHelper.removeRightSectionPane(cc,
1080: index);
1081: ConsoleConfigTagHelper.createRightSectionPane(cc,
1082: (index + 1), contextName, rightProps);
1083:
1084: } else {
1085: throw new UnexpectedSystemException(
1086: "Unknown Section '" + section + "'");
1087: }
1088: }
1089: //////////
1090: else {
1091: inSac.unknownAction();
1092: }
1093:
1094: //
1095: saveConsoleConfig(inCps, ccRcth);
1096: //MiscHelper.println("BasRcthStudServ rcth = \n"
1097: // + ccRcth.getXMLRepresentation(true));
1098: //MiscHelper.println("BasRcthStudServ ConsoleConfig not saved");
1099: } else {
1100: outValue = false;
1101: }
1102:
1103: return outValue;
1104: }
1105:
1106: //
1107: //
1108: //
1109: protected void saveConsoleConfig(ConsolePageSession inCps,
1110: RootConceptTagHolder inCcRcth) {
1111: //
1112:
1113: ConsoleService cs = ConsoleServiceCallerFactory
1114: .getConsoleService();
1115: UserIdentity ui = inCps.getUserHolder().getUserIdentity();
1116: RootConceptTagHolder localRcth = inCps
1117: .getCurrentApplicationRootHolder();
1118: String prefHan = localRcth.getPreferences()
1119: .getPreferencesHandle();
1120: cs.saveConsoleConfig(ui, prefHan, inCcRcth);
1121: }
1122:
1123: //
1124: //
1125: //
1126: //
1127: //
1128: public final static HashMap getAllLeftSectionPaneProperties(
1129: ConsoleConfig inCc, int inIndex) {
1130: //
1131: HashMap outValue = new HashMap();
1132:
1133: int count = inCc.getLeftSectionPanePropertyCount(inIndex);
1134: for (int i = 0; i < count; i++) {
1135: //
1136: String nextName = inCc.getLeftSectionPanePropertyName(
1137: inIndex, i);
1138: String nextValue = inCc.getLeftSectionPanePropertyValue(
1139: inIndex, i);
1140: //
1141: outValue.put(nextName, nextValue);
1142: }
1143:
1144: return outValue;
1145: }
1146:
1147: //
1148: public final static HashMap getAllCenterSectionPaneProperties(
1149: ConsoleConfig inCc, int inIndex) {
1150: //
1151: HashMap outValue = new HashMap();
1152:
1153: int count = inCc.getCenterSectionPanePropertyCount(inIndex);
1154: for (int i = 0; i < count; i++) {
1155: //
1156: String nextName = inCc.getCenterSectionPanePropertyName(
1157: inIndex, i);
1158: String nextValue = inCc.getCenterSectionPanePropertyValue(
1159: inIndex, i);
1160: //
1161: outValue.put(nextName, nextValue);
1162: }
1163:
1164: return outValue;
1165: }
1166:
1167: //
1168: public final static HashMap getAllRightSectionPaneProperties(
1169: ConsoleConfig inCc, int inIndex) {
1170: //
1171: HashMap outValue = new HashMap();
1172:
1173: int count = inCc.getRightSectionPanePropertyCount(inIndex);
1174: for (int i = 0; i < count; i++) {
1175: //
1176: String nextName = inCc.getRightSectionPanePropertyName(
1177: inIndex, i);
1178: String nextValue = inCc.getRightSectionPanePropertyValue(
1179: inIndex, i);
1180: //
1181: outValue.put(nextName, nextValue);
1182: }
1183:
1184: return outValue;
1185: }
1186: }
|