1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
12 package net.sourceforge.phpdt.internal.ui.preferences;
14 import java.util.HashMap;
17 import net.sourceforge.phpdt.core.IJavaProject;
18 import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener;
19 import net.sourceforge.phpdt.ui.PreferenceConstants;
21 import org.eclipse.jface.preference.IPreferenceStore;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.layout.GridData;
24 import org.eclipse.swt.layout.GridLayout;
25 import org.eclipse.swt.widgets.Composite;
26 import org.eclipse.swt.widgets.Control;
27 import org.eclipse.swt.widgets.Group;
30 * Options configuration block for editor related settings.
34 public class EditorConfigurationBlock extends OptionsConfigurationBlock {
36 /** Preference keys for the preferences in this block */
37 private static final String PREF_EDITOR_SAVE_ON_BLUR = PreferenceConstants.EDITOR_SAVE_ON_BLUR;
39 private static final String PREF_EDITOR_P_RTRIM_ON_SAVE = PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE;
42 * Creates a new editor configuration block.
45 * The status change listener
49 public EditorConfigurationBlock(final IStatusChangeListener context,
50 final IJavaProject project) {
51 super(context, project, getAllKeys());
55 * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
57 protected Control createContents(final Composite parent) {
59 Composite composite = new Composite(parent, SWT.NONE);
60 GridLayout layout = new GridLayout();
61 layout.numColumns = 1;
62 composite.setLayout(layout);
64 final String[] trueFalse = new String[] { IPreferenceStore.TRUE,
65 IPreferenceStore.FALSE };
67 Group user = new Group(composite, SWT.NONE);
68 user.setText(PreferencesMessages
69 .getString("EditorPreferencePage.file.title")); //$NON-NLS-1$
70 user.setLayout(new GridLayout());
71 user.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
73 String label = PreferencesMessages
74 .getString("EditorPreferencePage.save_on_blur"); //$NON-NLS-1$
75 addCheckBox(user, label, PREF_EDITOR_SAVE_ON_BLUR, trueFalse, 0);
77 label = PreferencesMessages
78 .getString("EditorPreferencePage.p_rtrim_on_save"); //$NON-NLS-1$
79 addCheckBox(user, label, PREF_EDITOR_P_RTRIM_ON_SAVE, trueFalse, 0);
84 private static String[] getAllKeys() {
85 return new String[] { PREF_EDITOR_SAVE_ON_BLUR,
86 PREF_EDITOR_P_RTRIM_ON_SAVE };
90 * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#getDefaultOptions()
92 protected Map getDefaultOptions() {
94 final String[] keys = fAllKeys;
95 final Map options = new HashMap();
96 final IPreferenceStore store = PreferenceConstants.getPreferenceStore();
98 for (int index = 0; index < keys.length; index++)
99 options.put(keys[index], store.getDefaultString(keys[index]));
105 * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
107 protected final String[] getFullBuildDialogStrings(final boolean workspace) {
112 * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#getOptions(boolean)
114 protected Map getOptions(final boolean inherit) {
116 final String[] keys = fAllKeys;
117 final Map options = new HashMap();
118 final IPreferenceStore store = PreferenceConstants.getPreferenceStore();
120 for (int index = 0; index < keys.length; index++)
121 options.put(keys[index], store.getString(keys[index]));
127 * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#setOptions(java.util.Map)
129 protected void setOptions(final Map options) {
131 final String[] keys = fAllKeys;
132 final IPreferenceStore store = PreferenceConstants.getPreferenceStore();
134 for (int index = 0; index < keys.length; index++)
135 store.setValue(keys[index], (String) fWorkingValues
140 * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(java.lang.String,java.lang.String)
142 protected void validateSettings(final String key, final String value) {