Java 类org.eclipse.emf.common.notify.impl.AdapterImpl 实例源码

项目:termsuite-ui    文件:ConfigureTaggerDialog.java   
public ConfigureTaggerDialog(Shell parentShell) {
    super(parentShell);
    setShellStyle(getShellStyle() | SWT.RESIZE);
    parentShell.addListener(SWT.RESIZE, new Listener() {

        @Override
        public void handleEvent(Event event) {
            form.reflow(true);

        }
    });
    this.taggerConfig = TermsuiteuiFactory.eINSTANCE.createETaggerConfig();
    this.taggerConfig.eAdapters().add(new AdapterImpl() {
        @Override
        public void notifyChanged(Notification msg) {
            if(msg.getFeatureID(ETaggerConfig.class) == TermsuiteuiPackage.ETAGGER_CONFIG__PATH 
                    || msg.getFeatureID(ETaggerConfig.class) == TermsuiteuiPackage.ETAGGER_CONFIG__TAGGER_TYPE)
                languageViewer.setInput(TaggerUtil.getSupportedLanguages(taggerConfig));
            if(msg.getFeatureID(ETaggerConfig.class) == TermsuiteuiPackage.ETAGGER_CONFIG__TAGGER_TYPE)
                updateTaggerName();
            refreshValidState();
        }

    });

}
项目:OpenSPIFe    文件:TestTemporalMember.java   
/**
 * Check the defaults
 */

public void testDefaults() {
    for (EPlanElement element : Util.createTestElements()) {
        TemporalMember member = element.getMember(TemporalMember.class);
        member.eAdapters().add(new AdapterImpl() {
            @Override
            public void notifyChanged(Notification msg) {
                Assert.fail("didn't expect any notifications");
            }
        });
        assertEquals("default for calculated variable wrong", CalculatedVariable.END, member.getCalculatedVariable());
        assertEquals("default for element wrong", element, member.getPlanElement());
        assertEquals("default for scheduled wrong", Boolean.TRUE, member.getScheduled());
        Util.check(member, null, DateUtils.ZERO_DURATION, null);
    }
}
项目:OpenSPIFe    文件:TestTemporalMemberPlanSharingNotificationFilter.java   
private void testFiltering(CalculatedVariable calculatedVariable, final EStructuralFeature derivedfeature, EStructuralFeature settableFeature) {
    TemporalMember member = TemporalFactory.eINSTANCE.createTemporalMember();
    member.setStartTime(TIME);
    member.setDuration(ONE_HOUR);
    member.setCalculatedVariable(calculatedVariable);
    member.eAdapters().add(new AdapterImpl() {

        @Override
        public void notifyChanged(Notification msg) {
            if (FILTER.matches(msg)) {
                assertTrue("derived temporal feature not filtered out", CommonUtils.equals(msg.getFeature(), derivedfeature));
            }
            super.notifyChanged(msg);
        }

    });

    try {
        member.eSet(derivedfeature, new Date(System.currentTimeMillis()));
        fail("expected failure state");
    } catch (Exception e) {
        // we expected this
    }

    member.eSet(settableFeature, DateUtils.add(TIME, ONE_HOUR));
}
项目:OpenSPIFe    文件:TickManager.java   
public TickManager(Page page) {
    this.page = page;
    this.page.eAdapters().add(new AdapterImpl() {

        @Override
        public void notifyChanged(Notification notification) {
            Object f = notification.getFeature();
            if (TimelinePackage.Literals.PAGE__CURRENT_PAGE_EXTENT == f
                    || TimelinePackage.Literals.PAGE__START_TIME == f
                    || TimelinePackage.Literals.PAGE__DURATION == f
                    || TimelinePackage.Literals.PAGE__ZOOM_OPTION == f) {
                update();
            }
            super.notifyChanged(notification);
        }

    });
    update();
}
项目:OpenSPIFe    文件:UndoableObservableValue.java   
@Override
protected void firstListenerAdded() {
    final Object eStructuralFeature = pd.getFeature(target);
    attachListener(new AdapterImpl() {
        @Override
        public void notifyChanged(Notification notification) {
            if (eStructuralFeature == notification.getFeature() && !notification.isTouch()) {
                final ValueDiff diff = Diffs.createValueDiff(notification.getOldValue(), notification.getNewValue());
                getRealm().exec(new Runnable() {
                    @Override
                    public void run() {
                        fireValueChange(diff);
                    }
                });
            }
        }
    });
}
项目:OpenSPIFe    文件:DefinitionContextImpl.java   
public DefinitionContextImpl(EObject target) {
    this.target = target;
    this.target.eAdapters().add(new AdapterImpl() {

        @Override
        public void notifyChanged(Notification msg) {
            int type = msg.getEventType();
            if (Notification.ADD == type
                    || Notification.ADD_MANY == type
                    || Notification.REMOVE == type
                    || Notification.REMOVE_MANY == type) {
                clearCache();
            }
            super.notifyChanged(msg);
        }

    });
}
项目:SPLevo    文件:VPExplorerContent.java   
/**
 * Set the variation point model wrapped by the content.
 *
 * DesignDecision: When a VPM is set, the content wrapper registers for any modifications of the
 * EMF resource containing the VPM model.
 *
 * @param vpm
 *            The vpm to present.
 */
