mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-09 19:43:27 +02:00
prompt for convertion on statup if workspace contains old make projects
This commit is contained in:
parent
c3f68d1518
commit
97ef2c67d1
4 changed files with 76 additions and 34 deletions
|
@ -271,10 +271,15 @@
|
||||||
name="Makefile Editor"
|
name="Makefile Editor"
|
||||||
icon="icons/ctool16/makefile.gif"
|
icon="icons/ctool16/makefile.gif"
|
||||||
filenames="Makefile,makefile"
|
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"
|
class="org.eclipse.cdt.make.internal.ui.editor.MakefileEditor"
|
||||||
id="org.eclipse.cdt.make.editor">
|
id="org.eclipse.cdt.make.editor">
|
||||||
</editor>
|
</editor>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.startup">
|
||||||
|
<startup>
|
||||||
|
</startup>
|
||||||
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -4,6 +4,8 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.ResourceBundle;
|
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.IWorkspace;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
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.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
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.Display;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.IStartup;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main plugin class to be used in the desktop.
|
* 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.
|
//The shared instance.
|
||||||
private static MakeUIPlugin plugin;
|
private static MakeUIPlugin plugin;
|
||||||
//Resource bundle.
|
//Resource bundle.
|
||||||
|
@ -178,4 +183,36 @@ public class MakeUIPlugin extends AbstractUIPlugin {
|
||||||
}
|
}
|
||||||
ErrorDialog.openError(shell, title, message, status);
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ package org.eclipse.cdt.make.ui.actions;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
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.core.MakeProjectNature;
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
import org.eclipse.cdt.make.ui.wizards.UpdateMakeProjectWizard;
|
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.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceProxy;
|
import org.eclipse.core.resources.IResourceProxy;
|
||||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||||
|
@ -84,6 +87,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) {
|
static public void run(boolean fork, IRunnableContext context, final IProject[] projects) {
|
||||||
try {
|
try {
|
||||||
context.run(fork, true, new IRunnableWithProgress() {
|
context.run(fork, true, new IRunnableWithProgress() {
|
||||||
|
|
|
@ -8,16 +8,11 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.make.ui.wizards;
|
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.MakeUIPlugin;
|
||||||
import org.eclipse.cdt.make.internal.ui.part.WizardCheckboxTablePart;
|
import org.eclipse.cdt.make.internal.ui.part.WizardCheckboxTablePart;
|
||||||
import org.eclipse.cdt.make.internal.ui.wizards.StatusWizardPage;
|
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.IProject;
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
||||||
|
@ -41,7 +36,7 @@ public class UpdateMakeProjectWizardPage extends StatusWizardPage {
|
||||||
|
|
||||||
public class MakeProjectContentProvider implements IStructuredContentProvider {
|
public class MakeProjectContentProvider implements IStructuredContentProvider {
|
||||||
public Object[] getElements(Object parent) {
|
public Object[] getElements(Object parent) {
|
||||||
return getProjects();
|
return UpdateMakeProjectAction.getOldProjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
@ -112,31 +107,9 @@ public class UpdateMakeProjectWizardPage extends StatusWizardPage {
|
||||||
updateStatus(genStatus);
|
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() {
|
private IStatus validatePlugins() {
|
||||||
Object[] allModels = getProjects();
|
Object[] allModels = UpdateMakeProjectAction.getOldProjects();
|
||||||
if (allModels == null || allModels.length == 0) {
|
if (allModels == null || allModels.length == 0) {
|
||||||
return createStatus(IStatus.ERROR, "No projects to update");
|
return createStatus(IStatus.ERROR, "No projects to update");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue