Ejemplo n.º 1
0
    /** @generated */
    public void notifyChanged(Notification notification) {
      if (notification.getNotifier() instanceof ResourceSet) {
        super.notifyChanged(notification);
      }
      if (!notification.isTouch() && myModifiedFilter.matches(notification)) {
        if (notification.getNotifier() instanceof Resource) {
          Resource resource = (Resource) notification.getNotifier();
          if (resource.isLoaded()) {
            boolean modified = false;
            for (Iterator /*<org.eclipse.emf.ecore.resource.Resource>*/ it =
                    myInfo.getLoadedResourcesIterator();
                it.hasNext() && !modified; ) {
              Resource nextResource = (Resource) it.next();
              if (nextResource.isLoaded()) {
                modified = nextResource.isModified();
              }
            }
            boolean dirtyStateChanged = false;
            synchronized (myInfo) {
              if (modified != myInfo.fCanBeSaved) {
                myInfo.fCanBeSaved = modified;
                dirtyStateChanged = true;
              }
            }
            if (dirtyStateChanged) {
              fireElementDirtyStateChanged(myInfo.getEditorInput(), modified);

              if (!modified) {
                myInfo.setModificationStamp(computeModificationStamp(myInfo));
              }
            }
          }
        }
      }
    }
  @Override
  public void notifyChanged(Notification notification) {
    super.notifyChanged(notification);

    if (!doRecord(notification)) return;

    if (notification.getNotifier() instanceof EObject) {
      recordObjectModification((EObject) notification.getNotifier());
    }
  }
 /**
  * Construct a RepositoryChangeNotification from the given notification. {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
  */
 public void notifyChanged(Notification notification) {
   super.notifyChanged(notification);
   // We don't notify handlers for removing adapter operations neither for Touch notifications
   if ((Notification.REMOVING_ADAPTER != (notification.getEventType()))
       && (!notification.isTouch())) {
     RepositoryChangeNotification newNotification =
         RepositoryChangeNotificationFactoryHolder.getChangeNotificationFactory()
             .createRepositoryChangeNotification(notification);
     this.notificator.notifyHandlers(newNotification);
   }
 }
