Class AbstractPasteCommand
java.lang.Object
com.ptc.windchill.enterprise.object.commands.AbstractPasteCommand
- Direct Known Subclasses:
PasteAnnotationCommands,PasteCommands
Abstract implementation of a paste command processor.
Implementation Notes:
Supported API: true
Extendable: true
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
DefaultUIComponentValidatorto validate the applicability of an item to be pasted. The implementing class is required to specify the validation key. The validator should override theperformFullPreValidation()method and return values that are eitherENABLEDorDISABLED. - For tables which do not use the standard added/removed/initial rows from
NmCommandBean to obtain the existing table rows, the method
getExistingOidsInTableshould 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:This is the action which is returned from the<action name="changePaste" ajax="row"> <description>Paste select changeables</description> <command class="com.ptc.windchill.enterprise.change2.commands.PasteChangeableCommands" method="paste"/> </action>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()andgetPasteSelectJavascript(). - When calling from a paste select form processor, the flag
pasteSelectshould be set prior to callingdoPaste()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
errorThresholdproperty.
Supported API: true
Extendable: true
-
Method Summary
Modifier and TypeMethodDescriptionprotected FormResultdoPaste()The method which performs the paste action.protected StringgetPasteJavascript(List<String> oidList) Retrieve the java script to call to invoke the paste of the items into the table.protected StringReturns the following default java script function name for pasting the objects into a given tablePTC.paste.pasteItems.protected NmActionThe paste select NmAction which can be overridden by subclasses.protected StringgetPasteSelectJavascript(NmAction action, String title, String msg) Retrieve the javascript to call to invoke the paste select for the table.protected abstract StringThe validation key use to perform validation of the selected/clipboard items.protected abstract StringThe table id of the table which is the target of the paste operation.protected FormResulthandleFormResult(FeedbackMessage fbmsg, List<String> addOidList) Default processing for the form result for the non-paste select case.protected booleanUsed to determine if the valid paste objects should be pasted as version references or object references.booleanDetermine whether or not the paste logic processing is fired from the paste select client.voidsetPasteSelect(Boolean pasteSelect) Set the paste select toggle indicating that processing is coming from paste select.
-
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
Set the paste select toggle indicating that processing is coming from paste select.
Supported API: true- Parameters:
pasteSelect-
-
doPaste
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 thedoPaste()method after initialization to perform the paste.
Supported API: true- Returns:
- Throws:
WTException
-
handleFormResult
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 toFormProcessingStatus.FAILUREif 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 toFormResultAction.JAVASCRIPTand 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
The paste select NmAction which can be overridden by subclasses. Will default to:netmarkeds.clipboardaction
Supported API: true- Returns:
- The NmAction for the paste select action
- Throws:
WTException
-
getPasteJavascript
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
Returns the following default java script function name for pasting the objects into a given tablePTC.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 isPTC.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 dialogmsg- The message for the paste select prompt dialog- Returns:
- Throws:
Exception
-
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
The table id of the table which is the target of the paste operation. This table id should not include theTABLE_PREFIXandTABLE_POSTFIXvalues. (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()andgetPasteJavascript()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
-