diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/CPropertyVarsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/CPropertyVarsTab.java index aa4c94a39d4..36807beef10 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/CPropertyVarsTab.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/CPropertyVarsTab.java @@ -31,6 +31,7 @@ import org.eclipse.cdt.internal.core.cdtvariables.UserDefinedVariableSupplier; import org.eclipse.cdt.ui.newui.AbstractCPropertyTab; import org.eclipse.cdt.ui.newui.CDTListComparator; import org.eclipse.cdt.ui.newui.NewUIMessages; +import org.eclipse.cdt.ui.newui.PrefPage_Abstract; import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor; import org.eclipse.core.runtime.CoreException; @@ -532,7 +533,9 @@ public class CPropertyVarsTab extends AbstractCPropertyTab { */ protected void performOK() { if (vars != null) try { - fUserSupplier.setWorkspaceVariables(vars); + if (fUserSupplier.setWorkspaceVariables(vars)) + if (page instanceof PrefPage_Abstract) + PrefPage_Abstract.isChanged = true; } catch (CoreException e) {} vars = null; super.performOK(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java index d753091146c..6667089b2b6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java @@ -160,8 +160,12 @@ public class ChangeBuildConfigActionBase { } // Check whether the project is CDT project if (project != null) { - ICConfigurationDescription[] tmp = getCfgs(project); - if (tmp == null || tmp.length == 0) project = null; + if (!CoreModel.getDefault().isNewStyleProject(project)) + project = null; + else { + ICConfigurationDescription[] tmp = getCfgs(project); + if (tmp == null || tmp.length == 0) project = null; + } } if (project != null) { fProjects.add(project); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java index fcec0ea69e1..88eff7671df 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java @@ -74,6 +74,10 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { if (res != null) { IProject p = res.getProject(); if (!p.isOpen()) continue; + + if (!CoreModel.getDefault().isNewStyleProject(p)) + continue; + IPath path = res.getProjectRelativePath(); // getting description in read-only mode ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java index e53e391aa84..131ef25f690 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java @@ -112,6 +112,7 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { private ICConfigurationDescription[] getCfgsRead(IResource res) { IProject p = res.getProject(); if (!p.isOpen()) return null; + if (!CoreModel.getDefault().isNewStyleProject(p)) return null; ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); if (prjd == null) return null; return prjd.getConfigurations(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java index 7b1284ef14a..83f9eb70062 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java @@ -61,6 +61,9 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { } if (prj != null) { + if (!CoreModel.getDefault().isNewStyleProject(prj)) + return false; + // 2 or more projects selected - cannot handle if (project != null && project != prj) { project = null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java index 176a8841d39..3dfc48b1b48 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java @@ -110,7 +110,7 @@ implements private static ICConfigurationDescription[] multiCfgs = null; // selected multi cfg private static ICProjectDescription prjd = null; private static int cfgIndex = 0; - private static boolean doneOK = false; +// private static boolean doneOK = false; // tabs private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.cPropertyTab"; //$NON-NLS-1$ public static final String ELEMENT_NAME = "tab"; //$NON-NLS-1$ @@ -123,7 +123,6 @@ implements private static final Object NOT_NULL = new Object(); public static final String EMPTY_STR = ""; //$NON-NLS-1$ - /* * Dialog widgets */ @@ -140,13 +139,14 @@ implements protected boolean isFolder = false; protected boolean isFile = false; protected boolean isMulti = false; + protected static int saveCounter = 0; // tabs - TabFolder folder; - ArrayList itabs = new ArrayList(); + protected TabFolder folder; + protected ArrayList itabs = new ArrayList(); ICPropertyTab currentTab; - class InternalTab { + protected class InternalTab { Composite comp; String text; String tip; @@ -182,8 +182,8 @@ implements public AbstractPage() { // reset static values before new session if (pages.size() == 0) { - doneOK = false; // see "performOk()" prjd = null; // force getting new descriptors + saveCounter = 0; // needs in performOK(); } // register current page if (!pages.contains(this)) pages.add(this); @@ -394,16 +394,21 @@ implements * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ public boolean performOk() { - if (doneOK || noContentOnPage || !displayedConfig) return true; + // this part is to be performed by every page + if (!noContentOnPage && displayedConfig) { + doInform(); + } + // checks whether it's a last page + if (++saveCounter < pages.size()) return true; + + // this part is to be performed once while OK pressed. IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { - forEach(ICPropertyTab.OK, null); - doneOK = true; // further pages need not to do anything - try { -// CoreModel.getDefault().setProjectDescription(getProject(), prjd); - CoreModel.getDefault().setProjectDescription(getProject(), prjd, true, monitor); + try { + doSave(monitor); } catch (CoreException e) { } - updateViews(internalElement); + if (!isForPrefs()) + updateViews(internalElement); } }; IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable); @@ -418,8 +423,24 @@ implements } catch (InterruptedException e) {} return true; } + + /** + * Action performed upon every page while OK pressed + * Normally, all tabs are informed about this action + */ + protected void doInform() { + forEach(ICPropertyTab.OK, null); + } - + /** + * Action performed once while OK pressed + * Assume that all pages are already informed. + * @param monitor + * @throws CoreException + */ + protected void doSave(IProgressMonitor monitor) throws CoreException { + CoreModel.getDefault().setProjectDescription(getProject(), prjd, true, monitor); + } /** * Apply changes for all tabs but for given page & current cfg only. @@ -897,13 +918,12 @@ implements // update views (in particular, display resource configurations) public static void updateViews(IResource res) { + if (res == null) return; IWorkbenchPartReference refs[] = CUIPlugin.getActiveWorkbenchWindow().getActivePage().getViewReferences(); for (int k = 0; k < refs.length; k++) { IWorkbenchPart part = refs[k].getPart(false); if (part != null && part instanceof IPropertyChangeListener) ((IPropertyChangeListener)part).propertyChange(new PropertyChangeEvent(res, PreferenceConstants.PREF_SHOW_CU_CHILDREN, null, null)); } -// WorkbenchPlugin.getDefault().getDecoratorManager().updateForEnablementChange(); } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java index 4567bac84b4..1a6919e6280 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java @@ -427,8 +427,11 @@ public class EnvironmentTab extends AbstractCPropertyTab { } protected void performOK() { - if (vars != null) - fUserSupplier.setWorkspaceEnvironment(vars); + if (vars != null) { + if (fUserSupplier.setWorkspaceEnvironment(vars)) + if (page instanceof PrefPage_Abstract) + PrefPage_Abstract.isChanged = true; + } vars = null; super.performOK(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java new file mode 100644 index 00000000000..fc725d81274 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.newui; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.cdt.core.model.CoreModel; + +/* This class is a base for preference pages + * which store data in preferences + * It means: + * - changes are saved by tabs, not by page + * - if changes are made, all projects are + * to be updated + */ +public class PrefPage_Abstract extends AbstractPrefPage { + + static public boolean isChanged; + + public PrefPage_Abstract() { + super(); + isChanged = false; + } + + protected void doSave(IProgressMonitor monitor) throws CoreException { + if (isChanged) { + CoreModel.getDefault().updateProjectDescriptions(null, monitor); + } + } + + protected String getHeader() { return null; } + protected boolean isSingle() { return true; } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Env.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Env.java index b15adfe5e27..b4b1e7fddda 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Env.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Env.java @@ -1,14 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.ui.newui; -public class PrefPage_Env extends AbstractPrefPage { - - protected boolean isSingle() { return true; } - - // Tabs themselves should save data - public boolean performOk() { - forEach(ICPropertyTab.OK, null); - return true; - } - - protected String getHeader() { return null; } +public class PrefPage_Env extends PrefPage_Abstract { } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Vars.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Vars.java index c81368db4c9..5a4c7543877 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Vars.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Vars.java @@ -1,14 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.ui.newui; -public class PrefPage_Vars extends AbstractPrefPage { - - protected boolean isSingle() { return true; } - protected String getHeader() { return null; } - - // Tabs themselves should save data - public boolean performOk() { - forEach(ICPropertyTab.OK, null); - return true; - } +public class PrefPage_Vars extends PrefPage_Abstract { }