Programatically updating the javadoc and declaration view [message #250005] |
Wed, 05 December 2007 07:38  |
Eclipse User |
|
|
|
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig473FD6180EA4412AB6CBD062
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi all,
We'd like to reuse the javadoc and declaration view to display
javadoc/java source corresponding to an element in a configuration file
in one of the projects in the workspace.
We're able to get hold of the IJavaElement and are putting in this
reflection hack to update the javadoc/declaration view with the
IJavaElement.
Is there a better way to do this ? Does my editor need to publish
something that I should be ?
/**
* Shows the java element in view specified by viewId
*/
public void show(final IJavaElement element, String viewId){
// get hold of the view javadoc/declaration view
AbstractInfoView infoView =3D (AbstractInfoView)
workbenchPart.getSite().getPage().findView(viewId);
// get hold of the computeInput protected method, and invoke it.
// returns the text to be set into the view.
Method computeInput =3D
AbstractInfoView.class.getDeclaredMethod("computeInput", Object.class);
computeInput.setAccessible(true);
String source =3D (String) computeInput.invoke(infoView, element);
// set the IJavaElement into the view.
Field fCurrentViewInput =3D
AbstractInfoView.class.getDeclaredField("fCurrentViewInput");
fCurrentViewInput.setAccessible(true);
fCurrentViewInput.set(infoView, element);
// set the text into the view
Method doSetInput =3D
AbstractInfoView.class.getDeclaredMethod("doSetInput", Object.class);
doSetInput.setAccessible(true);
doSetInput.invoke(infoView, source);
}
Cheers,
Ketan Padegaonkar
I blog... therefore I am... http://ketan.padegaonkar.name/
http://swtbot.org
Slackware is not for you. You do not possess the Tao.
-- +Chiron+
--------------enig473FD6180EA4412AB6CBD062
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHVpvZ50uB2zvyE8MRAqR6AJ9Zo77RX/znvUeP83+UaawbTj3Q6wCf TnBu
G/g/Gua4MzvOnPcv8yS5XEI=
=N1jw
-----END PGP SIGNATURE-----
--------------enig473FD6180EA4412AB6CBD062--
|
|
|
Re: Programatically updating the javadoc and declaration view [message #250156 is a reply to message #250005] |
Tue, 11 December 2007 10:20   |
Eclipse User |
|
|
|
Ketan Padegaonkar wrote:
>Hi all,
>
>We'd like to reuse the javadoc and declaration view to display
>javadoc/java source corresponding to an element in a configuration file
>in one of the projects in the workspace.
>
>We're able to get hold of the IJavaElement and are putting in this
>reflection hack to update the javadoc/declaration view with the
>IJavaElement.
>
>Is there a better way to do this ? Does my editor need to publish
>something that I should be ?
>
>
Not with 3.3.x. Stating with 3.4 M4 you'll see:
org.eclipse.jdt.internal.ui.infoviews.AbstractInfoView.setIn put(IJavaElement)
Dani
>/**
> * Shows the java element in view specified by viewId
> */
>public void show(final IJavaElement element, String viewId){
> // get hold of the view javadoc/declaration view
> AbstractInfoView infoView = (AbstractInfoView)
>workbenchPart.getSite().getPage().findView(viewId);
>
> // get hold of the computeInput protected method, and invoke it.
> // returns the text to be set into the view.
> Method computeInput =
>AbstractInfoView.class.getDeclaredMethod("computeInput", Object.class);
> computeInput.setAccessible(true);
> String source = (String) computeInput.invoke(infoView, element);
>
> // set the IJavaElement into the view.
> Field fCurrentViewInput =
>AbstractInfoView.class.getDeclaredField("fCurrentViewInput ");
> fCurrentViewInput.setAccessible(true);
> fCurrentViewInput.set(infoView, element);
>
> // set the text into the view
> Method doSetInput =
>AbstractInfoView.class.getDeclaredMethod("doSetInput", Object.class);
> doSetInput.setAccessible(true);
> doSetInput.invoke(infoView, source);
>
>}
>
>Cheers,
>Ketan Padegaonkar
>I blog... therefore I am... http://ketan.padegaonkar.name/
>http://swtbot.org
>
>Slackware is not for you. You do not possess the Tao.
> -- +Chiron+
>
>
>
|
|
|
Re: Programatically updating the javadoc and declaration view [message #250168 is a reply to message #250156] |
Wed, 12 December 2007 07:03  |
Eclipse User |
|
|
|
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigF4E1489BB37760B1D179E563
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Daniel Megert wrote:
> Ketan Padegaonkar wrote:
>=20
>> Hi all,
>>
>> We'd like to reuse the javadoc and declaration view to display
>> javadoc/java source corresponding to an element in a configuration fil=
e
>> in one of the projects in the workspace.
>>
>> We're able to get hold of the IJavaElement and are putting in this
>> reflection hack to update the javadoc/declaration view with the
>> IJavaElement.
>>
>> Is there a better way to do this ? Does my editor need to publish
>> something that I should be ?
>> =20
>>
> Not with 3.3.x. Stating with 3.4 M4 you'll see:
> org.eclipse.jdt.internal.ui.infoviews.AbstractInfoView.setIn put(IJavaEl=
ement)
Daniel, thanks for the heads up.
>=20
>=20
> Dani
>> Cheers,
>> Ketan Padegaonkar
>> I blog... therefore I am... http://ketan.padegaonkar.name/
>> http://swtbot.org
>>
>> Slackware is not for you. You do not possess the Tao.
>> -- +Chiron+
--=20
Ketan Padegaonkar
I blog... therefore I am... http://ketan.padegaonkar.name/
http://swtbot.org
Slackware is not for you. You do not possess the Tao.
-- +Chiron+
--------------enigF4E1489BB37760B1D179E563
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHX83450uB2zvyE8MRAjuoAJ9016RKXq/kXEF0AOEEnAGNB4FVrgCe LeCA
xPXdsknUDFXklQADGlsG50Y=
=G7K9
-----END PGP SIGNATURE-----
--------------enigF4E1489BB37760B1D179E563--
|
|
|
Powered by
FUDForum. Page generated in 0.04929 seconds