|
Added
Link Here
|
| 1 |
package org.eclipse.jpt.jpa.ui.internal.preferences; |
| 2 |
|
| 3 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
| 4 |
import org.eclipse.jface.dialogs.IDialogConstants; |
| 5 |
import org.eclipse.jface.preference.PreferencePage; |
| 6 |
import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; |
| 7 |
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; |
| 8 |
import org.eclipse.jpt.jpa.ui.internal.dialogs.DontShowAgainDialog; |
| 9 |
import org.eclipse.swt.SWT; |
| 10 |
import org.eclipse.swt.events.SelectionEvent; |
| 11 |
import org.eclipse.swt.events.SelectionListener; |
| 12 |
import org.eclipse.swt.layout.GridData; |
| 13 |
import org.eclipse.swt.layout.GridLayout; |
| 14 |
import org.eclipse.swt.widgets.Button; |
| 15 |
import org.eclipse.swt.widgets.Composite; |
| 16 |
import org.eclipse.swt.widgets.Control; |
| 17 |
import org.eclipse.swt.widgets.Group; |
| 18 |
import org.eclipse.swt.widgets.Label; |
| 19 |
import org.eclipse.ui.IWorkbench; |
| 20 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
| 21 |
|
| 22 |
/** |
| 23 |
* This is the root of the Java Persistence preferences hierarchy in the IDE |
| 24 |
* preferences dialog. |
| 25 |
* <p> |
| 26 |
* Structure: |
| 27 |
* <p> |
| 28 |
* Java Persistence<br> |
| 29 |
* |
| 30 |
* @version 2.2 |
| 31 |
* @since 2.2 |
| 32 |
*/ |
| 33 |
public class JptPerferencesPage extends PreferencePage implements IWorkbenchPreferencePage { |
| 34 |
|
| 35 |
@Override |
| 36 |
protected Control createContents(Composite parent) { |
| 37 |
|
| 38 |
Composite container= new Composite(parent, SWT.NONE); |
| 39 |
GridLayout layout= new GridLayout(); |
| 40 |
layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); |
| 41 |
layout.marginWidth= 0; |
| 42 |
layout.verticalSpacing= convertVerticalDLUsToPixels(10); |
| 43 |
layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); |
| 44 |
container.setLayout(layout); |
| 45 |
|
| 46 |
layout = new GridLayout(); |
| 47 |
layout.numColumns= 2; |
| 48 |
|
| 49 |
Group dontAskGroup = new Group(container, SWT.NONE); |
| 50 |
dontAskGroup.setLayout(layout); |
| 51 |
dontAskGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| 52 |
dontAskGroup.setText(JptUiMessages.JptPreferencesPage_DoNotShowDialogs); |
| 53 |
|
| 54 |
Label label = new Label(dontAskGroup, SWT.WRAP); |
| 55 |
label.setText(JptUiMessages.JptPreferencesPage_DoNotShowText); |
| 56 |
GridData data= new GridData(GridData.FILL, GridData.CENTER, true, false); |
| 57 |
data.widthHint= convertVerticalDLUsToPixels(50); |
| 58 |
label.setLayoutData(data); |
| 59 |
|
| 60 |
Button button = new Button(dontAskGroup, SWT.PUSH); |
| 61 |
button.setText(JptUiMessages.JptPreferencesPage_ClearButtonText); |
| 62 |
button.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); |
| 63 |
button.addSelectionListener(new SelectionListener() { |
| 64 |
public void widgetSelected(SelectionEvent e) { |
| 65 |
unhideAllDialogs(); |
| 66 |
} |
| 67 |
public void widgetDefaultSelected(SelectionEvent e) { |
| 68 |
unhideAllDialogs(); |
| 69 |
} |
| 70 |
}); |
| 71 |
|
| 72 |
return container; |
| 73 |
} |
| 74 |
|
| 75 |
public void init(IWorkbench workbench) { |
| 76 |
setPreferenceStore(JptJpaUiPlugin.instance().getPreferenceStore()); |
| 77 |
} |
| 78 |
|
| 79 |
private final void unhideAllDialogs() { |
| 80 |
Iterable<String> preferenceKeys = DontShowAgainDialog.allPreferenceKeys(); |
| 81 |
for (String preferenceKey : preferenceKeys) { |
| 82 |
final IEclipsePreferences pref = DontShowAgainDialog.getDontShowPreferences(); |
| 83 |
pref.putBoolean(preferenceKey, false); |
| 84 |
} |
| 85 |
} |
| 86 |
} |