本文整理汇总了Java中org.eclipse.emf.ecore.util.EContentAdapter类的典型用法代码示例。如果您正苦于以下问题:Java EContentAdapter类的具体用法?Java EContentAdapter怎么用?Java EContentAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EContentAdapter类属于org.eclipse.emf.ecore.util包,在下文中一共展示了EContentAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listen2Model
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
/**
* 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);
}
示例2: notifyProxyResolved
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
/**
* 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);
}
}
}
}
示例3: init
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
@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();
}
}
示例4: listen2Model
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
/**
* 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);
}
示例5: init
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
@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();
}
}
示例6: init
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
@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);
}
示例7: testHandleContentAdapter
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
@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());
}
示例8: addGeometry
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
@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);
}
}
示例9: EObjectWrapper
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
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);
}
}
}
});
}
示例10: initModiscoListener
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
private void initModiscoListener()
{
this.modiscoConfiguration.eAdapters().add(new EContentAdapter(){
@Override
public void notifyChanged(Notification msg)
{
if (msg.getEventType() == Notification.RESOLVE) return;
setDirty(true);
}
});
}
示例11: init
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
@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;
}
}
示例12: SimpleModelChangeListenerAddon
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
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);
}
});
}
示例13: registerListeners
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
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));
}
示例14: updateAdapters
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
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 );
}
}
}
}
示例15: getAdapter
import org.eclipse.emf.ecore.util.EContentAdapter; //导入依赖的package包/类
public EContentAdapter getAdapter( )
{
return adapter;
}