diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java index 5bdbf4196b8..df0dcb3764b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java @@ -23,14 +23,6 @@ import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; public class BracesTabPage extends FormatterTabPage { - /** - * Constant array for boolean selection - */ - private static String[] FALSE_TRUE = { - DefaultCodeFormatterConstants.FALSE, - DefaultCodeFormatterConstants.TRUE - }; - /** * Some C++ source code used for preview. */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java index cc01c049bb4..b32bd7da42d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,29 +20,10 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; - public class ControlStatementsTabPage extends FormatterTabPage { - /** - * Constant array for boolean selection - */ - private static String[] FALSE_TRUE = { - DefaultCodeFormatterConstants.FALSE, - DefaultCodeFormatterConstants.TRUE - }; - - /** - * Constant array for insert / not_insert. - */ - private static String[] DO_NOT_INSERT_INSERT = { - CCorePlugin.DO_NOT_INSERT, - CCorePlugin.INSERT - }; - - private final String PREVIEW= createPreviewHeader(FormatterMessages.ControlStatementsTabPage_preview_header) + "class Example {" + //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java index 9e9a8ba9867..4dcc42761d3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,7 +29,6 @@ import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess; public class FormatterProfileManager extends ProfileManager { - private static final List EMPTY_LIST = Collections.emptyList(); public final static String KANDR_PROFILE= "org.eclipse.cdt.ui.default.kandr_profile"; //$NON-NLS-1$ @@ -63,7 +62,7 @@ public class FormatterProfileManager extends ProfileManager { // Add the Profiles which are at default scope and hence are contributed by a product. try { - List defaultProfiles= new FormatterProfileStore(profileVersioner).readProfiles(new DefaultScope()); + List defaultProfiles= new FormatterProfileStore(profileVersioner).readProfiles(DefaultScope.INSTANCE); if (defaultProfiles != null) { Map profMap= new LinkedHashMap(); // Add the already loaded / created profiles to a map @@ -125,7 +124,7 @@ public class FormatterProfileManager extends ProfileManager { String profileId= instanceScope.getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null); if (profileId == null) { // request from bug 129427 - profileId= new DefaultScope().getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null); + profileId= DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null); // fix for bug 89739 // if (DEFAULT_PROFILE.equals(profileId)) { // default default: // IEclipsePreferences node= instanceScope.getNode(CCorePlugin.PLUGIN_ID); @@ -150,5 +149,4 @@ public class FormatterProfileManager extends ProfileManager { return p; return getProfile(DEFAULT_PROFILE); } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java index e95aff90101..b2d46ccaf32 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences.formatter; @@ -35,6 +36,13 @@ public abstract class FormatterTabPage extends ModifyDialogTabPage { */ protected static String[] TRUE_FALSE= { DefaultCodeFormatterConstants.TRUE, DefaultCodeFormatterConstants.FALSE }; + /** + * Constant array for boolean true/false selection. + * + * @since 5.3 + */ + protected static String[] FALSE_TRUE= { DefaultCodeFormatterConstants.FALSE, DefaultCodeFormatterConstants.TRUE }; + /** * Constant array for insert / not_insert. */ @@ -44,9 +52,9 @@ public abstract class FormatterTabPage extends ModifyDialogTabPage { private final IDialogSettings fDialogSettings; private Button fShowInvisibleButton; - public FormatterTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map workingValues) { + public FormatterTabPage(IModifyDialogTabPage.IModificationListener modifyListener, + Map workingValues) { super(modifyListener, workingValues); - fDialogSettings= CUIPlugin.getDefault().getDialogSettings(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java index 28735009d1b..2286cb752cd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * istvan@benedek-home.de - 103706 [formatter] indent empty lines - * Sergey Prigogin, Google + * Sergey Prigogin (Google) * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences.formatter; @@ -24,17 +24,8 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; - public class IndentationTabPage extends FormatterTabPage { - /** - * Constant array for boolean selection - */ - private static String[] FALSE_TRUE = { - DefaultCodeFormatterConstants.FALSE, - DefaultCodeFormatterConstants.TRUE - }; - /** * Some C++ source code used for preview. */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java index cfe1d6a3c44..c032bd1d8af 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,7 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Sergey Prigogin, Google + * Sergey Prigogin (Google) * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences.formatter; @@ -35,7 +35,6 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess; import org.eclipse.cdt.internal.ui.util.Messages; - /** * The model for the set of profiles which are available in the workbench. */ @@ -450,7 +449,7 @@ public abstract class ProfileManager extends Observable { String profileId= instanceScope.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null); if (profileId == null) { // request from bug 129427 - profileId= new DefaultScope().getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null); + profileId= DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null); } return profileId; } @@ -545,7 +544,6 @@ public abstract class ProfileManager extends Observable { } catch (BackingStoreException e) { // ignore } - } private boolean updatePreferences(IEclipsePreferences prefs, List keys, Map profileOptions) { @@ -567,7 +565,6 @@ public abstract class ProfileManager extends Observable { return hasChanges; } - /** * Update all formatter settings with the settings of the specified profile. * @param profile The profile to write to the preference store @@ -771,7 +768,6 @@ public abstract class ProfileManager extends Observable { notifyObservers(SETTINGS_CHANGED_EVENT); } - private void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) { IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects(); for (IProject project : projects) {