listScreen.editItem();
DisplayController.setCurrentScreen(listScreen.getEditScreen());
}
}
else if (c == Commands.getMoveCommand()) {
MailListCustomScreen listScreen = null;
if (s instanceof MailListCustomScreen) {
listScreen = (MailListCustomScreen)s;
}
else if (s instanceof DetailScreen) {
Displayable parentScreen = ((DetailScreen)s).getParentScreen();
if (parentScreen instanceof MailListCustomScreen) {
listScreen = (MailListCustomScreen)parentScreen;
}
}
if (listScreen != null) {
MoveMailScreen moveMailScreen = new MoveMailScreen(listScreen.getFolder(), listScreen);
DisplayController.setCurrentScreen(moveMailScreen);
}
}
else if (c == Commands.getAddCommand()) {
if (s instanceof ListScreenInterface) {
ListScreenInterface listScreen = (ListScreenInterface)s;
listScreen.newItem();
DisplayController.setCurrentScreen(listScreen.getEditScreen());
}
}
else if (c == Commands.getFindCommand()) {
if (s instanceof ListScreenInterface) {
ListScreenInterface listScreen = (ListScreenInterface)s;
DisplayController.setCurrentScreen(listScreen.getFindScreen());
}
}
else if (c == Commands.getDeleteCommand()) {
ListScreenInterface listScreen = null;
if (s instanceof ListScreenInterface) {
listScreen = (ListScreenInterface)s;
}
else if (s instanceof DetailScreen) {
Displayable parentScreen = ((DetailScreen)s).getParentScreen();
if (parentScreen instanceof ListScreenInterface) {
listScreen = (ListScreenInterface)parentScreen;
}
}
if (listScreen != null) {
listScreen.deleteSelectedItem();
DisplayController.setCurrentScreen(listScreen.getDisplayScreen());
}
}
else if (c == Commands.getSyncCommand() || c == Commands.getRecoverCommand()) {
boolean recovery = (c == Commands.getRecoverCommand());
if (s instanceof Syncable) {
Synchronizer synchronizer = new Synchronizer((Syncable)s);
synchronizer.syncItems(recovery);
}
else if (s instanceof MailListCustomScreen) {
mainScreen.getMailScreen().synchronizeMail(recovery);
}
else if (s instanceof CalendarMonthScreen) {
Synchronizer synchronizer = new Synchronizer(Scheduler.getInstance());
synchronizer.syncItems(recovery);
}
else {
mainScreen.getMailScreen().synchronizeMail(recovery);
Synchronizer synchronizer = new Synchronizer(Scheduler.getInstance());
synchronizer.syncItems(recovery);
synchronizer = new Synchronizer(mainScreen.getContactsScreen());
synchronizer.syncItems(recovery);
}
}
else if (c == Commands.getReceiveCommand()) {
Synchronizer synchronizer = new Synchronizer(mainScreen.getMailScreen().getInboxScreen());
synchronizer.downloadItems();
}
else if (c == Commands.getSendCommand()) {
MailListCustomScreen outboxScreen = mainScreen.getMailScreen().getOutboxScreen();
Synchronizer synchronizer = new Synchronizer(outboxScreen);
if (synchronizer.uploadItems()) {
outboxScreen.moveMails(MailMainScreen.SENT_NAME);
}
}
else if (c == Commands.getReplyCommand()) {
MailListCustomScreen listScreen = null;
if (s instanceof MailListCustomScreen) {
listScreen = (MailListCustomScreen)s;
}
else if (s instanceof DetailScreen) {
Displayable parentScreen = ((DetailScreen)s).getParentScreen();
if (parentScreen instanceof MailListCustomScreen) {
listScreen = (MailListCustomScreen)parentScreen;
}
}
if (listScreen != null) {
listScreen.reply();
}
}
else if (c == Commands.getShowLogCommand()) {
logScreen.setParentScreen(DisplayController.getCurrentScreen());
DisplayController.setCurrentScreen(logScreen);