2727import org .eclipse .help .internal .UAElement ;
2828import org .w3c .dom .Document ;
2929import org .w3c .dom .Element ;
30+ import org .w3c .dom .NamedNodeMap ;
3031import org .w3c .dom .Node ;
3132
3233public class Context extends UAElement implements IContext3 {
@@ -53,27 +54,37 @@ public void mergeContext(IContext src) {
5354 if (getText () == null || getText ().length () == 0 ) {
5455 setText (text );
5556 }
56- if (src instanceof IContext2 && getTitle () == null ) {
57- String title = (( IContext2 ) src ) .getTitle ();
57+ if (src instanceof IContext2 icontext2 && getTitle () == null ) {
58+ String title = icontext2 .getTitle ();
5859 if (title != null ) {
5960 setAttribute (ATTRIBUTE_TITLE , title );
6061 }
6162 }
62- if (src instanceof IContext3 ) {
63- ICommandLink [] commands = (( IContext3 ) src ) .getRelatedCommands ();
64- for (int i = 0 ; i < commands . length ;++ i ) {
65- appendChild (new CommandLink (commands [ i ] ));
63+ if (src instanceof IContext3 icontext3 ) {
64+ ICommandLink [] commands = icontext3 .getRelatedCommands ();
65+ for (ICommandLink command : commands ) {
66+ appendChild (new CommandLink (command ));
6667 }
6768 }
68- IHelpResource [] topics = src .getRelatedTopics ();
69- for (int i =0 ;i <topics .length ;++i ) {
70- if (topics [i ] instanceof ITopic ) {
71- appendChild (new Topic ((ITopic )topics [i ]));
69+ if (src instanceof UAElement uaelement ) {
70+ NamedNodeMap attributes = uaelement .getElement ().getAttributes ();
71+ for (int i = 0 ; i < attributes .getLength (); i ++) {
72+ Node attribute = attributes .item (i );
73+ String attributeName = attribute .getNodeName ();
74+ String attributeValue = attribute .getNodeValue ();
75+ if (getAttribute (attributeName ) == null ) {
76+ setAttribute (attributeName , attributeValue );
77+ }
7278 }
73- else {
79+ }
80+ IHelpResource [] relatedTopics = src .getRelatedTopics ();
81+ for (IHelpResource relatedTopic : relatedTopics ) {
82+ if (relatedTopic instanceof ITopic ) {
83+ appendChild (new Topic ((ITopic ) relatedTopic ));
84+ } else {
7485 Topic topic = new Topic ();
75- topic .setHref (topics [ i ] .getHref ());
76- topic .setLabel (topics [ i ] .getLabel ());
86+ topic .setHref (relatedTopic .getHref ());
87+ topic .setLabel (relatedTopic .getLabel ());
7788 appendChild (topic );
7889 }
7990 }
0 commit comments