Unable to report problem with the preferences plugin

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to report problem with the preferences plugin

Marcelo
Hi,

I tried to report and issue with the Griffon preferences plugin but there is no place to do that in github. Should it be reported through Griffon?

My problem with the plugin is that it should take the name of the last class in the hierarchy to create the default keys. In this way it would follow Java's inheritance rules for variables.

For example:

public class parent {

  private int inheritedValue;

  @Preference(default=0)
  public void setInheritedValue(int value) {
    inheritedValue = value;
  }

  public int getInheritedValue() {
    return inheritedValue;
  }
}

public class firstChild extends parent {
  public firstChild () {
    setInheritedValue(4);
  }
}

public class secondChild extends parent {
  public firstChild () {
    setInheritedValue(2);
  }
}

The keys and values generated should be:

firstChild.inheritedValue: 4
secondChild.inheritedValue: 2

In this way each child would have the correct value. Now, to enforce the same value, one would use the key value of the Preference annotation:

public class parent {

  private int inheritedValue;

  @Preference(key="sharedKey", default=0)
  public void setInheritedValue(int value) {
    inheritedValue = value;
  }

  public int getInheritedValue() {
    return inheritedValue;
  }
}

Then the result will be shared by all its descendants:

sharedKey: [number]

Where [number] will be the value set by the last child that persisted the configuration.

Thanks,

Marcelo.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to report problem with the preferences plugin

aalmiray
Administrator
Hi Marcelo,

Each plugin project has its own issue tracker. The link for the preferences plugin is https://github.com/griffon-plugins/griffon-preferences-plugin/issues

Cheers,
Andres
Reply | Threaded
Open this post in threaded view
|

Re: Unable to report problem with the preferences plugin

Marcelo
Thanks Andres! I just opened and issue.
Is there a way to circumvent this limitation? I noticed the amount of duplicated code in subclasses is growing quite a bit...
Marcelo.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to report problem with the preferences plugin

aalmiray
Administrator
Hi Marcelo,

There are two solutions:

1. upgrade to the recently released 1.5.0 of griffon-preferences :-)
2. provide your custom implementation of `PreferencesManager` overriding the `harvestDescriptors()` method.

I'd recommend going with #1 but just so you know #2 is a viable option in many cases as both core and plugins make it very easy to extend a base implementation and inject overriding bindings in a module.

Cheers,
Andres
Reply | Threaded
Open this post in threaded view
|

Re: Unable to report problem with the preferences plugin

Marcelo
Hi Andres!
Sorry I'm giving you so much work to answer back. Option # 1 will be!
Thanks again!
Marcelo
Reply | Threaded
Open this post in threaded view
|

Re: Unable to report problem with the preferences plugin

aalmiray
Administrator
No worries, this is how we make sure both the frameworks and plugins are water tight but also extensible.

Cheers,
Andres