📄 maxtreeitemxlt.java
字号:
package com.sinosoft.security.util.maxtree.xloadtree;
import com.sinosoft.security.util.maxtree.MaxTreeItem;
public class MaxTreeItemXlt implements MaxTreeItem {
public MaxTreeItemXlt() throws Exception {
}
public MaxTreeItemXlt(String sText, String sXmlSrc, String sAction,
String eParent, String sIcon, String sOpenIcon) {
}
private String sID = "";
private String sText = "";
private String sXmlSrc = "";
private String sAction = "";
private String eParent = "";
private String sIcon = "";
private String sOpenIcon = "";
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#getEParent()
*/
public String getEParent() {
return eParent;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#setEParent(java.lang.String)
*/
public void setEParent(String parent) {
eParent = parent;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#getSAction()
*/
public String getSAction() {
return sAction;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#setSAction(java.lang.String)
*/
public void setSAction(String action) {
sAction = action;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#getSIcon()
*/
public String getSIcon() {
return sIcon;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#setSIcon(java.lang.String)
*/
public void setSIcon(String icon) {
sIcon = icon;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#getSOpenIcon()
*/
public String getSOpenIcon() {
return sOpenIcon;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#setSOpenIcon(java.lang.String)
*/
public void setSOpenIcon(String openIcon) {
sOpenIcon = openIcon;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#getSText()
*/
public String getSText() {
return sText;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#setSText(java.lang.String)
*/
public void setSText(String text) {
sText = text;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#getSXmlSrc()
*/
public String getSXmlSrc() {
return sXmlSrc;
}
/*
* (非 Javadoc)
*
* @see com.sinosoft.security.mazingutil.maxtree.xloadtree.MaxTreeItem#setSXmlSrc(java.lang.String)
*/
public void setSXmlSrc(String xmlSrc) {
sXmlSrc = xmlSrc;
}
public String getSID() {
return sID;
}
public void setSID(String sID) {
sID = sID;
}
// public String toXML(Meta[] result,String parent,String rp){
// String icon = (sIcon.equalsIgnoreCase("")) ? "" : "" + sIcon + "";
// String oIcon = (sIcon.equalsIgnoreCase("")) ? "" : ""+ sOpenIcon+ "";
// Document document = DocumentHelper.createDocument();
// Element treeElement = document.addElement("tree");
// //XMLWriter writer = null;
// try{
// for(int i=0;i<result.length;i++)
// {
// this.setSText(result[i].getName());
// this.setEParent(result[i].getHandle());
// //System.out.println(""+sText+"");
// Element tree1Element = treeElement.addElement("tree");
// tree1Element.addAttribute("text", ""+sText+"");
// tree1Element.addAttribute("src", ""+sXmlSrc+"");
// tree1Element.addAttribute("action", "" + sAction + "");
// tree1Element.addAttribute("icon",icon);
// tree1Element.addAttribute("openIcon", oIcon);
// //treeElement.add(tree1Element);
// }
// document.addDocType("tree",
// null,"file://E:/CleanClear/WebContent/ui/xloadtree/tree.dtd");
//
// //OutputFormat format =new OutputFormat();
// //format.setLineSeparator("");
// //format.setEncoding("gb2312");
// //writer = new XMLWriter(format);
// //writer.write(document);
// //System.out.println("0000000000"+rp);
// OutputFormat format = OutputFormat.createPrettyPrint();
// format.setEncoding("gb2312");
// XMLWriter output = new XMLWriter(
// new FileWriter( new File(rp) ), format);
// output.write( document );
// output.close();
//
// }catch(Exception e)
// {}
// return document.asXML();
//
// //StringBuffer xmlbuilder = new StringBuffer();
// //String icon = (sIcon.equalsIgnoreCase("")) ? "" : "=\"" + sIcon + "\"";
// //String oIcon = (sIcon.equalsIgnoreCase("")) ? "" : "=\"" + sOpenIcon
// //+ "\"";
//
// //xmlbuilder.append("<tree text=\"" + sText + "\" src=\"" + sXmlSrc
// //+ "\" action=\"" + sAction + "\" " + icon + " " + oIcon
// //+ "/>\n");
// //return xmlbuilder.toString();
//
// }
public String toXML() {
StringBuffer xmlbuilder = new StringBuffer();
String icon = (sIcon.equalsIgnoreCase("")) ? "" : "icon=\"" + sIcon + "\"";
String oIcon = (sOpenIcon.equalsIgnoreCase("")) ? "" : "openIcon=\"" + sOpenIcon
+ "\"";
xmlbuilder.append("<tree text=\"" + sText + "\" src=\""
+ checkKeyword(sXmlSrc) + "\" action=\""
+ checkKeyword(sAction) + "\" " + icon +" "+ oIcon + "/>\n");
return xmlbuilder.toString();
}
public String toScript() {
String script = "new WebFXLoadTreeItem(\"" + sText + "\"," + "\""
+ sXmlSrc + "\"," + "\"" + sAction + "\","+"\"\",\""+sIcon+"\",\""+sOpenIcon+"\")";
return script;
}
public void addTreeItem(MaxTreeItem item) {
}
// private String checkKeyword(String str) {
// String str2 = str;
// if (str.contains("&"))
// str2 = str.replace("&", "&");
// return str2;
//
// }
private String checkKeyword(String str) {
String str2 = replace(str, "&", "&");
return str2;
}
/**
* 字符串替换,将 source 中的 oldString 全部换成 newString
*
* @param source
* 源字符串
* @param oldString
* 老的字符串
* @param newString
* 新的字符串
* @return 替换后的字符串
*/
public static String replace(String source, String oldString,
String newString) {
StringBuffer output = new StringBuffer();
int lengthOfSource = source.length(); // 源字符串长度
int lengthOfOld = oldString.length(); // 老字符串长度
int posStart = 0; // 开始搜索位置
int pos; // 搜索到老字符串的位置
while ((pos = source.indexOf(oldString, posStart)) >= 0) {
output.append(source.substring(posStart, pos));
output.append(newString);
posStart = pos + lengthOfOld;
}
if (posStart < lengthOfSource) {
output.append(source.substring(posStart));
}
return output.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -