File Source: ServerInfoDialog.java

         /* 
    P/P   *  Method: com.dmdirc.addons.lagdisplay.ServerInfoDialog__static_init
          */
     1  /*
     2   * Copyright (c) 2006-2009 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.lagdisplay;
    24  
    25  import com.dmdirc.Main;
    26  import com.dmdirc.Server;
    27  import com.dmdirc.ServerManager;
    28  import com.dmdirc.ServerState;
    29  import com.dmdirc.addons.ui_swing.MainFrame;
    30  import com.dmdirc.addons.ui_swing.components.statusbar.StatusbarPopupPanel;
    31  import com.dmdirc.addons.ui_swing.components.statusbar.StatusbarPopupWindow;
    32  
    33  import java.util.List;
    34  
    35  import javax.swing.JLabel;
    36  import javax.swing.JPanel;
    37  import javax.swing.JSeparator;
    38  
    39  
    40  /**
    41   * Shows information about all connected servers.
    42   *
    43   * @author chris
    44   */
    45  public class ServerInfoDialog extends StatusbarPopupWindow {
    46  
    47      /**
    48       * A version number for this class. It should be changed whenever the class
    49       * structure is changed (or anything else that would prevent serialized
    50       * objects being unserialized with the new class).
    51       */
    52      private static final long serialVersionUID = 3;
    53  
    54      /** The lag display plugin. */
    55      protected final LagDisplayPlugin plugin;
    56  
    57      /**
    58       * Creates a new ServerInfoDialog.
    59       *
    60       * @param ldp The {@link LagDisplayPlugin} we're using for info
    61       * @param parent The {@link JPanel} to use for positioning
    62       */
    63      public ServerInfoDialog(final LagDisplayPlugin ldp, final StatusbarPopupPanel parent) {
                 /* 
    P/P           *  Method: void com.dmdirc.addons.lagdisplay.ServerInfoDialog(LagDisplayPlugin, StatusbarPopupPanel)
                  * 
                  *  Presumptions:
                  *    com.dmdirc.Main:getUI(...)@64 != null
                  * 
                  *  Postconditions:
                  *    this.plugin == ldp
                  *    init'ed(this.plugin)
                  */
    64          super(parent, (MainFrame) Main.getUI().getMainWindow());
    65  
    66          this.plugin = ldp;
    67      }
    68  
    69      /** {@inheritDoc} */
    70      @Override
    71      protected void initContent(final JPanel panel) {
                 /* 
    P/P           *  Method: void initContent(JPanel)
                  * 
                  *  Preconditions:
                  *    (soft) panel != null
                  *    (soft) this.plugin != null
                  * 
                  *  Presumptions:
                  *    com.dmdirc.ServerManager:getServerManager(...)@72 != null
                  *    com.dmdirc.ServerManager:getServers(...)@72 != null
                  *    init'ed(com.dmdirc.ServerState.CONNECTED)
                  *    java.util.Iterator:next(...)@82 != null
                  * 
                  *  Test Vectors:
                  *    com.dmdirc.addons.lagdisplay.LagDisplayPlugin:shouldShowGraph(...)@77: {0}, {1}
                  *    java.util.Iterator:hasNext(...)@82: {0}, {1}
                  *    java.util.List:isEmpty(...)@74: {0}, {1}
                  */
    72          final List<Server> servers = ServerManager.getServerManager().getServers();
    73  
    74          if (servers.isEmpty()) {
    75              panel.add(new JLabel("No open servers."));
    76          } else {
    77              if (plugin.shouldShowGraph()) {
    78                  panel.add(new PingHistoryPanel(plugin), "span, grow, wrap");
    79                  panel.add(new JSeparator(), "span, grow, wrap");
    80              }
    81  
    82              for (Server server : servers) {
    83                  panel.add(new JLabel(server.getName()));
    84                  panel.add(new JLabel(server.getState() == ServerState.CONNECTED
    85                          ? server.getNetwork() : "---", JLabel.CENTER), "grow");
    86                  panel.add(new JLabel(server.getState() == ServerState.CONNECTED
    87                          ? plugin.getTime(server) : "---", JLabel.RIGHT), "grow, wrap");
    88              }
    89          }
    90      }
    91  
    92  
    93  }








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