use of org.eclipse.core.resources.ICommand in project che by eclipse.
the class Project method getDescription.
@Override
public IProjectDescription getDescription() throws CoreException {
return new IProjectDescription() {
@Override
public IBuildConfiguration[] getBuildConfigReferences(String s) {
return new IBuildConfiguration[0];
}
@Override
public ICommand[] getBuildSpec() {
return new ICommand[0];
}
@Override
public String getComment() {
return null;
}
@Override
public IProject[] getDynamicReferences() {
return new IProject[0];
}
@Override
public IPath getLocation() {
return null;
}
@Override
public URI getLocationURI() {
return null;
}
@Override
public String getName() {
return null;
}
@Override
public String[] getNatureIds() {
RegisteredProject project = workspace.getProjectRegistry().getProject(path.toString());
if (project == null) {
ResourcesPlugin.log(new Status(IStatus.ERROR, "resource", "Can't find project: " + path.toOSString()));
return new String[0];
}
Map<String, List<String>> attributes = project.getAttributes();
String language = "";
if (attributes.containsKey("language")) {
language = attributes.get("language").get(0);
}
return "java".equals(language) ? new String[] { "org.eclipse.jdt.core.javanature" } : new String[] { language };
}
@Override
public IProject[] getReferencedProjects() {
return new IProject[0];
}
@Override
public boolean hasNature(String s) {
String[] natureIds = getNatureIds();
for (String id : natureIds) {
if (s.equals(id)) {
return true;
}
}
return false;
}
@Override
public ICommand newCommand() {
return null;
}
@Override
public void setActiveBuildConfig(String s) {
}
@Override
public void setBuildConfigs(String[] strings) {
}
@Override
public void setBuildConfigReferences(String s, IBuildConfiguration[] iBuildConfigurations) {
}
@Override
public void setBuildSpec(ICommand[] iCommands) {
}
@Override
public void setComment(String s) {
}
@Override
public void setDynamicReferences(IProject[] iProjects) {
}
@Override
public void setLocation(IPath iPath) {
}
@Override
public void setLocationURI(URI uri) {
}
@Override
public void setName(String s) {
}
@Override
public void setNatureIds(String[] strings) {
}
@Override
public void setReferencedProjects(IProject[] iProjects) {
}
};
}
use of org.eclipse.core.resources.ICommand in project ow by vtst.
the class Utils method setProjectBuilder.
/**
* Set or remove a builder to a project.
* @param project The project.
* @param builderName The ID of the builder.
* @param status true to set the builder, false to remove it.
* @throws CoreException
*/
public static void setProjectBuilder(IProject project, String builderName, boolean status) throws CoreException {
IProjectDescription description = project.getDescription();
ICommand[] commands = description.getBuildSpec();
int i;
for (i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(builderName))
break;
}
if (status == (i < commands.length))
return;
ICommand[] newCommands;
if (status) {
newCommands = new ICommand[commands.length + 1];
System.arraycopy(commands, 0, newCommands, 0, commands.length);
ICommand command = description.newCommand();
command.setBuilderName(builderName);
newCommands[commands.length] = command;
} else {
newCommands = new ICommand[commands.length - 1];
System.arraycopy(commands, 0, newCommands, 0, i);
System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
}
description.setBuildSpec(newCommands);
project.setDescription(description, null);
}
use of org.eclipse.core.resources.ICommand in project sling by apache.
the class ProjectDescriptionManager method enableValidationBuilderAndCommand.
public void enableValidationBuilderAndCommand(IProject project, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
ICommand[] builders = description.getBuildSpec();
for (ICommand builder : builders) {
if (builder.getBuilderName().equals(VALIDATION_BUILDER_NAME)) {
logger.trace("Validation builder already installed, skipping");
return;
}
}
logger.trace("Installing validation builder");
ICommand[] newBuilders = new ICommand[builders.length + 1];
System.arraycopy(builders, 0, newBuilders, 0, builders.length);
ICommand validationCommand = description.newCommand();
validationCommand.setBuilderName(VALIDATION_BUILDER_NAME);
newBuilders[newBuilders.length - 1] = validationCommand;
description.setBuildSpec(newBuilders);
project.setDescription(description, monitor);
logger.trace("Installed validation builder");
}
use of org.eclipse.core.resources.ICommand in project bndtools by bndtools.
the class BndProjectNature method removeBuilder.
private static void removeBuilder(IProjectDescription desc) {
ICommand[] commands = desc.getBuildSpec();
List<ICommand> nu = new ArrayList<ICommand>();
for (ICommand command : commands) {
if (!command.getBuilderName().equals(BndtoolsConstants.BUILDER_ID)) {
nu.add(command);
}
}
desc.setBuildSpec(nu.toArray(new ICommand[0]));
}
use of org.eclipse.core.resources.ICommand in project bndtools by bndtools.
the class BndProjectNature method addBuilder.
private static void addBuilder(IProjectDescription desc) {
ICommand[] commands = desc.getBuildSpec();
for (ICommand command : commands) {
if (command.getBuilderName().equals(BndtoolsConstants.BUILDER_ID))
return;
}
ICommand[] nu = new ICommand[commands.length + 1];
System.arraycopy(commands, 0, nu, 0, commands.length);
ICommand command = desc.newCommand();
command.setBuilderName(BndtoolsConstants.BUILDER_ID);
nu[commands.length] = command;
desc.setBuildSpec(nu);
}
Aggregations