public void setVpm(VariationPointModel vpm) {
    this.vpm = vpm;
    if (navigatorToRefresh != null) {
        navigatorToRefresh.getCommonViewer().refresh();

        AdapterImpl changeListener = new AdapterImpl() {
            @Override
            public void notifyChanged(Notification notification) {
                navigatorToRefresh.getCommonViewer().refresh();
            }
        };
        if (vpm.eResource() != null) {
            vpm.eResource().eAdapters().add(changeListener);
        }
    }
}
项目:termsuite-ui    文件:TerminologyPart.java   
private void createViewer(Composite container) {

    layout = new TreeColumnLayout(true);
    container.setLayout(layout);
    this.viewer = new TerminologyViewer(viewerConfig, container, SWT.SINGLE| SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    GridDataFactory.fillDefaults().span(4, 1).grab(true, true).applyTo(viewer.getControl());

    for(String pName:viewerConfig.getSelectedPropertyNames()) 
        createColumn(PropertyUtil.forName(pName));
    viewerConfig.eAdapters().add(new AdapterImpl(){
        @Override
        public void notifyChanged(Notification msg) {
            if(msg.getFeatureID(ETerminoViewerConfig.class) == TermsuiteuiPackage.ETERMINO_VIEWER_CONFIG__SEARCH_STRING
                && msg.getNewValue() != null && !msg.getNewValue().toString().isEmpty())
                /*
                 * This is a non empty search string filter. Expand all nodes
                 * in order to make selected variant appear.
                 */
                viewer.expandToLevel(2);

        }
    });

    // attach a selection listener to our jface viewer
    TermSelectionListener listener = ContextInjectionFactory.make(TermSelectionListener.class, context);
    viewer.addSelectionChangedListener(listener);

    menuService.registerContextMenu(viewer.getControl(), POPUP_MENU_ID);
}
项目:termsuite-ui    文件:TerminologyViewer.java   
public TerminologyViewer(ETerminoViewerConfig config, Composite parent, int style) {
    super(parent, style);
    config.eAdapters().add(new AdapterImpl() {
        public void notifyChanged(Notification notification) {
            refresh();
        }
    });

    getTree().setLinesVisible(true);
    getTree().setHeaderVisible(true);
    setComparator(variationComparator);
    contentProvider = new TerminologyContentProvider(config);
    setContentProvider(contentProvider);
    addDoubleClickListener(new ExpandCollapseDoubleClickListener(this));
}
项目:dsl-devkit    文件:InferenceContainerImplCustom.java   
protected InferenceContainerImplCustom() {
  eAdapters().add(new AdapterImpl() {
    @SuppressWarnings("unchecked")
    @Override
    public void notifyChanged(final Notification msg) {
      if (msg.getFeature() != ModelInferencePackage.Literals.INFERENCE_CONTAINER__CONTENTS || eResource() == null) {
        return;
      }
      switch (msg.getEventType()) {
      case Notification.ADD:
        addFragmentMapping((EObject) msg.getNewValue());
        break;
      case Notification.ADD_MANY:
        for (EObject newObject : (List<EObject>) msg.getNewValue()) {
          addFragmentMapping(newObject);
        }
        break;
      case Notification.REMOVE:
        objectToFragmentMap.remove(msg.getOldValue());
        break;
      case Notification.REMOVE_MANY:
        for (EObject oldObject : (List<EObject>) msg.getOldValue()) {
          objectToFragmentMap.remove(oldObject);
        }
        break;
      default:
        break;
      }
    }
  });
}
项目:eavp    文件:FXRenderObject.java   
@Override
public void registerOption(DisplayOption option) {
    super.registerOption(option);

    // Listen to the option, refreshing the mesh when it changes
    option.eAdapters().add(new AdapterImpl() {
        @Override
        public void notifyChanged(Notification notification) {
            handleUpdate(notification);
        }
    });
}
项目:OpenSPIFe    文件:ActivityDictionary.java   
protected ActivityDictionary() {
    eAdapters().add(new AdapterImpl() {
        @Override
        public void notifyChanged(Notification n) {
            if (Notification.ADD == n.getEventType()
                    || Notification.ADD_MANY == n.getEventType()) {
                fireActivityDictionaryEvent(TYPE.DEF_ADDED);
            }
        }
    });
}
项目:OpenSPIFe    文件:ContainedElementObservable.java   
@Override
protected void firstListenerAdded()
{
  listener =
    new AdapterImpl()
    {
      @Override
      public void notifyChanged(Notification notification)
      {
        if (feature == notification.getFeature() && !notification.isTouch())
        {
        Boolean oldValue = CommonUtils.equals(notification.getOldValue(), value) || (notification.getOldValue() instanceof List && ((List)notification.getOldValue()).contains(value));
        Boolean newValue = CommonUtils.equals(notification.getNewValue(), value) || (notification.getNewValue() instanceof List && ((List)notification.getNewValue()).contains(value));
          final ValueDiff diff = Diffs.createValueDiff(oldValue, newValue);
          getRealm().exec
            (new Runnable()
             {
               @Override
        public void run()
               {
                 fireValueChange(diff);
               }
             });
        }
      }
    };
  target.eAdapters().add(listener);
}
项目:NeoEMF    文件:LoadedResourceNotifier.java   
public static void main(String[] args) throws IOException {
    JavaPackage.eINSTANCE.eClass();

    PersistenceBackendFactoryRegistry.register(BlueprintsURI.SCHEME,
            BlueprintsPersistenceBackendFactory.getInstance());

    ResourceSet rSet = new ResourceSetImpl();
    rSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put(BlueprintsURI.SCHEME,
            PersistentResourceFactory.getInstance());

    try (PersistentResource resource = (PersistentResource) rSet
            .createResource(BlueprintsURI.createFileURI(new File("models/sample.graphdb")))) {
        resource.load(Collections.emptyMap());
        checkModel(resource);
        Model model = (Model) resource.getContents().get(0);

        // Add an Adapter to the top-level element that outputs a simple log when an event is received
        model.eAdapters().add(new AdapterImpl() {
            @Override
            public void notifyChanged(Notification msg) {
                NeoLogger.info("Notification (type {0}) received from {1}", msg.getEventType(),
                        msg.getNotifier().getClass().getName());
            }
        });
        String oldName = model.getName();   // doesn't generate a log
        model.setName("New Name");          // generates a log
        model.setName(oldName);             // generates a log

    }
}
项目:model-repository-benchmark    文件:NodeAdapterFactory.java   
/**
     * Creates a new adapter for an object of class '{@link com.opencanarias.mset.benchmark.repository.model.neo4emf.node.Node <em>Node</em>}'.
     * <!-- begin-user-doc -->
     * This default implementation returns null so that we can easily ignore cases;
     * it's useful to ignore a case when inheritance will catch all the cases anyway.
     * <!-- end-user-doc -->
     * @return the new adapter.
     * @see com.opencanarias.mset.benchmark.repository.model.neo4emf.node.Node
     * @generated
     */
    public Adapter createNodeAdapter() {
        return new AdapterImpl(){
        @Override
        public void notifyChanged(Notification msg){            
                if (msg.getEventType()==INeo4emfNotification.GET){
                    EObject eObject = (EObject)msg.getNotifier();
//                  ((INeo4emfResource)eObject.eResource()).notifyGet(eObject,(EStructuralFeature)msg.getFeature());
                }
            }
        };
    }
项目:framework-grid    文件:EmfGridTableConfigurator.java   
private void registerAdapters() {
    configAdapter = new AdapterImpl() {
        @Override
        public void notifyChanged(Notification msg) {
            if (msg.getFeature() == GridPackage.Literals.MGRID_CONFIGURATION_SET__VIEW_SELECTION_MODE) {
                applySelectionMode();
            }
            // TODO add missing features
        }
    };
    config.eAdapters().add(configAdapter);
}
项目:NIEM-Modeling-Tool    文件:DiagramAspectActionProvider.java   
@Override
public ICommand getPostCommand(final IAdaptable viewAdapter) {
    final AbstractTransactionalCommand c = new AbstractTransactionalCommand(getTheEditingDomain(),
            Activator.INSTANCE.getString("_UI_DiagramPostAction_command_name"), null) {
        @Override
        protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info)
                throws ExecutionException {
            final View theNamespaceNode = (View) viewAdapter.getAdapter(View.class);
            final EObject theNamespace = theNamespaceNode.getElement();
            final Diagram theNamespaceDiagram = createAClassDiagram(theNamespace, theNamespaceNode.eResource(),
                    getThePageManager());
            createAnHyperLink(theNamespaceNode, theNamespaceDiagram);
            theNamespace.eAdapters().add(new AdapterImpl() {
                @Override
                public void notifyChanged(final Notification msg) {
                    final String theNewName = msg.getNewStringValue();
                    if (UMLPackage.Literals.NAMED_ELEMENT__NAME.equals(msg.getFeature())
                            && notEqual(msg.getOldValue(), theNewName)
                            && notEqual(theNewName, theNamespaceDiagram.getName())) {
                        theNamespaceDiagram.setName(theNewName);
                        updateAnHyperLink(theNamespaceNode, theNewName, theNewName);
                    }
                }
            });
            return CommandResult.newOKCommandResult();
        }
    };
    return c;
}
项目:termsuite-ui    文件:TerminologyPart.java   
@PostConstruct
public void createControls(final IEclipseContext context, 
        final ESelectionService selectionService,
        final EMenuService menuService,
        final EPartService partService,
        final Composite parent, MPart part) {
    parent.setLayout(new GridLayout(7, false));

    viewerConfig = createDefaultViewerConfig();
    context.set(ETerminoViewerConfig.class, viewerConfig);
    this.eventBroker.subscribe(
            TermSuiteEvents.SEARCH_TEXT_MODIFIED, 
            event -> viewerConfig.setSearchString((String)event.getProperty(IEventBroker.DATA))
        );
    viewerConfig.eAdapters().add(new AdapterImpl(){
        @Override
        public void notifyChanged(Notification msg) {
            super.notifyChanged(msg);
            if(msg.getFeatureID(ETerminoViewerConfig.class) == TermsuiteuiPackage.ETERMINO_VIEWER_CONFIG__SELECTED_PROPERTY_NAMES) {
                switch(msg.getEventType()) {
                case Notification.REMOVE:
                    Property<?> removedProperty = PropertyUtil.forName(msg.getOldStringValue());
                    for(TreeColumn column:viewer.getTree().getColumns()) {
                        if(column.getData().equals(removedProperty))
                            column.dispose();
                    }
                    break;
                case Notification.ADD:
                    createColumn(PropertyUtil.forName(msg.getNewStringValue()));
                }
                viewer.getControl().getParent().layout();
            }
        }
    });


    // populate headers
    createFilterHeader(parent);

    // populate viewer
    Composite container = new Composite(parent, SWT.None);
    GridDataFactory.fillDefaults().span(7, 1).grab(true, true).applyTo(container);
    createViewer(container);

    viewer.getNbTermsDisplayed().addChangeListener(e -> {
        ETerminology eTerminology = context.get(ETerminology.class);
        totalDisplayedTerms.setText(getTotalText(
                viewer.getNbTermsDisplayed().getValue(),
                eTerminologyService.readTerminology(eTerminology).getTerminology().getTerms().size()));
    });
    viewer.addSelectionChangedListener(e -> {
        IStructuredSelection selection = (IStructuredSelection)e.getSelection();
        if(!selection.isEmpty()) {
            Object el = selection.getFirstElement();
            if(el instanceof TermService) {
                selectionService.setSelection(el);
                termSuiteSelectionService.setActiveTerm((TermService)el);
            } if(el instanceof RelationService) {
                selectionService.setSelection(((RelationService)el).getTo());
                termSuiteSelectionService.setActiveTerm(((RelationService)el).getTo());
            }
        }
    });
}
项目:eavp    文件:FXRenderObject.java   
/**
 * The default constructor.
 * 
 * @param source
 *            The object to be rendered.
 * @param meshCache
 *            The cache of TriangleMeshes from which this object will draw
 *            the mesh to render.
 */
