java类org.eclipse.emf.ecore.util.EContentAdapter的实例源码

TinkerforgeBinding.java 文件源码 项目:openhab1-addons 阅读 35 收藏 0 点赞 0 评论 0
/**
 * Adds a listener {@link EContentAdapter} to the {@link Ecosystem}. The listener handles updated
 * sensor values and posts them to the openhab eventbus by
 * {@link #processTFDeviceValues(Notification) processTFDeviceValues}. Furthermore the addition
 * and removal of devices is handled by {@link #initializeTFDevices(Notification)
 * initializeTFDevices}.
 *
 * @param tinkerforgeEcosystem The EMF Ecosystem object.
 */
private void listen2Model(Ecosystem tinkerforgeEcosystem) {
    EContentAdapter modelAdapter = new EContentAdapter() {
        @Override
        public void notifyChanged(Notification notification) {
            super.notifyChanged(notification);
            logger.debug("TinkerforgeNotifier was notified");
            if (notification.getEventType() == Notification.ADD
                    || notification.getEventType() == Notification.ADD_MANY
                    || notification.getEventType() == Notification.REMOVE
                    || notification.getEventType() == Notification.REMOVE_MANY) {
                initializeTFDevices(notification);
            } else {
                processTFDeviceValues(notification);
            }
        }

    };
    tinkerforgeEcosystem.eAdapters().add(modelAdapter);
}
N4JSResource.java 文件源码 项目:n4js 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Creates a custom notification and sends it for proxy and loaded object. Registers adapters to loaded object.
 *
 * @param idx
 *            index in the contents list (first or second slot)
 * @param oldProxy
 *            the proxified object before being loaded
 */
protected void notifyProxyResolved(int idx, EObject oldProxy) {
    if (eNotificationRequired() && idx < contents.size()) {
        EObject newObject = contents.basicGet(idx);
        Notification notification = new NotificationImpl(Notification.RESOLVE, oldProxy, newObject) {
            @Override
            public Object getNotifier() {
                return N4JSResource.this;
            }

            @Override
            public int getFeatureID(Class<?> expectedClass) {
                return RESOURCE__CONTENTS;
            }
        };
        eNotify(notification);
        for (Adapter adapter : eAdapters()) {
            if (adapter instanceof EContentAdapter && !newObject.eAdapters().contains(adapter)) {
                newObject.eAdapters().add(adapter);
            }
        }
    }
}
PipelinePart.java 文件源码 项目:termsuite-ui 阅读 22 收藏 0 点赞 0 评论 0
@Inject @Optional
private void init(@UIEventTopic(TermSuiteEvents.EDITOR_INITIATED) Object part, MPart mPart) {
    if(this == part) {
        EPipeline pipeline = (EPipeline) context.get(TermSuiteUI.INPUT_OBJECT);
        this.pipelineValue.setValue(pipeline);
        this.context.set(EPipeline.class, pipeline);
        pipeline.eAdapters().add(new EContentAdapter() {
            public void notifyChanged(Notification notification) {
                super.notifyChanged(notification);
                if(notification.getFeature().equals(TermsuiteuiPackage.eINSTANCE.getEPipeline_Name())) {
                    mPart.setLabel(notification.getNewStringValue());
                } else {
                    // set dirty, unless this is a pipeline rename
                    dirty.setDirty(true);
                    validatePipeline();
                }
            }
        });
        validatePipeline();
    }
}
TinkerforgeBinding.java 文件源码 项目:openhab-hdl 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Adds a listener {@link EContentAdapter} to the {@link Ecosystem}. The listener handles updated
 * sensor values and posts them to the openhab eventbus by
 * {@link #processTFDeviceValues(Notification) processTFDeviceValues}. Furthermore the addition
 * and removal of devices is handled by {@link #initializeTFDevices(Notification)
 * initializeTFDevices}.
 * 
 * @param tinkerforgeEcosystem The EMF Ecosystem object.
 */
private void listen2Model(Ecosystem tinkerforgeEcosystem) {
  EContentAdapter modelAdapter = new EContentAdapter() {
    @Override
    public void notifyChanged(Notification notification) {
      super.notifyChanged(notification);
      logger.debug("TinkerforgeNotifier was notified");
      if (notification.getEventType() == Notification.ADD
          || notification.getEventType() == Notification.ADD_MANY
          || notification.getEventType() == Notification.REMOVE
          || notification.getEventType() == Notification.REMOVE_MANY) {
        initializeTFDevices(notification);
      } else {
        processTFDeviceValues(notification);
      }
    }

  };
  tinkerforgeEcosystem.eAdapters().add(modelAdapter);
}
TerminologyPart.java 文件源码 项目:termsuite-ui 阅读 24 收藏 0 点赞 0 评论 0
@Inject @Optional
    private void init(@UIEventTopic(TermSuiteEvents.EDITOR_INITIATED) Object part, MPart mPart) {
        if(this == part) {
            ETerminology terminology = (ETerminology)context.get(TermSuiteUI.INPUT_OBJECT);
            terminology.eAdapters().add(new EContentAdapter() {
                public void notifyChanged(Notification notification) {
                    super.notifyChanged(notification);
                    if(notification.getFeature().equals(TermsuiteuiPackage.eINSTANCE.getETerminology_Name())) {
                        mPart.setLabel(toPartLabel(terminology));
                    } else {
                        // set dirty
//                      dirty.setDirty(true);
                    }
                }
            });
            final IndexedCorpus indexedCorpus = eTerminologyService.readTerminology(terminology);
            context.set(IndexedCorpus.class, indexedCorpus);
            context.set(Terminology.class, indexedCorpus.getTerminology());
            final TerminologyService terminologyService = eTerminologyService.getTerminologyService(terminology);
            context.set(TerminologyService.class, terminologyService);
            Job job = Job.create("Open terminology", monitor -> {
                sync.asyncExec(() -> viewer.setInput(terminologyService));
                return Status.OK_STATUS;
            });
            job.schedule();
        }
    }
SolutionEditor.java 文件源码 项目:dawn-marketplace-server 阅读 20 收藏 0 点赞 0 评论 0
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    setSite(site);
    setInput(input);

    fSaveAction= ActionFactory.SAVE.create(getSite().getWorkbenchWindow());
    site.getActionBars().setGlobalActionHandler(ActionFactory.SAVE.getId(), fSaveAction);
    site.getActionBars().updateActionBars();

    FileEditorInput i = (FileEditorInput) input;
    try {
        node = MarketplaceSerializer.loadNode(i.getPath().toFile());
    } catch (Exception e) {
        // TODO: Notify about error loading
    }
    if (node==null) {
        node = MarketplaceFactory.eINSTANCE.createNode();
    }
    // detect changes
    EContentAdapter adapter = new EContentAdapter() {
        @Override
        public void notifyChanged(org.eclipse.emf.common.notify.Notification notification) {
            super.notifyChanged(notification);              
            dirty = true;
            SolutionEditor.this.firePropertyChange(IEditorPart.PROP_DIRTY);
            SolutionEditor.this.setPartName(getSolutionTitle());
        }
    };
    node.eAdapters().add(adapter);
    adapter.setTarget(node);
    setPartName(getSolutionTitle());
    firePropertyChange(IEditorPart.PROP_DIRTY);
}
GenericUnloaderTest.java 文件源码 项目:xtext-core 阅读 22 收藏 0 点赞 0 评论 0
@Test public void testHandleContentAdapter() throws Exception {
    EPackage root = createExample();
    EContentAdapter eContentAdapter = new EContentAdapter();
    root.eAdapters().add(eContentAdapter);
    IReferableElementsUnloader.GenericUnloader genericUnloader = new IReferableElementsUnloader.GenericUnloader();
    try {
        genericUnloader.unloadRoot(root);
    } catch (StackOverflowError e) {
        e.printStackTrace();
        fail("Unload does not cope with contentAdpaters");
    }
    // isEmtpy() does not work in EMF 3.5
    assertEquals(0, root.eAdapters().size());
}
FXAttachment.java 文件源码 项目:eavp 阅读 13 收藏 0 点赞 0 评论 0
@Override
public void addGeometry(Geometry geom) {
    super.addGeometry(geom);

    if (fxAttachmentNode == null) {
        fxAttachmentNode = new Group();
    }

    if (knownParts == null) {
        knownParts = new ArrayList<>();
    }

    // If the geometry is not recognized, add it
    if (!knownParts.contains(geom)) {

        // Register to listen for changes from the geometry or its children
        // INodes
        geom.eAdapters().add(new EContentAdapter() {

            @Override
            public void notifyChanged(Notification notification) {
                handleUpdate(geom, notification);
            }
        });

        // Add the geometry to the list of known parts
        knownParts.add(geom);

        // Have the geometry refreshed when it is added
        handleUpdate(geom, null);

    }
}
EObjectWrapper.java 文件源码 项目:Environment 阅读 14 收藏 0 点赞 0 评论 0
public EObjectWrapper(T master, List<T> slaves)
{
    this.slaves = slaves;
    this.master = master;

    this.master.eAdapters().add(new EContentAdapter()
    {
        @Override
        public void notifyChanged(Notification notification)
        {
            super.notifyChanged(notification);

            // Mind only 1-6 : SET, UNSET, ADD, REMOVE, ADD_ALL, REMOVE_ALL
            if (notification.getEventType() > 6 || notification.getEventType()<1)
                return;

            for (EObject slave : EObjectWrapper.this.slaves)
            {
                if (notification.getNotifier() != EObjectWrapper.this.master)
                {
                    if (((EObject)notification.getNotifier()).eContainer() == null) return;

                    String relativeURIFragmentPath = EcoreUtil.getRelativeURIFragmentPath(
                            EObjectWrapper.this.master,
                            (EObject) notification.getNotifier());

                    EObject subSlave = EcoreUtil.getEObject(slave, relativeURIFragmentPath);
                    pushToSlave(subSlave, notification);
                }
                else
                {
                    pushToSlave(slave, notification);
                }

            }
        }
    });
}
InputAlternative.java 文件源码 项目:Environment 阅读 18 收藏 0 点赞 0 评论 0
private void initModiscoListener()
{
    this.modiscoConfiguration.eAdapters().add(new EContentAdapter(){
        @Override
        public void notifyChanged(Notification msg)
        {
            if (msg.getEventType() == Notification.RESOLVE) return;
            setDirty(true);
        }
    });
}
HandlerEventAdapter.java 文件源码 项目:clickwatch 阅读 18 收藏 0 点赞 0 评论 0
@Override
public void init(IInternalNodeConnection connection) {
    super.init(connection);
    if (initializationRequired) {
        connection.getNode().eAdapters().add(new EContentAdapter() {
            @Override
            public void notifyChanged(Notification msg) {
                if (msg.getFeature() == ClickWatchModelPackage.eINSTANCE.getNode_Elements() || 
                        msg.getFeature() == ClickWatchModelPackage.eINSTANCE.getElement_Children() ||
                        msg.getFeature() == ClickWatchModelPackage.eINSTANCE.getElement_Handlers()) {
                    if (!metaDataMightHaveChanged) {
                        logger.log(ILogger.DEBUG, "HandlerEventAdapter realized that meta-data has changed", null);
                    }
                    metaDataMightHaveChanged = true;

                }
                super.notifyChanged(msg);
            }

            @Override
            protected void selfAdapt(Notification notification) {
                if (!(notification.getNotifier() instanceof Handler)) {
                    super.selfAdapt(notification);
                }
            }                             
        });
        initializationRequired = false;
    }
}
SimpleModelChangeListenerAddon.java 文件源码 项目:gemoc-studio-modeldebugging 阅读 15 收藏 0 点赞 0 评论 0
public SimpleModelChangeListenerAddon(final IExecutionEngine engine) {
    this.engine = engine;
    changes = new HashMap<>();
    registeredAddons = new HashSet<>();
    adapter = new EContentAdapter() {

        @Override
        public void notifyChanged(Notification notification) {
            super.notifyChanged(notification);
            int eventType = notification.getEventType();
            Object notifier = notification.getNotifier();
            if (eventType < Notification.EVENT_TYPE_COUNT && notifier instanceof EObject && !notification.isTouch()) {
                switch (notification.getEventType()) {
                case Notification.ADD:
                case Notification.ADD_MANY:
                    addFeatureChange((EStructuralFeature) notification.getFeature(),
                            (EObject) notification.getNotifier(), notification.getNewValue(),
                            FieldChange.ChangeType.ADD);
                    break;
                case Notification.REMOVE:
                case Notification.REMOVE_MANY:
                    addFeatureChange((EStructuralFeature) notification.getFeature(),
                            (EObject) notification.getNotifier(), notification.getOldValue(),
                            FieldChange.ChangeType.REMOVE);
                    break;
                case Notification.MOVE:
                case Notification.SET:
                case Notification.UNSET:
                    addFeatureChange((EStructuralFeature) notification.getFeature(),
                            (EObject) notification.getNotifier(), notification.getNewValue(),
                            FieldChange.ChangeType.MODIFY);
                    break;
                }
            }
        }
    };
    Set<Resource> allResources = org.eclipse.gemoc.commons.eclipse.emf.EMFResource.getRelatedResources(this.engine
            .getExecutionContext().getResourceModel());
    allResources.stream().forEach(r -> {
        if (r != null) {
            r.eAdapters().add(adapter);
        }
    });
}
DwFeatureModelConfiguratorEditor.java 文件源码 项目:DarwinSPL 阅读 14 收藏 0 点赞 0 评论 0
protected void registerListeners() {

        super.registerControlListeners();

        HyVarRecButtonListener hyVarRecButtonListener = new HyVarRecButtonListener();
        ButtonListener buttonListener = new ButtonListener();

        selectedConfiguration.eAdapters().add(new EContentAdapter() {
            @Override
            public void notifyChanged(Notification notification) {
                super.notifyChanged(notification);

                selectedConfigurationComposite.setConfiguration(selectedConfiguration, getCurrentSelectedDate());
            }
        });

        validateWithEvolutionButton.addSelectionListener(hyVarRecButtonListener);
        explainWithEvolutionButton.addSelectionListener(hyVarRecButtonListener);

        validateContextButton.addSelectionListener(hyVarRecButtonListener);
        explainButton.addSelectionListener(hyVarRecButtonListener);

        simulateButton.addSelectionListener(hyVarRecButtonListener);

        checkSatisfiabilityButton.addSelectionListener(buttonListener);
        checkConfigurationValidity.addSelectionListener(buttonListener);

//      numberOfPossibleConfigurationsButton.addSelectionListener(new SelectionAdapter() {
//          @Override
//          public void widgetSelected(SelectionEvent e) {
//              //calculateNumberOfPossibleConfigurations();
//          }
//      });

        selectedConfigurationComposite.getCompleteButton().addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                //autoCompleteVersions();
            }
        });

        selectedConfigurationComposite.getSaveConfigurationButton().addSelectionListener(new DwSaveConfigurationListener(this));

        selectedConfigurationComposite.getLoadConfigurationButton().addSelectionListener(new DwLoadConfigurationListener(this));

        selectedConfigurationComposite.getDeriveVariantButton().addSelectionListener(new DwDeriveVariantListener(this));
    }
