Link Here
|
49 |
import javax.swing.AbstractAction; |
49 |
import javax.swing.AbstractAction; |
50 |
import javax.swing.Action; |
50 |
import javax.swing.Action; |
51 |
import javax.swing.JMenu; |
51 |
import javax.swing.JMenu; |
|
|
52 |
import javax.swing.JPopupMenu; |
52 |
import javax.swing.JPopupMenu.Separator; |
53 |
import javax.swing.JPopupMenu.Separator; |
53 |
import javax.swing.SwingUtilities; |
54 |
import javax.swing.SwingUtilities; |
54 |
import org.openide.util.Exceptions; |
55 |
import org.openide.util.Exceptions; |
55 |
import org.openide.util.ImageUtilities; |
56 |
import org.openide.util.ImageUtilities; |
|
|
57 |
import org.openide.util.Lookup; |
56 |
import org.openide.util.NbBundle; |
58 |
import org.openide.util.NbBundle; |
57 |
|
59 |
|
58 |
/** |
60 |
/** |
Link Here
|
66 |
private final Object countersLock = new Object(); |
68 |
private final Object countersLock = new Object(); |
67 |
private final List<Action> actions = new ArrayList<Action>(); |
69 |
private final List<Action> actions = new ArrayList<Action>(); |
68 |
private int vcount = 0; |
70 |
private int vcount = 0; |
|
|
71 |
Lookup actionContext; |
72 |
boolean init; |
69 |
|
73 |
|
70 |
public DynamicMenu(String name) { |
74 |
public DynamicMenu(String name, Lookup actionContext) { |
71 |
super(name); |
75 |
super(name); |
|
|
76 |
this.actionContext = actionContext; |
72 |
add(validating); |
77 |
add(validating); |
73 |
} |
78 |
} |
74 |
|
79 |
|
Link Here
|
81 |
} |
86 |
} |
82 |
} |
87 |
} |
83 |
|
88 |
|
|
|
89 |
@Override |
90 |
public JPopupMenu getPopupMenu() { |
91 |
if (!init) { |
92 |
MenuConstructor.start(this, actionContext); |
93 |
init = true; |
94 |
} |
95 |
return super.getPopupMenu(); |
96 |
} |
97 |
|
84 |
private void refresh() { |
98 |
private void refresh() { |
85 |
try { |
99 |
try { |
86 |
SwingUtilities.invokeAndWait(new Runnable() { |
100 |
SwingUtilities.invokeAndWait(new Runnable() { |
Link Here
|
153 |
public void actionPerformed(ActionEvent e) { |
167 |
public void actionPerformed(ActionEvent e) { |
154 |
} |
168 |
} |
155 |
}; |
169 |
}; |
156 |
validating = |
170 |
validating |
157 |
new AbstractAction(NbBundle.getMessage(DynamicMenu.class, "ValidatingAction.text"), // NOI18N |
171 |
= new AbstractAction(NbBundle.getMessage(DynamicMenu.class, "ValidatingAction.text"), // NOI18N |
158 |
ImageUtilities.loadImageIcon("org/netbeans/modules/dlight/sendto/resources/wait.png", false)) { // NOI18N |
172 |
ImageUtilities.loadImageIcon("org/netbeans/modules/dlight/sendto/resources/wait.png", false)) { // NOI18N |
159 |
|
173 |
|
160 |
@Override |
174 |
@Override |
161 |
public void actionPerformed(ActionEvent e) { |
175 |
public void actionPerformed(ActionEvent e) { |
162 |
} |
176 |
} |
163 |
}; |
177 |
}; |
164 |
emptyAction.setEnabled(false); |
178 |
emptyAction.setEnabled(false); |
165 |
validating.setEnabled(false); |
179 |
validating.setEnabled(false); |
166 |
} |
180 |
} |