Menu.java 2.56 KB
Newer Older
Naung1 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
package com.csc.library.components;




public class Menu extends MyTag {

	private static final long serialVersionUID = 1L;
	String tagInput = "", hspace = "", checked = "";


	public Menu() {
		super();
		this.type = "menu";
	}

	/**
	 *  <p><b>BALL Edit</b>
	 *    <p>      this.setTable(cm.getProperty("table"));
	 * @param cm
	 * @param labelFont
	 * @param inputFont
	 */
	public Menu(ComponentManager cm) {
		super(cm);
		this.setValidCode(cm.getProperty("validCode"));
		this.setTable(cm.getProperty("table"));
		if(!cm.getProperty("value").trim().equals(""))
			this.setChecked(cm.getProperty("value").trim());
		else
			this.setChecked(cm.getProperty("defaultvalue").trim());
		this.ini();
	}

	public void setSelect(String[][] code) {
		sysCode = code;
	}

	public void ini() {
		String label2, tmpV, tmpL, input2 = "", check;
		tagInput = label2 = "";

		if ((this.help != null) && (this.help.length() > 0)) {
			label2 = "help";
			label2 = this.tagHelp(this.help, this.name, label2);
		}
		if (sysCode != null) {
			for (int point = 0; point < sysCode.length; point++) {
				tmpV = sysCode[point][0];
				/***********Ball Edit 11-03-05***************/		
				if((sysCode[point][1]==null))break;
				tmpL = this.spilltLang(sysCode[point][1]);	
				 //System.out.println("lang "+this.uPro.get("lang")+" Menu  tmpL ="+tmpL);
				 /**************************/
				if ((tmpV == null) && (tmpL == null)) {
					break;
				}
				check = "";
				//                this.logger.info(this.name+"  checked="+checked+" tmpV="+tmpV);
				if ((this.checked != null) && (this.checked.equalsIgnoreCase(tmpV))) {
					check = "SELECTED";
				}
				input2 = input2 + " <OPTION " + check + " VALUE=\"" + tmpV + "\"> " + tmpL + " </OPTION>";
			}
			this.tagInput =
				"<SELECT NAME=\""
					+ this.name
					+ "\"  onChange=\""
					+ onClick
					+ "\"  onMouseOver=\""
					+ this.onMouseOver
					+ "\"  onMouseOut=\""
					+ this.onMouseOut
					+ "\"   > "
					+ input2
					+ " </SELECT> "
					+ label2;
		}
	}

	public String process() {
		this.ini();
		if ((this.point != null) && (this.point.equalsIgnoreCase("l"))) {
			return this.tagInput + this.hspace + this.label;
		} else {
			return this.label + this.hspace + this.tagInput;
		}
	}

	public void setSpace(int space) {
		for (int i = 0; i < space; i++) {
			hspace = hspace + "&nbsp;";
		}
	}

	public void setSelect(String value, String label) {
		int i = this.sysCode.length;
		sysCode[i][0] = value;
		sysCode[i][1] = label;
	}

	public String getInput() {
		return this.tagInput;
	}

	public void setChecked(String check) {
		this.checked = check;
	}

}