📄 editform.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: EditForm.java
package com.modofo.mofire;
import java.io.PrintStream;
import java.util.Vector;
import javax.microedition.lcdui.*;
import org.kxmlrpc.XmlRpcClient;
// Referenced classes of package com.modofo.mofire:
// Post, ContentInput, MoFire, MoFireMgr,
// PostList, Setting
public class EditForm extends Form
implements CommandListener
{
Command settingCmd;
Command okCmd;
Command postCmd;
Command listCmd;
private TextField titleFld;
private TextField catFld;
ContentInput contentInput;
Post post;
Alert alert;
Setting curSetting;
public EditForm(String title)
{
super(title);
post = new Post();
settingCmd = new Command("Setting", 2, 1);
okCmd = new Command("OK", 4, 0);
listCmd = new Command("List", 2, 3);
addCommand(okCmd);
addCommand(settingCmd);
addCommand(listCmd);
titleFld = new TextField("Title", "", 200, 0);
catFld = new TextField("Category", "", 50, 2);
contentInput = new ContentInput("", "", 2000, 0);
contentInput.setEditForm(this);
addCommand(settingCmd);
addCommand(okCmd);
addCommand(listCmd);
alert = new Alert("");
alert.setType(AlertType.INFO);
append(titleFld);
append(catFld);
setCommandListener(this);
}
public void commandAction(Command arg0, Displayable arg1)
{
if (arg0 == okCmd)
doOkCmd();
else
if (arg0 == settingCmd)
doSettingCmd();
else
if (arg0 == listCmd)
doListCmd();
}
private void doSettingCmd()
{
MoFire.getInstance().setCurrent("settingList");
}
private void doListCmd()
{
PostList pl = MoFire.getInstance().getPostList();
MoFire.getInstance().setCurrent(pl);
}
private void doOkCmd()
{
post.setTitle(titleFld.getString().trim());
contentInput.setTitle(post.getTitle());
Display.getDisplay(MoFire.getInstance()).setCurrent(contentInput);
}
public void postContent(String cnt)
{
post.setContent(cnt);
Runnable call = new Runnable() {
public void run()
{
StringBuffer sb = new StringBuffer();
sb.append("<title>").append(post.getTitle()).append("</title>");
sb.append(post.getContent());
sb.append("\n Powered by MoFire");
XmlRpcClient xmlrpc = new XmlRpcClient(curSetting.getUrl());
Vector params = new Vector();
params.addElement(new Integer(1));
params.addElement(new Integer(1));
params.addElement(curSetting.getUser());
params.addElement(curSetting.getPwd());
params.addElement(sb.toString());
params.addElement(new Boolean(true));
String status = "success";
try
{
xmlrpc.execute("blogger.newPost", params);
}
catch (Exception e)
{
status = e.toString();
e.printStackTrace();
}
Alert alert = new Alert("status");
alert.setString(status);
alert.setType(AlertType.INFO);
alert.setTimeout(-2);
MoFire.getInstance().setCurrent(alert);
}
};
Thread t = new Thread(call);
t.start();
}
void setCurSetting(Setting curSetting2)
{
curSetting = curSetting2;
}
public void setPost(Post post)
{
this.post = post;
System.out.println("setPost:" + post);
titleFld.setString(post.getTitle());
catFld.setString((new StringBuffer(String.valueOf(post.getCategory()))).toString());
contentInput.setString(post.getContent());
}
public void savePost(String cnt)
{
post.setContent(cnt);
post.setTitle(titleFld.getString());
Vector posts = new Vector();
try
{
int newid = MoFire.getInstance().getMgr().savePost(post);
post.setId(newid);
posts = MoFire.getInstance().getMgr().getPosts(null);
}
catch (Exception e)
{
e.printStackTrace();
}
MoFire.getInstance().getPostList().setPosts(posts);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -