📄 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 + -