?? configinfoobject.java
字號:
/**
*
*/
package com.vanceinfo.socket.server;
import java.io.IOException;
import java.util.HashSet;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import com.vanceinfo.socket.today.Article;
import com.vanceinfo.socket.today.Articles;
import com.vanceinfo.socket.today.EditorPane;
import com.vanceinfo.socket.today.Item;
import com.vanceinfo.socket.today.MetaInfo;
import com.vanceinfo.socket.today.Today;
import com.vanceinfo.socket.today.ToolBar;
/**
* @author 谷明亮
* @description 配置信息對象實現
*/
public class ConfigInfoObject implements AbstractConfigInfoObject {
public Object getConfigInfoObject() {
SAXBuilder sb = new SAXBuilder();
Document doc = null;
try {
doc = sb.build(TodayServer.class.getResource("Today.xml"));
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Element root = doc.getRootElement();
Element window = root.getChild("window");
Element meta = window.getChild("meta");
Element toolbar = window.getChild("components").getChild("toolbar");
Element editorpane = window.getChild("components").getChild(
"editorpane");
MetaInfo metaInfo = new MetaInfo();
metaInfo.setTitle(meta.getChildText("title"));
metaInfo.setWidth(Integer.parseInt(meta.getChildText("width")));
metaInfo.setHeight(Integer.parseInt(meta.getChildText("height")));
metaInfo.setLayout(meta.getChildText("layout"));
metaInfo.setResizable(Boolean.parseBoolean(meta
.getChildText("resizable")));
int sizeOfToolbar = toolbar.getChildren("item").size();// 工具欄條目數
HashSet<Item> items = new HashSet<Item>();// 一個工具欄條目
Item item = null;
Articles articles = null;
Article article = null;
int articleCount = 0;
Element tempItem = null;
Element tempArticles = null;
for (int i = 0; i < sizeOfToolbar; i++) {
tempItem = (Element) toolbar.getChildren("item").get(i);
tempArticles = (Element) editorpane.getChildren("articles").get(i);
articleCount = tempArticles.getChildren("article").size();
Element tempArticle = null;
articles = new Articles();
article = new Article();
for (int j = 0; j < articleCount; j++) {
tempArticle = (Element) tempArticles.getChildren("article")
.get(j);
article.setId(Integer.parseInt(tempArticle
.getAttributeValue("id")));
article.setUri(tempArticle.getText());
articles.getArticles().add(article);
}
item = new Item(tempItem.getAttributeValue("type"), articles);
item.setIcon(tempItem.getText());
items.add(item);
}
ToolBar toolBar = new ToolBar(items);
EditorPane editorPane = new EditorPane(articles.getArticles());
Today today = new Today(metaInfo, toolBar, editorPane);
return today;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -