Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Object edit trigger
Topic Summary:
Created On: 18-May-2004 23:56
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 18-May-2004 23:56
User is offline View Users Profile Print this message


Catherine Yan

Posts: 43
Joined: 4-Aug-2003

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
Report this to a Moderator Report this to a Moderator
 19-May-2004 13:09
User is offline View Users Profile Print this message


Dennis Lockshine

Posts: 113
Joined: 7-Apr-2003

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
Report this to a Moderator Report this to a Moderator
 19-May-2004 16:29
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

"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
Report this to a Moderator Report this to a Moderator
 19-May-2004 16:32
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

BTW, pre-object-open triggers do NOT fire when you use the Object Properties box nor when you modify an attribute using DXL.
Report this to a Moderator Report this to a Moderator
 19-May-2004 22:33
User is offline View Users Profile Print this message


Catherine Yan

Posts: 43
Joined: 4-Aug-2003

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
Report this to a Moderator Report this to a Moderator
 19-May-2004 22:49
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
 25-May-2004 20:46
User is offline View Users Profile Print this message


Catherine Yan

Posts: 43
Joined: 4-Aug-2003

Hi, Louie,

One more question. Is it possbile to make the trigger fire only for the first editted object in each module?

Thanks!
Catherine
Report this to a Moderator Report this to a Moderator
 25-May-2004 22:56
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
 25-May-2004 23:04
User is offline View Users Profile Print this message


Catherine Yan

Posts: 43
Joined: 4-Aug-2003

This sounds like a good solution. Thanks a lot, Louie!
Catherine
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.