Tuesday, September 30, 2008

Tips and Tricks Part 4 - Moving component elements

While it would be great to have drag and drop of things like files and registry entries between components, in the meantime there is a nifty trick to move multiple elements between components.

The basics of the trick is to rename the source component to a temporary name, updating the references of only those elements that you wish to move. Then rename the temp component to its original name, updating no references. This will leave the elements that you wish to move "orphaned" with an invalid component.

Then, rename the target component to the temporary name, updating no relationships. This will leave the target component's elements "orphaned", but the elements that are being moved will now be attached the "temp" component.

The final step is to rename the "temp" component back to its original name (the target component), updating all relationships. This will result in the target component containing its original elements and the "moved" elements.

For example:


SourceCmp TargetCmp
File1 File3
File2 File4
Reg1 Reg3
Reg2 Reg4

Step1:
---> TempCmp TargetCmp
File1 File3
File2 File4
Reg1 Reg3
Reg2 Reg4

Step 2:
SourceCmp <--- TargetCmp
File1 File3
File2 File4
Reg1 Reg3
Reg2 Reg4

Step 3:
SourceCmp TargetCmp <---
File1 File3
File2 File4
Reg1 Reg3
Reg2 Reg4

Step 4:
SourceCmp ---> TargetCmp
File1 File3
File4
File2
Reg1 Reg3
Reg4
Reg2



When only moving a few items in one table, it is probably easier to simply copy and paste the target component's name into the relevant fields. But when moving many entries, especially from disparate tables, this method can be quicker. It is probably easiest done from the Component (F10) or Feature (F11) tree views.

This method applies equally well to any parent child entity where the children reference the parent, such as Dialogs and Controls.

No comments: