Discussion:
Manipulate Library and Browsing Path
(too old to reply)
Aleksander Oven
2008-03-13 23:35:49 UTC
Permalink
Anyone knows of a way to change the library and browsing paths from an
IDE wizard and have the changes immediately take effect (i.e. without
restarting the IDE)?
--
Regards,
Aleksander Oven
Dave Nottage [TeamB]
2008-03-14 00:35:51 UTC
Permalink
Post by Aleksander Oven
Anyone knows of a way to change the library and browsing paths from an
IDE wizard and have the changes immediately take effect (i.e. without
restarting the IDE)?
If you find a way, make sure users can confirm the change (because they
might not want it).

There's nothing more annoying than having settings changed
'automatically' without being notified. Unfortunately, the IDE already
does it, and unnecessarily, in my case.
--
Dave Nottage [TeamB]
Aleksander Oven
2008-03-14 00:57:53 UTC
Permalink
Post by Dave Nottage [TeamB]
If you find a way, make sure users can confirm the change (because they
might not want it). There's nothing more annoying than having settings
changed 'automatically' without being notified.
The change is destined to occur as a direct result of a user action -
selecting a profile from a dropdown list in the main window's toolbar.

It's a part of a bigger goal, which is an attempt at dynamically
adjusting the IDE to match project's vendor snapshot.
Basically, I want to extend Subversion's "vendor branches" concept to
include IDE-related settings (namely, design-time packages and paths).
--
Regards,
Aleksander Oven
Aleksander Oven
2008-03-14 01:37:47 UTC
Permalink
Post by Dave Nottage [TeamB]
If you find a way
It seems IOTAEnvironmentOptions and IOTAProjectOptions may be that way,
as hinted in this QC entry:

http://qc.codegear.com/wc/qcmain.aspx?d=24177

I'll check tomorrow and report back with findings.
--
Regards,
Aleksander Oven
Sasan Adami
2008-03-18 15:25:41 UTC
Permalink
Post by Aleksander Oven
It seems IOTAEnvironmentOptions and IOTAProjectOptions may be that way,
http://qc.codegear.com/wc/qcmain.aspx?d=24177
Here's an example. The procedure below updates the BDS library path.
ANewPath is a string and should contain the directories for the new
library path separated by semicolons.

Sasan.

-----

procedure UpdateIDELibraryPath(ANewPath: string);
var
EnvOptions: IOTAEnvironmentOptions;
begin
EnvOptions := (BorlandIDEServices as IOTAServices).GetEnvironmentOptions;
if Assigned(EnvOptions) then
EnvOptions.Values['LibraryPath'] := ANewPath;
end;
Aleksander Oven
2008-04-09 04:24:28 UTC
Permalink
Post by Sasan Adami
procedure UpdateIDELibraryPath(ANewPath: string);
var
EnvOptions: IOTAEnvironmentOptions;
begin
EnvOptions := (BorlandIDEServices as IOTAServices).GetEnvironmentOptions;
if Assigned(EnvOptions) then
EnvOptions.Values['LibraryPath'] := ANewPath;
end;
Thanks! It works. :)

As for the project options, it's a similar procedure:

procedure UpdateProjectLibraryPath(const aNewPath: AnsiString);
var
Proj: IOTAProject;
begin
Proj := (BorlandIDEServices as IOTAModuleServices).GetActiveProject();
if (Proj <> nil) then
Proj.ProjectOptions.Values['SrcPath'] := aNewPath;
end;
--
Regards,
Aleksander Oven
Aleksander Oven
2008-04-09 04:29:32 UTC
Permalink
Post by Aleksander Oven
I'll check tomorrow and report back with findings.
Wow, this took longer than I expected! :/

In the end, it wasn't setting the path that was tricky, but rather
programmatically uninstalling and installing design-time packages.

Luckily, I have it all working now, so it was worth the effort. :)
--
Regards,
Aleksander Oven
David Novo
2008-05-04 23:51:23 UTC
Permalink
Hello,

If you can share how you programatically installed/uninstalled design
time IDE packages, that would be great. We were going to try to go that
route, but there did not seem to be a way to do it. So instead, we
wrote an external script that we run to set up the IDe the way we want
for different projects. If we could do load certain IDE packages
automatically when loading a particular project, and unload then done,
that would be awesome.
Post by Aleksander Oven
In the end, it wasn't setting the path that was tricky, but rather
programmatically uninstalling and installing design-time packages.
--
Erik Berry
2008-05-05 13:44:54 UTC
Permalink
Post by David Novo
If you can share how you programatically installed/uninstalled design
time IDE packages, that would be great. We were going to try to go that
route, but there did not seem to be a way to do it. So instead, we
wrote an external script that we run to set up the IDe the way we want
for different projects. If we could do load certain IDE packages
automatically when loading a particular project, and unload then done,
Call LoadPackage. Depending on the IDE package type, you may also need to
manually call the Register/IDERegister exported procedure on the package.

Erik
Aleksander Oven
2008-05-06 08:45:37 UTC
Permalink
Post by Erik Berry
Call LoadPackage. Depending on the IDE package type, you may also need
to manually call the Register/IDERegister exported procedure on the
package.
Unfortunately, that's not going to work. IDE does a LOT of additional
stuff when you install/uninstall packages via IDE dialogs, like updating
the component palette and various internal structures.

See my reply to David.
--
Regards,
Aleksander Oven
Aleksander Oven
2008-05-06 08:43:56 UTC
Permalink
Post by David Novo
If you can share how you programatically installed/uninstalled design
time IDE packages, that would be great.
Sharing the code is not something I can do, sorry. I can share the idea
behind the code, though.

As many people before me have already determined, there's currently no
official way of installing and uninstalling the packages from within an
IDE expert. So after careful consideration I decided to embark on a
difficult, trial-and-error-ridden path of simulating user input.

In a nutshell, this is what's required:

- Locate the action object that belongs to the "Component|Install
packages" menu item, and execute it
- Locate the list box component on the form that opens
- Locate the "Add", "Remove" and "OK" buttons on that same form
- Loop the list box items, calling "Remove" button's OnClick event
handler for each item
- Execute the "Add" button's OnClick event handler for every new package
to install
- Confirm the changes by executing "OK" button's OnClick handler

In reality, it was much more complicated, because initial action can
open different forms with different control structure and layout,
depending on whether there is a project open or not, and the type of the
active project (package/exe/dll).

Additionally, IDE pops up a dialog for every package about to be
removed. In order to hide that dialog, I had to figure out which API
was called (different on XP/Vista) and patch it with my own, which only
returned IDYES. Similar thing when installing packages - I had to patch
the TOpenDialog.Execute() so that it didn't really open the dialog, but
simply filled in the FileName property.

Oh, and that whole library path manipulation thing I initially asked
about? It turned out modifying paths through the official interfaces
didn't persist the changes. So I had to go through the UI for this,
too.

All in all, it took me 2 months or so of work, and I still have some
quirks to iron out (e.g. all other expert's shortcut key overrides stop
working after I run the expert). But it works pretty well in the end,
and that's what matters to me. :)

I'm aware I'll have to redo some of the UI-dependent things for Delphi
2008, but that's ok, since my users won't be switching to that version
for some months after it becomes available, so there'll be plenty time.

I probably haven't made anyone reading this too happy, but I still hope
it was helpful in some way. :)
--
Regards,
Aleksander Oven
Continue reading on narkive:
Loading...