mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for [Bug 195160] Import hangs when importing project of version 3
This commit is contained in:
parent
9329353166
commit
2c81d31199
3 changed files with 109 additions and 76 deletions
|
@ -2026,7 +2026,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* Load the build information for the specified resource from its project
|
||||
* file. Pay attention to the version number too.
|
||||
*/
|
||||
private static ManagedBuildInfo loadBuildInfo(final IProject project) throws Exception {
|
||||
private static ManagedBuildInfo loadOldStyleBuildInfo(final IProject project) throws Exception {
|
||||
ManagedBuildInfo buildInfo = null;
|
||||
IFile file = project.getFile(SETTINGS_FILE_NAME);
|
||||
File cdtbuild = file.getLocation().toFile();
|
||||
|
@ -2644,7 +2644,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
|
||||
// try {
|
||||
// mngr.beginRule(rule, null);
|
||||
doSetLoaddedInfo(project, info);
|
||||
doSetLoaddedInfo(project, info, true);
|
||||
// } catch (IllegalArgumentException e) {
|
||||
// // TODO: set anyway for now
|
||||
// doSetLoaddedInfo(project, info);
|
||||
|
@ -2653,7 +2653,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
// }
|
||||
}
|
||||
|
||||
private synchronized static void doSetLoaddedInfo(IProject project, IManagedBuildInfo info){
|
||||
private synchronized static void doSetLoaddedInfo(IProject project, IManagedBuildInfo info, boolean overwrite){
|
||||
if(!overwrite && fInfoMap.get(project) != null)
|
||||
return;
|
||||
|
||||
if(info != null){
|
||||
fInfoMap.put(project, info);
|
||||
if(BuildDbgUtil.DEBUG)
|
||||
|
@ -2743,6 +2746,15 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
ManagedBuildInfo buildInfo = null;
|
||||
IProject proj = rc.getProject();
|
||||
|
||||
if(buildInfo == null){
|
||||
if(BuildDbgUtil.DEBUG)
|
||||
BuildDbgUtil.getInstance().traceln(BuildDbgUtil.BUILD_INFO_LOAD, "build info load: info is null, querying the update mngr"); //$NON-NLS-1$
|
||||
buildInfo = UpdateManagedProjectManager.getConvertedManagedBuildInfo(proj);
|
||||
}
|
||||
|
||||
if(buildInfo != null)
|
||||
return buildInfo;
|
||||
|
||||
// Check if there is any build info associated with this project for this session
|
||||
try {
|
||||
buildInfo = getLoaddedBuildInfo(proj);
|
||||
|
@ -2793,11 +2805,11 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
|
||||
|
||||
if(buildInfo == null){
|
||||
if(BuildDbgUtil.DEBUG)
|
||||
BuildDbgUtil.getInstance().traceln(BuildDbgUtil.BUILD_INFO_LOAD, "build info load: info is null, querying the update mngr"); //$NON-NLS-1$
|
||||
buildInfo = UpdateManagedProjectManager.getConvertedManagedBuildInfo(proj);
|
||||
}
|
||||
// if(buildInfo == null){
|
||||
// if(BuildDbgUtil.DEBUG)
|
||||
// BuildDbgUtil.getInstance().traceln(BuildDbgUtil.BUILD_INFO_LOAD, "build info load: info is null, querying the update mngr"); //$NON-NLS-1$
|
||||
// buildInfo = UpdateManagedProjectManager.getConvertedManagedBuildInfo(proj);
|
||||
// }
|
||||
}
|
||||
// if (buildInfo == null && resource instanceof IProject)
|
||||
// buildInfo = findBuildInfoSynchronized((IProject)resource, forceLoad);
|
||||
|
@ -2983,7 +2995,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
return getBuildInfo(resource, true);
|
||||
}
|
||||
|
||||
public static synchronized IManagedBuildInfo getOldStyleBuildInfo(IProject project) throws CoreException {
|
||||
public static IManagedBuildInfo getOldStyleBuildInfo(IProject project) throws CoreException {
|
||||
IManagedBuildInfo info = null;
|
||||
try {
|
||||
info = getLoaddedBuildInfo(project);
|
||||
|
@ -2992,10 +3004,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
|
||||
if(info == null){
|
||||
try {
|
||||
info = loadBuildInfo(project);
|
||||
info = loadOldStyleBuildInfo(project);
|
||||
|
||||
if(info != null)
|
||||
setLoaddedBuildInfo(project, info);
|
||||
doSetLoaddedInfo(project, info, false);
|
||||
} catch (Exception e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e));
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
|
|||
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
|
||||
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
|
||||
import org.eclipse.core.resources.ICommand;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -63,6 +62,11 @@ import org.eclipse.core.runtime.IStatus;
|
|||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||
|
||||
public class ProjectConverter implements ICProjectConverter {
|
||||
private final static String OLD_MAKE_BUILDER_ID = "org.eclipse.cdt.make.core.makeBuilder"; //$NON-NLS-1$
|
||||
|
@ -78,7 +82,6 @@ public class ProjectConverter implements ICProjectConverter {
|
|||
private final static String OLD_MAKE_TARGET_BUIDER_ID = "org.eclipse.cdt.make.MakeTargetBuilder"; //$NON-NLS-1$
|
||||
private final static String NEW_MAKE_TARGET_BUIDER_ID = "org.eclipse.cdt.build.MakeTargetBuilder"; //$NON-NLS-1$
|
||||
|
||||
private static final Object LOCK = new Object();
|
||||
private static ResourcePropertyHolder PROPS = new ResourcePropertyHolder(true);
|
||||
|
||||
private static String CONVERSION_FAILED_MSG_ID = "conversionFailed"; //$NON-NLS-1$
|
||||
|
@ -133,17 +136,13 @@ public class ProjectConverter implements ICProjectConverter {
|
|||
des.setConfigurationData(ManagedBuildManager.CFG_DATA_PROVIDER_ID, cfg.getConfigurationData());
|
||||
} else if(natureSet.contains(OLD_MNG_NATURE_ID)){
|
||||
try {
|
||||
synchronized (LOCK) {
|
||||
if(PROPS.getProperty(project, CONVERSION_FAILED_MSG_ID) != null)
|
||||
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), DataProviderMessages.getString("ProjectConverter.0"))); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
newDes = model.createProjectDescription(project, false);
|
||||
info = convertManagedBuildInfo(project, newDes);
|
||||
} catch (CoreException e) {
|
||||
synchronized (LOCK) {
|
||||
displayInfo(project, CONVERSION_FAILED_MSG_ID, DataProviderMessages.getString("ProjectConverter.10"), DataProviderMessages.getFormattedString("ProjectConverter.11", new String[]{project.getName(), e.getLocalizedMessage()})); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -235,11 +234,59 @@ public class ProjectConverter implements ICProjectConverter {
|
|||
|
||||
static void displayInfo(IProject proj, String id, String title, String message){
|
||||
if(PROPS.getProperty(proj, id) == null){
|
||||
UpdateManagedProjectManager.openInformation(title, message);
|
||||
openInformation(proj, id, title, message, false);
|
||||
PROPS.setProperty(proj, id, Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getBooleanFromQueryAnswer(String answer){
|
||||
if(IOverwriteQuery.ALL.equalsIgnoreCase(answer) ||
|
||||
IOverwriteQuery.YES.equalsIgnoreCase(answer))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static public boolean openQuestion(final IResource rc, final String id, final String title, final String message, IOverwriteQuery query, final boolean multiple){
|
||||
if(query != null)
|
||||
return getBooleanFromQueryAnswer(query.queryOverwrite(message));
|
||||
|
||||
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||
if(window == null){
|
||||
IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
window = windows[0];
|
||||
}
|
||||
|
||||
final Shell shell = window.getShell();
|
||||
final boolean [] answer = new boolean[1];
|
||||
shell.getDisplay().syncExec(new Runnable() {
|
||||
public void run() {
|
||||
if(multiple || PROPS.getProperty(rc, id) == null){
|
||||
PROPS.setProperty(rc, id, Boolean.TRUE);
|
||||
answer[0] = MessageDialog.openQuestion(shell,title,message);
|
||||
}
|
||||
}
|
||||
});
|
||||
return answer[0];
|
||||
}
|
||||
|
||||
static private void openInformation(final IResource rc, final String id, final String title, final String message, final boolean multiple){
|
||||
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||
if(window == null){
|
||||
IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
window = windows[0];
|
||||
}
|
||||
|
||||
final Shell shell = window.getShell();
|
||||
shell.getDisplay().syncExec(new Runnable() {
|
||||
public void run() {
|
||||
if(multiple || PROPS.getProperty(rc, id) == null){
|
||||
PROPS.setProperty(rc, id, Boolean.TRUE);
|
||||
MessageDialog.openInformation(shell,title,message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void convertMakeTargetInfo(final IProject project, ICProjectDescription des, IProgressMonitor monitor) throws CoreException{
|
||||
if(monitor == null)
|
||||
monitor = new NullProgressMonitor();
|
||||
|
@ -527,7 +574,7 @@ public class ProjectConverter implements ICProjectConverter {
|
|||
private IManagedBuildInfo convertManagedBuildInfo(IProject project, ICProjectDescription newDes) throws CoreException {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getOldStyleBuildInfo(project);
|
||||
|
||||
synchronized(LOCK){
|
||||
synchronized(PROPS){
|
||||
if(info != null && info.isValid()){
|
||||
IManagedProject mProj = info.getManagedProject();
|
||||
IConfiguration cfgs[] = mProj.getConfigurations();
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
|||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ProjectConverter;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -36,10 +37,6 @@ import org.eclipse.core.runtime.Path;
|
|||
import org.eclipse.core.runtime.PluginVersionIdentifier;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||
|
||||
public class UpdateManagedProjectManager {
|
||||
|
@ -68,13 +65,6 @@ public class UpdateManagedProjectManager {
|
|||
fUpdateProjectQuery = updateProjectQuery;
|
||||
}
|
||||
|
||||
private static boolean getBooleanFromQueryAnswer(String answer){
|
||||
if(IOverwriteQuery.ALL.equalsIgnoreCase(answer) ||
|
||||
IOverwriteQuery.YES.equalsIgnoreCase(answer))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
synchronized static private UpdateManagedProjectManager getUpdateManager(IProject project){
|
||||
UpdateManagedProjectManager mngr = getExistingUpdateManager(project);
|
||||
if(mngr == null)
|
||||
|
@ -184,10 +174,10 @@ public class UpdateManagedProjectManager {
|
|||
if (dstFile.exists()) {
|
||||
boolean shouldUpdate;
|
||||
if(query != null)
|
||||
shouldUpdate = getBooleanFromQueryAnswer(query.queryOverwrite(dstFile.getName()));
|
||||
shouldUpdate = ProjectConverter.getBooleanFromQueryAnswer(query.queryOverwrite(dstFile.getName()));
|
||||
else
|
||||
shouldUpdate = openQuestion(ConverterMessages.getResourceString("UpdateManagedProjectManager.0"), //$NON-NLS-1$
|
||||
ConverterMessages.getFormattedString("UpdateManagedProjectManager.1", new String[] {dstFile.getName(),project.getName()})); //$NON-NLS-1$
|
||||
shouldUpdate = ProjectConverter.openQuestion(fProject, "UpdateManagedProjectManager.0", ConverterMessages.getResourceString("UpdateManagedProjectManager.0"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ConverterMessages.getFormattedString("UpdateManagedProjectManager.1", new String[] {dstFile.getName(),project.getName()}), fOpenQuestionQuery, false); //$NON-NLS-1$
|
||||
|
||||
if (shouldUpdate) {
|
||||
dstFile.delete();
|
||||
|
@ -241,43 +231,27 @@ public class UpdateManagedProjectManager {
|
|||
}
|
||||
}
|
||||
|
||||
static private boolean openQuestion(final String title, final String message){
|
||||
if(fOpenQuestionQuery != null)
|
||||
return getBooleanFromQueryAnswer(fOpenQuestionQuery.queryOverwrite(message));
|
||||
// static private boolean openQuestion(IResource rc, final String title, final String message){
|
||||
// return ProjectConverter.openQuestion(rc, message, title, message, fOpenQuestionQuery, false);
|
||||
// }
|
||||
|
||||
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||
if(window == null){
|
||||
IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
window = windows[0];
|
||||
}
|
||||
|
||||
final Shell shell = window.getShell();
|
||||
final boolean [] answer = new boolean[1];
|
||||
shell.getDisplay().syncExec(new Runnable() {
|
||||
public void run() {
|
||||
answer[0] = MessageDialog.openQuestion(shell,title,message);
|
||||
}
|
||||
});
|
||||
return answer[0];
|
||||
}
|
||||
|
||||
static public void openInformation(final String title, final String message){
|
||||
if(fOpenQuestionQuery != null)
|
||||
return;// getBooleanFromQueryAnswer(fOpenQuestionQuery.queryOverwrite(message));
|
||||
|
||||
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||
if(window == null){
|
||||
IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
window = windows[0];
|
||||
}
|
||||
|
||||
final Shell shell = window.getShell();
|
||||
shell.getDisplay().syncExec(new Runnable() {
|
||||
public void run() {
|
||||
MessageDialog.openInformation(shell,title,message);
|
||||
}
|
||||
});
|
||||
}
|
||||
// static public void openInformation(final String title, final String message){
|
||||
// if(fOpenQuestionQuery != null)
|
||||
// return;// getBooleanFromQueryAnswer(fOpenQuestionQuery.queryOverwrite(message));
|
||||
//
|
||||
// IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||
// if(window == null){
|
||||
// IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
// window = windows[0];
|
||||
// }
|
||||
//
|
||||
// final Shell shell = window.getShell();
|
||||
// shell.getDisplay().syncExec(new Runnable() {
|
||||
// public void run() {
|
||||
// MessageDialog.openInformation(shell,title,message);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* returns ManagedBuildInfo for the current project
|
||||
|
@ -322,11 +296,11 @@ public class UpdateManagedProjectManager {
|
|||
|
||||
boolean shouldUpdate;
|
||||
if(fUpdateProjectQuery != null)
|
||||
shouldUpdate = getBooleanFromQueryAnswer(fUpdateProjectQuery.queryOverwrite(fProject.getFullPath().toString()));
|
||||
shouldUpdate = ProjectConverter.getBooleanFromQueryAnswer(fUpdateProjectQuery.queryOverwrite(fProject.getFullPath().toString()));
|
||||
else
|
||||
shouldUpdate = openQuestion(ConverterMessages.getResourceString("UpdateManagedProjectManager.3"), //$NON-NLS-1$
|
||||
ConverterMessages.getFormattedString("UpdateManagedProjectManager.4", new String[]{fProject.getName(),version.toString(),ManagedBuildManager.getBuildInfoVersion().toString()}) //$NON-NLS-1$
|
||||
);
|
||||
shouldUpdate = ProjectConverter.openQuestion(fProject, "UpdateManagedProjectManager.3", ConverterMessages.getResourceString("UpdateManagedProjectManager.3"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ConverterMessages.getFormattedString("UpdateManagedProjectManager.4", new String[]{fProject.getName(),version.toString(),ManagedBuildManager.getBuildInfoVersion().toString()}), //$NON-NLS-1$
|
||||
fOpenQuestionQuery, false);
|
||||
|
||||
if (!shouldUpdate){
|
||||
fIsInfoReadOnly = true;
|
||||
|
|
Loading…
Add table
Reference in a new issue