Search in sources :

Example 1 with IDataModelOperation

use of org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation in project webtools.sourceediting by eclipse.

the class SimpleWebFacetInstallDelegate method execute.

@Override
public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) throws CoreException {
    if (monitor != null)
        // $NON-NLS-1$
        monitor.beginTask("", 1);
    try {
        IDataModel model = (IDataModel) config;
        addNatures(project);
        final IVirtualComponent c = ComponentCore.createComponent(project, false);
        c.create(0, null);
        final IWorkspace ws = ResourcesPlugin.getWorkspace();
        final IPath pjpath = project.getFullPath();
        final IPath contentdir = setContentPropertyIfNeeded(model, pjpath, project);
        mkdirs(ws.getRoot().getFolder(contentdir));
        final IVirtualFolder webroot = c.getRootFolder();
        if (webroot.getProjectRelativePath().equals(new Path("/"))) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            webroot.createLink(new Path("/" + model.getStringProperty(ISimpleWebFacetInstallDataModelProperties.CONTENT_DIR)), 0, null);
        }
        ComponentUtilities.setServerContextRoot(project, model.getStringProperty(ISimpleWebFacetInstallDataModelProperties.CONTEXT_ROOT));
        try {
            ((IDataModelOperation) model.getProperty(FacetDataModelProvider.NOTIFICATION_OPERATION)).execute(monitor, null);
        } catch (ExecutionException e) {
            WSTWebPlugin.logError(e);
        }
    } finally {
        if (monitor != null)
            monitor.done();
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IWorkspace(org.eclipse.core.resources.IWorkspace) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent) ExecutionException(org.eclipse.core.commands.ExecutionException) IDataModelOperation(org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation)

Aggregations

ExecutionException (org.eclipse.core.commands.ExecutionException)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 IVirtualComponent (org.eclipse.wst.common.componentcore.resources.IVirtualComponent)1 IVirtualFolder (org.eclipse.wst.common.componentcore.resources.IVirtualFolder)1 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)1 IDataModelOperation (org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation)1