public FXRenderObject(INode source, MeshCache<TriangleMesh> meshCache) {
    super();

    // Save the data members
    this.source = source;
    this.meshCache = meshCache;

    // Create a new, empty group for the render
    render = new Group();

    // Try to get a mesh based on the source's type.
    TriangleMesh mesh = meshCache.getMesh(source.getType());

    // If there was no mesh for the source's type, instead specify one by a
    // mesh of triangles
    if (mesh == null) {
        mesh = meshCache.getMesh(source.getTriangles());
    }

    // If a mesh was returned, create a view from it and add it to the
    // render group. Otherwise, we will use an empty group to render the
    // object.
    if (mesh != null) {
        render.getChildren().add(new MeshView(mesh));
    }

    // Register as a listener to the source object
    source.eAdapters().add(new AdapterImpl() {
        @Override
        public void notifyChanged(Notification notification) {
            handleUpdate(notification);
        }
    });

    // Get the center of the data object from the source
    Vertex center = source.getCenter();

    // Move the render to the correct location
    if (center != null) {
        render.setTranslateX(center.getX());
        render.setTranslateY(center.getY());
        render.setTranslateZ(center.getZ());
    }
}
项目:OpenSPIFe    文件:ComboBindingFactory.java   
/**
 * Setup an EMF adapter on the target object that updates the combo control's choices and label when there is a change in the
 * value(s) of one of the features that the combo choice list depends on
 * 
 * @param combo
 * @param p
 * @param labeler
 * @param dependsOn
 */
