You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lécharny <el...@gmail.com> on 2017/08/25 16:39:59 UTC

Usage of ID like %PrefPage_StudioPage_id in plugin.xml

Hi Stefan,


a quick question : we are referencing a value through the
%PrefPage_StudioPage_id which is defined in many plugin.properties files
in many associated plugin.xml files :


org.apache.directory.studio.connection.ui

-----------------------------------------


in plugin.xml :

...

  <extension
      point="org.eclipse.ui.preferencePages">
    <page
        category="%PrefPage_StudioPage_id"

...

and in plugin.properties :

...

PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage

...


org.apache.directory.studio.ldapbrowser.common

----------------------------------------------


in plugin.xml :

...

   <extension
         point="org.eclipse.ui.preferencePages">
      <page
            category="%PrefPage_StudioPage_id"
...

and in plugin.properties :

...

PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage

...



org.apache.directory.studio.ldifeditor

--------------------------------------


in plugin.xml :

...

   <extension
         point="org.eclipse.ui.preferencePages">
      <page
            category="%PrefPage_StudioPage_id"

...

and in plugin.properties :

...

PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage

...


org.apache.directory.studio.schemaeditor

----------------------------------------


in plugin.xml :

...

    <extension
         point="org.eclipse.ui.preferencePages">
      <page
           
class="org.apache.directory.studio.schemaeditor.view.preferences.PluginPreferencePage"
            category="%PrefPage_StudioPage_id"
...

and in plugin.properties :

...

PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage

...



To my understanding, the plugin.propeties file is the default property
file, with some possible plugin_<lang>.properties files being localized
version of it. It does not seems to make sense to store identifiers in
it, and I'd rather use something like :



...

    <extension
         point="org.eclipse.ui.preferencePages">
      <page
           
class="org.apache.directory.studio.schemaeditor.view.preferences.PluginPreferencePage"
            category="org.apache.directory.studio.StudioPreferencePage"
...


in the plugin.xml.


Do you know if there is any valuable or historical reason why we have
such thing in our code ? (I know that Eclipse has eveolved a lot since
our first release, so what sounds weird now might have made sense years
ago. Or I may also miss some important - and unknown to me - thing about
the usage of ID in plugins).


Many thanks !



-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: Usage of ID like %PrefPage_StudioPage_id in plugin.xml

Posted by Emmanuel Lécharny <el...@gmail.com>.
Ok, after having dig a bit more, I now understand why Pierre-Arnaud
moved those IDs to plugin.properties file.


Some IDs are used in many places, either in plugin.xml and in source
files. At some point, my guess is that it was a souce of annoyance to
change all the instances when renaming one of those ID, with a risk of
missing oen of them, leading to some errors whci cause was diffifult to
track.


The plugin.properties file is available to store some properties that
can be discovered through a call to :

    XXXPlugin.getDefault().getPluginProperties().getString( <the
property> );

(and using a %<the property> in the plugin.xml file)

It's convenient enough to use, and offers a single point where the
property is defined under a referenced name.


At this point, here is what I suggest :

- when the property is only used in ne single place (like the
Plugin_Id), we should not put it in the plugin.property.

- if a property is referenced more than once in the code, then we should
keep the property in plugin.properties

- as we may have i18ned properties, using fragments
(plugin<lang>.properties files described in the build.property file (see
below), I suggest we split the properies in two sets : the i18ned
properties, and the reference IDs.


Here is the build.properies file where the fragments are defined :

    bin.includes = META-INF/,\
               .,\
               plugin.properties,\
               plugin_fr.properties,\
               plugin_de.properties,\
               plugin.xml,\
               resources/


wdyt ?



Le 26/08/2017 à 08:46, Stefan Seelmann a écrit :
> On 08/26/2017 01:32 AM, Emmanuel Lécharny wrote:
>> Seems like it roots in
>> https://issues.apache.org/jira/browse/DIRSTUDIO-375...
> Thanks for finding the Jira. I really don't know the reason behind. Do
> you want to change it back?
>
>

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: Usage of ID like %PrefPage_StudioPage_id in plugin.xml

Posted by Emmanuel Lécharny <el...@gmail.com>.

Le 26/08/2017 à 08:46, Stefan Seelmann a écrit :
> On 08/26/2017 01:32 AM, Emmanuel Lécharny wrote:
>> Seems like it roots in
>> https://issues.apache.org/jira/browse/DIRSTUDIO-375...
> Thanks for finding the Jira. 

It took me a part of ast night insomnia :-)

> I really don't know the reason behind. Do
> you want to change it back?

I do think that it goes against the semantic of plugin.properties, which
is supposed to be used for string that might be i18ned. But I remember
that Pierre-Arnaud was complaining about errors related to IDs being
used across the code base, and he probably used this trick to get rid of
such issue.

