📄 project.java
字号:
package g2w.app.gchm.gui;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URISyntaxException;
import g2w.app.gchm.util.ProjectUtility;
import org.jdom.Document;
import org.jdom.JDOMException;
/**
* A project bean.
*
* @author GreatGhoul
* @version 011 2009-3-21 19:50:53
*/
public class Project {
/** The project file */
private Document document;
private boolean changed;
/**
* Construct a project with indicated file path.
*
* @param path The project file's path.
* @throws IOException
* @throws JDOMException
*/
public Project(String path) throws JDOMException, IOException {
this.document = ProjectUtility.getProjectFile(path);
}
/**
* Construct a project with indicated file path.
*
* @param path The project file's path.
*/
public Project(Document document) {
this.document = document;
}
/**
* Get the project's document.
*
* @return The document.
*/
public Document getDocument() {
return this.document;
}
/**
* Set the changed status to be aFlag.
*
* @param aFlag The new status.
*/
public void setChanged(boolean aFlag) {
changed = aFlag;
}
/**
* Get if the project's content has been changed.
*
* @return The status.
*/
public boolean isChanged() {
return changed;
}
/**
* Get the project's title.
* @return
*/
public String getTitle() {
return document.getRootElement().getAttributeValue("title");
}
/**
* Get the home page's path.
*
* @return The home page's path.
*/
public String getHomePage() {
return document.getRootElement().getAttributeValue("homepage");
}
/**
* Get the default page's path.
*
* @return The default page's path.
*/
public String getDefaultPage() {
return document.getRootElement().getAttributeValue("defaultpage");
}
/**
* Get the about page's path.
*
* @return The about page's path.
*/
public String getAboutPage() {
return document.getRootElement().getAttributeValue("aboutpage");
}
/**
* Get the chm file's name.
*
* @return The chm file's name.
*/
public String getChmFileName() {
return document.getRootElement().getAttributeValue("filename");
}
/**
* Set the chm file's title.
*
* @param title The new title.
*/
public void setTitle(String title) {
document.getRootElement().setAttribute("title", title);
changed = true;
}
/**
* Set the home page.
*
* @param homePagePath The new home page's path.
*/
public void setHomePage(String homePagePath) {
document.getRootElement().setAttribute("homepage", homePagePath);
changed = true;
}
/**
* Set the default page.
*
* @param defaultPagePath The new default page's path.
*/
public void setDefaultPage(String defaultPagePath) {
document.getRootElement().setAttribute("defaultpage", defaultPagePath);
changed = true;
}
/**
* Set the about page's path.
*
* @param aboutPagePath The about page's path.
*/
public void setAboutPage(String aboutPagePath) {
document.getRootElement().setAttribute("aboutpage", aboutPagePath);
changed = true;
}
/**
* Set the chm file's filename.
*
* @param chmFileName The new file name.
*/
public void setChmFileName(String chmFileName) {
document.getRootElement().setAttribute("filename", chmFileName);
}
/**
* Save the current project.
*
* @throws FileNotFoundException
* @throws URISyntaxException
* @throws IOException
*/
public void save()
throws FileNotFoundException, URISyntaxException, IOException {
ProjectUtility.storeDocument(document);
changed = false;
}
public String getProjectPath() {
return document.getRootElement().getAttributeValue("local");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -