How to make a DOORS boolean attribute/column "False" if another attribute/column is not empty with DXL? - scripting

I have 2 attributes/columns. "A" and "B". A is as string of text. B is a boolean that can be True or False (when you edit it in DOORS, it's a drop down with 2 options T/F).
I want to use DXL to make B False if A is not empty.
Here's what I have so far, but I'm very new and unsure the syntax:
Object o
for o in current Module do{
if((o."A") == null)
{
o."B" = "False"
}
}
What I'm doing is I go into edit-mode on the DOORS module, click Edit -> Attributes -> "B" -> Edit... -> check DXL attribute -> Browse... -> New, write the code -> Ok, close all windows, Tools -> Refresh DXL Attributes. Correct?
When I Refresh, nothing happens, also when I clicked "check" after writing the code, there was no errors. Also when I go back the Edit -> Attributes and look back at the DXL for "B", I don't see my script there...

Try this dxl code
//Go to Edit -> Attributes, select 'B' attribute; select Edit and check the checkbox 'DXL attribute', click the 'Browse' button and paste the following code
//Press F5 to refresh DXL attributes
//Or 'Tool -> Refresh DXL attributes' to refresh DXL attributes
if((obj."A") == null)
{
obj.attrDXLName = "False"
}
else
{
obj.attrDXLName = "True"
}
Follow the below steps to see or edit the dxl code
Select the DXL attribute
Click Edit
Check the DXL Attribute box
Click Browse
Click Current

Related

How to Create a Custom Keyboard Shortcut in DOORS?

Its very time consuming to navigate through:
example:
X->Y->Z->A->B
Can we create a Custom Keyboard Shortcut for this in DOORS?
is this about following out-links?
If so, you could write a DXL script that opens the first out-linked module and navigates to the linked object. This script can be placed in a custom pull-down-menu. The script can be given a shortcut (accelerator key).
Script would look like this.
Object o = current
if (null o) error "no current object"
Link lnk
for lnk in o->"*" do {
ModName_ targetMod
targetMod = target lnk
Module mTgt = read(fullName(targetMod), true)
if (null mTgt) error "cannot open target module"
current = mTgt
Object oTgt = target lnk
current = oTgt
break
}
For information of how to build menus and accelerator keys, look in DXL manual, chapter "Rational DOORS window control"

How to bold every instance of a phrase in an attribute on doors with a DXL?

I have an attribute/column called "X" in a DOORS module. I want to bold the 3 phrases "America" and "Bahamas" and "Czech Republic" whenever they appear in this attribute.
BUT I also want to be able to manually edit the attribute whenever I want. Is this possible with a DXL attribute?
What I'm doing is I go into edit-mode on the DOORS module, click Edit -> Attributes -> "X" -> Edit... -> check DXL attribute -> Browse... -> New, write the code -> Ok, close all windows, Tools -> Refresh DXL Attributes. Correct?
Here's the general setup, idk the syntax:
Object o
for o in current Module do{
if((o."X") contains "America" or "Bahamas" or "Czech Republic")
{
font bold "America" or "Bahamas" or "Czech Republic"
}
}
Also, most cells will have all 3 phrases in it.

How can I get a click on a row in a table in Cuba framework?

I have to detect a click in a row in a table in Cuba framework but I don't find how.
I have a TreeTable. Then I have a button. If I have nothing selected in the table, I want the button disabled. If I click on a item I want the button to be enabled. If I click on a sub-item, I want the button to be disabled.
It is possible, in the action of the button to use a:
trackSelection = true
That will work, but enabled the button too if I click on a sub-item.
Then The idea is, when anything is clicked on the table, then do something. I have only to track the selection of any item, and then do a logic.
How can I track this selection?
I have tried anything like:
table.setClickListener("columnId", new CellClickListener() {
#Override
public void onClick(Entity item, String columnId) {
// TODO Auto-generated method stub
LOG.info("On cell click");
}
});
First, that don't work, even if I click on a cell. Then even if it will work, I have the complete row and not only a cell.
Somebody have an idea?
Thanks
Best regards
You can react on selection change in Table using CollectionDatasource.ItemChangeListener:
employeesDs.addItemChangeListener(event -> {
log.info("Datasource {} item has been changed from {} to {}",
event.getDs(), event.getPrevItem(), event.getItem());
});
See also: https://doc.cuba-platform.com/manual-6.9/datasource_listeners.html

How to check link is already clicked in java?

I am new to Selenium and also new to java coding.
Can you please tell me coding for already selected or active link of table and print data of table for already selected link then go to next link automatically?
I would recommend you the following approach.
Algorithm is simple:
1) if a link has certain color attributed -> then it is supposed to be not clicked yet
2) otherwise ( if color attribute differs) -> it has been clicked
So you should find selector of the link to analyze:
String cssLink ="blalbalbla";
then you find this element (link):
WebElement link1 = driver.findElement(By.cssSelector(cssLink));
then you get color attribute of it:
String colorExtracted= link1.getAttribute('color');
then you can analyze color obtained:
boolean result;
if(colorExtracted==clicked) {
result = true;
}
else {
result=false;
}
Hope this idea helps you.

Require a textbox to have value in FIllable PDF

I have a fillable PDF file. I would like to require that a TextBox has a value when the user saves the PDF document i.e. the value is not blank.
Here is what I tried:
(1) Setting the "Required" field on the "TextBox".
PROBLEM: That didn't do much except color the textbox red.
(2) I tried to use the following code in the "onBlur" event:
f = getField(event.target.name)
if (f.value.length == 0)
{
f.setFocus()
//Optional Message - Comment out the next line to remove
app.alert("This field is required. Please enter a value.")
}
PROBLEM: If the user never clicks this box there is no problem
(3) I tried to use the "Validation" tab and run a custom JavaScript.
PROBLEM: If you don't click on the box there is no validation so it is perfectly happy to leave the textbox blank if the user forgets to fill it in
OK, I am out of ideas... Anyone?
Since you are using Acrobat JavaScript I assume you use a viewer that supports and executes Acrobat JavaScript. In this situation you can set the document's WillSave action to a custom JavaScript action and perform validation here. I'm not sure if you can cancel the save operation but at least you can display an alert if the validation fails.
UPDATE: This script will loop through all the fields and display and alert if the field value is empty.
for ( var i = 0; i < this.numFields; i++) {
var fieldName = this.getNthFieldName(i);
var field = this.getField(fieldName);
if (field.value.length == 0)
{
field.setFocus()
app.alert("Field " + fieldName + " is required. Please enter a value.")
}
}
Put the script in document's Will Save action and it will run every time the user saves the form. In Acrobat you set this in Tools > JavaScript > Set Document Actions and select Document Will Save.