blob: 9dd6930c1c8ffd58928c1bfa43e816f60d9147a7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*******************************************************************************
* Copyright (c) 2000, 2005 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.make.ui.actions;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.dialogs.BuildTargetDialog;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.window.Window;
public class BuildTargetAction extends AbstractTargetAction {
public void run(IAction action) {
IContainer container = getSelectedContainer();
if (container != null) {
BuildTargetDialog dialog = new BuildTargetDialog(getShell(), container);
String name = null;
try {
name = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$
} catch (CoreException e) {
}
try {
if (name != null) {
IPath path = new Path(name);
name = path.segment(path.segmentCount() - 1);
IContainer targetContainer;
if (path.segmentCount() > 1) {
path = path.removeLastSegments(1);
targetContainer = (IContainer)container.findMember(path);
} else {
targetContainer = container;
}
IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(targetContainer, 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());
}
}
} catch (CoreException e) {
}
}
}
}
|