|
Added
Link Here
|
| 1 |
package org.eclipse.jst.j2ee.internal.ui.preferences; |
| 2 |
|
| 3 |
//import org.eclipse.core.resources.ResourcesPlugin; |
| 4 |
import org.eclipse.core.runtime.Preferences; |
| 5 |
import org.eclipse.jface.preference.PreferencePage; |
| 6 |
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; |
| 7 |
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; |
| 8 |
import org.eclipse.swt.SWT; |
| 9 |
import org.eclipse.swt.events.SelectionAdapter; |
| 10 |
import org.eclipse.swt.events.SelectionEvent; |
| 11 |
import org.eclipse.swt.layout.GridData; |
| 12 |
import org.eclipse.swt.layout.GridLayout; |
| 13 |
import org.eclipse.swt.widgets.Button; |
| 14 |
import org.eclipse.swt.widgets.Composite; |
| 15 |
import org.eclipse.swt.widgets.Control; |
| 16 |
import org.eclipse.swt.widgets.Group; |
| 17 |
import org.eclipse.swt.widgets.Label; |
| 18 |
import org.eclipse.ui.IWorkbench; |
| 19 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
| 20 |
|
| 21 |
public class JavaEEPreferencePage extends PreferencePage implements |
| 22 |
IWorkbenchPreferencePage { |
| 23 |
|
| 24 |
private Preferences preferences; |
| 25 |
private String name = J2EEPlugin.DYNAMIC_TRANSLATION_OF_JET_TEMPLATES_PREF_KEY; |
| 26 |
private Button showReferences; |
| 27 |
private boolean dynamicTranslation; |
| 28 |
|
| 29 |
public JavaEEPreferencePage() { |
| 30 |
setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.JAVA_EE_PREFERENCE_PAGE_NAME)); |
| 31 |
} |
| 32 |
|
| 33 |
@Override |
| 34 |
protected void performDefaults() { |
| 35 |
preferences.setToDefault(name); |
| 36 |
J2EEPlugin.getDefault().savePluginPreferences(); |
| 37 |
dynamicTranslation = preferences.getBoolean(name); |
| 38 |
showReferences.setSelection(dynamicTranslation); |
| 39 |
super.performDefaults(); |
| 40 |
} |
| 41 |
|
| 42 |
@Override |
| 43 |
protected Control createContents(Composite parent) { |
| 44 |
Composite result= new Composite(parent, SWT.NONE); |
| 45 |
GridLayout layout= new GridLayout(); |
| 46 |
layout.marginWidth= 0; |
| 47 |
result.setLayout(layout); |
| 48 |
Label spacer = new Label(result, SWT.NONE); |
| 49 |
Group buttonComposite= new Group(result, SWT.NONE); |
| 50 |
buttonComposite.setLayout(new GridLayout()); |
| 51 |
buttonComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| 52 |
buttonComposite.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.JAVA_EE_PREFERENCE_PAGE_JET_TEMPLATE)); |
| 53 |
|
| 54 |
showReferences = new Button(buttonComposite, SWT.CHECK); |
| 55 |
showReferences.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.JAVA_EE_PREFERENCE_PAGE_DYN_TRANSLATION_BTN_NAME)); //$NON-NLS-1$ |
| 56 |
showReferences.setSelection(dynamicTranslation); |
| 57 |
showReferences.addSelectionListener(new SelectionAdapter() { |
| 58 |
public void widgetSelected(SelectionEvent e) { |
| 59 |
dynamicTranslation = showReferences.getSelection(); |
| 60 |
} |
| 61 |
}); |
| 62 |
return result; |
| 63 |
} |
| 64 |
|
| 65 |
public void init(IWorkbench workbench) { |
| 66 |
preferences = J2EEPlugin.getDefault().getPluginPreferences(); |
| 67 |
dynamicTranslation = preferences.getBoolean(name); |
| 68 |
} |
| 69 |
|
| 70 |
@Override |
| 71 |
public boolean performOk() { |
| 72 |
preferences.setValue(name, showReferences.getSelection()); |
| 73 |
J2EEPlugin.getDefault().savePluginPreferences(); |
| 74 |
return super.performOk(); |
| 75 |
} |
| 76 |
} |