Pinned topic Problem using Copy Views 3.1.1


I am looking to either update the script to fix this or another script that I can use to set the Text Color of the column to be based on the Requirement attribute.
Any help is greatly appreciated!
Robert Allen
Goodrich - Sensors and Integrated Systems
Burnsville, MN
Attachments
-
Re: Problem using Copy Views 3.1.1
2011-04-08T13:07:31ZThis is the accepted answer. This is the accepted answer.
Add the following after line 200
string colourAttr = color(srcCol) ad = find(toMod, colourAttr) if (!null ad) { color(destCol, colourAttr) }
Tony Goodman
www.smartdxl.comUpdated on 2014-01-02T18:47:51Z at 2014-01-02T18:47:51Z by iron-man -
Re: Problem using Copy Views 3.1.1
2011-04-08T13:35:00ZThis is the accepted answer. This is the accepted answer.
- Tony_Goodman
- 2011-04-08T13:07:31Z
Add the following after line 200
<pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">string colourAttr = color(srcCol) ad = find(toMod, colourAttr) if (!null ad) { color(destCol, colourAttr) } </pre>
Tony Goodman
www.smartdxl.comHi Tony,
thanks for your help.
However when I add your lines after 200 this causes an error when no color is used on a column. So I added an additional statement.
string colourAttr = color(srcCol); if(!null(colourAttr)) { ad = find(toMod, colourAttr) if (!null ad) { color(destCol, colourAttr) } }
Now it works with no error at least, but it still does not copy the colors.
Best Regards,
AlexanderUpdated on 2014-01-02T18:48:35Z at 2014-01-02T18:48:35Z by iron-man -
Re: Problem using Copy Views 3.1.1
2011-04-08T15:06:10ZThis is the accepted answer. This is the accepted answer.
- Tony_Goodman
- 2011-04-08T13:07:31Z
Add the following after line 200
<pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">string colourAttr = color(srcCol) ad = find(toMod, colourAttr) if (!null ad) { color(destCol, colourAttr) } </pre>
Tony Goodman
www.smartdxl.com
Thanks a bunch for the reply. Alexander82 is right, though, in that the addition causes an error for columns that do not have a color. I added the code that he suggested, and I got the same result. It runs without errors, but the colors are not updated either.
Rob -
Re: Problem using Copy Views 3.1.1
2011-04-08T16:55:42ZThis is the accepted answer. This is the accepted answer.
- rallen
- 2011-04-08T15:06:10Z
Tony,
Thanks a bunch for the reply. Alexander82 is right, though, in that the addition causes an error for columns that do not have a color. I added the code that he suggested, and I got the same result. It runs without errors, but the colors are not updated either.
Rob
color( destCol, colourAttr )
does set the color, but when I do this:
colourAttr = color(destCol)
print("Column Color is " colourAttr " \n");
I see this in the DXL Output window: Column Color is Requirement
The color for the source column is using the "By Attribute" selection, but the destination still has default selected. How do I select the "By Attribute" color option?
Thanks,
Rob -
Re: Problem using Copy Views 3.1.1
2011-04-08T17:23:10ZThis is the accepted answer. This is the accepted answer.
- rallen
- 2011-04-08T16:55:42Z
I added some print statements to see what was going on, and I did find that the statement:
color( destCol, colourAttr )
does set the color, but when I do this:
colourAttr = color(destCol)
print("Column Color is " colourAttr " \n");
I see this in the DXL Output window: Column Color is Requirement
The color for the source column is using the "By Attribute" selection, but the destination still has default selected. How do I select the "By Attribute" color option?
Thanks,
Rob
int iCol = getSelectedCol(current Module)
Column col = column(current Module, iCol)
if (confirm("Set Color?")) //
then color(col, "z_GrayColumnText") // set to that attr
else color(col, "") // set to default
So you can set or reset color-by-attribute using "color(col, NameAttr)"
- Louie
-
Re: Problem using Copy Views 3.1.1
2011-04-11T14:30:44ZThis is the accepted answer. This is the accepted answer.
- llandale
- 2011-04-08T17:23:10Z
This works:
int iCol = getSelectedCol(current Module)
Column col = column(current Module, iCol)
if (confirm("Set Color?")) //
then color(col, "z_GrayColumnText") // set to that attr
else color(col, "") // set to default
So you can set or reset color-by-attribute using "color(col, NameAttr)"
- Louie
I'll give that a try.
Robert Allen
Principal Software Engineer
Goodrich Sensors and Integrated Systems -
Re: Problem using Copy Views 3.1.1
2011-04-13T15:45:36ZThis is the accepted answer. This is the accepted answer.
- llandale
- 2011-04-08T17:23:10Z
This works:
int iCol = getSelectedCol(current Module)
Column col = column(current Module, iCol)
if (confirm("Set Color?")) //
then color(col, "z_GrayColumnText") // set to that attr
else color(col, "") // set to default
So you can set or reset color-by-attribute using "color(col, NameAttr)"
- Louie
I have some questions about the code snippet you posted. I'm a complete DXL newbie, and I was unable to find answers anywhere else.
int iCol = getSelectedCol(current Module) - if I'm running a DXL script, is there a seleted column?
Column col = column(current Module, iCol)
if (confirm("Set Color?")) // - does this correspond to the "Edit Column" dialog box radio button under "Text Color"?
then color(col, "z_GrayColumnText") // set to that attr - The CopyViews DXL script does set the color to the attribute, but it doesn't take effect. I am pretty sure it's because the "Text Color" property of the column is not set correctly. I don't see any code in your snippet that would set that.
else color(col, "") // set to default -
Re: Problem using Copy Views 3.1.1
2011-04-13T19:52:25ZThis is the accepted answer. This is the accepted answer.
- rallen
- 2011-04-13T15:45:36Z
Louie,
I have some questions about the code snippet you posted. I'm a complete DXL newbie, and I was unable to find answers anywhere else.
int iCol = getSelectedCol(current Module) - if I'm running a DXL script, is there a seleted column?
Column col = column(current Module, iCol)
if (confirm("Set Color?")) // - does this correspond to the "Edit Column" dialog box radio button under "Text Color"?
then color(col, "z_GrayColumnText") // set to that attr - The CopyViews DXL script does set the color to the attribute, but it doesn't take effect. I am pretty sure it's because the "Text Color" property of the column is not set correctly. I don't see any code in your snippet that would set that.
else color(col, "") // set to defaultThe code as written is intended as a simple on-demand script. The user selects the column, runs the script, and it sets that column's color to the specified attribute. The user would then save the view. Yes, there should be an error check for when iCol < 0 suggesting there is no selected column. I see that a selected column turns the title bar of that column grey. The example I gave assumes that attribute "z_GrayColumnText" exists in the module and contains some colorable values, which means it must be an enumerated attribute whose individual type values have a color assigned to them.
If you are writing a script to perhaps set a specific column to a color for all views in the module, then it would have to load the view, find the right column (perhaps it has a standard Title), set the color, then re-save the view.
My version of CopyViews.dxl loops through the columns of the current view, in which case you won't need the 'selectedColumn' stuff, you already have the Column handle.
for srcCol in srcMod do {
When I run the script on a selected column it turns it gray. When I then check the column Properties, the "Text Color" part is indeed "By attribute" showing the attribute. I wonder if perhaps that attribute does not exist in your module; in which case the script will not work. Understand that reference is to the Attribute DEFINITION, not the Attribute TYPE. I see that in order to find out if the "color" command worked, you must trap the error with noError()/lastError().
Here's updated snippette with suitable error checking:int iCol = getSelectedCol(current Module) if (iCol < 0) { warningBox("Select a column") } else { Column col = column(current Module, iCol) string ErrMess if (confirm("Set Color?")) // then { noError() color(col, "z_GrayColumnXXText") // set to that attr - ErrMess = lastError() if (!null ErrMess) ack (ErrMess) } }
- Louie
>>> Now in my particular case, my attribute type "z_GrayColumnText" is enumerated with only one value "Gray" that has color Gray33 associated with it. There is also a attribute Definition "z_GrayColumnText" that uses that type, and has default value "Gray". I have numerous Attr-DXL in these modules that display various information, and when I display the Attr-DXL in a column, I use this script to turn ALL the text gray, so the user knows not to try to edit the value.
Perhaps a more realistic use is to have "Severity" attribute with values "Critical" associated with Red; "Medium" associated with Yellow, and "Not", which isn't associated with a color. Perhaps associate Object Text column with the color of Severity.- Louie
>>> Now in my particular case, my attribute type "z_GrayColumnText" is enumerated with only one value "Gray" that has color Gray33 associated with it. There is also a attribute Definition "z_GrayColumnText" that uses that type, and has default value "Gray". I have numerous Attr-DXL in these modules that display various information, and when I display the Attr-DXL in a column, I use this script to turn ALL the text gray, so the user knows not to try to edit the value.
Perhaps a more realistic use is to have "Severity" attribute with values "Critical" associated with Red; "Medium" associated with Yellow, and "Not", which isn't associated with a color. Perhaps associate Object Text column with the color of Severity.Updated on 2014-01-02T18:49:25Z at 2014-01-02T18:49:25Z by iron-man -
Re: Problem using Copy Views 3.1.1
2011-04-18T22:32:00ZThis is the accepted answer. This is the accepted answer.
- llandale
- 2011-04-13T19:52:25Z
The code as written is intended as a simple on-demand script. The user selects the column, runs the script, and it sets that column's color to the specified attribute. The user would then save the view. Yes, there should be an error check for when iCol < 0 suggesting there is no selected column. I see that a selected column turns the title bar of that column grey. The example I gave assumes that attribute "z_GrayColumnText" exists in the module and contains some colorable values, which means it must be an enumerated attribute whose individual type values have a color assigned to them.
<pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">int iCol = getSelectedCol(current Module) if (iCol < 0) { warningBox("Select a column") } else { Column col = column(current Module, iCol) string ErrMess if (confirm("Set Color?")) // then { noError() color(col, "z_GrayColumnXXText") // set to that attr - ErrMess = lastError() if (!null ErrMess) ack (ErrMess) } } </pre>
If you are writing a script to perhaps set a specific column to a color for all views in the module, then it would have to load the view, find the right column (perhaps it has a standard Title), set the color, then re-save the view.
My version of CopyViews.dxl loops through the columns of the current view, in which case you won't need the 'selectedColumn' stuff, you already have the Column handle.
for srcCol in srcMod do {
When I run the script on a selected column it turns it gray. When I then check the column Properties, the "Text Color" part is indeed "By attribute" showing the attribute. I wonder if perhaps that attribute does not exist in your module; in which case the script will not work. Understand that reference is to the Attribute DEFINITION, not the Attribute TYPE. I see that in order to find out if the "color" command worked, you must trap the error with noError()/lastError().
Here's updated snippette with suitable error checking:- Louie
>>> Now in my particular case, my attribute type "z_GrayColumnText" is enumerated with only one value "Gray" that has color Gray33 associated with it. There is also a attribute Definition "z_GrayColumnText" that uses that type, and has default value "Gray". I have numerous Attr-DXL in these modules that display various information, and when I display the Attr-DXL in a column, I use this script to turn ALL the text gray, so the user knows not to try to edit the value.
Perhaps a more realistic use is to have "Severity" attribute with values "Critical" associated with Red; "Medium" associated with Yellow, and "Not", which isn't associated with a color. Perhaps associate Object Text column with the color of Severity.
Thanks for your help. I was able to use your snippet to change the color based on another attribute. After that, I went back to the modifications suggested in a previous post, and they looked very similar. I decided to instrument what was there with print statements to see what was happening.
if(!null(colourAttr))
{
ad = find(toMod, colourAttr)
if (!null ad)
{
color(destCol, colourAttr)
}
}
I found that it was never getting to the color(destCol, colourAttr) statement, which was similar to your statement:
color(col, "z_GrayColumnXXText") // set to that attr -
I was able to remove the if(!null ad) and get the color to change as I was hoping!
Here are the lines that I added to the original script starting at line 202:
// Copy the column color, if it exists
string colourAttr = color(srcCol)
if( !null colourAttr )
{
color( destCol, colourAttr )
}
Thanks everyone for the help!
Robert Allen
Principal Software Engineer
Goodrich Corp, SIS-MN -
Re: Problem using Copy Views 3.1.1
2011-12-29T20:35:27ZThis is the accepted answer. This is the accepted answer.
- rallen
- 2011-04-18T22:32:00Z
Louie,
Thanks for your help. I was able to use your snippet to change the color based on another attribute. After that, I went back to the modifications suggested in a previous post, and they looked very similar. I decided to instrument what was there with print statements to see what was happening.
if(!null(colourAttr))
{
ad = find(toMod, colourAttr)
if (!null ad)
{
color(destCol, colourAttr)
}
}
I found that it was never getting to the color(destCol, colourAttr) statement, which was similar to your statement:
color(col, "z_GrayColumnXXText") // set to that attr -
I was able to remove the if(!null ad) and get the color to change as I was hoping!
Here are the lines that I added to the original script starting at line 202:
// Copy the column color, if it exists
string colourAttr = color(srcCol)
if( !null colourAttr )
{
color( destCol, colourAttr )
}
Thanks everyone for the help!
Robert Allen
Principal Software Engineer
Goodrich Corp, SIS-MN
Thanks,
Ken. -
Re: Problem using Copy Views 3.1.1
2012-05-16T07:52:20ZThis is the accepted answer. This is the accepted answer.
I am trying to do set the color of all columns in a view based on the color of a specific attribute. Using the sample code found on these posts I have managed to do this, partially. I said partially because looking at each column's properties I can see that the 'By Attribute' combo in the 'Text Color' frame is set to the attribute I want, but the radioBox is unfortunatelly set to 'Default' instead of being set to 'By Attribute'. Any suggestions on how could I also change the value of the radioBox ? Thanks in advance -
Re: Problem using Copy Views 3.1.1
2012-05-16T15:51:38ZThis is the accepted answer. This is the accepted answer.
- Mogg
- 2012-05-16T07:52:20Z
I am trying to do set the color of all columns in a view based on the color of a specific attribute. Using the sample code found on these posts I have managed to do this, partially. I said partially because looking at each column's properties I can see that the 'By Attribute' combo in the 'Text Color' frame is set to the attribute I want, but the radioBox is unfortunatelly set to 'Default' instead of being set to 'By Attribute'. Any suggestions on how could I also change the value of the radioBox ? Thanks in advance
-Louie -
Re: Problem using Copy Views 3.1.1
2012-07-18T13:39:37ZThis is the accepted answer. This is the accepted answer.
- mcnairk
- 2011-12-29T20:35:27Z
I tried adding the suggested code, but couldn't get it to work (although I got no errors). Can you please post the updated copyviews script?
Thanks,
Ken.
https://www.ibm.com/developerworks/wikis/display/dxl/Copy+views+accross+modules -
Re: Problem using Copy Views 3.1.1
2014-03-04T15:32:32ZThis is the accepted answer. This is the accepted answer.
- llandale
- 2012-05-16T15:51:38Z
The attribute that determines the color must be enumerated, and it's type must ..err.. should have colors defined for it's enumerated values. In the Edit Type dialog Enumerations tab, you should select an enumeration, then under "Use color" select "Specified", and then the color you want. Then Replace> the enumeration.
-LouieDoes anyone has the copyView script where it is possible to make a multiple selection of the target modules? I remember i had, but i can't find it anymore.
In the 3.1 you need to add one by one every taget module
-
Re: Problem using Copy Views 3.1.1
2015-04-16T21:02:20ZThis is the accepted answer. This is the accepted answer.
- bungle_77
- 2014-03-04T15:32:32Z
Does anyone has the copyView script where it is possible to make a multiple selection of the target modules? I remember i had, but i can't find it anymore.
In the 3.1 you need to add one by one every taget module
Did you find the script that copies views and attributes to multiple modules? Can you post it?
Anita