File Source: BrowserPlugin.java

         /* 
    P/P   *  Method: com.dmdirc.addons.addonbrowser.BrowserPlugin__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.addonbrowser;
    24  
    25  import com.dmdirc.config.prefs.PreferencesManager;
    26  import com.dmdirc.plugins.Plugin;
    27  import com.dmdirc.addons.ui_swing.components.pluginpanel.PluginPanel;
    28  
    29  import java.awt.Component;
    30  import java.awt.event.ActionEvent;
    31  import java.awt.event.ActionListener;
    32  
    33  import javax.swing.JButton;
    34  
    35  /**
    36   * Allows the user to browse and download plugins from within the DMDirc ui.
    37   * 
    38   * @author chris
    39   */
         /* 
    P/P   *  Method: void com.dmdirc.addons.addonbrowser.BrowserPlugin()
          * 
          *  Postconditions:
          *    this.loaded == 0
          */
    40  public class BrowserPlugin extends Plugin implements ActionListener {
    41      
    42      /** Whether or not we're loaded. */
    43      private boolean loaded = false;
    44  
    45      /** {@inheritDoc} */
    46      @Override
    47      public void onLoad() {
                 /* 
    P/P           *  Method: void onLoad()
                  * 
                  *  Postconditions:
                  *    this.loaded == 1
                  */
    48          loaded = true;
    49      }
    50  
    51      /** {@inheritDoc} */
    52      @Override
    53      public void onUnload() {
                 /* 
    P/P           *  Method: void onUnload()
                  * 
                  *  Postconditions:
                  *    this.loaded == 0
                  */
    54          loaded = false;
    55      }
    56  
    57      /** {@inheritDoc} */
    58      @Override
    59      public void showConfig(final PreferencesManager manager) {
                 /* 
    P/P           *  Method: void showConfig(PreferencesManager)
                  * 
                  *  Preconditions:
                  *    init'ed(this.loaded)
                  *    (soft) manager != null
                  * 
                  *  Presumptions:
                  *    arr$.length@62 <= 232-1
                  *    arr$.length@66 <= 232-1
                  *    com.dmdirc.addons.ui_swing.components.pluginpanel.PluginPanel:getComponents(...)@62 != null
                  *    com.dmdirc.config.prefs.PreferencesCategory:getObject(...)@61 != null
                  *    com.dmdirc.config.prefs.PreferencesManager:getCategory(...)@61 != null
                  *    ...
                  * 
                  *  Test Vectors:
                  *    this.loaded: {0}, {1}
                  *    java.lang.String:startsWith(...)@63: {0}, {1}
                  */
    60          if (loaded) {
    61              final PluginPanel pp = ((PluginPanel) manager.getCategory("Plugins").getObject());
    62              for (Component comp : pp.getComponents()) {
    63                  if (comp instanceof JButton && ((JButton) comp).getText().startsWith("Get more")) {
    64                      final JButton button = (JButton) comp;
    65                      
    66                      for (ActionListener listener : button.getActionListeners()) {
    67                          button.removeActionListener(listener);
    68                      }
    69                      
    70                      button.addActionListener(this);
    71                  }
    72              }
    73          }
    74      }
    75  
    76      /** {@inheritDoc} */
    77      @Override
    78      public void actionPerformed(final ActionEvent e) {
                 /* 
    P/P           *  Method: void actionPerformed(ActionEvent)
                  * 
                  *  Preconditions:
                  *    com/dmdirc/Main.controller != null
                  */
    79          new DownloaderWindow();
    80      }
    81  
    82  }








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