@@ -2536,7 +2536,7 @@ public bool OnInsertItemInVector(object argument)
25362536 UndoableUnitOfWorkHelper . Do ( string . Format ( xWorksStrings . ksUndoInsert , command . UndoRedoTextInsert ) ,
25372537 string . Format ( xWorksStrings . ksRedoInsert , command . UndoRedoTextInsert ) , Cache . ActionHandlerAccessor , ( ) =>
25382538 {
2539- result = m_list . CreateAndInsert ( className ) ;
2539+ result = m_list . CreateAndInsert ( className , out _ ) ;
25402540 } ) ;
25412541 }
25422542 catch ( ApplicationException ae )
@@ -2612,6 +2612,83 @@ public bool OnDuplicateItemInVector(object argument)
26122612 return result ;
26132613 }
26142614
2615+ /// <summary>
2616+ /// see if it makes sense to provide the "duplicate XXX" command now
2617+ /// </summary>
2618+ /// <param name="commandObject"></param>
2619+ /// <param name="display"></param>
2620+ /// <returns></returns>
2621+ public virtual bool OnDisplayDuplicateSelectedItem ( object commandObject , ref UIItemDisplayProperties display )
2622+ {
2623+ CheckDisposed ( ) ;
2624+
2625+ string className = Cache . MetaDataCacheAccessor . GetClassName ( m_list . ListItemsClass ) ;
2626+ if ( m_list . CurrentObject == null ||
2627+ ! m_list . IsCurrentObjectValid ( ) ||
2628+ ! m_list . CanInsertClass ( m_list . CurrentObject . ClassName ) ||
2629+ ! ( m_list . CurrentObject is ICloneableCmObject ) )
2630+ {
2631+ display . Visible = display . Enabled = false ;
2632+ }
2633+ else
2634+ {
2635+ display . Text = string . Format ( display . Text , GetTypeNameForUi ( m_list . CurrentObject ) ) ;
2636+ }
2637+
2638+ return true ;
2639+ }
2640+
2641+ /// <summary>
2642+ /// Duplicate selected item in a non-possibilities list.
2643+ /// </summary>
2644+ public bool OnDuplicateSelectedItem ( object argument )
2645+ {
2646+ CheckDisposed ( ) ;
2647+
2648+ if ( ! Editable )
2649+ return false ;
2650+
2651+ if ( m_list . CurrentObject == null ||
2652+ ! m_list . IsCurrentObjectValid ( ) ||
2653+ ! m_list . CanInsertClass ( m_list . CurrentObject . ClassName ) ||
2654+ ! ( m_list . CurrentObject is ICloneableCmObject ) )
2655+ return false ;
2656+
2657+ SaveOnChangeRecord ( ) ;
2658+
2659+ var command = ( Command ) argument ;
2660+ ICmObject selectedObject = m_list . CurrentObject ;
2661+ string className = selectedObject . ClassName ;
2662+ bool result = false ;
2663+ m_suppressSaveOnChangeRecord = true ;
2664+ ICmObject newObj = null ;
2665+
2666+ try
2667+ {
2668+ UndoableUnitOfWorkHelper . Do ( string . Format ( xWorksStrings . ksUndoDuplicate , className ) ,
2669+ string . Format ( xWorksStrings . ksRedoDuplicate , className ) ,
2670+ Cache . ActionHandlerAccessor , ( ) =>
2671+ {
2672+ result = m_list . CreateAndInsert ( className , out newObj ) ;
2673+ ( ( ICloneableCmObject ) selectedObject ) . SetCloneProperties ( newObj ) ;
2674+ } ) ;
2675+ }
2676+ catch ( ApplicationException ae )
2677+ {
2678+ throw new ApplicationException ( "Could not duplicate the item requested by the command " + command . ConfigurationNode , ae ) ;
2679+ }
2680+ finally
2681+ {
2682+ m_suppressSaveOnChangeRecord = false ;
2683+ }
2684+
2685+ if ( newObj != null )
2686+ m_mediator . BroadcastMessage ( "UpdateItemCheckedState" , newObj ) ;
2687+ m_mediator . BroadcastMessage ( "FocusFirstPossibleSlice" , null ) ;
2688+ return result ;
2689+ }
2690+
2691+
26152692 #endregion
26162693
26172694 /// <summary>
0 commit comments