Beispiel #1
0
 @Override
 public void actionPerformed(ActionEvent arg0) {
   ContactFormPanel cfPanel = cfPage.getContent();
   ContactListPanel clPanel = clPage.getContent();
   String sAhra = cfPanel.getFieldText(Contact.Fields.AHRA);
   String uname = cfPanel.getFieldText(Contact.Fields.USER_NAME);
   String fname = cfPanel.getFieldText(Contact.Fields.FULL_NAME);
   String group = cfPanel.getFieldText(Contact.Fields.GROUP);
   if (AHRA.validate(sAhra)) {
     AHRA ahra = new AHRA(sAhra);
     Contact c = new Contact(ahra, group, uname, fname);
     cList.addContact(c);
     final ContactWidget widget = clPanel.addContact(c, Fields.AHRA);
     System.out.println("Submit: " + c);
     switchView(clPage);
     ((ContactFormPanel) cfPage.getContent()).reset();
     (new Thread() {
           @Override
           public void run() {
             widget.animateAdd();
           }
         })
         .start();
   }
 }
Beispiel #2
0
  public MainControl(ContactList cl, JPanel mp) {
    /* Link data. */
    cList = cl;
    /* Link main view. */
    mainPanel = mp;

    genBrute();

    /* Initialize views. */
    clPage = new ContactListPage(cList);
    cfPage = new ContactFormPage();

    ContactListPanel widgetPanel = clPage.getContent();
    ContactListMenu widgetMenu = clPage.getMenu();
    ContactFormPanel formPanel = cfPage.getContent();
    ContactFormMenu formMenu = cfPage.getMenu();

    /* Set listeners. */
    /* WidgetListener is no longer global.
     * ContactWidget now has a reference
     * which is set in addContactWidgetlistener() */
    ContactWidgetListener widgetListener = new ContactWidgetListener();
    AddContactListener addButtonListener = new AddContactListener();
    SearchContactListener searchButtonListener = new SearchContactListener();
    ContactFormFocusListener focusListener = new ContactFormFocusListener();
    ContactFormSubmitListener submitListener = new ContactFormSubmitListener();
    ContactFormCancelListener cancelListener = new ContactFormCancelListener();
    widgetPanel.addContactWidgetListener(widgetListener);
    widgetMenu.addAddButtonListener(addButtonListener);
    widgetMenu.addSearchButtonListener(searchButtonListener);
    formPanel.addFormFocusListener(focusListener);
    formMenu.addSubmitButtonListener(submitListener);
    formMenu.addCancelButtonListener(cancelListener);
    /* Set current view to the contact list. */
    currentView = clPage;
    clPage.setVisible(true);
    cfPage.setVisible(false);
    mainPanel.add(clPage);
    mainPanel.add(cfPage);
    mainPanel.setPreferredSize(new Dimension(200, 400));
  }