| Newsgroups |
gmane.comp.java.netbeans.modules.openide.devel |
| Message-ID |
<[email protected]> |
--Apple-Mail=_33CB9C12-B3EE-4564-B13E-11CD8E8436E9
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
I would probably not use NodeAction, probably there=E2=80=99s a better =
way of doing the below =E2=80=94 definitely get this book: =
https://leanpub.com/nbp4beginners
If you want to work with a menu item, probably you can add an =
AcrtionListener to it but, again, this approach below with NodeAction is =
probably in most cases not the right approach.
I recommend getting the book referenced above.
Geertjan Wielenga | Principal Product Manager
Phone: +31620320056 |=20
Oracle Developer Tools
ORACLE Netherlands | Hertogswetering 163-167 | 3543 AS Utrecht | =
Netherlands
Oracle is committed to developing practices and products that help =
protect the environment
> On 12 Sep 2017, at 09:59, bjarven <[email protected]> wrote:
>=20
> Hi, I'm wondering if there's any other way of doing this other than =
the deprecated method NodeAction.performAction().=20
>=20
> I have a class that extends NodeAction, and it has a popup presenter. =
To get the data from the selected menu item i use performAction. But =
it's deprecated, so I guess there's another better way of doing this... =
Any recommendations?=20
>=20
>=20
> Code:
>=20
> public class MyAction extends NodeAction{
>=20
> @Override
> public JMenuItem getPopupPresenter() {
> JMenu menu =3D new JMenu();
> menu.setText("My menu");
> for (int i =3D 0; i < myItems.length; i++) {
> ExtendedMenuItem item =3D new ExtendedMenuItem(key);
> item.setText(key);
> item.addActionListener(this);
> menu.add(item);
> }
> return menu;
> }
>=20
> @Override
> public void actionPerformed(ActionEvent e) {
> // need actionPerfomed to get information about the menu items!
> if (e.getSource() instanceof ExtendedMenuItem) {
> ExtendedMenuItem eItem =3D (ExtendedMenuItem) =
e.getSource();
> for (Node node : getActivatedNodes()) {
> // do something with the selected nodes depending on =
the menu choice
> }
> }
> }
>=20
> @Override
> protected void performAction(Node[] arg0) {
> // won't get any information about the menu here...
>=20
> }
> }
>=20
>=20
>=20
>=20
>=20
>=20
>=20
--Apple-Mail=_33CB9C12-B3EE-4564-B13E-11CD8E8436E9
Content-Type: multipart/related;
type="text/html";
boundary="Apple-Mail=_B33E9E81-EF28-4BD5-897E-4EF64E89F5E9"
--Apple-Mail=_B33E9E81-EF28-4BD5-897E-4EF64E89F5E9
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=utf-8
<html><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space;"><div class=3D""><br =
class=3D""></div><div class=3D"">I would probably not use NodeAction, =
probably there=E2=80=99s a better way of doing the below =E2=80=94 =
definitely get this book: <a =
href=3D"https://leanpub.com/nbp4beginners" =
class=3D"">https://leanpub.com/nbp4beginners</a></div><div class=3D""><br =
class=3D""></div><div class=3D"">If you want to work with a menu item, =
probably you can add an AcrtionListener to it but, again, this approach =
below with NodeAction is probably in most cases not the right =
approach.</div><div class=3D""><br class=3D""></div><div class=3D"">I =
recommend getting the book referenced above.</div><div class=3D""><br =
class=3D""></div><br class=3D""><div class=3D""><span><img =
apple-inline=3D"yes" id=3D"5EFCBA06-9C1C-4AAC-936B-A4E275A984B2" =
src=3D"cid:[email protected]" class=3D""></span><br =
class=3D"">Geertjan Wielenga | Principal Product Manager<br =
class=3D"">Phone: +31620320056 | <br =
class=3D"">Oracle Developer Tools<br class=3D""><br class=3D"">ORACLE=
Netherlands | Hertogswetering 163-167 | 3543 AS Utrecht =
| Netherlands<br class=3D""><span><img apple-inline=3D"yes" =
id=3D"805F908E-5BD7-478A-8E8E-DE8183F73B16" =
src=3D"cid:[email protected]" class=3D""></span><br =
class=3D""><br class=3D"">Oracle is committed to developing practices =
and products that help protect the environment<br class=3D""></div><br =
class=3D""><blockquote type=3D"cite" class=3D"">On 12 Sep 2017, at =
09:59, bjarven <<a href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a>> wrote:<br class=3D""><br =
class=3D"">Hi, I'm wondering if there's any other way of doing this =
other than the deprecated method NodeAction.performAction(). <br =
class=3D""><br class=3D"">I have a class that extends NodeAction, and it =
has a popup presenter. To get the data from the selected menu item i use =
performAction. But it's deprecated, so I guess there's another =
better way of doing this... Any recommendations? <br class=3D""><br =
class=3D""><br class=3D"">Code:<br class=3D""><br class=3D"">public =
class MyAction extends NodeAction{<br class=3D""><br class=3D""> =
@Override<br class=3D""> public JMenuItem =
getPopupPresenter() {<br class=3D""> JMenu =
menu =3D new JMenu();<br class=3D""> =
menu.setText("My menu");<br class=3D""> =
for (int i =3D 0; i < myItems.length; i++) {<br class=3D""> =
ExtendedMenuItem item =3D new =
ExtendedMenuItem(key);<br class=3D""> =
item.setText(key);<br class=3D""> =
item.addActionListener(this);<br class=3D""> =
menu.add(item);<br class=3D""> =
}<br class=3D""> return menu;<br =
class=3D""> }<br class=3D""><br class=3D""> =
@Override<br class=3D""> public void =
actionPerformed(ActionEvent e) {<br class=3D""> =
// need actionPerfomed to get information about the menu items!<br =
class=3D""> if (e.getSource() instanceof =
ExtendedMenuItem) {<br class=3D""> =
ExtendedMenuItem eItem =3D (ExtendedMenuItem) e.getSource();<br =
class=3D""> for (Node node : =
getActivatedNodes()) {<br class=3D""> =
// do something with the selected nodes depending on =
the menu choice<br class=3D""> =
}<br class=3D""> }<br class=3D""> =
}<br class=3D""><br class=3D""> @Override<br =
class=3D""> protected void performAction(Node[] arg0) {<br =
class=3D""> // won't get any information about =
the menu here...<br class=3D""><br class=3D""> }<br =
class=3D"">}<br class=3D""><br class=3D""><br class=3D""><br =
class=3D""><br class=3D""><br class=3D""><br class=3D""><br =
class=3D""></blockquote><br class=3D""></body></html>=
--Apple-Mail=_B33E9E81-EF28-4BD5-897E-4EF64E89F5E9
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="Mail Attachment.gif"
Content-Type: image/gif;
x-unix-mode=0666;
name="Mail Attachment.gif"
Content-Id: <[email protected]>
R0lGODlhcgAaAMQAAP8QEP/w8P/Q0P/g4P8wMP9gYP8gIP+goP9QUP+QkP+wsP9wcP+AgP9AQP/A
wP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAA
AAAALAAAAAByABoAAAX/ICSOZGmeaKqubOu+cCzPdC0GCqPvvBKUDp5wp1gFdIPVIDfcOQa6A8yR
aO4gweQoUHh4v2Bw4SdihM9egyBF8ALIpkEXDR44vA2XwkD/IgYGAAZbbX1nBGRmhl8AWiUJYicC
AIsPDFh4LXOGjQ4NAAhrEIUPBQcOqKmoB5sEZV4JqqoHhQVxlGAOJQG4AAunsqg/dw95KwdfBgzB
qKIEBMaQDwCiKpOwEIq6KANuJg14igZwEHPULMTGKbxetjF8D1ItxK7aKl8lCl8DAfALW1+2rUi3
QtqgGN2mwYCXzYvAON624LoEQZ9DEfRcEFSBIE2DjyBDfnyIqRgMcA8a/z5AZQWXOxEdHxwUgfIg
sX/zMqlAWclVCQFefLpAqdJBAFJn3owgtpJEQkslEWjUmYLnomokcDlS4s0eFzQNqvXDEyzmAwFP
yaXYmGJBuxlzELWIacueiE0AFGyF4HbaNTquUEpFRxUFUC9YXQzARYAkEJSNipKQ9kDu0i9SKKNZ
9iXswMIoYgI4oJYFskpgzkkmcdrviELqmPVt1HpRAaaLqCE1lBgjvEpqRtgl8Tevygd7TcCuiKvP
m8OVEkAIYLYPThSsRIpEQJr1x94QBIT09FH6QJC6AiRAoB1kEb7tRb4MvyB+AwSlbejfz7+///8A
BijggAQWaOCBCCao4A+CDDbo4IMQRijhhBQKGAIAOw==
--Apple-Mail=_B33E9E81-EF28-4BD5-897E-4EF64E89F5E9
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="Mail Attachment.gif"
Content-Type: image/gif;
x-unix-mode=0666;
name="Mail Attachment.gif"
Content-Id: <[email protected]>
R0lGODlhLAAcAMQAAP///0x9RHmec9Pf0aa+oleFULHGrmKNW+nv6I+uivT39N7n3W6VZ7zPuZu2
lsjXxYSmfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAA
AAAALAAAAAAsABwAQAXhICCOZGmeaDoaReC+sKAMR7GopIA6boIvLgPAVSAgALxjSYdrOp/Q6NPg
YqIEPkTBV2taTwgGbEw+PAZo3FfKbqMQQfeJ8DoY0Hg0wxhAKBgHCl5XLgMqDwFCAAIFPIYDgidr
OUQGkSh0cQMJAQyXOXKhoqOkpaanI2aoIwMErq+uCY0BMlANKpxkYwQGBH82TpMicD0pAgQACToD
AchqhAG3KQ4HIlQNnErG0IYqB9EAiEQvwEsozC43hy0CAeXMwsLDLS8MAvf497ruCZ+gOA0gfNt3
AIK0J/JWKVzIsEQIADs=
--Apple-Mail=_B33E9E81-EF28-4BD5-897E-4EF64E89F5E9--
--Apple-Mail=_33CB9C12-B3EE-4564-B13E-11CD8E8436E9--