Ejemplo n.º 4
0
  public void notifyChanged(Notification notification) {
    super.notifyChanged(notification);

    /*
     * We create partOpened / partClosed events based on both MPartWidget
     * events.
     *
     * The initial MPartVisible events are sent early and don't have the
     * actual implementation included. The MPartWidget events are sent as a
     * final step of "part is created" and therefore we use it to create
     * partOpened events. When the part is closed the widget is set to null.
     */
    if (MApplicationPackage.Literals.UI_ELEMENT__WIDGET.equals(notification.getFeature())) {
      if (notification.getEventType() != Notification.SET) return;
      if (notification.getOldValue() == notification.getNewValue())
        return; // avoid extra notifications
      Object part = notification.getNotifier();
      if (part instanceof MPart) {
        IWorkbenchPartReference ref = toPartRef((MPart) part);
        if (ref != null) {
          boolean isVisible = ((MPart) part).isVisible();
          if (isVisible) {
            if (notification.getNewValue() == null) {
              /*
               * not sure if this is the right place to fix bug
               * 283922 but if there is no widget and
               * isVisible==true, we must be shutting down, and we
               * should not send partOpened notifications.
               */
              return;
            }
            SaveablesList modelManager =
                (SaveablesList)
                    ref.getPart(true).getSite().getService(ISaveablesLifecycleListener.class);
            modelManager.postOpen(ref.getPart(true));
            partList.firePartOpened(ref);
          }
        }
      }
      return;
    }

    // Interpret E4 activation events:
    if (!MApplicationPackage.Literals.ELEMENT_CONTAINER__ACTIVE_CHILD.equals(
        notification.getFeature())) return;

    // at this time we only interpreting SET events
    if (notification.getEventType() != Notification.SET
        || notification.getEventType() != Notification.CREATE) return;

    // make sure something actually changed
    Object oldPart = notification.getOldValue();
    Object newPart = notification.getNewValue();

    // create 3.x visibility events
    if ((newPart != oldPart) && (oldPart instanceof MPart) && (newPart instanceof MPart))
      changeVisibility((MPart) oldPart, (MPart) newPart);

    // create 3.x activation events
    final Object object = e4Context.get(IServiceConstants.ACTIVE_PART);
    if ((newPart != oldPart) && newPart instanceof MPerspective) {
      // let legacy Workbench know about perspective activation
      IWorkbenchPage page = (IWorkbenchPage) e4Context.get(IWorkbenchPage.class.getName());
      if (page != null) {
        String id = ((MPerspective) newPart).getId();
        IPerspectiveDescriptor[] descriptors = page.getOpenPerspectives();
        for (IPerspectiveDescriptor desc : descriptors) {
          if (!id.equals(desc.getId())) continue;
          page.setPerspective(desc);
        }
      }
    }
    if (object instanceof MPart) {
      IWorkbenchPartReference ref = toPartRef((MPart) object);
      if (ref != null) {
        // set the Focus to the newly active part
        IWorkbenchPart part = ref.getPart(true);
        part.setFocus();
        // Update the action bars
        SubActionBars bars = (SubActionBars) ((PartSite) part.getSite()).getActionBars();
        bars.partChanged(part);
        partList.setActivePart(ref);
        if (ref instanceof IEditorReference) {
          IEditorReference editorReference = (IEditorReference) ref;
          partList.setActiveEditor(editorReference);
          final IEditorPart editor = editorReference.getEditor(true);
          e4Context.set(ISources.ACTIVE_EDITOR_NAME, editor);
          e4Context.set(ISources.ACTIVE_EDITOR_ID_NAME, editor.getSite().getId());
          e4Context.set(ISources.ACTIVE_EDITOR_INPUT_NAME, editor.getEditorInput());
        }
      }
    } else {
      partList.setActiveEditor(null);
      e4Context.set(ISources.ACTIVE_EDITOR_NAME, null);
      e4Context.set(ISources.ACTIVE_EDITOR_ID_NAME, null);
      e4Context.set(ISources.ACTIVE_EDITOR_INPUT_NAME, null);
      partList.setActivePart(null);
    }
  }
 @Override
 public void notifyChanged(final Notification notification) {
   super.notifyChanged(notification);
   Object newValue = notification.getNewValue();
   Object oldValue = notification.getOldValue();
   switch (notification.getEventType()) {
     case Notification.ADD:
       if (newValue instanceof DcdComponentInstantiation) {
         final DcdComponentInstantiation object =
             (DcdComponentInstantiation) notification.getNewValue();
         this.modelMap.add(object);
       } else if (newValue instanceof DcdConnectInterface) {
         final DcdConnectInterface object = (DcdConnectInterface) newValue;
         if (object.getSource() == null || object.getTarget() == null || object.getId() == null) {
           return;
         }
         this.modelMap.add(object);
       }
       break;
     case Notification.ADD_MANY:
       for (Object obj : ((Collection<?>) newValue)) {
         if (obj instanceof DcdComponentInstantiation) {
           final DcdComponentInstantiation object = (DcdComponentInstantiation) obj;
           this.modelMap.add(object);
         } else if (newValue instanceof DcdConnectInterface) {
           final DcdConnectInterface object = (DcdConnectInterface) newValue;
           if (object.getSource() == null
               || object.getTarget() == null
               || object.getId() == null) {
             return;
           }
           this.modelMap.add(object);
         }
       }
       break;
     case Notification.REMOVE:
       if (oldValue instanceof DcdComponentInstantiation) {
         final DcdComponentInstantiation object = (DcdComponentInstantiation) oldValue;
         this.modelMap.remove(object);
       } else if (oldValue instanceof DcdComponentPlacement) {
         final DcdComponentPlacement object = (DcdComponentPlacement) oldValue;
         for (DcdComponentInstantiation i : object.getComponentInstantiation()) {
           this.modelMap.remove(i);
         }
       } else if (oldValue instanceof DcdConnectInterface) {
         final DcdConnectInterface object = (DcdConnectInterface) oldValue;
         this.modelMap.remove(object);
       }
       break;
     case Notification.REMOVE_MANY:
       for (Object obj : ((Collection<?>) oldValue)) {
         if (obj instanceof DcdComponentInstantiation) {
           final DcdComponentInstantiation object = (DcdComponentInstantiation) obj;
           this.modelMap.remove(object);
         } else if (oldValue instanceof DcdComponentPlacement) {
           final DcdComponentPlacement object = (DcdComponentPlacement) oldValue;
           for (DcdComponentInstantiation i : object.getComponentInstantiation()) {
             this.modelMap.remove(i);
           }
         } else if (obj instanceof DcdConnectInterface) {
           final DcdConnectInterface object = (DcdConnectInterface) obj;
           this.modelMap.remove(object);
         }
       }
       break;
     default:
       break;
   }
 }
 @Override
 protected void setTarget(EObject target) {
   if (target.eResource() instanceof XtextResource) {
     super.setTarget(target);
   }
 }
 /** Only attach to XtextResources */
 @Override
 protected void setTarget(Resource target) {
   if (target instanceof XtextResource) {
     super.setTarget(target);
   }
 }