Class AbstractPasteCommand

java.lang.Object
com.ptc.windchill.enterprise.object.commands.AbstractPasteCommand
Direct Known Subclasses:
PasteAnnotationCommands, PasteCommands

public abstract class AbstractPasteCommand extends Object
Abstract implementation of a paste command processor.

Implementation Notes:
  • Implementing classes should call doPaste() to perform the default processing of the paste call, which will handle all of the common error conditions/messages and call either the paste select or paste javascript.
  • The implementation is designed to use a DefaultUIComponentValidator to validate the applicability of an item to be pasted. The implementing class is required to specify the validation key. The validator should override the performFullPreValidation() method and return values that are either ENABLED or DISABLED.
  • For tables which do not use the standard added/removed/initial rows from NmCommandBean to obtain the existing table rows, the method getExistingOidsInTable should be overridden to provide the objects which are present in the table.
  • Implementations of the class should declare an action which calls the implementation's static method (accepting an NmCommandBean as an argument), the implementor should call the doPaste( ) method above. An example configuration might look like the following:
     <action name="changePaste" ajax="row">
        <description>Paste select changeables</description>
        <command class="com.ptc.windchill.enterprise.change2.commands.PasteChangeableCommands" method="paste"/>
     </action>
     
    This is the action which is returned from the getPasteSelectAction() method.
  • By default, the javascript functions present in paste.jsfrags will be used to handle the client side processing of paste. These may be overridden using the methods getPasteJavascript() and getPasteSelectJavascript().
  • When calling from a paste select form processor, the flag pasteSelect should be set prior to calling doPaste() by the processor. This will ensure the proper logic is followed for the paste select processing.
  • For partial errors, a fixed number of objects will be shown prior to seeing the "...". This number can be tailored by setting the errorThreshold property.


Supported API: true

Extendable: true
  • Method Details

    • isPasteSelect

      public boolean isPasteSelect()
      Determine whether or not the paste logic processing is fired from the paste select client. Currently this involves checking the command bean for the presence of a value "pasteSelect" being true.

      Supported API: true
      Returns:
    • setPasteSelect

      public void setPasteSelect(Boolean pasteSelect)
      Set the paste select toggle indicating that processing is coming from paste select.

      Supported API: true
      Parameters:
      pasteSelect -
    • doPaste

      protected FormResult doPaste() throws WTException
      The method which performs the paste action. Requires the command bean to have been set prior to being called. Will return the FormResult with the appropriate error messages, or javascript calls etc. Implementing classes should call the doPaste() method after initialization to perform the paste.

      Supported API: true
      Returns:
      Throws:
      WTException
    • handleFormResult

      protected FormResult handleFormResult(FeedbackMessage fbmsg, List<String> addOidList)
      Default processing for the form result for the non-paste select case. If the Feedback message is defined, then an error condition should be assumed. This implementation will set the status to FormProcessingStatus.FAILURE if the message is not null (as well as setting the message). If there are one or more items to add to the table, the next action will be set to FormResultAction.JAVASCRIPT and the javascript function for paste will be called.

      Supported API: true
      Parameters:
      fbmsg - The feedback message (if errors exist)
      addOidList - The list of oids that are to be added
      Returns:
      A configured FormResult
    • getPasteSelectAction

      protected NmAction getPasteSelectAction() throws WTException
      The paste select NmAction which can be overridden by subclasses. Will default to:
        netmarkeds.clipboard action


      Supported API: true
      Returns:
      The NmAction for the paste select action
      Throws:
      WTException
    • getPasteJavascript

      protected String getPasteJavascript(List<String> oidList)
      Retrieve the java script to call to invoke the paste of the items into the table. By default will call:
        PTC.paste.pasteItems('OR:wt.part.WTPart','some_table_id',false,status)


      Supported API: true
      Parameters:
      oidList - The string list of oids to pass to the JS call.
      Returns:
      java script
    • getPasteJavascriptFunction

      protected String getPasteJavascriptFunction()
      Returns the following default java script function name for pasting the objects into a given table PTC.paste.pasteItems. When overriding this function the returned function name should be defined in a name space for example for promotion objects the function name is PTC.promotion.pasteItems.

      Supported API: true
      Returns:
      paste function name
    • getPasteSelectJavascript

      protected String getPasteSelectJavascript(NmAction action, String title, String msg) throws Exception
      Retrieve the javascript to call to invoke the paste select for the table. By default will call:
        PTC.paste.launchPasteSelectItems('some title','some message','table__tableId_TABLE,'netmarkets/jsp/object/clipboard.jsp')


      Supported API: true
      Parameters:
      title - The title for the paste select prompt dialog
      msg - The message for the paste select prompt dialog
      Returns:
      Throws:
      Exception
    • getPasteValidationKey

      protected abstract String getPasteValidationKey()
      The validation key use to perform validation of the selected/clipboard items. If the key is null, then this designates that validation should be skipped.

      Supported API: true
      Returns:
      the validation key or null if no validation is needed.
    • getTableId

      protected abstract String getTableId()
      The table id of the table which is the target of the paste operation. This table id should not include the TABLE_PREFIX and TABLE_POSTFIX values. (ie. it should be the defined table value, not the raw value).

      Supported API: true
      Returns:
      The table id. Should not be null unless also overridding the getPasteSelectJavascript() and getPasteJavascript() methods.
    • isPasteAsVersionReference

      protected boolean isPasteAsVersionReference()
      Used to determine if the valid paste objects should be pasted as version references or object references. The default return value is true to specify that the objects pasted are version references.

      Supported API: true
      Returns:
      true