I'm using TextStyle and Styler to provide coloring in an SWT window I am creating.
I'm having a problem in my Styler method applyChanges(). The method (an abstract method built into Styler by the authors of SWT) takes a TextStyle object and applies formatting to it, for example, like this:
public void applyStyles(TextStyle textStyle) {
textStyle.background = new Color(null, new RGB(102, 0, 58));
//yada yada
}
However, instead of applying styles directly to it, I would like to assign an attribute that already carries all the styles. In other words, I am trying this:
public void applyStyles(TextStyle textStyle) {
textStyle= this.textStyleAttributeStyle;
}
Unfortunately, though this is not working and I believe it has something to do with passing the attribute by reference because when I copy the attributes one by one, for example like
public void applyStyles(TextStyle textStyle) {
textStyle.background= this.textStyleAttributeStyle.background;
}
it works great!
So my question is, how can I provide a complete clone/copy of every attribute in textStyleAttributeStyle and copy it to the corresponding attribute in textStyle in the shortest amount of code?