Search in sources :

Example 16 with ProjectFileHandler

use of org.eclipse.titan.designer.properties.data.ProjectFileHandler in project titan.EclipsePlug-ins by eclipse.

the class WorkspaceHandlingLibrary method importProjectIntoWorkspace.

/**
 * Imports a "source directory"and all sub elements into the workspace as a project.
 * <p>
 * The source directory should be a valid project.
 * <p>
 * Please note that the name of the project can be different from the name of the directory.
 *
 * @param projectName the name of the project to be created
 * @param sourceLocation the location of the directory to be imported
 *
 * @return the imported project
 */
public static IProject importProjectIntoWorkspace(final String projectName, final URI sourceLocation) throws CoreException {
    assertNotNull(projectName);
    assertNotNull(sourceLocation);
    IProject project = workspace.getRoot().getProject(projectName);
    IProjectDescription description = workspace.newProjectDescription(projectName);
    description.setLocationURI(sourceLocation);
    project.create(description, null);
    project.open(null);
    ProjectFileHandler handler = new ProjectFileHandler(project);
    handler.loadProjectSettings();
    return project;
}
Also used : ProjectFileHandler(org.eclipse.titan.designer.properties.data.ProjectFileHandler) IProjectDescription(org.eclipse.core.resources.IProjectDescription) IProject(org.eclipse.core.resources.IProject)

Example 17 with ProjectFileHandler

use of org.eclipse.titan.designer.properties.data.ProjectFileHandler in project titan.EclipsePlug-ins by eclipse.

the class ConfigurationManagerControl method changeActualConfiguration.

/**
 * Changes the actually used configuration to the one being selected in
 * the configuration selector. Also loads all of the settings of the new
 * configuration into the project.
 */
public void changeActualConfiguration() {
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    ISchedulingRule rule = ruleFactory.createRule(project);
    try {
        Job.getJobManager().beginRule(rule, new NullProgressMonitor());
        actualConfiguration = configurations.getText();
        final HashSet<IResource> changedResources = new HashSet<IResource>();
        final Document document = ProjectDocumentHandlingUtility.getDocument(project);
        Node configurationNode = ProjectFileHandler.findConfigurationNode(document.getDocumentElement(), actualConfiguration);
        if (actualConfiguration == null) {
            ErrorReporter.logError("The configuration `" + actualConfiguration + "' for project `" + project.getName() + "' does not exist.");
        } else {
            ProjectFileHandler fileHandler = new ProjectFileHandler(project);
            fileHandler.loadProjectInfoFromNode(configurationNode, changedResources);
        }
    } finally {
        Job.getJobManager().endRule(rule);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProjectFileHandler(org.eclipse.titan.designer.properties.data.ProjectFileHandler) Node(org.w3c.dom.Node) IResourceRuleFactory(org.eclipse.core.resources.IResourceRuleFactory) Document(org.w3c.dom.Document) IResource(org.eclipse.core.resources.IResource) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) HashSet(java.util.HashSet)

Aggregations

ProjectFileHandler (org.eclipse.titan.designer.properties.data.ProjectFileHandler)17 CoreException (org.eclipse.core.runtime.CoreException)14 IProject (org.eclipse.core.resources.IProject)9 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 QualifiedName (org.eclipse.core.runtime.QualifiedName)7 IFile (org.eclipse.core.resources.IFile)6 IProjectDescription (org.eclipse.core.resources.IProjectDescription)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 HashSet (java.util.HashSet)4 IWorkspace (org.eclipse.core.resources.IWorkspace)4 URI (java.net.URI)3 IPath (org.eclipse.core.runtime.IPath)3 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)3 ArrayList (java.util.ArrayList)2 Path (org.eclipse.core.runtime.Path)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 Document (org.w3c.dom.Document)2 Node (org.w3c.dom.Node)2