`
yianpuodiaotu
  • 浏览: 237667 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

How to create dynamic web project using facets

Web 
阅读更多

To create a blank faceted project, you can use one of the ProjectFacetsManager.create() methods.

Once the project is created you will need to set fixed facets (those facets that the user cannot deselect (WTP sets jst.java and jst.web for the Dynamic Web Project as fixed) and set the runtime. You can do this using setFixedProjectFacets() and addTargetedRuntime() methods of IFacetedProject.

The next step is to install facets. You can do that using the modify method of IFacetedProject or the convenience method installProjectFacet.

Now your project is created and configured.

/**
	 * Install Fixed Facet,for example:jst.web
	 * @param project
	 *            the project on which to install facets
	 * @param facets
	 *            the name of the facet
	 * @param monitor
	 *            a progress monitor
	 * @throws CoreException
	 */
	public static void setFixedFacet(IProject project,String facets[],IProgressMonitor monitor) throws CoreException {
		List<IProjectFacet> list = new ArrayList<IProjectFacet>();
		IProjectFacet facet; 
		for(String str :facets ){
			facet = ProjectFacetsManager.getProjectFacet(str);
			list.add(facet);
		}
		SubMonitor.convert(monitor, 1);
		
		try {
			IFacetedProject facetedProject = ProjectFacetsManager.create(project);
			facetedProject.setFixedProjectFacets(new HashSet<IProjectFacet>(list));
		} finally {
			monitor.done();
		}
	}
	
	/**
	 * Install Facet,for example: the Java Facet.
	 * 
	 * @param project
	 *            the project on which to install facets
	 * @param facet
	 *            the name of the facet
	 * @param monitor
	 *            a progress monitor
	 * @throws CoreException
	 */
	@SuppressWarnings("deprecation")
	public static void installFacet(IProject project,String facet,IProgressMonitor monitor) throws CoreException {
		final IProjectFacet targetProjectFacet = ProjectFacetsManager.getProjectFacet(facet);
		IFacetedProject facetedProject = ProjectFacetsManager.create(project);
		
		if (!facetedProject.hasProjectFacet(targetProjectFacet)) {// settings
			SubMonitor progress = SubMonitor.convert(monitor, 1);
			try {
				progress.subTask("install facets"); //$NON-NLS-1$
				IProjectFacetVersion defaultVersion = targetProjectFacet.getDefaultVersion();
				
				facetedProject.installProjectFacet(defaultVersion, null, progress);
			} finally {
				monitor.done();
			}
		}
	}

 

 

分享到:
评论

相关推荐

    professional visual studio 2008

    How to build web applications using ASP.NET AJAX, Silverlight, and ASP.NET MVC Ideas for building Office and Mobile applications, WPF, WCF, and WF projects Ways to effectively analyze and identify ...

    Learning.Bootstrap

    Unearth the potential of Bootstrap to create responsive web pages using modern techniques About This Book Understand the various facets of Bootstrap 3.x such as Base CSS and Components in a pragmatic...

    Mastering Windows 8 C++ App Development

    "Mastering Windows 8 C++ App Development" shows you how to create Windows Store apps that use many of the new features and functionality available for Windows 8. You'll discover how you can harness ...

    eclipse支持jdk 1.8 compiler 支持JDK1.8 project facets 支持JDK1.8 集成svn,maven工具

    eclipse支持jdk 1.8 compiler 支持JDK1.8 project facets 支持JDK1.8 找了很久终于找到了,免安装的,拿过去就可以用,集成svn,maven,git等工具

    Learning Bootstrap

    Learn about components, jQuery plugins, and other unique features that make Bootstrap an amazing utility to create remarkable web pages. Get to grips with the Bootstrap technical hub, which hosts the...

    Beginning PHP and MySQL: From Novice to Professional, 5th Edition

    Anyone who wants to get started using PHP to write dynamic web applications. Table of Contents Chapter 1: Introducing PHP Chapter 2: Configuring Your Environment Chapter 3: PHP Basics Chapter 4: ...

    Learning Redis

    By working with real world scenarios pertaining to using Redis, you will discover sharding and indexing techniques, along with how to improve scalability and performance through persistent strategies...

    Rails for .NET Developers (Facets of Ruby)

    You'll come to learn the joy and power inherent in the "convention over configuration" philosophy, the natural elegance of the MVC architecture, and the essence of REST-based design as you develop ...

    Exploring C++ 11

    Put everything together to create sophisticated programs that work with pointers, dynamic memory and overloaded functions to achieve the results you want. Who this book is for Read this book if you ...

    Android.Database.Best.Practices.0134437993

    Through a complete case study, you’ll learn how to design your data access layer to simplify all facets of data management and avoid unwanted technical debt. You’ll also find detailed solutions for ...

    多面Rasch模型下的FACETS软件

    多面Rasch模型下的FACETS软件,希望该软件能够对主观性评价领域的研究者有所帮助

    Chef: Powerful Infrastructure Automation

    By the end of this course, you will be confident in how to manage your infrastructure, scale using the cloud, and extend the built-in functionality of Chef itself.The books used in this Learning Path...

    ASP.NET 4 Unleashed(part 1)

    The authors first introduce the ASP.NET Framework’s basic controls and show how to create common site-wide layouts and styles. Next, they cover all aspects of accessing, presenting, organizing, and ...

    Chef.Powerful.Infrastructure.Automation.1788392973.pdf

    Learn Chef Provisioning like a boss and discover how to deploy software and manage hosts, along with engaging recipes to automate your cloud and server infrastructure with Chef. About This Book ...

    Learning Xcode 8(PACKT,2016)

    Over the course of the book, you will continue to explore the many facets of iOS development in Xcode by adding new features to your app, integrating gestures and sensors, and even creating an Apple ...

    如何快速创建一个maven项目

    首先,我们通过File-&gt;New-&gt;Maven Project进入创建Maven项目的面板 Maven项目面板,此时我们必须选中Create a simple project复选...找到Project Facets选项,可以看到Dynamic Web Module和Java,这两个可以修改版本。

    Visual C++ 编程资源大全(英文源码 表单)

    (156KB)&lt;END&gt;&lt;br&gt;90,Dialog2.zip A step by step tutorial showing how to create your first windows program using MFC(112KB)&lt;END&gt;&lt;br&gt;91,MyMDIApp.zip A brief step-by-step tutorial that demonstrates ...

    Microsoft Azure Security Center

    You’ll learn how to secure any Azure workload, and optimize virtually all facets of modern security, from policies and identity to incident response and risk management. Whatever your role in Azure ...

    Learning.Xcode.8.1785885723

    Learn how to use the power of Xcode to turn your next great app idea into a reality About This Book Learn the theory and tools behind app development using Swift 3 and Xcode 8 Build a fully featured ...

Global site tag (gtag.js) - Google Analytics