Moving source code units using Project Manager window?

Moving source code units using Project Manager window?

I'm using Delphi XE, and I noticed that I can drag files up or down in the Project Manager window, and while dragging I see a nice blue line showing the target drop position. But it seems that is as far as it goes - nothing further happens with the drop action. I have my project layout with a few directories (eg: src/model; src/other; src/tests etc). I expected to be able to drag a unit from the "model" directory to the "other" directory - inside the Project Manager window. The IDE would then update the program unit, .dpr and .dproj files with the moved unit. But it doesn't do any of that! I have to do a "File -> Save As...", and save it in the new location. Then use Windows Explorer to manually delete the old copy of the unit!

Has this terrible usage been improved since Delphi XE? I sure hope so. Otherwise, what is the point of the Project Manager window's drag-n-drop functionality then. Why do I see the blue target location indicator, but nothing actually happens. Hell, with Delphi XE, I can't even create a new folder for source code (I have to use the Windows Save As dialog).

On a side note: Lazarus IDE, Eclipse, Intellij IDEA all allow this functionality for years already.

Comments

  1. Sadly....yes; this is how the project manager works. To frustrate you further, in one of my projects, the files are not even sorted in alphabetical order especially when I add a new unit and even after multiple restarts of the IDE. But I am ok with these glitches; learnt to live with them

    ReplyDelete
  2. Yikes! I've returned to Delphi for a contracting job (2 weeks already with Delphi XE) - having done Free Pascal and Lazarus contracting work for the last couple of years. I've constantly heard from Delphi developers that Lazarus is rubbish. How wrong they were! Lazarus IDE is brilliant - in features and stability. The Lazarus Project Manager allows you to drag and drop (moving files around or dropping new files in from the OS) - in the process in updates all references to that unit if it is renamed, asks if you want to delete the old one, and it even renames (or deletes) the compiled unit of the old name. That's how things are supposed to work.

    ReplyDelete
  3. Playing around further with the Delphi Project Manager screen, I found a awkward work-around - but at least it is slightly more useful that File ➝ Save As. I can F2 on a selected file, which allows me to edit it (function seems intermittent though). The I can type in the relative path and unit name to the new directory location. Hit Enter, and it moves the unit. Yeah!

    BUT, it still doesn't update any other units that referenced the old unit name, and even worse, the IDE doesn't rename or delete the old DCU files. So you might have some fun seeing your project compile, but new unit updates don't apply at runtime, because they are still using/referencing the old DCU files. :-(

    ReplyDelete
  4. After F2, I reckon you need to manually edit the project file and the location of the unit (hit Ctrl-V on the project file).

    I, also, think that DCUs are correctly not deleted as there is no way for the IDE to know that your intention was really to rename a unit and all the byproducts. It's the same as expecting Word to delete a file when you save it under a different name

    ReplyDelete
  5. Hello.
    Try this: (that works in Tokyo, but maybe...)
    1. Select file in Project Manager
    2. Go to Object Inspector
    3. In Object Inspector change File Name (use ..\Newname or newfolder\NewName trick also work)

    Delphi will move file to the new location and rename it, delete old file and update .dpr/.dproj. Voila.

    I hope it's work in XE too...

    btw, is 2017 year and Project Manager still cannot handle simple drag'n drop or right click context menu to do it... Very sad...

    ReplyDelete
  6. John Kouraklis F2 automatically updates the renamed/moved units in all DPRs of the current project group. Renaming the DCUs would indeed be quite tedious as they are possibly spread over different places depending on the entries for DCU output in the different build configurations/platforms. After all the DCU has to be re-compiled anyway because of the rename. I developed the habit to delete the DCU folders from time to time. This not only gets rid of the superfluous DCUs, but also makes the compiler complain for those units still referring to the old unit names in their uses clause.

    ReplyDelete
  7. Uwe Raabe I don't use F2 to relocate/rename units so not really familiar what is updated. It was just a guess. I do the same with DCUs although not as religiously as I should

    ReplyDelete
  8. Thanks for all the input. So what I take from this is that the "drag-n-drop" support I see in the Project Manager window is just fake - there is no functionality behind it. Strange that it allows dragging then.

    ReplyDelete
  9. Well, if the visual component has drag-n-drop support it doesn't always means that the programmer has put the functionality behind the visual effects. Nevertheless, if there's an option to hide the visual effects of drag-n-drop, the programmer should use it until it actually implements any intended functionality. It's just not fair for the user when the visuals are there but nothing happens in the background 🤔

    ReplyDelete
  10. Graeme Geldenhuys The dragging is currently just a visual reorder of the units inside the treeview (what effect should dragging a file while keeping it in the same folder else have). It allows to move often used units to the top. Obviously this doesn't play well with the autosort option also available there. I agree that the project manager could be a little bit more sophisticated here. BTW, is anyone aware of a similar feature request in QP?

    ReplyDelete
  11. Uwe Raabe: The auto-sort issue is easy to resolve. If you drag files up or down in the same folder, then on drop simply disable the auto-sort option. The developer clearly showed intent that at that point he/she didn't want auto-sorting to apply.

    And while you are at it, if dragging a file to a different folder - keep auto-sort enabled (if it was enabled), but then move the unit to the new folder, and update the .dpr and .dproj files to match. Both features supported without fuss.

    If EMBT needs more IDE developers to work on improvements or fresh ideas, they should just ask - I'm available soon. ;-)

    ReplyDelete

Post a Comment