📄 bookitem.java
字号:
/********************************************************************
*
* 版权说明,此程序仅供学习参考。不能用于商业
*
********************************************************************/
package org.pook.main;
import java.io.IOException;
import java.util.Vector;
import javax.microedition.lcdui.Image;
import org.pook.Pook;
import org.pook.Resources;
import org.pook.file.BookFile;
import org.pook.file.BookFileManager;
import org.pook.log.Log;
import org.pook.model.File;
import org.pook.ui.Command;
import org.pook.ui.IconMenu;
import org.pook.ui.List;
import org.pook.ui.Menu;
import org.pook.ui.event.CommandListener;
import org.pook.ui.form.FormPanel;
import org.pook.ui.form.MenuPanel;
/**
* <b>类名:MainMenu.java</b> </br> 编写日期: 2006-9-15 <br/> 程序功能描述: <br/> Demo:
* <br/> Bug: <br/>
*
* 程序变更日期 :<br/> 变更作者 :<br/> 变更说明 :<br/>
*
* @author wuhua </br> <a href="mailto:rrq12345@163.com">rrq12345@163.com</a>
*/
public class BookItem extends FormPanel implements CommandListener {
private Log log = Log.getLog("BookItem");
private Command ok = new Command("进入", Command.LEFT, Command.FIRST_PRIORITY);
private Command back = new Command("返回", Command.RIGHT,
Command.GENERAL_PRIORITY);
private List list;
/**
* 用户处理返回索引
*/
private int backIndex;
private File file;
private StringBuffer sb = new StringBuffer();;
public BookItem() {
super(Resources.MY_BOOK);
initContenxt();
this.addCommand(ok);
this.addCommand(back);
this.setSoftButtonListener(this);
this.setSoftButtonStyle(0xFFFFFF, 0x000000);
}
private void initContenxt() {
list = new List(Resources.ARROW);
list.setStyle(0x80D4F2, 0xFFFFFF);
this.append(list);
}
public void addBookList(Vector lists) {
this.list.append(lists);
}
public void commandAction(Command cmd) {
if (cmd == ok) {
openNextFileList();
} else {
openBack();
}
}
/**
* 返回
*
*/
private void openBack() {
if (backIndex == 0) {
Pook.openForm(Pook.MAINMENU);
} else {
list.setSelectIndex(0);
backIndex--;
this.addBookList((Vector) Resources.FILE_LIST.elementAt(backIndex));
Resources.FILE_LIST.removeElement((Vector) Resources.FILE_LIST
.elementAt(backIndex+1));
skipPath();
}
this.repaint();
}
private void skipPath() {
String s = sb.reverse().toString();
for(int i =0; i<2;i++){
int index = s.indexOf((int)'/');
log.debug(index);
s = s.substring(index+1, s.length() );
}
sb = new StringBuffer();
sb.append(s);
sb.reverse();
sb.append("/");
log.debug(sb);
}
private void skipPathFileName() {
String s = sb.reverse().toString();
int index = s.indexOf((int)'/');
log.debug(index);
s = s.substring(index+1, s.length() );
sb = new StringBuffer();
sb.append(s);
sb.reverse();
sb.append("/");
log.debug(sb);
}
/**
* 打开文件列表,直到打开非目录为止
*
*/
private void openNextFileList() {
BookFile bf = null;
try {
if(backIndex == 0){
bf = BookFileManager.openBookFile(getPath());
file = bf.openFile();
}else{
bf = BookFileManager.openBookFile(getPath());
if(!bf.exists()){
Pook.openMessageDialog("错误", "文件不存在,请查证!" +
"目录错误:" + getPath() , this);
skipPathFileName();
return;
}
file = bf.openFile();
}
} catch (Exception e1) {
Pook.openMessageDialog("错误", "文件不存在,请查证!" +
"目录错误:" + getPath(), this);
}
if (bf.isFile()) {
} else {
Vector listNames = null;
try {
listNames = bf.listName();
} catch (IOException e) {
Pook.openMessageDialog("错误", "文件不存在,请查证!", this);
}
this.addBookList(listNames);
Resources.FILE_LIST.addElement(listNames);
list.setSelectIndex(0);
backIndex++;
}
bf.close();
this.repaint();
}
private String getPath(){
String name = list.getSelectString();
log.debug(name);
if(backIndex == 0){
sb = new StringBuffer();
sb.append("file:///" + name);
}else{
sb.append(name);
}
return sb.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -