use of org.eclipse.swt.events.ControlListener in project org.eclipse.rap by eclipse-rap.
the class TableColumn_Test method testPackWithVirtual.
@Test
public void testPackWithVirtual() {
final java.util.List<Widget> log = new ArrayList<Widget>();
Listener setDataListener = new Listener() {
@Override
public void handleEvent(Event event) {
log.add(event.item);
}
};
ControlListener resizeListener = new ControlAdapter() {
@Override
public void controlResized(ControlEvent event) {
log.add(event.widget);
}
};
// Must not try to access items if there aren't any
log.clear();
table = new Table(shell, SWT.VIRTUAL);
column = new TableColumn(table, SWT.NONE);
column.setWidth(200);
column.addControlListener(resizeListener);
column.pack();
// ensure that pack() did something
assertEquals(1, log.size());
// Ensure that pack resolves only first virtual item
log.clear();
table = new Table(shell, SWT.VIRTUAL);
column = new TableColumn(table, SWT.NONE);
table.setSize(100, 50);
table.setItemCount(100);
table.addListener(SWT.SetData, setDataListener);
column.pack();
assertEquals(1, log.size());
}
use of org.eclipse.swt.events.ControlListener in project org.eclipse.rap by eclipse-rap.
the class TableColumn_Test method testRemoveControlListener.
@Test
public void testRemoveControlListener() {
ControlListener listener = mock(ControlListener.class);
column.addControlListener(listener);
column.removeControlListener(listener);
assertFalse(column.isListening(SWT.Move));
assertFalse(column.isListening(SWT.Resize));
}
use of org.eclipse.swt.events.ControlListener in project org.eclipse.rap by eclipse-rap.
the class TableColumn_Test method testMoveEvent.
@Test
public void testMoveEvent() {
final java.util.List<ControlEvent> log = new ArrayList<ControlEvent>();
column.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent event) {
fail("unexpected event: controlMoved");
}
@Override
public void controlResized(ControlEvent event) {
log.add(event);
}
});
final TableColumn column1 = new TableColumn(table, SWT.NONE);
column1.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent event) {
log.add(event);
}
@Override
public void controlResized(ControlEvent event) {
fail("unexpected event: controlResized");
}
});
ControlEvent event;
// Changing column width leads to resize event and move event of the next
// columns
log.clear();
column.setWidth(column.getWidth() + 1);
assertEquals(2, log.size());
event = log.get(0);
assertSame(column, event.getSource());
event = log.get(1);
assertSame(column1, event.getSource());
}
use of org.eclipse.swt.events.ControlListener in project org.eclipse.rap by eclipse-rap.
the class TableColumn_Test method testResizeEvent.
@Test
public void testResizeEvent() {
final java.util.List<ControlEvent> log = new ArrayList<ControlEvent>();
column.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent event) {
fail("unexpected event: controlMoved");
}
@Override
public void controlResized(ControlEvent event) {
log.add(event);
}
});
ControlEvent event;
// Changing column width leads to resize event
log.clear();
column.setWidth(column.getWidth() + 1);
assertEquals(1, log.size());
event = log.get(0);
assertSame(column, event.getSource());
// Setting the column width to the same value it already has as well leads
// to resize event
log.clear();
column.setWidth(column.getWidth());
assertEquals(1, log.size());
event = log.get(0);
assertEquals(column, event.getSource());
}
use of org.eclipse.swt.events.ControlListener in project org.eclipse.rap by eclipse-rap.
the class TreeColumn_Test method testRemoveControlListener.
@Test
public void testRemoveControlListener() {
ControlListener listener = mock(ControlListener.class);
column.addControlListener(listener);
column.removeControlListener(listener);
assertFalse(column.isListening(SWT.Move));
assertFalse(column.isListening(SWT.Resize));
}
Aggregations