blob: 194c9605593cad66b3b6a126ca1fee8c500632c5 (
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
68
69
70
71
72
73
|
/*******************************************************************************
* Copyright (c) 2004, 2008 John Krasnay 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:
* John Krasnay - initial API and implementation
*******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.config;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
/**
* Project nature that defines Vex Plugin projects.
*/
public class PluginProjectNature implements IProjectNature {
public static final String ID = "org.eclipse.wst.xml.vex.ui.pluginNature"; //$NON-NLS-1$
public void configure() throws CoreException {
this.registerBuilder();
}
public void deconfigure() throws CoreException {
// System.out.println("deconfiguring " + project.getName());
project.deleteMarkers(IMarker.PROBLEM, true, 1);
}
public IProject getProject() {
return this.project;
}
public void setProject(IProject project) {
this.project = project;
}
// ====================================================== PRIVATE
private IProject project;
private void registerBuilder() throws CoreException {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
boolean found = false;
for (int i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(PluginProjectBuilder.ID)) {
found = true;
break;
}
}
if (!found) {
// add builder to project
ICommand command = desc.newCommand();
command.setBuilderName(PluginProjectBuilder.ID);
ICommand[] newCommands = new ICommand[commands.length + 1];
// Add it before other builders.
System.arraycopy(commands, 0, newCommands, 1, commands.length);
newCommands[0] = command;
desc.setBuildSpec(newCommands);
project.setDescription(desc, null);
}
}
}
|