public Form getSupportMe() {
    if (frmSupportMe == null) {
      // ---------------------------------------------
      // Form f = ...
      frmSupportMe = new Form("Support Me");
      frmSupportMe.setLayout(new BorderLayout());

      Image bimage = null;
      try {
        bimage = Image.createImage("/images/metaLabSmall.png");
      } catch (IOException ex) {
        ex.printStackTrace();
      }

      Label bottomText = new Label(bimage);
      bottomText.setAlignment(Component.CENTER);
      bottomText.setText("Our Logo");
      bottomText.setTextPosition(Component.BOTTOM);

      Container buttonBar = new Container(new BoxLayout(BoxLayout.X_AXIS));
      buttonBar.addComponent(new Button("Add"));
      buttonBar.addComponent(new Button("Remove"));
      buttonBar.addComponent(new Button("Edit"));
      buttonBar.addComponent(new Button("Send"));
      buttonBar.addComponent(new Button("Exit"));

      frmSupportMe.addComponent(BorderLayout.CENTER, bottomText);
      frmSupportMe.addComponent(BorderLayout.SOUTH, buttonBar);
      frmSupportMe.addCommand(mBackCommand);
      frmSupportMe.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmSupportMe;
  }
  public Form getAboutUs() {
    final Form f = new Form("Event counting");
    if (frmAboutUs == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      final Button pushButton = new Button("Tap me!");
      final Label countLabel = new Label(" ");
      pushButton.addActionListener(
          new ActionListener() {
            private int c = 0;

            public void actionPerformed(ActionEvent ae) {
              c++;
              countLabel.setText(Integer.toString(c));
              f.layoutContainer();
              pushButton.setText("Tapped " + Integer.toString(c) + " times");
              // System.out.println(Integer.toString(c));
            }
          });
      f.addComponent(pushButton);
      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return f;
  }
  public Form getAboutYou() {
    Form f = new Form("...placeholder ...");
    if (frmAboutYou == null) {
      f.addComponent(new Label("Choose Back to return to the home screen."));

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return f;
  }
  public void startApp() {
    Display.init(this);

    installTheme();

    createUI();

    mHomeForm.show();
  }
  public Form getResources() {
    if (frmResources == null) {
      frmResources = new Form("Resources");

      List list = new List();
      list.addItem("uno");
      list.addItem("due");
      list.addItem("tre");
      list.addItem("quattro");
      list.addItem("cinque");
      list.addItem("sei");
      frmResources.addComponent(list);

      ComboBox comboBox = new ComboBox(list.getModel());
      frmResources.addComponent(comboBox);
      frmResources.addCommand(mBackCommand);
      frmResources.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmResources;
  }
  public Form getMessages() {
    if (frmMessages == null) {
      // ---------------------------------------------------
      frmMessages = new Form("Messages");
      TextArea area = new TextArea("Peppino");
      frmMessages.addComponent(area);

      TextArea big =
          new TextArea(
              "On February 24, 1815, the lookout at "
                  + "Notre-Dame de la Garde signalled the arrival of the three-master "
                  + "Pharaon, coming from Smyrna, Trieste and Naples.",
              5,
              20);
      frmMessages.addComponent(big);
      frmMessages.addCommand(mBackCommand);
      frmMessages.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      // ---------------------------------------

    }
    return frmMessages;
  }
  public Form getToDoList() {
    Form f = new Form("To Do List");
    if (frmToDoList == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
      Label sLabel = new Label("To Do List appears here");
      f.addComponent(sLabel);

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
  public Form getCalendar() {
    Form f = new Form("Calendar");

    if (frmCalendar == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      Calendar cal = new Calendar();
      f.addComponent(cal);
      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
  public Form getTorch() {
    Form f = new Form("Torch");
    if (frmTorch == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
      Label sLabel = new Label("Torch");
      f.addComponent(sLabel);
      /*
                  UIManager uim = UIManager.getInstance();
                  Hashtable ht = new Hashtable();
                  ht.put("sel#" + Style.BG_COLOR, "d0d0ed");
                  ht.put(Style.BG_COLOR, "ffffff");
                  ht.put(Style.FG_COLOR, "000056");
                  uim.setThemeProps(ht);
      */

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
 public void actionPerformed(ActionEvent ae) {
   if (ae.getSource() == btnSurveysFrm) {
     frmSurveys.setTransitionInAnimator(Transition3D.createCube(300, false));
     frmSurveys.setTransitionOutAnimator(Transition3D.createCube(300, true));
     frmSurveys.show();
   } else if (ae.getSource() == btnChallengesFrm) {
     frmChallenges.show();
   } else if (ae.getSource() == btnCalendarFrm) {
     frmCalendar.show();
   } else if (ae.getSource() == btnContactsFrm) {
     frmContacts.show();
   } else if (ae.getSource() == btnToDoFrm) {
     frmToDoList.show();
   } else if (ae.getSource() == btnTorch) {
     frmTorch.show();
   } else if (ae.getSource() == btnResourceFrm) {
     frmResources.setTransitionInAnimator(Transition3D.createCube(300, false));
     frmResources.setTransitionOutAnimator(Transition3D.createCube(300, true));
     frmResources.show();
   } else if (ae.getSource() == mCubeButton) {
     frmMessages.setTransitionInAnimator(Transition3D.createCube(300, false));
     frmMessages.setTransitionOutAnimator(Transition3D.createCube(300, true));
     frmMessages.show();
   } else if (ae.getSource() == btnSupportFrm) {
     frmSupportMe.setTransitionInAnimator(Transition3D.createCube(300, false));
     frmSupportMe.setTransitionOutAnimator(Transition3D.createCube(300, true));
     frmSupportMe.show();
   } else if (ae.getSource() == btnAboutUs) {
     frmAboutUs.setTransitionInAnimator(Transition3D.createCube(300, false));
     frmAboutUs.setTransitionOutAnimator(Transition3D.createCube(300, true));
     frmAboutUs.show();
   } else if (ae.getSource() == btnAboutYou) {
     frmAboutYou.setTransitionInAnimator(Transition3D.createCube(300, false));
     frmAboutYou.setTransitionOutAnimator(Transition3D.createCube(300, true));
     frmAboutYou.show();
   } else if (ae.getSource() == mFilesButton) {
     mAwayForm.setTransitionInAnimator(Transition3D.createCube(300, false));
     mAwayForm.setTransitionOutAnimator(Transition3D.createCube(300, true));
     mAwayForm.show();
   } else if (ae.getSource() == mRotateButton) {
     mAwayForm.setTransitionInAnimator(Transition3D.createRotation(300, true));
     mAwayForm.setTransitionOutAnimator(Transition3D.createRotation(300, false));
     mAwayForm.show();
   } else if (ae.getSource() == mBackCommand) {
     mHomeForm.show();
   } else if (ae.getCommand() == mExitCommand) {
     notifyDestroyed();
   }
 }
  /*
   public PIMBrowser getPimToDo() {
      if (pimToDo == null) {
          // write pre-init user code here
          pimToDo = new PIMBrowser(getDisplay(), PIM.TODO_LIST);
          pimToDo.setTitle("To Do List");
          pimToDo.addCommand(PIMBrowser.SELECT_PIM_ITEM);
          pimToDo.addCommand(getBackCommand5());
          pimToDo.setCommandListener(this);
          // write post-init user code here
      }
      return pimToDo;
  }
  */
  public Form fullgetToDoList() {
    Form f = new Form("To Do List");
    if (frmToDoList == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
      toDoList = new List();
      pim = PIM.getInstance();
      f.addComponent(toDoList);

      final TextArea searchField = TextField.create();
      f.addComponent(searchField);

      Button searchButton = new Button("Search");
      searchButton.setPreferredW(f.getWidth() / 2 - 5);
      searchButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              populateToDoList(searchField.getText());
            }
          });
      Button clearButton = new Button("Clear");
      clearButton.setPreferredW(f.getWidth() / 2 - 5);
      clearButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              searchField.setText("");
              populateToDoList("");
            }
          });
      Container buttonContainer = new Container();
      buttonContainer.setLayout(new BorderLayout());
      buttonContainer.addComponent(BorderLayout.WEST, searchButton);
      buttonContainer.addComponent(BorderLayout.EAST, clearButton);
      f.addComponent(buttonContainer);

      populateToDoList(searchField.getText());

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
  public Form getChallenges() {
    Form f = new Form("Top Challenges");

    if (frmChallenges == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      class Node {
        Object[] children;
        String value;

        public Node(String value, Object[] children) {
          this.children = children;
          this.value = value;
        }

        public String toString() {
          return value;
        }
      }
      TreeModel model =
          new TreeModel() {
            Node[] sillyTree = {
              new Node(
                  "Energy Banner: 23 completed: 77 Rewards available",
                  new Node[] {
                    new Node(
                        "CHALLENGE: Get together a minimum of 5 friends or family, create a Banner with energy-saving awareness message, display in your community",
                        new Node[] {}),
                    new Node("REWARD: R15 Airtime (only 77 Rewards remaining)", new Node[] {}),
                    new Node(
                        "TO WIN: Send in a photo of you and your friends holding the banner in your community",
                        new Node[] {}),
                    new Node("CLOSES: 21 June 2013", new Node[] {}),
                  }),
              new Node("Well Watch", new Node[] {new Node("A", new Node[] {})}),
              new Node(
                  "Hear Me, My Friend",
                  new Node[] {
                    new Node("A", new Node[] {}),
                  }),
            };

            public Vector getChildren(Object parent) {
              Node n = (Node) parent;
              Object[] nodes;
              if (parent == null) {
                nodes = sillyTree;
              } else {
                nodes = n.children;
              }
              Vector v = new Vector();
              for (int iter = 0; iter < nodes.length; iter++) {
                v.addElement(nodes[iter]);
              }
              return v;
            }

            public boolean isLeaf(Object node) {
              Node n = (Node) node;
              return n.children == null || n.children.length == 0;
            }
          };

      f.setLayout(new BorderLayout());
      f.addComponent(BorderLayout.CENTER, new Tree(model));

      /*
      f.addComponent(area);

      TextArea big = new TextArea("Keep your community clean and win lots of STUFF");
      big.setGrowByContent(true);
      big.setEditable(false);
      f.addComponent(big);


      List list = new List();
        list.addItem("Street Clean Up");
        list.addItem("Drinking Water Clean-Up");
        list.addItem("Deadland Tidy");
        list.addItem("Tree Rescue");
        f.addComponent(list);

      f.addComponent(new Tree(list));
       */

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
  public Form getSurveys() {
    if (frmSurveys == null) {
      frmSurveys = new Form("Surveys");
      Label sLabel = new Label("Surveys On Board");
      frmSurveys.addComponent(sLabel);

      frmSurveys.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      RadioButton rb;
      ButtonGroup group = new ButtonGroup();

      rb = new RadioButton("Grilled chicken");
      group.add(rb);
      frmSurveys.addComponent(rb);

      rb = new RadioButton("Filet mignon");
      group.add(rb);
      frmSurveys.addComponent(rb);

      rb = new RadioButton("Mahi mahi");
      group.add(rb);
      frmSurveys.addComponent(rb);

      rb = new RadioButton("Chili");
      group.add(rb);
      frmSurveys.addComponent(rb);

      CheckBox cb;

      cb = new CheckBox("Guacamole");
      frmSurveys.addComponent(cb);

      cb = new CheckBox("Tabasco sauce");
      frmSurveys.addComponent(cb);

      cb = new CheckBox("Mango salsa");
      frmSurveys.addComponent(cb);

      cb = new CheckBox("Mayonnaise");
      frmSurveys.addComponent(cb);

      cb = new CheckBox("Whipped cream");
      frmSurveys.addComponent(cb);

      frmSurveys.addCommand(mBackCommand);
      frmSurveys.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmSurveys;
  }
  private void createUI() {
    // Set up screen for transitions.
    mAwayForm = new Form("...placeholder ...");
    mAwayForm.addComponent(new Label("Choose Back to return to the home screen."));

    mBackCommand = new Command("Back");
    mAwayForm.addCommand(mBackCommand);
    mAwayForm.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.

    frmSurveys = getSurveys();
    frmChallenges = getChallenges();
    frmResources = getResources();
    frmMessages = getMessages();
    frmSupportMe = getSupportMe();
    frmAboutUs = getAboutUs();
    frmAboutYou = getAboutYou();
    frmCalendar = getCalendar();
    frmContacts = getContacts();
    frmToDoList = getToDoList();
    frmTorch = getTorch();

    // Set up main screen.
    mHomeForm = new Form("Today");
    mHomeForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

    btnChallengesFrm = new Button("Challenges");
    btnChallengesFrm.addActionListener(this);
    mHomeForm.addComponent(btnChallengesFrm);

    btnSurveysFrm = new Button("Surveys");
    btnSurveysFrm.addActionListener(this);
    mHomeForm.addComponent(btnSurveysFrm);

    btnResourceFrm = new Button("Resources");
    btnResourceFrm.addActionListener(this);
    mHomeForm.addComponent(btnResourceFrm);

    mCubeButton = new Button("Messages");
    mCubeButton.addActionListener(this);
    mHomeForm.addComponent(mCubeButton);

    btnSupportFrm = new Button("Support Me");
    btnSupportFrm.addActionListener(this);
    mHomeForm.addComponent(btnSupportFrm);

    btnContactsFrm = new Button("Contacts");
    btnContactsFrm.addActionListener(this);
    mHomeForm.addComponent(btnContactsFrm);

    btnCalendarFrm = new Button("Calendar");
    btnCalendarFrm.addActionListener(this);
    mHomeForm.addComponent(btnCalendarFrm);

    btnToDoFrm = new Button("To Do");
    btnToDoFrm.addActionListener(this);
    mHomeForm.addComponent(btnToDoFrm);

    mFilesButton = new Button("Files");
    mFilesButton.addActionListener(this);
    mHomeForm.addComponent(mFilesButton);

    btnAboutUs = new Button("About Us");
    btnAboutUs.addActionListener(this);
    mHomeForm.addComponent(btnAboutUs);

    btnAboutYou = new Button("About You");
    btnAboutYou.addActionListener(this);
    mHomeForm.addComponent(btnAboutYou);

    btnTorch = new Button("Torch");
    btnTorch.addActionListener(this);
    mHomeForm.addComponent(btnTorch);

    mExitCommand = new Command("Exit");
    mHomeForm.addCommand(mExitCommand);
    mHomeForm.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
  }
Beispiel #15
0
 public void setTitle(String title) {
   super.setTitle(Compatibility.toLowerCaseIfFT(title));
 }