Skip to content

Commit

Permalink
Fixes PDE preference page template
Browse files Browse the repository at this point in the history
The current template assumes that the plug-in has an activator. As we do
not use activators anymore in the default plug-in template, we should
also adjust this template.

Plus getting rid of NON-Javadoc
  • Loading branch information
vogella committed Dec 19, 2023
1 parent 7f37e02 commit 7d111eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package $packageName$;

import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.*;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbench;
import $pluginClass$;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.FrameworkUtil;

/**
* This class represents a preference page that
Expand Down Expand Up @@ -31,7 +33,8 @@ public class $pageClassName$

public $pageClassName$() {
super(GRID);
setPreferenceStore($activator$.getDefault().getPreferenceStore());
ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, String.valueOf(FrameworkUtil.getBundle(getClass()).getBundleId()));
setPreferenceStore(scopedPreferenceStore);
setDescription("A demonstration of a preference page implementation");
}

Expand Down Expand Up @@ -61,9 +64,7 @@ public void createFieldEditors() {
new StringFieldEditor(PreferenceConstants.P_STRING, "A &text preference:", getFieldEditorParent()));
}

/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
@Override
public void init(IWorkbench workbench) {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package $packageName$;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.FrameworkUtil;

import $pluginClass$;

/**
* Class used to initialize default preference values.
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {

/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = $activator$.getDefault().getPreferenceStore();
ScopedPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, String.valueOf(FrameworkUtil.getBundle(getClass()).getBundleId()));

store.setDefault(PreferenceConstants.P_BOOLEAN, true);
store.setDefault(PreferenceConstants.P_CHOICE, "choice2");
store.setDefault(PreferenceConstants.P_STRING,
Expand Down

0 comments on commit 7d111eb

Please sign in to comment.