?? notemanagerworkflow.java
字號:
/*
* Created on 2005-3-3
*
* Note Project
*/
package com.favo.note;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import com.favo.ui.BackgroundTask;
import com.favo.ui.BaseController;
import com.favo.ui.BaseView;
import com.favo.ui.ProgressGaugeUI;
import com.favo.ui.ProgressObserver;
import java.util.Vector;
/**
* @author Favo
*
* NoteListWorlflow <<Controller>>
*/
public class NoteManagerWorkflow extends BaseController {
NoteManagerUI noteListUI;
Vector noteTitleList;
Vector noteIdList;
Command YesCMD = new Command("Yes", Command.OK, 2);
Command NoCMD = new Command("No", Command.CANCEL, 2);
/**
*
*/
public NoteManagerWorkflow() {
super();
}
public BaseView getView() {
return noteListUI;
}
public void setView(BaseView ui) {
this.noteListUI = (NoteManagerUI)ui;
}
/**
* 顯示所選則的筆記
*
* @param index
* 索引
*/
public void showNoteDispose(final int index) {
ProgressObserver poUI = ProgressGaugeUI.getInstance();
BackgroundTask bkTask = new BackgroundTask(poUI, getView().getScreen(), getView().getDisplay()) {
public boolean runTask() {
alertScreen = new Alert(
"Error",
"Can't open the note",
null, AlertType.ERROR);
needAlert = true;
NotepadWorkflow notepadWorkflow=new NotepadWorkflow(((Integer)(noteIdList.elementAt(index))).intValue());
NotepadUI notepadUI=new NotepadUI(notepadWorkflow);
notepadUI.displayScreen();
getProgressObserver().updateProgress("ok!");
return true;
}
public void cancel() {
}
};
BackgroundTask.runWithProgressGauge(bkTask, "open...",
"please wait", false, getView().getDisplay() );
}
/**
* 刪除所選則的筆記
*
* @param index
* 索引
*/
public void deleteNoteDispose(final int index) {
Alert al = new Alert("Delete Confirm",
"Do you want to delete the note :"
+ (String) noteTitleList.elementAt(index), null,
AlertType.CONFIRMATION);
al.setTimeout(Alert.FOREVER);
al.addCommand(YesCMD);
al.addCommand(NoCMD);
al.setCommandListener(new CommandListener() {
public void commandAction(Command cmd, Displayable arg1) {
if (cmd == YesCMD) {
ProgressObserver poUI = ProgressGaugeUI.getInstance();
BackgroundTask bkTask = new BackgroundTask(poUI, getView().getScreen(), getView().getDisplay()) {
public boolean runTask() {
alertScreen = new Alert(
"Error",
"Can't delete the note",
null, AlertType.ERROR);
needAlert = true;
try {
NoteLocator.getInstance().deleteNote(((Integer)(noteIdList.elementAt(index))).intValue());
} catch (Exception e) {
e.printStackTrace();
getView().getDisplay().setCurrent(alertScreen);
return false;
}
noteTitleList.removeElementAt(index);
noteIdList.removeElementAt(index);
getView().displayScreen();
return true;
}
public void cancel() {
}
};
BackgroundTask.runWithProgressGauge(bkTask, "delete...",
"please wait", false, getView().getDisplay() );
} else{
getView().displayScreen();
}
}
});
getView().getDisplay().setCurrent(al);
}
/**
* 取得新聞標題的列表,返回String數組
*
* @return
*/
public String[] getNoteTitleList() {
if (noteTitleList == null) {
noteTitleList=new Vector();
noteIdList=new Vector();
try {
NoteLocator.getInstance().getNoteInfoList(noteTitleList,noteIdList);
} catch (Exception e) {
e.printStackTrace();
getView().getDisplay().setCurrent(
new Alert("can't getNoteTitleList"));
return new String[] {};
}
String[] titleArray=new String[noteTitleList.size()];
for (int i = 0; i < noteTitleList.size(); i++) {
titleArray[i]=(String)noteTitleList.elementAt(i);
}
return titleArray;
} else {
String[] titleArray = new String[noteTitleList.size()];
for (int i = 0; i < titleArray.length; i++) {
titleArray[i] = (String) noteTitleList.elementAt(i);
}
return titleArray;
}
}
public void newNoteDispose() {
NoteEditWorkflow noteEditWorkflow=new NoteEditWorkflow(NoteLocator.NEWNODE);
NoteEditUI noteEditUI=new NoteEditUI(noteEditWorkflow);
noteEditUI.displayScreen();
}
/**
*
*/
public void editNoteDispose(final int index) {
// TODO Auto-generated method stub
ProgressObserver poUI = ProgressGaugeUI.getInstance();
BackgroundTask bkTask = new BackgroundTask(poUI, getView().getScreen(), getView().getDisplay()) {
public boolean runTask() {
alertScreen = new Alert(
"Error",
"Can't open the note",
null, AlertType.ERROR);
needAlert = true;
NoteEditWorkflow noteEditWorkflow=new NoteEditWorkflow(((Integer)(noteIdList.elementAt(index))).intValue());
NoteEditUI noteEditUI=new NoteEditUI(noteEditWorkflow);
noteEditUI.displayScreen();
return true;
}
public void cancel() {
}
};
BackgroundTask.runWithProgressGauge(bkTask, "open...",
"please wait", false, getView().getDisplay() );
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -