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());
}
Aggregations