1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-11 10:15:39 +02:00

Bug #177768 and other changes

This commit is contained in:
Oleg Krasilnikov 2007-03-19 15:40:55 +00:00
parent 17a776c11a
commit 6abbfb49f2
10 changed files with 123 additions and 42 deletions

View file

@ -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.AbstractCPropertyTab;
import org.eclipse.cdt.ui.newui.CDTListComparator; import org.eclipse.cdt.ui.newui.CDTListComparator;
import org.eclipse.cdt.ui.newui.NewUIMessages; 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.cdtvariables.CdtVariableResolver;
import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor; import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -532,7 +533,9 @@ public class CPropertyVarsTab extends AbstractCPropertyTab {
*/ */
protected void performOK() { protected void performOK() {
if (vars != null) try { if (vars != null) try {
fUserSupplier.setWorkspaceVariables(vars); if (fUserSupplier.setWorkspaceVariables(vars))
if (page instanceof PrefPage_Abstract)
PrefPage_Abstract.isChanged = true;
} catch (CoreException e) {} } catch (CoreException e) {}
vars = null; vars = null;
super.performOK(); super.performOK();

View file

@ -160,8 +160,12 @@ public class ChangeBuildConfigActionBase {
} }
// Check whether the project is CDT project // Check whether the project is CDT project
if (project != null) { if (project != null) {
ICConfigurationDescription[] tmp = getCfgs(project); if (!CoreModel.getDefault().isNewStyleProject(project))
if (tmp == null || tmp.length == 0) project = null; project = null;
else {
ICConfigurationDescription[] tmp = getCfgs(project);
if (tmp == null || tmp.length == 0) project = null;
}
} }
if (project != null) { if (project != null) {
fProjects.add(project); fProjects.add(project);

View file

@ -74,6 +74,10 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
if (res != null) { if (res != null) {
IProject p = res.getProject(); IProject p = res.getProject();
if (!p.isOpen()) continue; if (!p.isOpen()) continue;
if (!CoreModel.getDefault().isNewStyleProject(p))
continue;
IPath path = res.getProjectRelativePath(); IPath path = res.getProjectRelativePath();
// getting description in read-only mode // getting description in read-only mode
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);

View file

@ -112,6 +112,7 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
private ICConfigurationDescription[] getCfgsRead(IResource res) { private ICConfigurationDescription[] getCfgsRead(IResource res) {
IProject p = res.getProject(); IProject p = res.getProject();
if (!p.isOpen()) return null; if (!p.isOpen()) return null;
if (!CoreModel.getDefault().isNewStyleProject(p)) return null;
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
if (prjd == null) return null; if (prjd == null) return null;
return prjd.getConfigurations(); return prjd.getConfigurations();

View file

@ -61,6 +61,9 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
} }
if (prj != null) { if (prj != null) {
if (!CoreModel.getDefault().isNewStyleProject(prj))
return false;
// 2 or more projects selected - cannot handle // 2 or more projects selected - cannot handle
if (project != null && project != prj) { if (project != null && project != prj) {
project = null; project = null;

View file

@ -110,7 +110,7 @@ implements
private static ICConfigurationDescription[] multiCfgs = null; // selected multi cfg private static ICConfigurationDescription[] multiCfgs = null; // selected multi cfg
private static ICProjectDescription prjd = null; private static ICProjectDescription prjd = null;
private static int cfgIndex = 0; private static int cfgIndex = 0;
private static boolean doneOK = false; // private static boolean doneOK = false;
// tabs // tabs
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.cPropertyTab"; //$NON-NLS-1$ 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$ public static final String ELEMENT_NAME = "tab"; //$NON-NLS-1$
@ -123,7 +123,6 @@ implements
private static final Object NOT_NULL = new Object(); private static final Object NOT_NULL = new Object();
public static final String EMPTY_STR = ""; //$NON-NLS-1$ public static final String EMPTY_STR = ""; //$NON-NLS-1$
/* /*
* Dialog widgets * Dialog widgets
*/ */
@ -140,13 +139,14 @@ implements
protected boolean isFolder = false; protected boolean isFolder = false;
protected boolean isFile = false; protected boolean isFile = false;
protected boolean isMulti = false; protected boolean isMulti = false;
protected static int saveCounter = 0;
// tabs // tabs
TabFolder folder; protected TabFolder folder;
ArrayList itabs = new ArrayList(); protected ArrayList itabs = new ArrayList();
ICPropertyTab currentTab; ICPropertyTab currentTab;
class InternalTab { protected class InternalTab {
Composite comp; Composite comp;
String text; String text;
String tip; String tip;
@ -182,8 +182,8 @@ implements
public AbstractPage() { public AbstractPage() {
// reset static values before new session // reset static values before new session
if (pages.size() == 0) { if (pages.size() == 0) {
doneOK = false; // see "performOk()"
prjd = null; // force getting new descriptors prjd = null; // force getting new descriptors
saveCounter = 0; // needs in performOK();
} }
// register current page // register current page
if (!pages.contains(this)) pages.add(this); if (!pages.contains(this)) pages.add(this);
@ -394,16 +394,21 @@ implements
* @see org.eclipse.jface.preference.IPreferencePage#performOk() * @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/ */
public boolean 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() { IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) { public void run(IProgressMonitor monitor) {
forEach(ICPropertyTab.OK, null); try {
doneOK = true; // further pages need not to do anything doSave(monitor);
try {
// CoreModel.getDefault().setProjectDescription(getProject(), prjd);
CoreModel.getDefault().setProjectDescription(getProject(), prjd, true, monitor);
} catch (CoreException e) { } } catch (CoreException e) { }
updateViews(internalElement); if (!isForPrefs())
updateViews(internalElement);
} }
}; };
IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable); IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
@ -418,8 +423,24 @@ implements
} catch (InterruptedException e) {} } catch (InterruptedException e) {}
return true; 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. * Apply changes for all tabs but for given page & current cfg only.
@ -897,13 +918,12 @@ implements
// update views (in particular, display resource configurations) // update views (in particular, display resource configurations)
public static void updateViews(IResource res) { public static void updateViews(IResource res) {
if (res == null) return;
IWorkbenchPartReference refs[] = CUIPlugin.getActiveWorkbenchWindow().getActivePage().getViewReferences(); IWorkbenchPartReference refs[] = CUIPlugin.getActiveWorkbenchWindow().getActivePage().getViewReferences();
for (int k = 0; k < refs.length; k++) { for (int k = 0; k < refs.length; k++) {
IWorkbenchPart part = refs[k].getPart(false); IWorkbenchPart part = refs[k].getPart(false);
if (part != null && part instanceof IPropertyChangeListener) if (part != null && part instanceof IPropertyChangeListener)
((IPropertyChangeListener)part).propertyChange(new PropertyChangeEvent(res, PreferenceConstants.PREF_SHOW_CU_CHILDREN, null, null)); ((IPropertyChangeListener)part).propertyChange(new PropertyChangeEvent(res, PreferenceConstants.PREF_SHOW_CU_CHILDREN, null, null));
} }
// WorkbenchPlugin.getDefault().getDecoratorManager().updateForEnablementChange();
} }
} }

View file

@ -427,8 +427,11 @@ public class EnvironmentTab extends AbstractCPropertyTab {
} }
protected void performOK() { protected void performOK() {
if (vars != null) if (vars != null) {
fUserSupplier.setWorkspaceEnvironment(vars); if (fUserSupplier.setWorkspaceEnvironment(vars))
if (page instanceof PrefPage_Abstract)
PrefPage_Abstract.isChanged = true;
}
vars = null; vars = null;
super.performOK(); super.performOK();
} }

View file

@ -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; }
}

View file

@ -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; package org.eclipse.cdt.ui.newui;
public class PrefPage_Env extends AbstractPrefPage { public class PrefPage_Env extends PrefPage_Abstract {
protected boolean isSingle() { return true; }
// Tabs themselves should save data
public boolean performOk() {
forEach(ICPropertyTab.OK, null);
return true;
}
protected String getHeader() { return null; }
} }

View file

@ -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; package org.eclipse.cdt.ui.newui;
public class PrefPage_Vars extends AbstractPrefPage { public class PrefPage_Vars extends PrefPage_Abstract {
protected boolean isSingle() { return true; }
protected String getHeader() { return null; }
// Tabs themselves should save data
public boolean performOk() {
forEach(ICPropertyTab.OK, null);
return true;
}
} }