📄 logsettingsform.java
字号:
/*
* Copyright (C) 2006-2007 Funambol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.funambol.mailclient.ui.view;
import com.funambol.mailclient.ui.controller.UIController;
import com.funambol.mailclient.loc.Localization;
import com.funambol.util.Log;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemStateListener;
/**
* This form shows all the settings related to the
* Log functions
* The user will be able to configure the log level for
* the application and see the log content
*/
public class LogSettingsForm extends Form implements CommandListener {
private Command backCommand;
private Command viewLogCommand;
private Command saveCommand;
// Stats ONLY for Development purposes. TO BE REMOVED in final release
private ChoiceGroup logLevelChoice;
private String logEnablingChoiceLabel;
/** Creates a new instance of LogSettingsForm */
public LogSettingsForm() {
super(Localization.getMessages().LOG_SETTINGS_FORM_TITLE);
backCommand = UIController.backCommand;
viewLogCommand =
new Command(Localization.getMessages().LSF_VIEW_LOG_COMMAND,
UIController.COMMAND_TYPE, 5);
saveCommand = UIController.saveCommand;
//append(getLogEnablingChoice());
append(getLogLevelChoice());
int logLevel = UIController.mailClientConfig.getLogLevel();
logLevelChoice.setSelectedIndex(getIndexFromLogLevel(logLevel), true);
addCommand(backCommand);
addCommand(viewLogCommand);
addCommand(saveCommand);
setCommandListener(this);
}
public void commandAction(Command command, Displayable displayable) {
if (command == backCommand) {
UIController.showBackScreen();
} else if (command == viewLogCommand) {
UIController.showLogViewer(this);
} else if (command == saveCommand) {
UIController.updateLogLevel(getLogLevelFromIndex(logLevelChoice.getSelectedIndex()));
UIController.showBackScreen();
}
}
private Item getLogLevelChoice() {
if (logLevelChoice == null) {
logLevelChoice =
new ChoiceGroup(Localization.getMessages().LSF_LOG_LEVEL_CHOICE_LABEL, Choice.EXCLUSIVE, new String[] {
Localization.getMessages().LSF_LOG_LEVEL_DISABLED,
Localization.getMessages().LSF_LOG_LEVEL_CHOICE_0,
Localization.getMessages().LSF_LOG_LEVEL_CHOICE_1
}, new Image[] {null, null, null});
}
return logLevelChoice;
}
/**
* get the log level from the index
* @param index the index of the selected item in loglevelchoice
* @return the log level corresponding to the given index
*/
private int getLogLevelFromIndex(int index) {
switch ( index ) {
case 0 :
return Log.DISABLED;
case 1:
return Log.ERROR;
case 2:
return Log.INFO;
default:
return Log.DISABLED;
}
}
/**
* get the index of the item to be selected in
* loglevelchoice from the given log level
* @param loglevel the log level
* @return the index of loglevelchoice corresponding
* to the given log level
*/
private int getIndexFromLogLevel(int logLevel) {
switch ( logLevel ) {
case Log.DISABLED:
return 0;
case Log.ERROR:
return 1;
case Log.INFO:
return 2;
default:
return 0;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -