mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fixed bug#43605
cleanup ui actions Create/Build target so they can be made availible though a hotkey
This commit is contained in:
parent
6b17a6477b
commit
4833b2d494
10 changed files with 217 additions and 180 deletions
|
@ -7,20 +7,22 @@ WizardNewCMakeProject.description=Create a new C Project which uses a simple mak
|
||||||
WizardNewCCMakeProject.name=Standard Make C++ Project
|
WizardNewCCMakeProject.name=Standard Make C++ Project
|
||||||
WizardNewCCMakeProject.description=Create a new C++ Project which uses a simple makefile.
|
WizardNewCCMakeProject.description=Create a new C++ Project which uses a simple makefile.
|
||||||
|
|
||||||
WizardConvertMakeProject.name=Convert to Make Project
|
WizardConvertMakeProject.name=Convert to a C/C++ Make Project
|
||||||
WizardConvertMakeProject.description=Convert a C/C++ Project to use a simple makefile
|
WizardConvertMakeProject.description=Convert to a C/C++ Project which uses a simple makefile
|
||||||
|
|
||||||
MenuMakeNew.label=Make Builds
|
|
||||||
|
|
||||||
ActionMakeCreateTarget.label=Create Make Target...
|
ActionMakeCreateTarget.label=Create Make Target...
|
||||||
ActionMakeBuildTarget.label=Build Make Target...
|
ActionMakeBuildTarget.label=Build Make Target...
|
||||||
|
|
||||||
ActionMakeUpdate.label=Update Old Make Project...
|
ActionMakeUpdate.label=Update Old Make Project...
|
||||||
|
ActionMakeUpdate.tooltip=Update Old Make Project
|
||||||
|
|
||||||
CommandMakeBuildCreate.name=Build/Create Make Target
|
CommandTargetBuild.name=Make Target Build
|
||||||
CommandMakeBuildCreate.description=Build or create a new make build target
|
CommandTargetBuild.description=Invoke a make target build for the selected container.
|
||||||
|
CommandTargetCreate.name=Create Make Target
|
||||||
|
CommandTargetCreate.description=Create a new make build target for the selected container.
|
||||||
|
|
||||||
PreferenceMakeProject.name=New Make Projects
|
PreferenceMakeProject.name=New Make Projects
|
||||||
|
|
||||||
PropertyMakeProject.name= C/C++ Make Project
|
PropertyMakeProject.name= C/C++ Make Project
|
||||||
|
|
||||||
ViewCatagoryMake.name=Make
|
ViewCatagoryMake.name=Make
|
||||||
|
@ -28,6 +30,3 @@ ViewMake.name=Make Targets
|
||||||
|
|
||||||
ActionSetMake.label=Make Actions
|
ActionSetMake.label=Make Actions
|
||||||
ActionSetUpdateMake.label=Update Make Projects
|
ActionSetUpdateMake.label=Update Make Projects
|
||||||
|
|
||||||
CommandMakeBuild.name=Make Target Build
|
|
||||||
CommandMakeBuild.description=Invoke a make target build for the selected container.
|
|
|
@ -39,12 +39,14 @@
|
||||||
icon="icons/ctool16/convert-normal.gif"
|
icon="icons/ctool16/convert-normal.gif"
|
||||||
category="org.eclipse.cdt.ui.newCWizards"
|
category="org.eclipse.cdt.ui.newCWizards"
|
||||||
class="org.eclipse.cdt.make.ui.wizards.ConvertToMakeProjectWizard"
|
class="org.eclipse.cdt.make.ui.wizards.ConvertToMakeProjectWizard"
|
||||||
project="true"
|
|
||||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||||
id="org.eclipse.cdt.ui.wizards.ConvertToMakeWizard">
|
id="org.eclipse.cdt.ui.wizards.ConvertToMakeWizard">
|
||||||
<description>
|
<description>
|
||||||
%MakeConversionWizard.description
|
%WizardConvertMakeProject.description
|
||||||
</description>
|
</description>
|
||||||
|
<selection
|
||||||
|
class="org.eclipse.core.resources.IProject">
|
||||||
|
</selection>
|
||||||
</wizard>
|
</wizard>
|
||||||
<!-- For C++ Wizards -->
|
<!-- For C++ Wizards -->
|
||||||
<wizard
|
<wizard
|
||||||
|
@ -64,12 +66,14 @@
|
||||||
icon="icons/ctool16/convert-normal.gif"
|
icon="icons/ctool16/convert-normal.gif"
|
||||||
category="org.eclipse.cdt.ui.newCCWizards"
|
category="org.eclipse.cdt.ui.newCCWizards"
|
||||||
class="org.eclipse.cdt.make.ui.wizards.ConvertToMakeProjectWizard"
|
class="org.eclipse.cdt.make.ui.wizards.ConvertToMakeProjectWizard"
|
||||||
project="true"
|
|
||||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||||
id="org.eclipse.cdt.ui.wizards.ConvertToMakeWizard">
|
id="org.eclipse.cdt.ui.wizards.ConvertToMakeWizard">
|
||||||
<description>
|
<description>
|
||||||
%MakeConversionWizard.description
|
%WizardConvertMakeProject.description
|
||||||
</description>
|
</description>
|
||||||
|
<selection
|
||||||
|
class="org.eclipse.core.resources.IProject">
|
||||||
|
</selection>
|
||||||
</wizard>
|
</wizard>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
|
@ -113,58 +117,20 @@
|
||||||
value="org.eclipse.cdt.make.core.makeNature">
|
value="org.eclipse.cdt.make.core.makeNature">
|
||||||
</filter>
|
</filter>
|
||||||
</objectContribution>
|
</objectContribution>
|
||||||
<objectContribution
|
|
||||||
objectClass="org.eclipse.core.resources.IProject"
|
|
||||||
adaptable="true"
|
|
||||||
id="org.eclipse.cdt.make.ui.popupMenu.UpdateContribution">
|
|
||||||
<visibility>
|
|
||||||
<and>
|
|
||||||
<not>
|
|
||||||
<objectState
|
|
||||||
name="nature"
|
|
||||||
value="org.eclipse.cdt.make.core.makeNature">
|
|
||||||
</objectState>
|
|
||||||
</not>
|
|
||||||
<objectState
|
|
||||||
name="nature"
|
|
||||||
value="org.eclipse.cdt.core.cnature">
|
|
||||||
</objectState>
|
|
||||||
<or>
|
|
||||||
<objectState
|
|
||||||
name="projectPersistentProperty"
|
|
||||||
value="org.eclipse.cdt.core.buildLocation">
|
|
||||||
</objectState>
|
|
||||||
<objectState
|
|
||||||
name="projectPersistentProperty"
|
|
||||||
value="org.eclipse.cdt.core.buildFullArguments">
|
|
||||||
</objectState>
|
|
||||||
<objectState
|
|
||||||
name="projectPersistentProperty"
|
|
||||||
value="org.eclipse.cdt.core.buildIncrementalArguments">
|
|
||||||
</objectState>
|
|
||||||
<objectState
|
|
||||||
name="projectPersistentProperty"
|
|
||||||
value="org.eclipse.cdt.make.goals">
|
|
||||||
</objectState>
|
|
||||||
</or>
|
|
||||||
</and>
|
|
||||||
</visibility>
|
|
||||||
<action
|
|
||||||
label="%ActionMakeUpdate.label"
|
|
||||||
icon="icons/ctool16/update_old.gif"
|
|
||||||
class="org.eclipse.cdt.make.ui.actions.UpdateMakeProjectAction"
|
|
||||||
enablesFor="+"
|
|
||||||
id="org.eclipse.cdt.make.ui.UpdateProjectMakeAction">
|
|
||||||
</action>
|
|
||||||
</objectContribution>
|
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.commands">
|
point="org.eclipse.ui.commands">
|
||||||
<command
|
<command
|
||||||
name="%CommandMakeBuild.name"
|
name="%CommandTargetBuild.name"
|
||||||
description="%CommandMakeBuild.description"
|
description="%CommandTargetBuild.description"
|
||||||
category="org.eclipse.ui.category.project"
|
category="org.eclipse.ui.category.project"
|
||||||
id="org.eclipse.cdt.make.ui.makeTargetCommand">
|
id="org.eclipse.cdt.make.ui.targetBuildCommand">
|
||||||
|
</command>
|
||||||
|
<command
|
||||||
|
name="%CommandTargetCreate.name"
|
||||||
|
description="%CommandTargetCreate.description"
|
||||||
|
category="org.eclipse.ui.category.project"
|
||||||
|
id="org.eclipse.cdt.make.ui.targetCreateCommand">
|
||||||
</command>
|
</command>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
|
@ -220,48 +186,56 @@
|
||||||
<and>
|
<and>
|
||||||
<not>
|
<not>
|
||||||
<objectState
|
<objectState
|
||||||
name="nature"
|
name="projectNature"
|
||||||
value="org.eclipse.cdt.make.core.makeNature">
|
value="org.eclipse.cdt.make.core.makeNature">
|
||||||
</objectState>
|
</objectState>
|
||||||
</not>
|
</not>
|
||||||
<objectState
|
<objectState
|
||||||
name="nature"
|
name="projectNature"
|
||||||
value="org.eclipse.cdt.core.cnature">
|
value="org.eclipse.cdt.core.cnature">
|
||||||
</objectState>
|
</objectState>
|
||||||
<or>
|
|
||||||
<objectState
|
|
||||||
name="projectPersistentProperty"
|
|
||||||
value="org.eclipse.cdt.core.buildLocation">
|
|
||||||
</objectState>
|
|
||||||
<objectState
|
|
||||||
name="projectPersistentProperty"
|
|
||||||
value="org.eclipse.cdt.core.buildFullArguments">
|
|
||||||
</objectState>
|
|
||||||
<objectState
|
|
||||||
name="projectPersistentProperty"
|
|
||||||
value="org.eclipse.cdt.core.buildIncrementalArguments">
|
|
||||||
</objectState>
|
|
||||||
<objectState
|
|
||||||
name="projectPersistentProperty"
|
|
||||||
value="org.eclipse.cdt.make.goals">
|
|
||||||
</objectState>
|
|
||||||
</or>
|
|
||||||
</and>
|
</and>
|
||||||
</enablement>
|
</enablement>
|
||||||
</action>
|
</action>
|
||||||
</actionSet>
|
</actionSet>
|
||||||
<actionSet
|
<actionSet
|
||||||
label="%ActionSetMakeTarget.name"
|
label="%ActionSetMake.label"
|
||||||
id="org.eclipse.cdt.make.ui.makeTargetActionSet">
|
id="org.eclipse.cdt.make.ui.makeTargetActionSet">
|
||||||
<action
|
<action
|
||||||
definitionId="org.eclipse.cdt.make.ui.makeTargetCommand"
|
definitionId="org.eclipse.cdt.make.ui.targetBuildCommand"
|
||||||
label="%ActionMakeBuildTarget.name"
|
label="%ActionMakeBuildTarget.label"
|
||||||
class="org.eclipse.cdt.make.ui.actions.BuildTargetAction"
|
class="org.eclipse.cdt.make.ui.actions.BuildTargetAction"
|
||||||
|
menubarPath="project/additions"
|
||||||
enablesFor="1"
|
enablesFor="1"
|
||||||
id="org.eclipse.cdt.make.ui.makeTargetAction">
|
id="org.eclipse.cdt.make.ui.makeTargetAction">
|
||||||
<selection
|
<enablement>
|
||||||
class="org.eclipse.core.resources.IContainer">
|
<or>
|
||||||
</selection>
|
<objectClass
|
||||||
|
name="org.eclipse.core.resources.IContainer">
|
||||||
|
</objectClass>
|
||||||
|
<objectClass
|
||||||
|
name="org.eclipse.cdt.core.model.ICContainer">
|
||||||
|
</objectClass>
|
||||||
|
</or>
|
||||||
|
</enablement>
|
||||||
|
</action>
|
||||||
|
<action
|
||||||
|
definitionId="org.eclipse.cdt.make.ui.targetCreateCommand"
|
||||||
|
label="%ActionMakeCreateTarget.label"
|
||||||
|
class="org.eclipse.cdt.make.ui.actions.CreateTargetAction"
|
||||||
|
menubarPath="project/additions"
|
||||||
|
enablesFor="1"
|
||||||
|
id="org.eclipse.cdt.make.ui.createTargetAction">
|
||||||
|
<enablement>
|
||||||
|
<or>
|
||||||
|
<objectClass
|
||||||
|
name="org.eclipse.core.resources.IContainer">
|
||||||
|
</objectClass>
|
||||||
|
<objectClass
|
||||||
|
name="org.eclipse.cdt.core.model.ICContainer">
|
||||||
|
</objectClass>
|
||||||
|
</or>
|
||||||
|
</enablement>
|
||||||
</action>
|
</action>
|
||||||
</actionSet>
|
</actionSet>
|
||||||
</extension>
|
</extension>
|
||||||
|
@ -296,6 +270,9 @@
|
||||||
<viewShortcut
|
<viewShortcut
|
||||||
id="org.eclipse.cdt.make.ui.views.MakeView">
|
id="org.eclipse.cdt.make.ui.views.MakeView">
|
||||||
</viewShortcut>
|
</viewShortcut>
|
||||||
|
<actionSet
|
||||||
|
id="org.eclipse.cdt.make.ui.makeTargetActionSet">
|
||||||
|
</actionSet>
|
||||||
</perspectiveExtension>
|
</perspectiveExtension>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ MakeCWizardSettings.description=Define the project and 'make' builder settings
|
||||||
MakeCCWizardSettings.title=C++/Make Project Settings
|
MakeCCWizardSettings.title=C++/Make Project Settings
|
||||||
MakeCCWizardSettings.description=Define the project and 'make' builder settings
|
MakeCCWizardSettings.description=Define the project and 'make' builder settings
|
||||||
|
|
||||||
|
WizardMakeProjectConversion.title=Convert to C/C++ Make project
|
||||||
|
WizardMakeProjectConversion.description=Convert a prject to a C/C++ project which uses 'make' to build it.
|
||||||
|
|
||||||
MakeWizardUpdate.window_title=Make Project Migration
|
MakeWizardUpdate.window_title=Make Project Migration
|
||||||
MakeWizardUpdatePage.title=Make Project Migration
|
MakeWizardUpdatePage.title=Make Project Migration
|
||||||
MakeWizardUpdatePage.description=Migrate older make projects to new make builder.
|
MakeWizardUpdatePage.description=Migrate older make projects to new make builder.
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Created on 25-Sep-2003
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.make.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
|
import org.eclipse.core.resources.IContainer;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.IObjectActionDelegate;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||||
|
import org.eclipse.ui.actions.ActionDelegate;
|
||||||
|
|
||||||
|
public abstract class AbstractTargetAction
|
||||||
|
extends ActionDelegate
|
||||||
|
implements IObjectActionDelegate, IWorkbenchWindowActionDelegate {
|
||||||
|
private IWorkbenchPart fPart;
|
||||||
|
private IWorkbenchWindow fWindow;
|
||||||
|
private IContainer fContainer;
|
||||||
|
|
||||||
|
protected Shell getShell() {
|
||||||
|
if (fPart != null) {
|
||||||
|
return fPart.getSite().getShell();
|
||||||
|
} else if (fWindow != null) {
|
||||||
|
return fWindow.getShell();
|
||||||
|
}
|
||||||
|
return MakeUIPlugin.getActiveWorkbenchShell();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IContainer getSelectedContainer() {
|
||||||
|
return fContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||||
|
fPart = targetPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(IWorkbenchWindow window) {
|
||||||
|
fWindow = window;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectionChanged(IAction action, ISelection selection) {
|
||||||
|
boolean enabled = false;
|
||||||
|
if (selection instanceof IStructuredSelection) {
|
||||||
|
IStructuredSelection sel = (IStructuredSelection) selection;
|
||||||
|
if (sel.getFirstElement() instanceof ICContainer) {
|
||||||
|
fContainer = (IContainer) ((ICContainer) sel.getFirstElement()).getUnderlyingResource();
|
||||||
|
} else if (sel.getFirstElement() instanceof IContainer) {
|
||||||
|
fContainer = (IContainer) sel.getFirstElement();
|
||||||
|
} else {
|
||||||
|
fContainer = null;
|
||||||
|
}
|
||||||
|
if (fContainer != null && MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(fContainer.getProject())) {
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
action.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,7 +8,6 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.make.ui.actions;
|
package org.eclipse.cdt.make.ui.actions;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICContainer;
|
|
||||||
import org.eclipse.cdt.make.core.IMakeTarget;
|
import org.eclipse.cdt.make.core.IMakeTarget;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
|
@ -19,39 +18,30 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.jface.window.Window;
|
import org.eclipse.jface.window.Window;
|
||||||
import org.eclipse.ui.IObjectActionDelegate;
|
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
|
||||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
|
||||||
import org.eclipse.ui.actions.ActionDelegate;
|
|
||||||
|
|
||||||
public class BuildTargetAction extends ActionDelegate implements IObjectActionDelegate, IWorkbenchWindowActionDelegate {
|
public class BuildTargetAction extends AbstractTargetAction {
|
||||||
|
|
||||||
IWorkbenchPart fPart;
|
|
||||||
IContainer fContainer;
|
|
||||||
|
|
||||||
public void run(IAction action) {
|
public void run(IAction action) {
|
||||||
if (fContainer != null) {
|
IContainer container = getSelectedContainer();
|
||||||
BuildTargetDialog dialog = new BuildTargetDialog(fPart.getSite().getShell(), fContainer);
|
if (container != null) {
|
||||||
|
BuildTargetDialog dialog = new BuildTargetDialog(getShell(), container);
|
||||||
String name = null;
|
String name = null;
|
||||||
try {
|
try {
|
||||||
name = (String) fContainer.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"));
|
name = (String) container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"));
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
if ( name != null) {
|
if ( name != null) {
|
||||||
IPath path = new Path(name);
|
IPath path = new Path(name);
|
||||||
name = path.segment(path.segmentCount() - 1);
|
name = path.segment(path.segmentCount() - 1);
|
||||||
IContainer container;
|
IContainer targetContainer;
|
||||||
if ( path.segmentCount() > 1) {
|
if ( path.segmentCount() > 1) {
|
||||||
path = path.removeLastSegments(1);
|
path = path.removeLastSegments(1);
|
||||||
container = (IContainer) fContainer.findMember(path);
|
targetContainer = (IContainer) container.findMember(path);
|
||||||
} else {
|
} else {
|
||||||
container = fContainer;
|
targetContainer = container;
|
||||||
}
|
}
|
||||||
IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(container, name);
|
IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(targetContainer, name);
|
||||||
if (target != null)
|
if (target != null)
|
||||||
dialog.setTarget(target);
|
dialog.setTarget(target);
|
||||||
}
|
}
|
||||||
|
@ -59,9 +49,9 @@ public class BuildTargetAction extends ActionDelegate implements IObjectActionDe
|
||||||
IMakeTarget target = dialog.getTarget();
|
IMakeTarget target = dialog.getTarget();
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
try {
|
try {
|
||||||
IPath path = target.getContainer().getProjectRelativePath().removeFirstSegments(fContainer.getProjectRelativePath().segmentCount());
|
IPath path = target.getContainer().getProjectRelativePath().removeFirstSegments(container.getProjectRelativePath().segmentCount());
|
||||||
path = path.append(target.getName());
|
path = path.append(target.getName());
|
||||||
fContainer.setSessionProperty(
|
container.setSessionProperty(
|
||||||
new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"),
|
new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"),
|
||||||
path.toString());
|
path.toString());
|
||||||
} catch (CoreException e1) {
|
} catch (CoreException e1) {
|
||||||
|
@ -71,23 +61,6 @@ public class BuildTargetAction extends ActionDelegate implements IObjectActionDe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
|
||||||
fPart = targetPart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(IWorkbenchWindow window) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
|
||||||
if (selection instanceof IStructuredSelection) {
|
|
||||||
IStructuredSelection sel = (IStructuredSelection) selection;
|
|
||||||
if (sel.getFirstElement() instanceof ICContainer) {
|
|
||||||
fContainer = (IContainer) ((ICContainer) sel.getFirstElement()).getUnderlyingResource();
|
|
||||||
} else if (sel.getFirstElement() instanceof IContainer) {
|
|
||||||
fContainer = (IContainer) sel.getFirstElement();
|
|
||||||
} else {
|
|
||||||
fContainer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,52 +8,20 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.make.ui.actions;
|
package org.eclipse.cdt.make.ui.actions;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICContainer;
|
|
||||||
import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog;
|
import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog;
|
||||||
import org.eclipse.core.resources.IContainer;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.ui.IObjectActionDelegate;
|
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
|
||||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
|
||||||
import org.eclipse.ui.actions.ActionDelegate;
|
|
||||||
|
|
||||||
public class CreateTargetAction extends ActionDelegate implements IObjectActionDelegate, IWorkbenchWindowActionDelegate {
|
public class CreateTargetAction extends AbstractTargetAction {
|
||||||
|
|
||||||
IWorkbenchPart fPart;
|
|
||||||
IContainer fContainer;
|
|
||||||
|
|
||||||
public void run(IAction action) {
|
public void run(IAction action) {
|
||||||
if ( fContainer != null ) {
|
if ( getSelectedContainer() != null ) {
|
||||||
MakeTargetDialog dialog;
|
MakeTargetDialog dialog;
|
||||||
try {
|
try {
|
||||||
dialog = new MakeTargetDialog(fPart.getSite().getShell(), fContainer);
|
dialog = new MakeTargetDialog(getShell(), getSelectedContainer());
|
||||||
dialog.open();
|
dialog.open();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
|
||||||
fPart = targetPart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(IWorkbenchWindow window) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
|
||||||
if ( selection instanceof IStructuredSelection ) {
|
|
||||||
IStructuredSelection sel = (IStructuredSelection)selection;
|
|
||||||
if ( sel.getFirstElement() instanceof ICContainer ) {
|
|
||||||
fContainer = (IContainer) ((ICContainer)sel.getFirstElement()).getUnderlyingResource();
|
|
||||||
} else if (sel.getFirstElement() instanceof IContainer ) {
|
|
||||||
fContainer = (IContainer)sel.getFirstElement();
|
|
||||||
} else {
|
|
||||||
fContainer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.core.resources.IResourceProxy;
|
||||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.OperationCanceledException;
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
@ -86,21 +87,14 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IProject[] getOldProjects() {
|
public static IProject[] getOldProjects() {
|
||||||
IProject[] project = MakeUIPlugin.getWorkspace().getRoot().getProjects();
|
IProject[] project = MakeUIPlugin.getWorkspace().getRoot().getProjects();
|
||||||
Vector result = new Vector();
|
Vector result = new Vector();
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < project.length; i++) {
|
for (int i = 0; i < project.length; i++) {
|
||||||
if (project[i].isAccessible()) {
|
if (isOldProject(project[i])) {
|
||||||
IProjectDescription desc = project[i].getDescription();
|
result.add(project[i]);
|
||||||
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) {
|
} catch (CoreException e) {
|
||||||
|
@ -110,6 +104,18 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
|
||||||
return (IProject[]) result.toArray(new IProject[result.size()]);
|
return (IProject[]) result.toArray(new IProject[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static boolean isOldProject(IProject project) throws CoreException {
|
||||||
|
if (project.isAccessible()) {
|
||||||
|
IProjectDescription desc = project.getDescription();
|
||||||
|
ICommand builder[] = desc.getBuildSpec();
|
||||||
|
for (int j = 0; j < builder.length; j++) {
|
||||||
|
if (builder[j].getBuilderName().equals(MakeCorePlugin.OLD_BUILDER_ID)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static public void run(boolean fork, IRunnableContext context, final IProject[] projects) {
|
static public void run(boolean fork, IRunnableContext context, final IProject[] projects) {
|
||||||
try {
|
try {
|
||||||
|
@ -135,7 +141,7 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
|
||||||
MakeUIPlugin.logException(e, "Error", "Error updating Make Projects");
|
MakeUIPlugin.logException(e, "Error", "Error updating Make Projects");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TargetConvertVisitor implements IResourceProxyVisitor {
|
public static class TargetConvertVisitor implements IResourceProxyVisitor {
|
||||||
private final int TOTAL_WORK = 100;
|
private final int TOTAL_WORK = 100;
|
||||||
private int halfWay = TOTAL_WORK / 2;
|
private int halfWay = TOTAL_WORK / 2;
|
||||||
|
@ -198,7 +204,7 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
|
||||||
new SubProgressMonitor(monitor, 1));
|
new SubProgressMonitor(monitor, 1));
|
||||||
|
|
||||||
// convert .cdtproject
|
// convert .cdtproject
|
||||||
CCorePlugin.getDefault().mapCProjectOwner(project[i], MakeCorePlugin.getUniqueIdentifier() + ".make", true);
|
CCorePlugin.getDefault().mapCProjectOwner(project[i], MakeCorePlugin.MAKE_PROJECT_ID, true);
|
||||||
// add new nature
|
// add new nature
|
||||||
MakeProjectNature.addNature(project[i], new SubProgressMonitor(monitor, 1));
|
MakeProjectNature.addNature(project[i], new SubProgressMonitor(monitor, 1));
|
||||||
|
|
||||||
|
@ -242,6 +248,20 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
public void selectionChanged(IAction action, ISelection selection) {
|
||||||
|
boolean enabled = false;
|
||||||
fSelection = selection;
|
fSelection = selection;
|
||||||
|
if (fSelection instanceof IStructuredSelection) {
|
||||||
|
Object sel = ((IStructuredSelection) fSelection).getFirstElement();
|
||||||
|
if (sel instanceof IAdaptable) {
|
||||||
|
IResource res = (IResource) ((IAdaptable) sel).getAdapter(IResource.class);
|
||||||
|
try {
|
||||||
|
if (res instanceof IProject && isOldProject((IProject) res)) {
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
action.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,11 @@ import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
*/
|
*/
|
||||||
public class ConvertToMakeProjectWizard extends ConversionWizard {
|
public class ConvertToMakeProjectWizard extends ConversionWizard {
|
||||||
|
|
||||||
private MakeProjectWizardOptionPage optionsPage;
|
|
||||||
private static final String WZ_TITLE = "WizardMakeProjectConversion.title"; //$NON-NLS-1$
|
private static final String WZ_TITLE = "WizardMakeProjectConversion.title"; //$NON-NLS-1$
|
||||||
private static final String WZ_DESC = "WizardMakeProjectConversion.description"; //$NON-NLS-1$
|
private static final String WZ_DESC = "WizardMakeProjectConversion.description"; //$NON-NLS-1$
|
||||||
private static final String PREFIX = "WizardMakeConversion"; //$NON-NLS-1$
|
private static final String PREFIX = "WizardMakeConversion"; //$NON-NLS-1$
|
||||||
private static final String WINDOW_TITLE = "WizardMakeConversion.windowTitle"; //$NON-NLS-1$
|
private static final String WINDOW_TITLE = "WizardMakeConversion.windowTitle"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String WZ_SETTINGS_TITLE = "WizardMakeProjectConversionSettings.title"; //$NON-NLS-1$
|
|
||||||
private static final String WZ_SETTINGS_DESC = "WizardMakeProjectConversionSettings.description"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConvertToStdMakeConversionWizard Wizard constructor
|
* ConvertToStdMakeConversionWizard Wizard constructor
|
||||||
*/
|
*/
|
||||||
|
@ -89,16 +85,18 @@ public class ConvertToMakeProjectWizard extends ConversionWizard {
|
||||||
*/
|
*/
|
||||||
public void addPages() {
|
public void addPages() {
|
||||||
addPage(mainPage = new ConvertToMakeProjectWizardPage(getPrefix()));
|
addPage(mainPage = new ConvertToMakeProjectWizardPage(getPrefix()));
|
||||||
addPage(optionsPage = new MakeProjectWizardOptionPage(MakeUIPlugin.getResourceString(WZ_SETTINGS_TITLE), MakeUIPlugin.getResourceString(WZ_SETTINGS_DESC)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProjectID() {
|
public String getProjectID() {
|
||||||
return MakeCorePlugin.getUniqueIdentifier() + ".make"; //$NON-NLS-1$
|
return MakeCorePlugin.MAKE_PROJECT_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doRun(IProgressMonitor monitor) throws CoreException {
|
protected void doRun(IProgressMonitor monitor) throws CoreException {
|
||||||
monitor.beginTask("Converting to Make Project...", 2);
|
monitor.beginTask("Converting to Make Project...", 2);
|
||||||
super.doRun(new SubProgressMonitor(monitor, 1));
|
try {
|
||||||
optionsPage.performApply(new SubProgressMonitor(monitor, 1));
|
super.doRun(new SubProgressMonitor(monitor, 1));
|
||||||
|
} finally {
|
||||||
|
monitor.done();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,17 @@ package org.eclipse.cdt.make.ui.wizards;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
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.ui.wizards.conversion.ConvertProjectWizardPage;
|
import org.eclipse.cdt.ui.wizards.conversion.ConvertProjectWizardPage;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -64,4 +72,24 @@ public class ConvertToMakeProjectWizardPage extends ConvertProjectWizardPage {
|
||||||
public boolean isCandidate(IProject project) {
|
public boolean isCandidate(IProject project) {
|
||||||
return true; // all
|
return true; // all
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void convertProject(IProject project, IProgressMonitor monitor, String projectID) throws CoreException {
|
||||||
|
monitor.beginTask("Converting Make project...", 3);
|
||||||
|
try {
|
||||||
|
super.convertProject(project, new SubProgressMonitor(monitor, 1), projectID);
|
||||||
|
MakeProjectNature.addNature(project, new SubProgressMonitor(monitor, 1));
|
||||||
|
CCorePlugin.getDefault().mapCProjectOwner(project, projectID, true);
|
||||||
|
} finally {
|
||||||
|
monitor.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createControl(Composite parent) {
|
||||||
|
super.createControl(parent);
|
||||||
|
IStructuredSelection sel = ((BasicNewResourceWizard)getWizard()).getSelection();
|
||||||
|
if ( sel != null) {
|
||||||
|
tableViewer.setCheckedElements(sel.toArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,6 @@ public abstract class NewMakeProjectWizard extends NewCProjectWizard {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProjectID() {
|
public String getProjectID() {
|
||||||
return MakeCorePlugin.getUniqueIdentifier() + ".make"; //$NON-NLS-1$
|
return MakeCorePlugin.MAKE_PROJECT_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue