/*******************************************************************************
 * Copyright 2013 Google Inc. All Rights Reserved.
 *
 * 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
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 *******************************************************************************/
package com.google.appengine.eclipse.wtp.managedapis;

import com.google.gdt.eclipse.managedapis.ManagedApiProject;
import com.google.gdt.eclipse.managedapis.extensiontypes.IManagedApiProjectInitializationCallback;

/**
 * Adds an observer to get notified about changes made to project with managed APIs.
 */
public final class ProjectInitializationCallback implements
    IManagedApiProjectInitializationCallback {
  @Override
  public void onInitialization(ManagedApiProject project) {
    project.registerManagedApiProjectObserver(new ManagedApiProjectObserverImpl(project));
  }
}

@@ -829,16 +829,139 @@
 dapis;%0A%0A
+import com.google.appengine.eclipse.wtp.AppEnginePlugin;%0Aimport com.google.appengine.eclipse.wtp.facet.IGaeFacetConstants;%0A
 import c
@@ -1113,16 +1113,182 @@
 lback;%0A%0A
+import org.eclipse.core.resources.IProject;%0Aimport org.eclipse.core.runtime.CoreException;%0Aimport org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;%0A%0A
 /**%0A * A
@@ -1540,17 +1540,20 @@
 Project 
-p
+apiP
 roject) 
@@ -1558,17 +1558,277 @@
 ) %7B%0A    
-p
+IProject project = apiProject.getProject();%0A    try %7B%0A      boolean isFaceted = FacetedProjectFramework.isFacetedProject(project);%0A      if (isFaceted%0A          && FacetedProjectFramework.hasProjectFacet(project, IGaeFacetConstants.GAE_FACET_ID)) %7B%0A        apiP
 roject.r
@@ -1894,17 +1894,20 @@
 verImpl(
-p
+apiP
 roject))
@@ -1908,14 +1908,97 @@
 ject));%0A
+      %7D%0A    %7D catch (CoreException e) %7B%0A      AppEnginePlugin.logMessage(e);%0A    %7D%0A
   %7D%0A%7D%0A

Fix for NPE attempting to add listener for non-gae project