templatePageName= Templates
spellingPrefName= Spelling
codeAssistPageName= Code Assist
+editorPageName= Editor
editorMarkOccurrencesPage= Mark Occurrences
#
class="net.sourceforge.phpdt.internal.ui.preferences.CodeAssistPreferencePage"
id="net.sourceforge.phpdt.internal.ui.preferences.CodeAssistPreferencePage">
</page>
- <page
+ <page name="%editorPageName"
+ category="net.sourceforge.phpeclipse.preferences.PHPPreferencePage"
+ class="net.sourceforge.phpdt.internal.ui.preferences.EditorPreferencePage"
+ id="net.sourceforge.phpdt.internal.ui.preferences.EditorPreferencePage">
+ </page>
+ <page
name="%templatePageName"
category="net.sourceforge.phpeclipse.preferences.PHPPreferencePage"
class="net.sourceforge.phpdt.internal.ui.preferences.JavaTemplatePreferencePage"
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sourceforge.phpdt.core.IJavaProject;
+import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener;
+import net.sourceforge.phpdt.ui.PreferenceConstants;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * Options configuration block for editor related settings.
+ *
+ * @since 3.0
+ */
+public class EditorConfigurationBlock extends OptionsConfigurationBlock {
+
+ /** Preference keys for the preferences in this block */
+ private static final String PREF_EDITOR_SAVE_ON_BLUR = PreferenceConstants.EDITOR_SAVE_ON_BLUR;
+
+ private static final String PREF_EDITOR_P_RTRIM_ON_SAVE = PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE;
+
+ /**
+ * Creates a new editor configuration block.
+ *
+ * @param context
+ * The status change listener
+ * @param project
+ * The Java project
+ */
+ public EditorConfigurationBlock(final IStatusChangeListener context,
+ final IJavaProject project) {
+ super(context, project, getAllKeys());
+ }
+
+ /*
+ * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents(final Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+
+ final String[] trueFalse = new String[] { IPreferenceStore.TRUE,
+ IPreferenceStore.FALSE };
+
+ Group user = new Group(composite, SWT.NONE);
+ user.setText(PreferencesMessages
+ .getString("EditorPreferencePage.file.title")); //$NON-NLS-1$
+ user.setLayout(new GridLayout());
+ user.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ String label = PreferencesMessages
+ .getString("EditorPreferencePage.save_on_blur"); //$NON-NLS-1$
+ addCheckBox(user, label, PREF_EDITOR_SAVE_ON_BLUR, trueFalse, 0);
+
+ label = PreferencesMessages
+ .getString("EditorPreferencePage.p_rtrim_on_save"); //$NON-NLS-1$
+ addCheckBox(user, label, PREF_EDITOR_P_RTRIM_ON_SAVE, trueFalse, 0);
+
+ return composite;
+ }
+
+ private static String[] getAllKeys() {
+ return new String[] { PREF_EDITOR_SAVE_ON_BLUR,
+ PREF_EDITOR_P_RTRIM_ON_SAVE };
+ }
+
+ /*
+ * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#getDefaultOptions()
+ */
+ protected Map getDefaultOptions() {
+
+ final String[] keys = fAllKeys;
+ final Map options = new HashMap();
+ final IPreferenceStore store = PreferenceConstants.getPreferenceStore();
+
+ for (int index = 0; index < keys.length; index++)
+ options.put(keys[index], store.getDefaultString(keys[index]));
+
+ return options;
+ }
+
+ /*
+ * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
+ */
+ protected final String[] getFullBuildDialogStrings(final boolean workspace) {
+ return null;
+ }
+
+ /*
+ * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#getOptions(boolean)
+ */
+ protected Map getOptions(final boolean inherit) {
+
+ final String[] keys = fAllKeys;
+ final Map options = new HashMap();
+ final IPreferenceStore store = PreferenceConstants.getPreferenceStore();
+
+ for (int index = 0; index < keys.length; index++)
+ options.put(keys[index], store.getString(keys[index]));
+
+ return options;
+ }
+
+ /*
+ * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#setOptions(java.util.Map)
+ */
+ protected void setOptions(final Map options) {
+
+ final String[] keys = fAllKeys;
+ final IPreferenceStore store = PreferenceConstants.getPreferenceStore();
+
+ for (int index = 0; index < keys.length; index++)
+ store.setValue(keys[index], (String) fWorkingValues
+ .get(keys[index]));
+ }
+
+ /*
+ * @see net.sourceforge.phpdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(java.lang.String,java.lang.String)
+ */
+ protected void validateSettings(final String key, final String value) {
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
+import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
+import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Preference page for spell checking preferences.
+ *
+ * @since 3.0
+ */
+public class EditorPreferencePage extends PreferencePage implements
+ IWorkbenchPreferencePage, IStatusChangeListener {
+
+ /** The spelling configuration block */
+ private final EditorConfigurationBlock fBlock = new EditorConfigurationBlock(
+ this, null);
+
+ /**
+ * Creates a new spelling preference page.
+ */
+ public EditorPreferencePage() {
+
+ setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
+ setDescription(PreferencesMessages
+ .getString("EditorPreferencePage.description")); //$NON-NLS-1$
+ setTitle(PreferencesMessages.getString("EditorPreferencePage.title")); //$NON-NLS-1$
+ }
+
+ /*
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents(final Composite parent) {
+
+ final Control control = fBlock.createContents(parent);
+ Dialog.applyDialogFont(control);
+
+ return control;
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(final Composite parent) {
+ super.createControl(parent);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
+ IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
+ }
+
+ /*
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(final IWorkbench workbench) {
+ // Do nothing
+ }
+
+ /*
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+ fBlock.performDefaults();
+
+ super.performDefaults();
+ }
+
+ /*
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ public boolean performOk() {
+
+ if (!fBlock.performOk(true))
+ return false;
+
+ return super.performOk();
+ }
+
+ /*
+ * @see net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
+ */
+ public void statusChanged(final IStatus status) {
+ setValid(!status.matches(IStatus.ERROR));
+
+ StatusUtil.applyToStatusLine(this, status);
+ }
+}
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
OverlayPreferenceStore.BOOLEAN,
PreferenceConstants.EDITOR_FORMAT_JAVADOCS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
- OverlayPreferenceStore.BOOLEAN,
- PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
OverlayPreferenceStore.BOOLEAN,
button = addCheckBox(group, label,
PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
- label = PreferencesMessages
- .getString("JavaEditorPreferencePage.p_rtrim_on_save");
- addCheckBox(group, label, PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE, 1);
//
// label = PreferencesMessages
// .getString("JavaEditorPreferencePage.addJavaDocTags");
JavaEditorPreferencePage.escapeStringsSQ= &Escape text when pasting into a single quoted PHP string
JavaEditorPreferencePage.addJavaDocTags= Add PHPdoc &tags
JavaEditorPreferencePage.smartPaste= Pasting fo&r correct indentation
-JavaEditorPreferencePage.p_rtrim_on_save= Remove trailing spaces on editor save
JavaEditorPreferencePage.smartHomeEnd= S&mart cursor positioning at line start and end
JavaEditorPreferencePage.subWordNavigation= Smart cursor positioning in &PHP names
SpellingPreferencePage.preferences.engine=&Language
SpellingPreferencePage.preferences.advanced=&Advanced
+EditorPreferencePage.description=General Editor Preferences:
+EditorPreferencePage.title=Editor
+EditorPreferencePage.file.title=File Saving
+EditorPreferencePage.save_on_blur=&Save files when focus is lost
+EditorPreferencePage.p_rtrim_on_save=&Remove trailing spaces on save
+
JavaEditorPreferencePage.AnnotationDecoration.NONE=None
JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES=Squiggles
public static final String EDITOR_DISABLE_OVERWRITE_MODE = "disable_overwrite_mode"; //$NON-NLS-1$
/**
+ * A named preference that controls saving of a file on loss of editor focus.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public static final String EDITOR_SAVE_ON_BLUR = "save_on_blur"; //$NON-NLS-1$
+
+ /**
* A named preference that controls the "smart semicolon" smart typing
* handler
* <p>
import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
import net.sourceforge.phpdt.ui.text.folding.IJavaFoldingStructureProvider;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.ui.IPreferenceConstants;
import net.sourceforge.phpeclipse.ui.editor.BrowserUtil;
+import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil;
import net.sourceforge.phpeclipse.webbrowser.views.BrowserView;
import org.eclipse.core.resources.IMarker;
}
}
-
+
/**
* Finds the next position after the given position.
*
* Default constructor.
*/
public PHPEditor() {
- super();
+ super();
}
/*
setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools
.getColorManager(), store, this,
IPHPPartitions.PHP_PARTITIONING));
-
+
// TODO changed in 3.x ?
// setRangeIndicator(new DefaultRangeIndicator());
// if
Preferences preferences = PHPeclipsePlugin.getDefault()
.getPluginPreferences();
preferences.addPropertyChangeListener(fPropertyChangeListener);
-
IInformationControlCreator informationControlCreator = new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
boolean cutDown = false;
installOccurrencesFinder();
PlatformUI.getWorkbench().addWindowListener(fActivationListener);
-
+
+ /*
+ * start of EDITOR_SAVE_ON_BLUR
+ * ed_mann
+ */
+ final PHPEditor editor = this;
+ FocusListener focusListener = new FocusListener() {
+
+ public void focusGained(FocusEvent e) {
+ return;
+ }
+
+ public void focusLost(FocusEvent e) {
+ //viewer.get
+ if(editor.isDirty() && PHPeclipsePlugin.getDefault().getPreferenceStore()
+ .getBoolean(PreferenceConstants.EDITOR_SAVE_ON_BLUR)){
+ editor.doSave(null);
+ }
+ }
+ };
+ projectionViewer.getTextWidget().addFocusListener(focusListener);
+ /*
+ * end of EDITOR_SAVE_ON_BLUR
+ * ed_mann
+ */
+
setWordWrap();
}