diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml index 3fd917f70ba..002d57859e9 100644 --- a/build/org.eclipse.cdt.make.ui/plugin.xml +++ b/build/org.eclipse.cdt.make.ui/plugin.xml @@ -113,6 +113,7 @@ point="org.eclipse.ui.commands"> @@ -303,7 +304,6 @@ 1) { - path = path.removeLastSegments(1); - targetContainer = (IContainer)container.findMember(path); - } else { - targetContainer = container; - } - IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(targetContainer, name); + IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(container, name); if (target != null) dialog.setTarget(target); } if (dialog.open() == Window.OK) { IMakeTarget target = dialog.getTarget(); if (target != null) { - IPath path = - target.getContainer().getProjectRelativePath().removeFirstSegments( - container.getProjectRelativePath().segmentCount()); - path = path.append(target.getName()); - container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), //$NON-NLS-1$ - path.toString()); + container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), + TargetBuild.LAST_TARGET), target.getName()); + IPath path = target.getContainer().getProjectRelativePath(); + container.getProject().setSessionProperty( + new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), + TargetBuild.LAST_TARGET_CONTAINER), path.toString()); } } } catch (CoreException e) { diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetHandler.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetHandler.java new file mode 100644 index 00000000000..ebee40f2fbb --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetHandler.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2011 Axel Mueller and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Axel Mueller - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.make.ui.actions; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * Handler for {@link org.eclipse.cdt.make.ui.actions.BuildTargetAction} + * + * @since 7.1 + * + * @noextend This class is not intended to be subclassed by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public class BuildTargetHandler extends AbstractHandler { + + public Object execute(ExecutionEvent event) throws ExecutionException { + final BuildTargetAction buildAction= new BuildTargetAction(); + ISelection selection = HandlerUtil.getCurrentSelection( event ); + IWorkbenchPart part = HandlerUtil.getActivePart( event ); + buildAction.setActivePart(null, part); + buildAction.selectionChanged(null, selection); + + if (buildAction.isEnabled()) { + buildAction.run(null); + } + return null; + } + +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java index 364bfe90617..01053fa3186 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.make.core.IMakeTargetManager; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.cdt.make.internal.ui.MessageLine; +import org.eclipse.cdt.make.ui.TargetBuild; import org.eclipse.cdt.utils.ui.controls.ControlFactory; import org.eclipse.core.resources.IContainer; import org.eclipse.core.runtime.CoreException; @@ -493,15 +494,17 @@ public class MakeTargetDialog extends Dialog { String lastTargetName = null; IContainer container = target.getContainer(); try { - lastTargetName = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$ + lastTargetName = (String) container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), + TargetBuild.LAST_TARGET)); } catch (CoreException e) { } if (lastTargetName != null && lastTargetName.equals(target.getName())) { - IPath path = container.getProjectRelativePath().removeFirstSegments( - container.getProjectRelativePath().segmentCount()); - path = path.append(targetName); - container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), //$NON-NLS-1$ - path.toString()); + container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), + TargetBuild.LAST_TARGET), targetName); + IPath path = target.getContainer().getProjectRelativePath(); + container.getProject().setSessionProperty( + new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), + TargetBuild.LAST_TARGET_CONTAINER), path.toString()); } fTargetManager.renameTarget(target, targetName); diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java index dc3502873bd..44be9772a27 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java @@ -48,12 +48,17 @@ public class BuildTargetAction extends SelectionListenerAction { TargetBuild.buildTargets(shell, targets); // set last target property for last element IContainer container = targets[targets.length-1].getContainer(); - IPath path = container.getProjectRelativePath().removeFirstSegments( - container.getProjectRelativePath().segmentCount()); - path = path.append(targets[targets.length-1].getName()); try { - container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(),"lastTarget"), //$NON-NLS-1$ - path.toString()); + container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), + TargetBuild.LAST_TARGET), targets[targets.length - 1].getName()); + } catch (CoreException e) { + } + // store container of last target, too + try { + IPath path = container.getProjectRelativePath(); + container.getProject().setSessionProperty( + new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), + TargetBuild.LAST_TARGET_CONTAINER), path.toString()); } catch (CoreException e) { } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java index 96c56e86211..8f301a84816 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.core.IMakeTargetManager; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.make.ui.TargetBuild; import org.eclipse.core.resources.IContainer; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.QualifiedName; @@ -84,13 +85,19 @@ public class DeleteTargetAction extends SelectionListenerAction { String lastTargetName = null; IContainer container = ((IMakeTarget) target).getContainer(); try { - lastTargetName = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$ + lastTargetName = (String) container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), + TargetBuild.LAST_TARGET)); } catch (CoreException e) { } if (lastTargetName != null && lastTargetName.equals(((IMakeTarget) target).getName())) { try { container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), - "lastTarget"), null); //$NON-NLS-1$ + TargetBuild.LAST_TARGET), null); + } catch (CoreException e) { + } + try { + container.getProject().setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), + TargetBuild.LAST_TARGET_CONTAINER), null); } catch (CoreException e) { } }