File Source: ClientEvents.java

     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.actions.metatypes;
    24  
    25  import com.dmdirc.FrameContainer;
    26  import com.dmdirc.actions.interfaces.ActionMetaType;
    27  import com.dmdirc.commandparser.PopupMenu;
    28  import com.dmdirc.commandparser.PopupType;
    29  import com.dmdirc.config.ConfigManager;
    30  
    31  import com.dmdirc.config.prefs.PreferencesManager;
    32  import javax.swing.KeyStroke;
    33  import javax.swing.text.StyledDocument;
    34  
    35  /**
    36   * Defines client-wide events.
    37   *
    38   * @author Chris
    39   */
         /* 
    P/P   *  Method: ClientEvents valueOf(String)
          * 
          *  Postconditions:
          *    init'ed(return_value)
          */
    40  public enum ClientEvents implements ActionMetaType {
    41      
    42      /** Client event type. */
             /* 
    P/P       *  Method: com.dmdirc.actions.metatypes.ClientEvents__static_init
              * 
              *  Postconditions:
              *    $VALUES == &new ClientEvents[](ClientEvents__static_init#28)
              *    CLIENT_EVENT == &new ClientEvents(ClientEvents__static_init#1)
              *    $VALUES[0] == &new ClientEvents(ClientEvents__static_init#1)
              *    CLIENT_EVENT_WITH_BUFFER == &new ClientEvents(ClientEvents__static_init#16)
              *    $VALUES[5] == &new ClientEvents(ClientEvents__static_init#16)
              *    CLIENT_EVENT_WITH_KEY == &new ClientEvents(ClientEvents__static_init#13)
              *    $VALUES[4] == &new ClientEvents(ClientEvents__static_init#13)
              *    CLIENT_EVENT_WITH_PREFS == &new ClientEvents(ClientEvents__static_init#19)
              *    $VALUES[6] == &new ClientEvents(ClientEvents__static_init#19)
              *    CLIENT_EVENT_WITH_STYLE == &new ClientEvents(ClientEvents__static_init#22)
              *    ...
              */
    43      CLIENT_EVENT(new String[]{}),
    44      /** Client event type, with a frame argument. */
    45      WINDOW_EVENT(new String[]{"window"}, FrameContainer.class),
    46      /** Client event with frame and message. */
    47      WINDOW_EVENT_WITH_MESSAGE(new String[]{"window", "message"}, FrameContainer.class, String.class),
    48      /** A popup-related event. */
    49      POPUP_EVENT(new String[]{"popup type", "popup", "configuration manager"}, PopupType.class, PopupMenu.class, ConfigManager.class),
    50      /** Client event type, with a key argument. */
    51      CLIENT_EVENT_WITH_KEY(new String[]{"key event"}, KeyStroke.class),
    52      /** Client event with an origin and editable buffer. */
    53      CLIENT_EVENT_WITH_BUFFER(new String[]{"origin", "buffer"}, FrameContainer.class, StringBuffer.class),
    54      /** Client event with preferences manager. */
    55      CLIENT_EVENT_WITH_PREFS(new String[]{"preferences manager"}, PreferencesManager.class),
    56      /** Client event with a styled doc. */
    57      CLIENT_EVENT_WITH_STYLE(new String[]{"styled document", "start offset", "length"}, StyledDocument.class, Integer.class, Integer.class),
    58      /** Unknown command event type. */
    59      UNKNOWN_COMMAND(new String[]{"source", "command", "arguments"}, FrameContainer.class, String.class, String[].class);
    60      
    61      /** The names of the arguments for this meta type. */
    62      private String[] argNames;
    63      /** The classes of the arguments for this meta type. */
    64      private Class[] argTypes;
    65      
    66      /**
    67       * Creates a new instance of this meta-type.
    68       *
    69       * @param argNames The names of the meta-type's arguments
    70       * @param argTypes The types of the meta-type's arguments
    71       */
             /* 
    P/P       *  Method: void com.dmdirc.actions.metatypes.ClientEvents(String, int, String[], Class[])
              * 
              *  Postconditions:
              *    this.argNames == argNames
              *    init'ed(this.argNames)
              *    this.argTypes == argTypes
              *    init'ed(this.argTypes)
              */
    72      ClientEvents(final String[] argNames, final Class ... argTypes) {
    73          this.argNames = argNames;
    74          this.argTypes = argTypes;
    75      }
    76      
    77      /** {@inheritDoc} */
    78      @Override
    79      public int getArity() {
                 /* 
    P/P           *  Method: int getArity()
                  * 
                  *  Preconditions:
                  *    this.argNames != null
                  *    this.argNames.length <= 232-1
                  * 
                  *  Postconditions:
                  *    return_value == this.argNames.length
                  *    return_value >= 0
                  */
    80          return argNames.length;
    81      }
    82      
    83      /** {@inheritDoc} */
    84      @Override
    85      public Class[] getArgTypes() {
                 /* 
    P/P           *  Method: Class[] getArgTypes()
                  * 
                  *  Preconditions:
                  *    init'ed(this.argTypes)
                  * 
                  *  Postconditions:
                  *    return_value == this.argTypes
                  *    init'ed(return_value)
                  */
    86          return argTypes;
    87      }
    88      
    89      /** {@inheritDoc} */
    90      @Override
    91      public String[] getArgNames() {
                 /* 
    P/P           *  Method: String[] getArgNames()
                  * 
                  *  Preconditions:
                  *    init'ed(this.argNames)
                  * 
                  *  Postconditions:
                  *    return_value == this.argNames
                  *    init'ed(return_value)
                  */
    92          return argNames;
    93      }
    94      
    95      /** {@inheritDoc} */
    96      @Override
    97      public String getGroup() {
                 /* 
    P/P           *  Method: String getGroup()
                  * 
                  *  Postconditions:
                  *    return_value == &amp;"General Events"
                  */
    98          return "General Events";
    99      }    
   100      
   101  }








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