Is it possible to invoke refactoring from the Open Tools API? - delphi

The Delphi IDE has a plugin system, the Open Tools API. The IDE also has a number of refactorings available, such as a rename refactoring to rename a field, method, etc - an identifier.
Is it possible to invoke this, or any, refactorings from the OTAPI? If not, is there a hacky way to do it?
My research shows no mentions of refactorings in ToolsAPI.pas, but I don't want to give up with "No." It doesn't mean there isn't a way to do it - it just means I don't know what it is :)

There is no support at all from OTA. Therefore your only hope is to hunt down the menu items or actions, invoke their OnClick or OnExecute handlers, poke values into the dialogs that are shown, and then programmatically press the dialog OK buttons.

Related

A shortcut in the Delphi IDE triggers two actions

Maybe this question is very specific for me, but I'll give it a try. Here's the scenario:
In Delphi XE2 the shortcut "Ctrl+Shift+7" toggles bookmark (likewise Ctrl+Shift+[1..9] for the other bookmarks)
I have installed ModelMaker Tools (v. 9.1.0, but I believe I had this error earlier also), where I have assigned the shortcut "Shift+Ctrl+Alt+Y" to "Sync Declaration/Implementation".
Whenever I use the ModelMaker shortcut I also set the bookmark (7). Why is this? Note that contrary to the "real" shortcut (Ctrl+Shift+7) the bookmark isn't toggled, only set.
This behaviour puzzles me. Does anyone have an explanation? It's not a big problem, since I rarely use that many bookmarks, but it got me curious.
For a couple of refactorings, ModelMaker Code Explorer sets some bookmarks for your convenience.
It is documented somewhere, but I forgot where (:
Edit: it is documented here.
All refactoring operations that modify the IDE edit buffers
(optionally) drop bookmark #7 at the current cursor position. Similar
to how Extract Method drops bookmarks #8 at the original code and #9
at the extracted method. The bookmark numbers can be customized on the
History Tab which also allows disabling dropping specific bookmarks.

Library to create forms/GUIs/dialogs from scripts?

At the moment, whenever I need a custom dialog, however simple, I use Delphi's form designer to create a new dialog form. The form is then wrapped in an easy to use ShowMessage() type function.
In some situations it would be easier if forms could be created at run-time from a script. The script would detail all form components and their properties, much like Delphi's .DFM files.
Creating GUIs from scripts could be useful in other situations as well. For example, a GUI of a mini application could be embedded into the window of an existing application. Or the GUI script could be modified at run-time to create GUI variations.
I could create something to do this myself, but I assume other people have already tackled this problem. However I can't find anything using google. Is there anything currently available offering this kind of functionality? (Free or otherwise) Or does it already exist in Delphi?
Check out some of the scripting solutions for Delphi. For example, the TMS Scripting Studio, dwScript, RemObject's, FastScript, etc. I believe some of them are able to use DFM's for this purpose.
http://www.torry.net/pages.php?id=280 Delphin v.1.21, it can process DFM files, maybe you just want the DFM to code converter.
You might try XI Library (commercial): http://xilib.com/
I have never used it, it's just something sitting in my bookmarks, but it looks like it fits the bill. Not a scripting engine, more of a way to define dialog boxes via XML. There's sample XML code right on the front page, just click "Show the example".

how to change the hot-key used to invoke code insight?

I want to change the hot-key to invoke code insight in Delphi 2010, being the original Ctrl enter, i want to change it to spacebar without installing CnWizards, how can I archive this?
While you could write an IDE wizard to do something like this, using a common key like space to trigger code insight would have many annoying side effects. I can't recommend using such a common keystroke. Consider Ctrl+Space or Ctrl+Shift+Space.
There is no built-in Delphi functionality to change that hotkey.
You can write your own IDE expert to do that. Since cnWizards already provides the functionality you want, the sources of cnWizard are a good start to see how to write your own IDE expert.
--jeroen

How to detect if file in IDE is being edited using Open Tools API

I made a small IDE plug-in using Open Tools API that accesses ClearCase. It has menu items "Check In", "Check Out", etc. It works OK but I want it to check out a read-only file automatically if I start typing in IDE editor or if I attempt to save the file. Do you think this is possible?
I tried a few things but gave up eventually. IOTAEditorServices.KeyboardServices has AddKeyboardBinding method which looked promising. Using it I added a notifier with binding type btPartial (and later tried btComplete) and the plug-in started detecting some shortcut key presses but not all keyboard events, far from it... Any ideas would be much appreciated!
I think a "cleaner" way is to hook up a IOTAEditorNotifier to each editor and have your IOTAEditor.Modified method called by the IDE whenever the contents of the editor is modified, whether by keyboard, mouse or programmatically from another plugin.
Here's an example which registers an IOTAIDENotifier to be notified of files being opened in the IDE so it can register its IOTAEditorNotifier instances.
I must be possible somehow: we use SourceConexion (http://www.epocalipse.com/scx.htm) here, which auto checks-out the file before you edit the source or change the form.
JVCS has IDE integration support, it is open source, maybe they have implemented this too:
http://jedivcs.sourceforge.net/

Delphi 7 - Embedded file open dialog in a form

Does anyone know if it is possible to embed a file open dialog inside your own form?
We have a tabbed dialog and on one of the tabs we want the user to be able to browse for a file with the same functionality as the the standard open dialog e.g. 'Look in' combobox, places bar, shell file list, file name comboedit with name completion etc etc.
I've looked at recreating the dialog with some 3rd party components, namely Jam Shell Browser Components
I can get most of the functionality this way, but I'm missing a couple of things e.g. the places bar and the filename auto completion\suggestion
I don't want to say it's impossible but considering the amount of ugly winapi hacks you'd probably involve I suggest "recreating the dialog with some 3rd party components" but with VirtualShellTools.
VirtualShellTools can be downloaded from this SVN archive.
And here's the google code project page.
(At least it has the filename autocompletion combobox though i am not sure if it has the places bar). Hope it helps.
The places bar is not that difficult to implement using a TListView component set to large icons. The Raize Components library also has some source that would help in this arena.
Just a small note, it's fairly easy to add an auto-completing combobox with SHAutoComplete.
See this article for details.
Maybe this Shell Controls Demo can help you.
Edit: ATM the site seems to be down. The Wayback Machine helps.
Here's the latest download link for the controls involved from the wayback machine:
I would re-create it: it shouldn't take long with the VCL Components. The autocomplete is not hard, and you can get the rest of the data if you look through the windows docs long enough.
You can try and cheat by detecting the tab change and displaying the open dialog as if it were the tab page. You will have to detect the user clicking outside of the dialog (e.g. on a different tab) and prevent it closing until you want to change tabs.
Cheers

Resources