I will evaluate the situation and come back with an anwser this week-end.

Thanks Stefan !

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: Usage of ID like %PrefPage_StudioPage_id in plugin.xml

Posted by Emmanuel Lécharny <el...@gmail.com>.
An exemple :

The aciitemeditor plugin defines a PLIGIN_ID constant that is read from
teh plugin.properties file :

ACIITemConstants.java :
    String PLUGIN_ID =
Activator.getDefault().getPluginProperties().getString( "Plugin_id" );
//$NON-NLS-1$

Activator.java :

    public static ImageDescriptor getImageDescriptor( String path )
    {
        return imageDescriptorFromPlugin( ACIITemConstants.PLUGIN_ID,
path );
    }


ACIItemDialog.java, buttonPressed() :
    ...
            catch ( ParseException pe )
            {
                IStatus status = new Status( IStatus.ERROR,
ACIITemConstants.PLUGIN_ID, 1, Messages
                    .getString( "ACIItemDialog.error.invalidSyntax" ),
pe ); //$NON-NLS-1$
    ...

and okPressed()
    ...
        catch ( ParseException pe )
        {
            IStatus status = new Status( IStatus.ERROR,
ACIITemConstants.PLUGIN_ID, 1, Messages
                .getString( "ACIItemDialog.error.invalidSyntax" ), pe );
//$NON-NLS-1$
    ...


ACIItemTabFolderComposite.java, setInput() :
    ...
            IStatus status = new Status( IStatus.ERROR,
ACIITemConstants.PLUGIN_ID, 1, Messages
                .getString( "ACIItemTabFolderComposite.error.onInput" ),
pe ); //$NON-NLS-1$
    ...

and tabSelected()
    ...
                IStatus status = new Status( IStatus.ERROR,
ACIITemConstants.PLUGIN_ID, 1, Messages
                    .getString(
"ACIItemTabFolderComposite.error.onVisualEditor" ), pe ); //$NON-NLS-1$
    ...



I think we can keep the constant, using this form instead :

    String PLUGIN_ID = "org.apache.directory.studio.aciitemeditor";
//$NON-NLS-1$


or
    String Plugin_ID = ACIITemConstants.class.getPackage().getName();

assuming the Plugin_ID is always the package name.

-- 

Emmanuel Lecharny

Symas.com
directory.apache.org


Re: Usage of ID like %PrefPage_StudioPage_id in plugin.xml

Posted by Stefan Seelmann <ma...@stefan-seelmann.de>.
On 08/26/2017 01:32 AM, Emmanuel Lécharny wrote:
> Seems like it roots in
> https://issues.apache.org/jira/browse/DIRSTUDIO-375...

Thanks for finding the Jira. I really don't know the reason behind. Do
you want to change it back?



Re: Usage of ID like %PrefPage_StudioPage_id in plugin.xml

Posted by Emmanuel Lécharny <el...@gmail.com>.
Seems like it roots in
https://issues.apache.org/jira/browse/DIRSTUDIO-375...


Not sure it was a good idea.


Le 25/08/2017 à 18:39, Emmanuel Lécharny a écrit :
> Hi Stefan,
>
>
> a quick question : we are referencing a value through the
> %PrefPage_StudioPage_id which is defined in many plugin.properties files
> in many associated plugin.xml files :
>
>
> org.apache.directory.studio.connection.ui
>
> -----------------------------------------
>
>
> in plugin.xml :
>
> ...
>
>   <extension
>       point="org.eclipse.ui.preferencePages">
>     <page
>         category="%PrefPage_StudioPage_id"
>
> ...
>
> and in plugin.properties :
>
> ...
>
> PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage
>
> ...
>
>
> org.apache.directory.studio.ldapbrowser.common
>
> ----------------------------------------------
>
>
> in plugin.xml :
>
> ...
>
>    <extension
>          point="org.eclipse.ui.preferencePages">
>       <page
>             category="%PrefPage_StudioPage_id"
> ...
>
> and in plugin.properties :
>
> ...
>
> PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage
>
> ...
>
>
>
> org.apache.directory.studio.ldifeditor
>
> --------------------------------------
>
>
> in plugin.xml :
>
> ...
>
>    <extension
>          point="org.eclipse.ui.preferencePages">
>       <page
>             category="%PrefPage_StudioPage_id"
>
> ...
>
> and in plugin.properties :
>
> ...
>
> PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage
>
> ...
>
>
> org.apache.directory.studio.schemaeditor
>
> ----------------------------------------
>
>
> in plugin.xml :
>
> ...
>
>     <extension
>          point="org.eclipse.ui.preferencePages">
>       <page
>            
> class="org.apache.directory.studio.schemaeditor.view.preferences.PluginPreferencePage"
>             category="%PrefPage_StudioPage_id"
> ...
>
> and in plugin.properties :
>
> ...
>
> PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage
>
> ...
>
>
>
> To my understanding, the plugin.propeties file is the default property
> file, with some possible plugin_<lang>.properties files being localized
> version of it. It does not seems to make sense to store identifiers in
> it, and I'd rather use something like :
>
>
>
> ...
>
>     <extension
>          point="org.eclipse.ui.preferencePages">
>       <page
>            
> class="org.apache.directory.studio.schemaeditor.view.preferences.PluginPreferencePage"
>             category="org.apache.directory.studio.StudioPreferencePage"
> ...
>
>
> in the plugin.xml.
>
>
> Do you know if there is any valuable or historical reason why we have
> such thing in our code ? (I know that Eclipse has eveolved a lot since
> our first release, so what sounds weird now might have made sense years
> ago. Or I may also miss some important - and unknown to me - thing about
> the usage of ID in plugins).
>
>
> Many thanks !
>
>
>

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: Usage of ID like %PrefPage_StudioPage_id in plugin.xml

Posted by Emmanuel Lécharny <el...@gmail.com>.
Actually, some of those IDs are referenced in teh code, like :


in
org.apache.directory.studio.connection.ui.ConnectionParameterPageManager :

        IExtensionPoint extensionPoint = registry.getExtensionPoint(
ConnectionUIPlugin.getDefault()
            .getPluginProperties().getString(
"ExtensionPoint_ConnectionParameterPages_id" ) ); //$NON-NLS-1$


in plugin.xml :

    ...

    <plugin>
        <extension-point
id="org.apache.directory.studio.connectionparameterpages"
name="%ExtensionPoint_ConnectionParameterPages_name"

    ...

and in plugin.properties :

    ...

   
ExtensionPoint_ConnectionParameterPages_id=org.apache.directory.studio.connectionparameterpages

    ...


( note that I would have expected to see <extension-point
id="%ExtensionPoint_ConnectionParameterPages_id" in the plugin.xml file...)


but still, I don't really see the added value of having such an
indirection when the property is not localized.


wdyt ?



Le 25/08/2017 à 18:39, Emmanuel Lécharny a écrit :
> Hi Stefan,
>
>
> a quick question : we are referencing a value through the
> %PrefPage_StudioPage_id which is defined in many plugin.properties files
> in many associated plugin.xml files :
>
>
> org.apache.directory.studio.connection.ui
>
> -----------------------------------------
>
>
> in plugin.xml :
>
> ...
>
>   <extension
>       point="org.eclipse.ui.preferencePages">
>     <page
>         category="%PrefPage_StudioPage_id"
>
> ...
>
> and in plugin.properties :
>
> ...
>
> PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage
>
> ...
>
>
> org.apache.directory.studio.ldapbrowser.common
>
> ----------------------------------------------
>
>
> in plugin.xml :
>
> ...
>
>    <extension
>          point="org.eclipse.ui.preferencePages">
>       <page
>             category="%PrefPage_StudioPage_id"
> ...
>
> and in plugin.properties :
>
> ...
>
> PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage
>
> ...
>
>
>
> org.apache.directory.studio.ldifeditor
>
> --------------------------------------
>
>
> in plugin.xml :
>
> ...
>
>    <extension
>          point="org.eclipse.ui.preferencePages">
>       <page
>             category="%PrefPage_StudioPage_id"
>
> ...
>
> and in plugin.properties :
>
> ...
>
> PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage
>
> ...
>
>
> org.apache.directory.studio.schemaeditor
>
> ----------------------------------------
>
>
> in plugin.xml :
>
> ...
>
>     <extension
>          point="org.eclipse.ui.preferencePages">
>       <page
>            
> class="org.apache.directory.studio.schemaeditor.view.preferences.PluginPreferencePage"
>             category="%PrefPage_StudioPage_id"
> ...
>
> and in plugin.properties :
>
> ...
>
> PrefPage_StudioPage_id=org.apache.directory.studio.StudioPreferencePage
>
> ...
>
>
>
> To my understanding, the plugin.propeties file is the default property
> file, with some possible plugin_<lang>.properties files being localized
> version of it. It does not seems to make sense to store identifiers in
> it, and I'd rather use something like :
>
>
>
> ...
>
>     <extension
>          point="org.eclipse.ui.preferencePages">
>       <page
>            
> class="org.apache.directory.studio.schemaeditor.view.preferences.PluginPreferencePage"
>             category="org.apache.directory.studio.StudioPreferencePage"
> ...
>
>
> in the plugin.xml.
>
>
> Do you know if there is any valuable or historical reason why we have
> such thing in our code ? (I know that Eclipse has eveolved a lot since
> our first release, so what sounds weird now might have made sense years
> ago. Or I may also miss some important - and unknown to me - thing about
> the usage of ID in plugins).
>
>
> Many thanks !
>
>
>

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org