package tool.builder;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
public class ToolNature implements IProjectNature {
public static final String PROJECT_FOLDER_NAME = "Projects";
public static final String LIBRARY_FOLDER_NAME = "Libraries";
public static final String UDS_LIBRARY_FOLDER_NAME = "UDS-Libraries";
public static final String REPOS_INTERFACE = ".reposInterface";
public static final String LOCAL_REPOS_FOLDER = ".localRepos";
public static final String PROJECT_QUALIFIED_NAME = "Tool";
public static final String REPOS_PROPERTY = "TOOL_REPOS";
public static final String ROOT_PROPERTY = "TOOL_ROOT";
public static final String LOGGER_PROPERTY = "TOOL_LOGGER";
public static final String WORKSPACE_PROPERTY = "TOOL_WORKSPACE";
public static final String WORKSPACE_PASSWORD_PROPERTY = "TOOL_WORKSPACE_PASSWORD";
public static final String REPOS_OBJECT = "TOOL_REPOS_OBJECT";
public static final String REPOS_SESSION_OBJECT = "TOOL_REPOS_SESSION_OBJECT";
public static final String PLAN_CACHE = "TOOL PLAN CACHE";
public static final String CURSOR_CACHE = "TOOL CURSOR CACHE";
public static final String SO_CACHE = "TOOL SERVICE OBJECT CACHE";
public static final String TYPE_CACHE = "TOOL TYPE CACHE";
public static final String COMPONENT_EXTENSIONS = "cla|CLA|wcl|WCL|ifc|IFC|sob|SOB|cur|CUR|con|CON";
public static final String DEFAULT_LOG_FLAGS = "\"%stdout(err:sh:* cfg:c4:23:* cfg:os:21 trc:ui:10:1)\"";
public static final String TOOL_PLAN_PROPERTY = "TOOL PLAN PROPERTY";
public static final QualifiedName toolPlanQualifiedName = new QualifiedName(PROJECT_QUALIFIED_NAME, TOOL_PLAN_PROPERTY);
public static final QualifiedName worspacePasswordQualifiedName = new QualifiedName(PROJECT_QUALIFIED_NAME, WORKSPACE_PASSWORD_PROPERTY);
public static final String SOURCE_FOLDER = "SourceFolder";
public static final QualifiedName sourceFolderQualifiedName = new QualifiedName(PROJECT_QUALIFIED_NAME, SOURCE_FOLDER);
public static final QualifiedName forteRootQualifiedName = new QualifiedName(PROJECT_QUALIFIED_NAME, ROOT_PROPERTY);
public static final QualifiedName loggerQualifiedName = new QualifiedName(PROJECT_QUALIFIED_NAME, LOGGER_PROPERTY);
public static final QualifiedName reposQualifiedName = new QualifiedName(PROJECT_QUALIFIED_NAME, REPOS_PROPERTY);
public static final QualifiedName workspaceQualifiedName = new QualifiedName(PROJECT_QUALIFIED_NAME, WORKSPACE_PROPERTY);
public static final String TOOL_PLAN_NAME = "ToolPlanName";
public static final QualifiedName toolPlanNameQualifiedName = new QualifiedName(PROJECT_QUALIFIED_NAME, TOOL_PLAN_NAME);
public static final QualifiedName fscriptInstanceQualifiedName = new QualifiedName(PROJECT_QUALIFIED_NAME, "FscriptInstance");
public static final QualifiedName repositoryStateQualifiedName = new QualifiedName(PROJECT_QUALIFIED_NAME, "Repository State");
/**
* ID of this project nature
*/
public static final String NATURE_ID = "ToolBuilder.toolNature";
private IProject project;
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#configure()
*/
public void configure() throws CoreException {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
for (int i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(FscriptBuilder.BUILDER_ID)) {
return;
}
}
ICommand[] newCommands = new ICommand[commands.length + 1];
System.arraycopy(commands, 0, newCommands, 0, commands.length);
ICommand command = desc.newCommand();
command.setBuilderName(FscriptBuilder.BUILDER_ID);
newCommands[newCommands.length - 1] = command;
desc.setBuildSpec(newCommands);
project.setDescription(desc, null);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#deconfigure()
*/
public void deconfigure() throws CoreException {
IProjectDescription description = getProject().getDescription();
ICommand[] commands = description.getBuildSpec();
for (int i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(FscriptBuilder.BUILDER_ID)) {
ICommand[] 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);
return;
}
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#getProject()
*/
public IProject getProject() {
return project;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
*/
public void setProject(IProject project) {
this.project = project;
}
}