1. /*
  2. * Copyright 1999,2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package peaklau.eaglefund;
  17. import javax.microedition.lcdui.ChoiceGroup;
  18. import javax.microedition.lcdui.Command;
  19. import javax.microedition.lcdui.CommandListener;
  20. import javax.microedition.lcdui.Displayable;
  21. import javax.microedition.lcdui.Form;
  22. /**
  23. * FundModifyScreen class <br>
  24. *
  25. * Selecting one fund to modify its quota.<br>
  26. *
  27. * <br>
  28. *
  29. * @author peaklau <br>
  30. * email:<A HREF="mailto:peaklau@hotmail.com">peaklau@hotmail.com</A> <br>
  31. * <a href="http://www.peaklau.com/fund/english/">HomePage</a>
  32. * @version $Revision: 1.1 $ $Date: 2007/05/09 16:07:04 $
  33. */
  34. public class FundModifyScreen extends Form implements CommandListener {
  35. private Command back=new Command("返回",Command.BACK,1);
  36. private Command refresh=new Command("刷新数据",Command.BACK,1);
  37. private Command ok=new Command("选择",Command.OK,1);
  38. private INavigator navigator=null;
  39. private ChoiceGroup codeChoices=null;
  40. private int codeChoicesID=0;
  41. public FundModifyScreen(INavigator navigator){
  42. super("修改基金");
  43. this.navigator=navigator;
  44. codeChoices=new ChoiceGroup("选择要修改的基金",ChoiceGroup.EXCLUSIVE,DataCenter.getFunds(),null);
  45. codeChoicesID=append(codeChoices);
  46. addCommand(ok);
  47. addCommand(back);
  48. addCommand(refresh);
  49. setCommandListener(this);
  50. }
  51. private void refreshData(){
  52. if(codeChoices!=null){
  53. this.delete(codeChoicesID);
  54. }
  55. codeChoices=new ChoiceGroup("选择要修改的基金",ChoiceGroup.EXCLUSIVE,DataCenter.getFunds(),null);
  56. codeChoicesID=append(codeChoices);
  57. }
  58. public void commandAction(Command command, Displayable displayable) {
  59. if(command == refresh){
  60. refreshData();
  61. }else if(command == back){
  62. navigator.getDisplay().setCurrent(navigator.getDisplayable("mainScreen"));
  63. }else if(command == ok){
  64. for(int i=0;i<codeChoices.size();i++){
  65. if(codeChoices.isSelected(i)){
  66. String codeID=codeChoices.getString(i);
  67. navigator.getDisplay().setCurrent(new FundDoModifyScreen(codeID,navigator));
  68. navigator.getCanvas("valueScreen").refresh();
  69. }
  70. }
  71. }
  72. }
  73. }