![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Object edit trigger Topic Summary: Created On: 18-May-2004 23:56 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I need to create a trigger that will open a pop up window when anybody edits an object that has a link. But it seems the object pre open trigger affects all attribute updates too. How can I prevent the trigger from firing when the user clicks in the attribute columns?
Thanks! Catherine |
|
![]() |
|
![]() |
|
Catherine-
Instead of creating a trigger that fires when an Object is edited, you can instead have the trigger fire only when a particular attribute is double-clicked. For example, your trigger definition may be rewritten to look something like this: Trigger t=trigger("modifyObjectText", module->attribute->"Object Text", pre, modify, 10, "#include <myTrigger>") In my experience, I believe that having a trigger call a dialog box will not function properly. In the cases that I have tried, it always seems to turn the object pink and call up the link/copy/move dialog. Please let the group know if your experiment works. -Dennis |
|
![]() |
|
![]() |
|
"modify" is "save". Pre-Save-Attr triggers fire when the user FINISHES editing the attribute; NOT when they double click on it (that would be an object-open trigger). The following commands inside your Trigger code will tell you which attribute/object is being edited:
Object oCurr = current; if (null oCurr) halt // ?Possible? Trigger tCurr = current; if (null tCurr) halt // ?Possible? AttrDef adCurr = attrdef(tCurr); if (null adCurr) halt //?Possible? string NameAttr = adCurr.name // get name of attr being modified Yes, the "attrdef(trig) command is incorrectly documented in the manual; but only works for attr-save triggers and does NOT work for object-open triggers. Don't forget that "pre" means you can cancel the save with the "set(trigPreConFail)" command. I've managed to have such a trigger "realize" a warning dialog box (without "showing") it, and after a few seconds the code "hides" the warning. Don't think the realize lets the user interact with the DB if that is your intention (such as Cancel or Confirm changes); but a regular "confirm" should work. - Louie |
|
![]() |
|
![]() |
|
BTW, pre-object-open triggers do NOT fire when you use the Object Properties box nor when you modify an attribute using DXL.
|
|
![]() |
|
![]() |
|
Thanks a lot, Dennis and Lauie! I got the pre save attribute trigger to work. I'm using a confirmation box to alert the user. I would like to reset the object text to what it was when the user chooses "No". How can I do that?
Thanks! Catherine |
|
![]() |
|
![]() |
|
Remember that "pre" triggers fire BEFORE the event and can cancel the event. In this case the event is saving the attribute value. If your trigger issues "set(trigPreConFail)" then the save does NOT occur. And that's the main purpose of "pre" triggers. Otherwise they'd all be "post" and there would be no need to specify "post".
if (!confirm("Are you DEAD sure you want to do this??")) set(trigPreConFail) - Louie |
|
![]() |
|
![]() |
|
Hi, Louie,
One more question. Is it possbile to make the trigger fire only for the first editted object in each module? Thanks! Catherine |
|
![]() |
|
![]() |
|
I suppose the Trigger could delete itself after it has run; but then you'd need another module-close trigger that reapplied the object-edit trigger. That looks messy.
The trigger itself, however, could check some flag to see if its run already once for this module and if it has do nothing. I've done something like this as follows: lets say your trigger name is "TrigWarnLinks". The trigger would get an Environment Variable called "TrigWarnLinks" (see "getenv" and "setenv"). If its value is the same and the base mod name plus the current "session" number then it would stop; otherwise it would set the variable with that value and proceed. You'll need a function: string GetEnvValue(Module mod) { string NameBase = name(mod) string Session = intOf(session()) "" return(NameBase "_" Session) } If you opened one module and activated the trigger; then activated it for some other module; then it would be active again for the first module. I'd practice with getenv and setenv in a test program before continuing. In DOORS v5 the "TrigWarnLinks" variable will appear in your DOORS.ini. In v6 and v7 its in the registry in the DOORS section. - Louie |
|
![]() |
|
![]() |
|
This sounds like a good solution. Thanks a lot, Louie!
Catherine |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Object edit trigger
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.