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

1. Fix to not build the non-initialized project

2. small UI fixes
This commit is contained in:
Mikhail Sennikovsky 2007-06-06 15:45:47 +00:00
parent e7795ac42c
commit e8fa5343a0
6 changed files with 85 additions and 2 deletions

View file

@ -30,10 +30,12 @@ import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.ACBuilder; import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.util.ListComparator; import org.eclipse.cdt.core.settings.model.util.ListComparator;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer; import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2; import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
@ -467,6 +469,11 @@ public class CommonBuilder extends ACBuilder {
} }
} }
protected boolean isCdtProjectCreated(IProject project){
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project, false);
return des != null && !des.isCdtProjectCreating();
}
/** /**
* @see IncrementalProjectBuilder#build * @see IncrementalProjectBuilder#build
*/ */
@ -475,6 +482,9 @@ public class CommonBuilder extends ACBuilder {
IProject project = getProject(); IProject project = getProject();
if(!isCdtProjectCreated(project))
return project.getReferencedProjects();
if(VERBOSE) if(VERBOSE)
outputTrace(project.getName(), ">>build requested, type = " + kind); //$NON-NLS-1$ outputTrace(project.getName(), ">>build requested, type = " + kind); //$NON-NLS-1$
@ -488,6 +498,9 @@ public class CommonBuilder extends ACBuilder {
} }
protected IProject[] build(int kind, IProject project, IBuilder[] builders, boolean isForeground, IProgressMonitor monitor) throws CoreException{ protected IProject[] build(int kind, IProject project, IBuilder[] builders, boolean isForeground, IProgressMonitor monitor) throws CoreException{
if(!isCdtProjectCreated(project))
return project.getReferencedProjects();
int num = builders.length; int num = builders.length;
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
IConfiguration activeCfg = info.getDefaultConfiguration(); IConfiguration activeCfg = info.getDefaultConfiguration();
@ -1456,6 +1469,10 @@ public class CommonBuilder extends ACBuilder {
protected void clean(IProgressMonitor monitor) throws CoreException { protected void clean(IProgressMonitor monitor) throws CoreException {
IProject curProject = getProject(); IProject curProject = getProject();
if(!isCdtProjectCreated(curProject))
return;
IBuilder[] builders = ManagedBuilderCorePlugin.createBuilders(curProject, null); IBuilder[] builders = ManagedBuilderCorePlugin.createBuilders(curProject, null);
for(int i = 0; i < builders.length; i++){ for(int i = 0; i < builders.length; i++){
IBuilder builder = builders[i]; IBuilder builder = builders[i];

View file

@ -50,6 +50,7 @@ public class ChangeConfigAction extends Action {
while (iter.hasNext()) { while (iter.hasNext()) {
IProject prj = (IProject)iter.next(); IProject prj = (IProject)iter.next();
ICProjectDescription prjd = CDTPropertyManager.getProjectDescription(prj); ICProjectDescription prjd = CDTPropertyManager.getProjectDescription(prj);
boolean changed = false;
ICConfigurationDescription[] configs = prjd.getConfigurations(); ICConfigurationDescription[] configs = prjd.getConfigurations();
if (configs != null && configs.length > 0) { if (configs != null && configs.length > 0) {
for (int i = 0; i < configs.length; i++) { for (int i = 0; i < configs.length; i++) {
@ -57,10 +58,14 @@ public class ChangeConfigAction extends Action {
configs[i].setActive(); configs[i].setActive();
CDTPropertyManager.performOk(null); CDTPropertyManager.performOk(null);
AbstractPage.updateViews(prj); AbstractPage.updateViews(prj);
changed = true;
break; break;
} }
} }
} }
if(!changed)
CDTPropertyManager.performCancel(null);
} }
} }
} }

View file

@ -389,6 +389,9 @@ implements
public boolean performCancel() { public boolean performCancel() {
if (! noContentOnPage && displayedConfig) forEach(ICPropertyTab.CANCEL); if (! noContentOnPage && displayedConfig) forEach(ICPropertyTab.CANCEL);
CDTPropertyManager.performCancel(this);
return true; return true;
} }
public void performDefaults() { public void performDefaults() {

View file

@ -98,7 +98,24 @@ public class CDTPropertyManager {
*/ */
public static void performOk(Object p) { public static void performOk(Object p) {
if (saveDone) return; if (saveDone) return;
performOkForced(p); performOkForced(p);
if (pages.size() == 0) {
project = null;
prjd = null;
saveDone = false;
}
}
public static void performCancel(Object p) {
saveDone = true;
if (pages.size() == 0) {
project = null;
prjd = null;
saveDone = false;
}
} }
/** /**
@ -112,6 +129,12 @@ public class CDTPropertyManager {
} catch (CoreException e) { } catch (CoreException e) {
CUIPlugin.getDefault().logErrorMessage(UIMessages.getString("AbstractPage.11") + e.getLocalizedMessage()); //$NON-NLS-1$ CUIPlugin.getDefault().logErrorMessage(UIMessages.getString("AbstractPage.11") + e.getLocalizedMessage()); //$NON-NLS-1$
} }
if (pages.size() == 0) {
project = null;
prjd = null;
saveDone = false;
}
} }
// pages utilities // pages utilities
@ -137,6 +160,23 @@ public class CDTPropertyManager {
} }
} }
} }
if (pages.size() == 0) {
// if(!saveDone){
// if(prjd != null){
// saveDone = !prjd.isModified();
// }
// }
saveDone = true;
// if(saveDone){
project = null;
prjd = null;
saveDone = false;
// }
}
} }
} }

View file

@ -273,4 +273,8 @@ public class ManageConfigDialog extends Dialog {
table.setFocus(); table.setFocus();
updateButtons(); updateButtons();
} }
ICProjectDescription getProjectDescription(){
return des;
}
} }

View file

@ -12,8 +12,11 @@
package org.eclipse.cdt.ui.newui; package org.eclipse.cdt.ui.newui;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.window.Window; import org.eclipse.jface.window.Window;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
public class ManageConfigRunner implements IConfigManager { public class ManageConfigRunner implements IConfigManager {
@ -41,10 +44,21 @@ public class ManageConfigRunner implements IConfigManager {
boolean result = false; boolean result = false;
if (d.open() == Window.OK) { if (d.open() == Window.OK) {
if (doOk) { if (doOk) {
CDTPropertyManager.performOk(d.getShell()); // CDTPropertyManager.performOk(d.getShell());
ICProjectDescription des = d.getProjectDescription();
if(des != null){
try {
CoreModel.getDefault().setProjectDescription(obs[0], des);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} }
AbstractPage.updateViews(obs[0]); AbstractPage.updateViews(obs[0]);
result = true; result = true;
} else if (doOk) {
CDTPropertyManager.performCancel(d.getShell());
} }
return result; return result;
} }