use of org.eclipse.swt.events.ControlListener in project yamcs-studio by yamcs.
the class CommandHistoryView method processCommandHistoryEntry.
public void processCommandHistoryEntry(CommandHistoryEntry cmdhistEntry) {
// Maybe we need to update structure
for (CommandHistoryAttribute attr : cmdhistEntry.getAttrList()) {
if (IGNORED_ATTRIBUTES.contains(attr.getName()))
continue;
String shortName = CommandHistoryRecordContentProvider.toHumanReadableName(attr);
if (!dynamicColumns.contains(shortName)) {
TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.LEFT);
column.getColumn().setText(shortName);
column.getColumn().addSelectionListener(getSelectionAdapter(column.getColumn()));
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((CommandHistoryRecord) element).getTextForColumn(shortName, showRelativeTime);
}
@Override
public String getToolTipText(Object element) {
return ((CommandHistoryRecord) element).getTooltipForColumn(shortName);
}
@Override
public Image getImage(Object element) {
String imgLoc = ((CommandHistoryRecord) element).getImageForColumn(shortName);
if (CommandHistoryRecordContentProvider.GREEN.equals(imgLoc))
return greenBubble;
else if (CommandHistoryRecordContentProvider.RED.equals(imgLoc))
return redBubble;
else
return null;
}
});
dynamicColumns.add(shortName);
tableLayout.addColumnData(new ColumnPixelData(90));
column.getColumn().setWidth(90);
column.getColumn().addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
checkMinWidth(column.getColumn());
}
});
}
}
// Now add content
tableContentProvider.processCommandHistoryEntry(cmdhistEntry);
updateSummaryLine();
}
use of org.eclipse.swt.events.ControlListener in project yamcs-studio by yamcs.
the class CommandQueuedTableViewer method addFixedColumns.
private void addFixedColumns(TableColumnLayout tcl) {
TableViewerColumn nameColumn = new TableViewerColumn(this, SWT.NONE);
nameColumn.getColumn().setText(COL_QUEUE);
nameColumn.getColumn().setToolTipText("The queue which contains the command");
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(200));
TableViewerColumn userColumn = new TableViewerColumn(this, SWT.NONE);
userColumn.getColumn().setText(COL_USER);
userColumn.getColumn().setToolTipText("The user who submitted the command");
tcl.setColumnData(userColumn.getColumn(), new ColumnWeightData(200));
TableViewerColumn stringColumn = new TableViewerColumn(this, SWT.CENTER);
stringColumn.getColumn().setText(COL_STRING);
stringColumn.getColumn().setToolTipText("Command source code");
tcl.setColumnData(stringColumn.getColumn(), new ColumnWeightData(200));
TableViewerColumn timeColumn = new TableViewerColumn(this, SWT.LEFT);
timeColumn.getColumn().setText(COL_TIME);
timeColumn.getColumn().setToolTipText("Time");
tcl.setColumnData(timeColumn.getColumn(), new ColumnWeightData(200));
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(nameColumn);
columns.add(userColumn);
columns.add(stringColumn);
columns.add(timeColumn);
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 yamcs-studio by yamcs.
the class EventLogTableViewer method addFixedColumns.
private void addFixedColumns() {
// sort listener common for all columns
Listener sortListener = event -> {
TableColumn column = (TableColumn) event.widget;
// TODO should this sort logic not move up into this class? Why are columns passed?
EventLogContentProvider contentProvider = (EventLogContentProvider) getContentProvider();
contentProvider.sort(column);
};
TableViewerColumn messageColumn = new TableViewerColumn(this, SWT.NONE);
messageColumn.getColumn().setText(COL_MESSAGE);
messageColumn.getColumn().addListener(SWT.Selection, sortListener);
tableLayout.addColumnData(new ColumnPixelData(300));
TableViewerColumn sourceColumn = new TableViewerColumn(this, SWT.NONE);
sourceColumn.getColumn().setText(COL_SOURCE);
sourceColumn.getColumn().addListener(SWT.Selection, sortListener);
tableLayout.addColumnData(new ColumnPixelData(150));
TableViewerColumn generationColumn = new TableViewerColumn(this, SWT.NONE);
generationColumn.getColumn().setText(COL_GENERATION);
generationColumn.getColumn().addListener(SWT.Selection, sortListener);
tableLayout.addColumnData(new ColumnPixelData(150));
TableViewerColumn receptionColumn = new TableViewerColumn(this, SWT.NONE);
receptionColumn.getColumn().setText(COL_RECEPTION);
receptionColumn.getColumn().addListener(SWT.Selection, sortListener);
tableLayout.addColumnData(new ColumnPixelData(150));
TableViewerColumn seqNumColum = new TableViewerColumn(this, SWT.RIGHT);
seqNumColum.getColumn().setText(COL_SEQNUM);
seqNumColum.getColumn().addListener(SWT.Selection, sortListener);
tableLayout.addColumnData(new ColumnPixelData(80));
if (!EventLogPreferences.isShowSequenceNumberColumn()) {
tableLayout.addColumnData(new ColumnPixelData(0));
seqNumColum.getColumn().setResizable(false);
}
if (!EventLogPreferences.isShowGenerationColumn()) {
tableLayout.addColumnData(new ColumnPixelData(0));
generationColumn.getColumn().setResizable(false);
}
if (!EventLogPreferences.isShowReceptionColumn()) {
tableLayout.addColumnData(new ColumnPixelData(0));
receptionColumn.getColumn().setResizable(false);
}
for (TableColumn tableColumn : getTable().getColumns()) {
tableColumn.setMoveable(true);
// prevent resize to 0
tableColumn.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (tableColumn.getWidth() < 5)
tableColumn.setWidth(5);
}
});
}
// TODO use IMemento or something
// !! Keep these values in sync with EventLogViewerComparator constructor
getTable().setSortColumn(receptionColumn.getColumn());
getTable().setSortDirection(SWT.UP);
}
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);
}
Aggregations