File Source: InvitePopup.java

         /* 
    P/P   *  Method: com.dmdirc.addons.ui_swing.components.statusbar.InvitePopup__static_init
          */
     1  /*
     2   * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
     3   *
     4   * Permission is hereby granted, free of charge, to any person obtaining a copy
     5   * of this software and associated documentation files (the "Software"), to deal
     6   * in the Software without restriction, including without limitation the rights
     7   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     8   * copies of the Software, and to permit persons to whom the Software is
     9   * furnished to do so, subject to the following conditions:
    10   *
    11   * The above copyright notice and this permission notice shall be included in
    12   * all copies or substantial portions of the Software.
    13   *
    14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    20   * SOFTWARE.
    21   */
    22  
    23  package com.dmdirc.addons.ui_swing.components.statusbar;
    24  
    25  import com.dmdirc.Invite;
    26  import com.dmdirc.Server;
    27  import com.dmdirc.ui.messages.Formatter;
    28  import java.awt.Window;
    29  import javax.swing.JLabel;
    30  import javax.swing.JPanel;
    31  
    32  /**
    33   * Shows information about received invites.
    34   *
    35   * @since 0.6.3m1
    36   * @author chris
    37   */
    38  public class InvitePopup extends StatusbarPopupWindow {
    39  
    40      /**
    41       * A version number for this class. It should be changed whenever the class
    42       * structure is changed (or anything else that would prevent serialized
    43       * objects being unserialized with the new class).
    44       */
    45      private static final long serialVersionUID = 1;
    46  
    47      /** The server to show invites for. */
    48      private final Server server;
    49  
    50      /**
    51       * Creates a new InvitePopup for the specified panel and server.
    52       * 
    53       * @param parent The parent of this popup
    54       * @param server The server to show invites for
    55       * @param parentWindow Parent window
    56       */
    57      public InvitePopup(final JPanel parent, final Server server, final Window parentWindow) {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.ui_swing.components.statusbar.InvitePopup(JPanel, Server, Window)
                  * 
                  *  Postconditions:
                  *    this.parent == parent
                  *    init'ed(this.parent)
                  *    this.parentWindow == parentWindow
                  *    init'ed(this.parentWindow)
                  *    this.server == server
                  *    init'ed(this.server)
                  */
    58          super(parent, parentWindow);
    59          this.server = server;
    60      }
    61  
    62      /** {@inheritDoc} */
    63      @Override
    64      protected void initContent(final JPanel panel) {
                 /* 
    P/P           *  Method: void initContent(JPanel)
                  * 
                  *  Preconditions:
                  *    this.server != null
                  *    (soft) panel != null
                  * 
                  *  Presumptions:
                  *    com.dmdirc.Invite:getSource(...).length@67 >= 1
                  *    com.dmdirc.Invite:getSource(...)@67 != null
                  *    com.dmdirc.Invite:getTimestamp(...)@68 - java.lang.System:currentTimeMillis(...)@68 in {-4_294_967_295_999..2_147_483_648_999}
                  *    com.dmdirc.Server:getInvites(...)@65 != null
                  *    java.util.Iterator:next(...)@65 != null
                  * 
                  *  Test Vectors:
                  *    java.util.Iterator:hasNext(...)@65: {0}, {1}
                  */
    65          for (Invite invite : server.getInvites()) {
    66              panel.add(new JLabel(invite.getChannel()), "growx, pushx");
    67              panel.add(new JLabel(invite.getSource()[0], JLabel.CENTER), "growx, pushx, al center");
    68              panel.add(new JLabel(Formatter.formatDuration((int)
    69                      (System.currentTimeMillis() - invite.getTimestamp()) / 1000) + " ago",
    70                      JLabel.RIGHT), "growx, pushx, al right, wrap");
    71          }
    72      }
    73  
    74  }








SofCheck Inspector Build Version : 2.17854
InvitePopup.java 2009-Jun-25 01:54:24
InvitePopup.class 2009-Sep-02 17:04:15