protected void setupComboUpdater(final Combo combo, final Label label, final DetailProviderParameter p, final LabelProvider labeler, final List<EStructuralFeature> dependsOn) {
    final EObject object = p.getTarget();
    final IItemPropertyDescriptor pd = p.getPropertyDescriptor();
    final Adapter comboUpdater = new AdapterImpl() {
        @Override
        public void notifyChanged(Notification msg) {
            if (dependsOn.contains(msg.getFeature())) {
                WidgetUtils.runInDisplayThread(combo, new Runnable() {
                    @Override
                    public void run() {
                        Object selection = null;
                        int index = combo.getSelectionIndex();
                        if (index >= 0) {
                            selection = combo.getItem(index);
                        }
                        List<Object> choices = getComboChoices(p);
                        // Update the values used in the two FiniteOrderedSetUpdateValueStrategy instances
                        targetToModelUpdateValueStrategy.setValues(choices);
                        modelToTargetUpdateValueStrategy.setValues(choices);
                        String items[];
                        if (pd.isSortChoices(object)) {
                            items = sort(choices, labeler);
                        } else {
                            items = label(choices, labeler);
                        }
                        combo.setItems(items);
                        // reselect old selection if it is still amongst the items
                        if (selection != null) {
                            for (int i=0; i<items.length; i++) {
                                if (items[i].equals(selection)) {
                                    combo.select(i);
                                    break;
                                }
                            }
                        }
                        // the label for the combo may need updating as well
                        String displayName = pd.getDisplayName(object);
                        if (!label.getText().equals(displayName)) {
                            label.setText(displayName);
                            label.getParent().layout();
                        }
                    }
                });
            }
        }
    };
    object.eAdapters().add(comboUpdater);
    combo.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            object.eAdapters().remove(comboUpdater);
            combo.removeDisposeListener(this);
        }
    });
}
项目:NeoEMF    文件:NewResourceNotifier.java   
public static void main(String[] args) throws IOException {
    JavaPackage.eINSTANCE.eClass();
    JavaFactory factory = JavaFactory.eINSTANCE;

    PersistenceBackendFactoryRegistry.register(BlueprintsURI.SCHEME,
            BlueprintsPersistenceBackendFactory.getInstance());

    ResourceSet rSet = new ResourceSetImpl();
    rSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put(BlueprintsURI.SCHEME,
            PersistentResourceFactory.getInstance());

    try (PersistentResource resource = (PersistentResource) rSet
            .createResource(BlueprintsURI.createFileURI(new File("models/notifier_example.graphdb")))) {
        resource.save(Collections.emptyMap());
        // Create a new Model element with and set its name
        Model newModel = factory.createModel();
        newModel.setName("myModel");
        // Add the created element to the resource
        resource.getContents().add(newModel);

        // Add an Adapter to the top-level element that outputs a simple log
        // when an event is received
        newModel.eAdapters().add(new AdapterImpl() {
            @Override
            public void notifyChanged(Notification msg) {
                NeoLogger.info("Notification (type {0}) received from {1}", msg.getEventType(),
                        msg.getNotifier().getClass().getName());
            }
        });

        // Update the Model
        String oldName = newModel.getName();                                    // doesn't generate a log
        newModel.setName("New Name");                                           // generates a log
        newModel.getCompilationUnits().add(factory.createCompilationUnit());    // generates a log

        // Save the resource and update it again
        resource.save(Collections.emptyMap());
        newModel.setName(oldName);                                              // generates a log

    }
}