/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* 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:
* Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.wgadesigner.natures;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import de.innovationgate.eclipse.utils.FileUtils;
import de.innovationgate.eclipse.wgadesigner.WGADesignerPlugin;
public class WGADesign implements IProjectNature {
private IProject _project;
public void configure() throws CoreException {
FileUtils.createFolder(_project, "design");
}
public void deconfigure() throws CoreException {
}
public IProject getProject() {
return _project;
}
public void setProject(IProject project) {
_project = project;
}
/**
* returns the name for this wga design
* @return
*/
public String getName() {
return _project.getName();
}
public IFolder getDesignFolder() {
return _project.getFolder("design");
}
public IFolder getTMLFolder() {
return getDesignFolder().getFolder("tml");
}
public static WGADesign fromSelection(ISelection selection) {
if (selection instanceof IStructuredSelection) {
IStructuredSelection structSelection = (IStructuredSelection) selection;
Object selectedElement = structSelection.getFirstElement();
if (selectedElement instanceof IProject) {
IProject project = (IProject) selectedElement;
try {
return (WGADesign) project.getNature(WGADesignerPlugin.NATURE_WGA_DESIGN);
} catch (Exception e) {
}
}
}
return null;
}
}