Search in sources :

Example 1 with IErlModelChangeListener

use of org.erlide.engine.model.root.IErlModelChangeListener in project erlide_eclipse by erlang.

the class IErlModelTest method addModelChangeListener.

// void addModelChangeListener(IErlModelChangeListener listener);
// void removeModelChangeListener(IErlModelChangeListener listener);
@Test
public void addModelChangeListener() throws Exception {
    final List<IErlElement> changed = Lists.newArrayList();
    final IErlModelChangeListener listener = new IErlModelChangeListener() {

        @Override
        public void elementChanged(final IErlElement element) {
            changed.add(element);
        }
    };
    final IErlModule module2 = ErlideTestUtils.createModule(project, "zz.erl", "-module(zz).\n");
    final IErlModule module3 = ErlideTestUtils.createModule(project, "tt.erl", "-module(tt).\n");
    model.addModelChangeListener(listener);
    module2.open(null);
    model.removeModelChangeListener(listener);
    module3.open(null);
    final List<IErlElement> changed2 = Lists.newArrayList(changed);
    changed.clear();
    final List<IErlElement> changed3 = Lists.newArrayList(changed);
    changed.clear();
    assertEquals(1, changed2.size());
    assertEquals(0, changed3.size());
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlModule(org.erlide.engine.model.root.IErlModule) IErlModelChangeListener(org.erlide.engine.model.root.IErlModelChangeListener) Test(org.junit.Test)

Aggregations

IErlElement (org.erlide.engine.model.IErlElement)1 IErlModelChangeListener (org.erlide.engine.model.root.IErlModelChangeListener)1 IErlModule (org.erlide.engine.model.root.IErlModule)1 Test (org.junit.Test)1