1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

prompt for convertion on statup if workspace contains old make projects

This commit is contained in:
David Inglis 2003-09-16 18:18:36 +00:00
parent c3f68d1518
commit 97ef2c67d1
4 changed files with 76 additions and 34 deletions

View file

@ -271,10 +271,15 @@
name="Makefile Editor"
icon="icons/ctool16/makefile.gif"
filenames="Makefile,makefile"
contributorClass="org.eclipse.cdt.make.internal.ui.editor.MakefileEditorActionContributor"
contributorClass="org.eclipse.cdt.make.internal.ui.editor.MakefileEditorActionContributor"
class="org.eclipse.cdt.make.internal.ui.editor.MakefileEditor"
id="org.eclipse.cdt.make.editor">
</editor>
</extension>
<extension
point="org.eclipse.ui.startup">
<startup>
</startup>
</extension>
</plugin>

View file

@ -4,6 +4,8 @@ import java.lang.reflect.InvocationTargetException;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.cdt.make.ui.actions.UpdateMakeProjectAction;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@ -11,15 +13,18 @@ import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* The main plugin class to be used in the desktop.
*/
public class MakeUIPlugin extends AbstractUIPlugin {
public class MakeUIPlugin extends AbstractUIPlugin implements IStartup {
//The shared instance.
private static MakeUIPlugin plugin;
//Resource bundle.
@ -63,7 +68,7 @@ public class MakeUIPlugin extends AbstractUIPlugin {
public static IWorkbenchWindow getActiveWorkbenchWindow() {
return getDefault().getWorkbench().getActiveWorkbenchWindow();
}
/**
* Returns the string from the plugin's resource bundle,
* or 'key' if not found.
@ -146,7 +151,7 @@ public class MakeUIPlugin extends AbstractUIPlugin {
status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), e);
log(status);
}
/**
* Utility method with conventions
*/
@ -178,4 +183,36 @@ public class MakeUIPlugin extends AbstractUIPlugin {
}
ErrorDialog.openError(shell, title, message, status);
}
public void earlyStartup() {
final IProject[] oldProject = UpdateMakeProjectAction.getOldProjects();
if (oldProject.length > 0) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (MessageDialog
.openQuestion(
getShell(),
"Update make projects",
"Older 'make' projects have been detected in your workspace. \n"
+ "These projects are no longer supported, "
+ "would you like to convert these now?")
== true) {
ProgressMonitorDialog pd = new ProgressMonitorDialog(getShell());
UpdateMakeProjectAction.run(false, pd, oldProject);
}
}
});
}
return;
}
protected Shell getShell() {
if (getActiveWorkbenchShell() != null) {
return getActiveWorkbenchShell();
} else {
IWorkbenchWindow[] windows = getDefault().getWorkbench().getWorkbenchWindows();
return windows[0].getShell();
}
}
}

View file

@ -10,6 +10,7 @@ package org.eclipse.cdt.make.ui.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Vector;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICProject;
@ -21,9 +22,11 @@ import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.wizards.UpdateMakeProjectWizard;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
@ -83,6 +86,30 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
}
}
public static IProject[] getOldProjects() {
IProject[] project = MakeUIPlugin.getWorkspace().getRoot().getProjects();
Vector result = new Vector();
try {
for (int i = 0; i < project.length; i++) {
if (project[i].isAccessible()) {
IProjectDescription desc = project[i].getDescription();
ICommand builder[] = desc.getBuildSpec();
for (int j = 0; j < builder.length; j++) {
if (builder[j].getBuilderName().equals(MakeCorePlugin.OLD_BUILDER_ID)) {
result.add(project[i]);
break;
}
}
}
}
} catch (CoreException e) {
MakeUIPlugin.logException(e);
}
return (IProject[]) result.toArray(new IProject[result.size()]);
}
static public void run(boolean fork, IRunnableContext context, final IProject[] projects) {
try {

View file

@ -8,16 +8,11 @@
***********************************************************************/
package org.eclipse.cdt.make.ui.wizards;
import java.util.Vector;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.part.WizardCheckboxTablePart;
import org.eclipse.cdt.make.internal.ui.wizards.StatusWizardPage;
import org.eclipse.core.resources.ICommand;
import org.eclipse.cdt.make.ui.actions.UpdateMakeProjectAction;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.CheckboxTableViewer;
@ -41,7 +36,7 @@ public class UpdateMakeProjectWizardPage extends StatusWizardPage {
public class MakeProjectContentProvider implements IStructuredContentProvider {
public Object[] getElements(Object parent) {
return getProjects();
return UpdateMakeProjectAction.getOldProjects();
}
public void dispose() {
@ -112,31 +107,9 @@ public class UpdateMakeProjectWizardPage extends StatusWizardPage {
updateStatus(genStatus);
}
protected IProject[] getProjects() {
IProject[] project = MakeUIPlugin.getWorkspace().getRoot().getProjects();
Vector result = new Vector();
try {
for (int i = 0; i < project.length; i++) {
if (project[i].isAccessible()) {
IProjectDescription desc = project[i].getDescription();
ICommand builder[] = desc.getBuildSpec();
for (int j = 0; j < builder.length; j++) {
if (builder[j].getBuilderName().equals(MakeCorePlugin.OLD_BUILDER_ID)) {
result.add(project[i]);
break;
}
}
}
}
} catch (CoreException e) {
MakeUIPlugin.logException(e);
}
return (IProject[]) result.toArray(new IProject[result.size()]);
}
private IStatus validatePlugins() {
Object[] allModels = getProjects();
Object[] allModels = UpdateMakeProjectAction.getOldProjects();
if (allModels == null || allModels.length == 0) {
return createStatus(IStatus.ERROR, "No projects to update");
}