📄 profile.java
字号:
package com.ismyway.anyview.win;
import javax.microedition.lcdui.Command;
import com.ismyway.anyview.others.Configure;
import com.ismyway.anyview.others.Settings;
import com.ismyway.fairyui.Component;
import com.ismyway.fairyui.ListBox;
import com.ismyway.fairyui.ListElement;
import com.ismyway.fairyui.MenuItem;
import com.ismyway.fairyui.Panel;
import com.ismyway.fairyui.PopMenu;
import com.ismyway.fairyui.ValueChangeListener;
import com.ismyway.util.Res;
import com.ismyway.util.Theme;
public class Profile extends Panel implements ValueChangeListener{
MenuItem[] mainmenu;
ListBox profile = new ListBox(true);
public Profile() {
setTitle(Res.get("Profile"));
setCommandListener(this);
mainmenu = new MenuItem[] {
new MenuItem(Res.get("New")),
new MenuItem(Res.get("Edit")),
new MenuItem(Res.get("Delete")),
new MenuItem(Res.get("Load")),
new MenuItem(Res.get("Close")) };
profile.setItemListener(this);
add(profile);
loadProfile();
PopMenu menu = new PopMenu(this, mainmenu);
addCommand(new Command(Res.get("Menu"), Command.OK, 1), menu);
addCommand(new Command(Res.get("Close"), Command.EXIT, 1));
}
private void loadProfile() {
// row.clear();
// String[] names = Configure.getConfigureNames();
// for (int i = 0; i < names.length; i++) {
// row.add(new StringItem(names[i], null));
// }
profile.clear();
String[] names = Configure.getConfigureNames();
int selectedIndex = Configure.configureIndex;
if (selectedIndex > names.length - 1) {
selectedIndex = 0;
}
//System.out.println("selectedIndex = " + selectedIndex);
for (int i = 0; i < names.length; i++) {
//System.out.println(i + ", " + names[i]);
profile.add(new ListElement(names[i], i == selectedIndex));
}
}
public void reActive() {
int oldpointer = currentPointer;
loadProfile();
validate();
setPointer(oldpointer);
}
public void commandAction(Command command, Component c) {
String func = command.getLabel();
if (func.equals(Res.get("Close"))) {
mainCanvas.closePopup();
}
}
public void callback(Component component, Command cmd, Object[] parameters) {
String func = cmd.getLabel();
if (func.equals(Res.get("New"))) {
if (component instanceof PopMenu) {
mainCanvas.showPopup(new NewProfile(this),
Settings.ANIMATE_DOWN);
} else {
try {
String name = (String) parameters[0];
//System.out.println("name = " + name);
if (null != name && !"".equals(name)) {
Configure.create(name);
loadProfile();
validate();
}
} catch (Exception e) {
e.printStackTrace();
}
//showAlert(copyofCurrentPath + filename, null);
}
} else if (func.equals(Res.get("Delete"))) {
//System.out.println("profile.getCheckedIndex() = " + profile.getCheckedIndex());
if (-1 != profile.getCheckedIndex() && profile.getCheckedIndex() < hotpots.size() && hotpots.size() > 1) {
int index = currentPointer;
Configure.delete(index);
loadProfile();
validate();
} else {
showAlert(Res.get("Can't Delete All") + Res.get("Profile"));
}
} else if (func.equals(Res.get("Close"))) {
mainCanvas.closePopup();
} else if (func.equals(Res.get("Load"))) {
valueChanged(profile);
} else if (func.equals(Res.get("Edit"))) {
if (currentPointer > -1 && currentPointer < hotpots.size()) {
//System.out.println("currentPointer = " + currentPointer);
mainCanvas.showPopup(new ProfileSet(currentPointer), Settings.ANIMATE_UP);
}
}
}
public void valueChanged(Object obj) {
if (obj instanceof ListBox) {
ListBox lb = (ListBox) obj;
if (lb == profile) {
int index = profile.getCheckedIndex();
Configure.loadProfile(index);
Theme.COMPLEX_THEME = Configure.complexTheme;
Theme.loadTheme(Configure.themeName);
repaint();
//System.out.println("selectedIndex = " + Configure.configureIndex);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -