示例#1
0
 /**
  * finds the user object in the array list and loads it to an object variable that is returned to
  * main
  *
  * @param input string name of the user
  */
 public static void login(String input) {
   int val = finduser(input);
   if (val == -1) {
     System.out.println("User " + input + " does not exist");
     return;
   }
   Controller controller = new Controller(users.get(val));
   controller.runner();
 }
示例#2
0
  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    PopUp popup;
    if ("Add".equals(e.getActionCommand())) {
      popup = new PopUp(1, 0);
      if (popup.text != null && popup.text.length() != 0) {

        try {
          if (!control.create_user(popup.text, popup.secondText)) {
            popup = new PopUp("User Already Exists");
          }
        } catch (IOException e1) {
          // TODO Auto-generated catch block
        }
      }
      populateUsers();
    } else if ("Logout".equals(e.getActionCommand())) {
      try {
        JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
        topFrame.setVisible(false);
        popup = new PopUp(4, 0);
        if (popup.response == 0) {
          padre.logout();
        } else {
          topFrame.setVisible(true);
        }
      } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }

    } else {
      popup = new PopUp(3, 0);
      if (popup.response == 0) {
        if (userList.getSelectedValue() == null) // checks to see if the list is empty
        {
        } else // deletes the user
        {
          try {
            System.out.println(control.delete_user(userList.getSelectedValue()));
          } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        }
      }
      populateUsers();
    }
  }
示例#3
0
 /** Called to populate the List of users */
 private void populateUsers() {
   listModel.clear();
   users = control.list_users();
   for (int i = 0; i < users.length; i++) {
     listModel.addElement(users[i]);
   }
   userList.setSelectedIndex(0);
 }
示例#4
0
  private void displayAlbums() {
    /* Use a Textview to portray that no albums exist in the center of the screen
     *
     * Use a Base Adapter to display any existing albums
     *
     */

    TextView tv = (TextView) findViewById(R.id.textview);

    if (c.getAlbums().isEmpty()
        == true) // Tell the user no albums exist in the center of the screen
    {
      tv.setVisibility(View.VISIBLE);
      tv.setGravity(Gravity.CENTER);
      tv.setText("No Albums Exist");

      AlbumListAdapter adapter = new AlbumListAdapter(context, b.list_albums, b);

      gv.setAdapter(adapter);
    } else {
      tv.setVisibility(View.GONE); // the text view is only responsible for no albums selected
      AlbumListAdapter adapter = new AlbumListAdapter(context, b.list_albums, b);

      gv.setAdapter(adapter);
      registerForContextMenu(gv);

      gv.setOnItemClickListener(
          new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              album_holder.clear();
              album_holder.add(b.list_albums.get(position));
              view.showContextMenu();
            }
          });
    }
  }