use of org.eclipse.swt.events.ControlListener in project yamcs-studio by yamcs.
the class DataLinkTableViewer method addFixedColumns.
private void addFixedColumns(TableColumnLayout tcl) {
TableViewerColumn nameColumn = new TableViewerColumn(this, SWT.LEFT);
nameColumn.getColumn().setText(COL_NAME);
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(18));
TableViewerColumn typeColumn = new TableViewerColumn(this, SWT.LEFT);
typeColumn.getColumn().setText(COL_TYPE);
tcl.setColumnData(typeColumn.getColumn(), new ColumnWeightData(18));
TableViewerColumn specColumn = new TableViewerColumn(this, SWT.LEFT);
specColumn.getColumn().setText(COL_SPEC);
tcl.setColumnData(specColumn.getColumn(), new ColumnWeightData(18));
TableViewerColumn streamColumn = new TableViewerColumn(this, SWT.LEFT);
streamColumn.getColumn().setText(COL_STREAM);
tcl.setColumnData(streamColumn.getColumn(), new ColumnWeightData(18));
TableViewerColumn statusColumn = new TableViewerColumn(this, SWT.CENTER);
statusColumn.getColumn().setText(COL_STATUS);
tcl.setColumnData(statusColumn.getColumn(), new ColumnWeightData(18));
TableViewerColumn datacount = new TableViewerColumn(this, SWT.RIGHT);
datacount.getColumn().setText(COL_DATACOUNT);
tcl.setColumnData(datacount.getColumn(), new ColumnWeightData(10));
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(nameColumn);
columns.add(typeColumn);
columns.add(specColumn);
columns.add(streamColumn);
columns.add(statusColumn);
columns.add(datacount);
for (TableViewerColumn column : columns) {
// prevent resize to 0
column.getColumn().addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (column.getColumn().getWidth() < 5)
column.getColumn().setWidth(5);
}
});
}
}
use of org.eclipse.swt.events.ControlListener in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Control method test_addControlListenerLorg_eclipse_swt_events_ControlListener.
@Test
public void test_addControlListenerLorg_eclipse_swt_events_ControlListener() {
ControlListener listener = new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
eventOccurred = true;
}
@Override
public void controlResized(ControlEvent e) {
eventOccurred = true;
}
};
control.addControlListener(listener);
eventOccurred = false;
control.notifyListeners(SWT.Move, new Event());
assertTrue(eventOccurred);
eventOccurred = false;
control.notifyListeners(SWT.Resize, new Event());
assertTrue(eventOccurred);
control.removeControlListener(listener);
}
use of org.eclipse.swt.events.ControlListener in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Control method test_addControlListenerControlMovedAdapterLorg_eclipse_swt_events_ControlListener.
@Test
public void test_addControlListenerControlMovedAdapterLorg_eclipse_swt_events_ControlListener() {
ControlListener listener = ControlListener.controlMovedAdapter(e -> eventOccurred = true);
control.addControlListener(listener);
eventOccurred = false;
control.notifyListeners(SWT.Move, new Event());
assertTrue(eventOccurred);
eventOccurred = false;
control.notifyListeners(SWT.Resize, new Event());
assertFalse(eventOccurred);
control.removeControlListener(listener);
eventOccurred = false;
control.notifyListeners(SWT.Move, new Event());
assertFalse(eventOccurred);
control.notifyListeners(SWT.Resize, new Event());
assertFalse(eventOccurred);
}
use of org.eclipse.swt.events.ControlListener in project eclipse.platform.swt by eclipse.
the class Bug497705_setBoundsAfterSetVisible method fails_unecessaryEvents.
@Test
public void fails_unecessaryEvents() {
// Breaks on Gtk3.8 & onwards
testControl.setVisible(false);
AtomicInteger resizeCount = new AtomicInteger(0);
AtomicInteger moveCount = new AtomicInteger(0);
testControl.addControlListener(new ControlListener() {
@Override
public void controlResized(ControlEvent e) {
resizeCount.incrementAndGet();
}
@Override
public void controlMoved(ControlEvent e) {
moveCount.incrementAndGet();
}
});
for (int i = 0; i < 10; i++) {
// Once bounds set, calling same bounds shouldn't trigger SWT.MOVE events.
testControl.setBounds(x, y, width, height);
}
if (resizeCount.get() != 1 || moveCount.get() != 1) {
passed = false;
log.append("\nERROR:\nExpected only one Resize and one Move event.\nActually received R/M:" + resizeCount.get() + "/" + moveCount.get());
}
}
use of org.eclipse.swt.events.ControlListener in project tmdm-studio-se by Talend.
the class XObjectBrowser method createToolbar.
protected void createToolbar(final Composite parent) {
toolBar = new TdEditorToolBar(parent);
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
toolBar.getToolbarControl().setLayoutData(data);
toolBar.addResizeListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
parent.getParent().layout(true);
parent.layout(true);
}
});
}
Aggregations