001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.console.base.context;
009:
010: //base classes
011: import java.io.IOException;
012:
013: //project specific classes
014: import org.jfolder.common.UnexpectedSystemException;
015: import org.jfolder.console.base.ConsolePageContext;
016: import org.jfolder.console.base.NamesForSubCpc;
017: import org.jfolder.console.base.context.BaseSubUpDownConsolePageContext;
018: import org.jfolder.console.config.ConsoleConfig;
019: import org.jfolder.console.config.ConsoleConfigTagPreferencesHelper;
020:
021: //other classes
022:
023: public class ConfigInstanceForUpDownContext extends
024: BaseSubUpDownConsolePageContext {
025:
026: //
027: private RenderConsolePageContextHelper rctph = null;
028: //
029: private ConsoleConfig cc = null;
030: private int section = 0;
031: private int index = 0;
032:
033: private ConfigInstanceForUpDownContext(
034: RenderConsolePageContextHelper inRctph,
035: ConsolePageContext inCpc, ConsoleConfig inCc,
036: int inSection, int inIndex) {
037:
038: super (inCpc, getUpName(inSection, inIndex), getDownName(
039: inSection, inIndex));
040: //
041: //
042: this .rctph = inRctph;
043: //
044: this .cc = inCc;
045: this .section = inSection;
046: this .index = inIndex;
047: //
048: setColumnWidth(1);
049: }
050:
051: protected final static ConfigInstanceForUpDownContext newInstance(
052: RenderConsolePageContextHelper inRctph,
053: ConsolePageContext inCpc, ConsoleConfig inCc,
054: int inSection, int inIndex) throws IOException {
055:
056: ConfigInstanceForUpDownContext outValue = null;
057:
058: if (inCpc.isSubConsolePageContextPresent(NamesForSubCpc
059: .getBaseSubUpDownCpcName(getUpName(inSection, inIndex),
060: getDownName(inSection, inIndex)))) {
061: //
062: Object o = inCpc.getSubConsolePageContext(NamesForSubCpc
063: .getBaseSubUpDownCpcName(getUpName(inSection,
064: inIndex), getDownName(inSection, inIndex)));
065: outValue = (ConfigInstanceForUpDownContext) o;
066: } else {
067: outValue = new ConfigInstanceForUpDownContext(inRctph,
068: inCpc, inCc, inSection, inIndex);
069: inCpc.registerSubConsolePageContext(NamesForSubCpc
070: .getBaseSubUpDownCpcName(getUpName(inSection,
071: inIndex), getDownName(inSection, inIndex)),
072: outValue);
073: }
074:
075: outValue.copyFromParent(inCpc);
076: outValue.createConsolePage(inCpc.getWriter(), inCpc
077: .getPageSetupContext());
078:
079: return outValue;
080: }
081:
082: //
083: public int getUpDownWidth() {
084:
085: int outValue = 0;
086:
087: if (this .section == RenderConsolePageContextHelper.AREA__CENTER) {
088: //
089: outValue = Integer
090: .parseInt(this .cc
091: .getCenterSectionPaneProperty(
092: this .index,
093: ConsoleConfigTagPreferencesHelper.PROP_NAME__WIDTH));
094: } else {
095: throw UnexpectedSystemException.unknownState();
096: }
097:
098: outValue = (outValue / getColumnWidth());
099:
100: return outValue;
101: //return 4;
102: }
103:
104: public void renderUpPane() throws IOException {
105: String context = this .cc
106: .getCenterSectionPaneContext(this .index);
107: this .rctph.renderSubPane(this , context, this .cc, this .section,
108: this .index);
109: //ConfigInstanceForLeftRightContext.newInstance(
110: // this, 1, 3, "tree", "tag");
111: }
112:
113: public void renderDownPane() throws IOException {
114: if ((this .index + 2) < (this .cc.getCenterSectionPaneCount())) {
115: ConfigInstanceForLeftRightContext.newInstance(this .rctph,
116: this , this .cc, this .section, (this .index + 1));
117: } else {
118: String context = this .cc
119: .getCenterSectionPaneContext((this .index + 1));
120: this .rctph.renderSubPane(this , context, this .cc,
121: this .section, (this .index + 1));
122: }
123: }
124:
125: private final static String getUpName(int inSection, int inIndex) {
126: return (inSection + "-" + inIndex + "-" + "U");
127: }
128:
129: private final static String getDownName(int inSection, int inIndex) {
130: return (inSection + "-" + inIndex + "-" + "D");
131: }
132: }
|