@Override
 public Adapter adaptNew(Notifier object, Object type) {
   if (type == ExtendedPropertiesAdapter.class && object instanceof EObject) {
     Adapter adapter = bpmn2ModelSwitch.doSwitch((EObject) object);
     if (adapter != null && !(object instanceof EClass)) {
       ((EObject) object).eAdapters().add(adapter);
     }
     return adapter;
   }
   return super.adaptNew(object, type);
 }
 public static void initializeWindowServices(MWindow childWindow) {
   IEclipseContext windowContext = childWindow.getContext();
   initWindowContext(windowContext);
   // Mostly MWindow contexts are lazily created by renderers and is not
   // set at this point.
   ((EObject) childWindow)
       .eAdapters()
       .add(
           new AdapterImpl() {
             @Override
             public void notifyChanged(Notification notification) {
               if (notification.getFeatureID(MWindow.class) != BasicPackageImpl.WINDOW__CONTEXT)
                 return;
               IEclipseContext windowContext = (IEclipseContext) notification.getNewValue();
               initWindowContext(windowContext);
             }
           });
 }
 public static void initializeServices(MApplication appModel) {
   IEclipseContext appContext = appModel.getContext();
   // make sure we only add trackers once
   if (appContext.containsKey(CONTEXT_INITIALIZED)) return;
   appContext.set(CONTEXT_INITIALIZED, "true");
   initializeApplicationServices(appContext);
   List<MWindow> windows = appModel.getChildren();
   for (MWindow childWindow : windows) {
     initializeWindowServices(childWindow);
   }
   ((EObject) appModel)
       .eAdapters()
       .add(
           new AdapterImpl() {
             @Override
             public void notifyChanged(Notification notification) {
               if (notification.getFeatureID(MApplication.class)
                   != UiPackageImpl.ELEMENT_CONTAINER__CHILDREN) return;
               if (notification.getEventType() != Notification.ADD) return;
               MWindow childWindow = (MWindow) notification.getNewValue();
               initializeWindowServices(childWindow);
             }
           });
 }