SimpleModelChangeListenerAddon.java 文件源码 项目:ModelDebugging 阅读 16 收藏 0 点赞 0 评论 0
public SimpleModelChangeListenerAddon(final IExecutionEngine engine) {
    this.engine = engine;
    changes = new HashMap<>();
    registeredAddons = new HashSet<>();
    adapter = new EContentAdapter() {

        @Override
        public void notifyChanged(Notification notification) {
            super.notifyChanged(notification);
            int eventType = notification.getEventType();
            Object notifier = notification.getNotifier();
            if (eventType < Notification.EVENT_TYPE_COUNT && notifier instanceof EObject && !notification.isTouch()) {
                switch (notification.getEventType()) {
                case Notification.ADD:
                case Notification.ADD_MANY:
                    addFeatureChange((EStructuralFeature) notification.getFeature(),
                            (EObject) notification.getNotifier(), notification.getNewValue(),
                            FieldChange.ChangeType.ADD);
                    break;
                case Notification.REMOVE:
                case Notification.REMOVE_MANY:
                    addFeatureChange((EStructuralFeature) notification.getFeature(),
                            (EObject) notification.getNotifier(), notification.getOldValue(),
                            FieldChange.ChangeType.REMOVE);
                    break;
                case Notification.MOVE:
                case Notification.SET:
                case Notification.UNSET:
                    addFeatureChange((EStructuralFeature) notification.getFeature(),
                            (EObject) notification.getNotifier(), notification.getNewValue(),
                            FieldChange.ChangeType.MODIFY);
                    break;
                }
            }
        }
    };
    Set<Resource> allResources = org.eclipse.gemoc.commons.eclipse.emf.EMFResource.getRelatedResources(this.engine
            .getExecutionContext().getResourceModel());
    allResources.stream().forEach(r -> {
        if (r != null) {
            r.eAdapters().add(adapter);
        }
    });
}
TaskSelectType.java 文件源码 项目:birt 阅读 16 收藏 0 点赞 0 评论 0
protected void updateAdapters( )
{
    EObject model = getChartModelObject( );

    if ( container instanceof ChartWizard )
    {
        // Refresh all adapters
        EContentAdapter adapter = ( (ChartWizard) container ).getAdapter( );

        model.eAdapters( ).remove( adapter );
        TreeIterator<EObject> iterator = model.eAllContents( );
        while ( iterator.hasNext( ) )
        {
            EObject oModel = iterator.next( );
            oModel.eAdapters( ).remove( adapter );
        }
        model.eAdapters( ).add( adapter );
    }
    else
    {
        // For extension case, create an adapter and add change listener
        EList<Adapter> adapters = model.eAdapters( );
        if ( adapters.isEmpty( ) )
        {
            // Get the previous adapter if existent
            if ( adapter == null )
            {
                adapter = new ChartAdapter( container );
                adapter.addListener( this );
            }
            adapters.add( adapter );
        }
        else
        {
            if ( adapters.get( 0 ) instanceof ChartAdapter )
            {
                ( (ChartAdapter) adapters.get( 0 ) ).addListener( this );
            }
        }
    }
}
ChartWizard.java 文件源码 项目:birt 阅读 19 收藏 0 点赞 0 评论 0
public EContentAdapter getAdapter( )
{
    return adapter;
}


问题


面经


文章

微信
公众号

扫码关注公众号