Lines 40-48
Link Here
|
40 |
import org.openide.util.Lookup; |
40 |
import org.openide.util.Lookup; |
41 |
import org.openide.util.NbBundle; |
41 |
import org.openide.util.NbBundle; |
42 |
import org.openide.util.Utilities; |
42 |
import org.openide.util.Utilities; |
43 |
|
|
|
44 |
import java.lang.ref.WeakReference; |
43 |
import java.lang.ref.WeakReference; |
45 |
import java.util.ArrayList; |
44 |
import java.util.ArrayList; |
|
|
45 |
import java.util.Collection; |
46 |
import java.util.Hashtable; |
46 |
import java.util.Hashtable; |
47 |
import java.util.Iterator; |
47 |
import java.util.Iterator; |
48 |
import java.util.Map; |
48 |
import java.util.Map; |
Lines 52-58
Link Here
|
52 |
import javax.swing.AbstractButton; |
52 |
import javax.swing.AbstractButton; |
53 |
import javax.swing.Action; |
53 |
import javax.swing.Action; |
54 |
import javax.swing.Icon; |
54 |
import javax.swing.Icon; |
55 |
|
|
|
56 |
import javax.swing.ImageIcon; |
55 |
import javax.swing.ImageIcon; |
57 |
import javax.swing.JCheckBoxMenuItem; |
56 |
import javax.swing.JCheckBoxMenuItem; |
58 |
import javax.swing.JComponent; |
57 |
import javax.swing.JComponent; |
Lines 143-154
Link Here
|
143 |
} |
142 |
} |
144 |
|
143 |
|
145 |
/** Attaches menu item to an action. |
144 |
/** Attaches menu item to an action. |
|
|
145 |
* You can supply an alternative implementation |
146 |
* for this method by implementing method |
147 |
* {@link ButtonActionConnector#connect(JMenuItem, Action, boolean)} and |
148 |
* registering an instance of {@link ButtonActionConnector} in the |
149 |
* default lookup. |
146 |
* @param item menu item |
150 |
* @param item menu item |
147 |
* @param action action |
151 |
* @param action action |
148 |
* @param popup create popup or menu item |
152 |
* @param popup create popup or menu item |
149 |
* @since 3.29 |
153 |
* @since 3.29 |
150 |
*/ |
154 |
*/ |
151 |
public static void connect(JMenuItem item, Action action, boolean popup) { |
155 |
public static void connect(JMenuItem item, Action action, boolean popup) { |
|
|
156 |
for (ButtonActionConnector bac : Lookup.getDefault().lookupAll(ButtonActionConnector.class)) { |
157 |
if (bac.connect(item, action, popup)) { |
158 |
return; |
159 |
} |
160 |
} |
152 |
Bridge b = new MenuBridge(item, action, popup); |
161 |
Bridge b = new MenuBridge(item, action, popup); |
153 |
|
162 |
|
154 |
if (item instanceof Actions.MenuItem) { |
163 |
if (item instanceof Actions.MenuItem) { |
Lines 246-256
Link Here
|
246 |
* "com/mycompany/myIcon_rollover.gif" for setRolloverIcon. SystemAction has |
255 |
* "com/mycompany/myIcon_rollover.gif" for setRolloverIcon. SystemAction has |
247 |
* special support for iconBase - please check {@link SystemAction#iconResource} |
256 |
* special support for iconBase - please check {@link SystemAction#iconResource} |
248 |
* for more details. |
257 |
* for more details. |
|
|
258 |
* You can supply an alternative implementation |
259 |
* for this method by implementing method |
260 |
* {@link ButtonActionConnector#connect(AbstractButton, Action)} and |
261 |
* registering an instance of {@link ButtonActionConnector} in the |
262 |
* default lookup. |
249 |
* @param button the button |
263 |
* @param button the button |
250 |
* @param action the action |
264 |
* @param action the action |
251 |
* @since 3.29 |
265 |
* @since 3.29 |
252 |
*/ |
266 |
*/ |
253 |
public static void connect(AbstractButton button, Action action) { |
267 |
public static void connect(AbstractButton button, Action action) { |
|
|
268 |
for (ButtonActionConnector bac : Lookup.getDefault().lookupAll(ButtonActionConnector.class)) { |
269 |
if (bac.connect(button, action)) { |
270 |
return; |
271 |
} |
272 |
} |
254 |
Bridge b = new ButtonBridge(button, action); |
273 |
Bridge b = new ButtonBridge(button, action); |
255 |
b.updateState(null); |
274 |
b.updateState(null); |
256 |
} |
275 |
} |
Lines 1301-1306
Link Here
|
1301 |
|
1320 |
|
1302 |
} |
1321 |
} |
1303 |
|
1322 |
|
|
|
1323 |
/** |
1324 |
* SPI for being able to supply alternative implementation of |
1325 |
* connection between actions and the presenters. The implementations |
1326 |
* of this interface are being looked up in the default lookup. |
1327 |
* If there is no implemenation in the lookup the default implementation |
1328 |
* is used. |
1329 |
* @see org.openide.util.Lookup#getDefault() |
1330 |
*/ |
1331 |
public static interface ButtonActionConnector { |
1332 |
/** |
1333 |
* Connects the action to the supplied button. |
1334 |
* @return true if the connection was successful and no |
1335 |
* further actions are needed. If false is returned the |
1336 |
* default connect implementation is called |
1337 |
*/ |
1338 |
public boolean connect(AbstractButton button, Action action); |
1339 |
/** |
1340 |
* Connects the action to the supplied JMenuItem. |
1341 |
* @return true if the connection was successful and no |
1342 |
* further actions are needed. If false is returned the |
1343 |
* default connect implementation is called |
1344 |
*/ |
1345 |
public boolean connect(JMenuItem item, Action action, boolean popup); |
1346 |
} |
1304 |
|
1347 |
|
1305 |
private static class DisabledButtonFilter extends RGBImageFilter { |
1348 |
private static class DisabledButtonFilter extends RGBImageFilter { |
1306 |
DisabledButtonFilter() { |
1349 |
DisabledButtonFilter() { |