Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreferenceInitializer - default initialization part III #1606

Closed
eselmeister opened this issue Jan 10, 2024 · 1 comment
Closed

PreferenceInitializer - default initialization part III #1606

eselmeister opened this issue Jan 10, 2024 · 1 comment

Comments

@eselmeister
Copy link
Contributor

Depends on:
#1604

@eselmeister
Copy link
Contributor Author

Using settings can't be easier than that:

public class PreferenceSupplier extends AbstractPreferenceSupplier implements IPreferenceSupplier {

	public static final int MIN_LIMIT = 1;
	public static final int MAX_LIMIT = Integer.MAX_VALUE;
	//
	public static final String P_LIMIT = "limit";
	public static final int DEF_LIMIT = 5;

	public static IPreferenceSupplier INSTANCE() {

		return INSTANCE(PreferenceSupplier.class);
	}

	@Override
	public String getPreferenceNode() {

		return Activator.getContext().getBundle().getSymbolicName();
	}

	@Override
	public void initializeDefaults() {

		putDefault(P_LIMIT, DEF_LIMIT);
	}

	public static int getLimit() {

		return INSTANCE().getInteger(P_LIMIT);
	}

	public static void setLimit(int limit) {

		INSTANCE().putInteger(P_LIMIT, limit);
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant