Revision 639 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/java/org/gvsig/scripting/swing/impl/composer/MenuBarHelper.java
MenuBarHelper.java | ||
---|---|---|
30 | 30 |
return this.menu; |
31 | 31 |
} |
32 | 32 |
|
33 |
public void add(String text) {
|
|
34 |
this.add(text, null, null); |
|
33 |
public JMenuItem add(String text) {
|
|
34 |
return this.add(text, null, null);
|
|
35 | 35 |
} |
36 | 36 |
|
37 |
public void add(String parent, Action action, Object context) {
|
|
37 |
public JMenuItem add(String parent, Action action, Object context) {
|
|
38 | 38 |
String[] sparent = parent.split("/"); |
39 | 39 |
JMenu entry; |
40 | 40 |
for( int i=0; i<this.menu.getMenuCount(); i++ ) { |
41 | 41 |
entry = this.menu.getMenu(i); |
42 | 42 |
if( entry.getText().equalsIgnoreCase(sparent[0]) ) { |
43 |
this.add(entry,sparent,1, action, context); |
|
44 |
return; |
|
43 |
return this.add(entry,sparent,1, action, context); |
|
45 | 44 |
} |
46 | 45 |
} |
47 | 46 |
entry = new JMenu(sparent[0]); |
48 | 47 |
this.menu.add(entry); |
49 |
this.add(entry, sparent, 1, action, context); |
|
48 |
return this.add(entry, sparent, 1, action, context);
|
|
50 | 49 |
} |
51 | 50 |
|
52 |
private void add(JMenu entry, String parent, Action action, Object context) {
|
|
51 |
private JMenuItem add(JMenu entry, String parent, Action action, Object context) {
|
|
53 | 52 |
String[] sparent = parent.split("/"); |
54 |
this.add(entry, sparent, 1, action, context); |
|
53 |
return this.add(entry, sparent, 1, action, context);
|
|
55 | 54 |
} |
56 | 55 |
|
57 |
private void add(JMenu menu, String parent[], int level, Action action, Object context) {
|
|
58 |
JMenuItem entry; |
|
56 |
private JMenuItem add(JMenu menu, String parent[], int level, Action action, Object context) {
|
|
57 |
JMenuItem entry = null;
|
|
59 | 58 |
if( parent.length == level ) { |
60 | 59 |
for( int i=0; i<menu.getItemCount(); i++ ) { |
61 | 60 |
entry = menu.getItem(i); |
... | ... | |
71 | 70 |
entry = new JMenuItemWithContext(action, context); |
72 | 71 |
menu.add(entry); |
73 | 72 |
} |
74 |
return; |
|
73 |
return entry;
|
|
75 | 74 |
} |
76 | 75 |
for( int i=0; i<menu.getItemCount(); i++ ) { |
77 | 76 |
entry = menu.getItem(i); |
78 | 77 |
if( entry instanceof JMenu && entry.getText().equalsIgnoreCase(parent[level]) ) { |
79 |
this.add((JMenu) entry,parent,level+1, action, context); |
|
80 |
return; |
|
78 |
entry = this.add((JMenu) entry,parent,level+1, action, context);
|
|
79 |
return entry;
|
|
81 | 80 |
} |
82 | 81 |
} |
83 | 82 |
if( "-".equals(parent[level]) ) { |
... | ... | |
85 | 84 |
} else { |
86 | 85 |
entry = new JMenu(parent[level]); |
87 | 86 |
menu.add(entry); |
88 |
this.add((JMenu) entry, parent, level+1, action, context); |
|
87 |
entry = this.add((JMenu) entry, parent, level+1, action, context);
|
|
89 | 88 |
} |
89 |
return entry; |
|
90 | 90 |
} |
91 | 91 |
|
92 | 92 |
public static class JMenuItemWithContext extends JMenuItem { |
Also available in: Unified diff