use of org.eclipse.swt.events.ControlEvent in project yamcs-studio by yamcs.
the class ParameterTableViewer 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(40));
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterInfo cnt = (ParameterInfo) element;
return cnt.getQualifiedName();
}
});
TableViewerColumn engValueColumn = new TableViewerColumn(this, SWT.RIGHT);
engValueColumn.getColumn().setText(COL_ENG);
tcl.setColumnData(engValueColumn.getColumn(), new ColumnWeightData(10));
engValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
return String.valueOf(getValue(value.getEngValue()));
}
});
TableViewerColumn rawValueColumn = new TableViewerColumn(this, SWT.RIGHT);
rawValueColumn.getColumn().setText(COL_RAW);
tcl.setColumnData(rawValueColumn.getColumn(), new ColumnWeightData(10));
rawValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
return String.valueOf(getValue(value.getRawValue()));
}
});
TableViewerColumn gentimeValueColumn = new TableViewerColumn(this, SWT.LEFT);
gentimeValueColumn.getColumn().setText(COL_TIME);
tcl.setColumnData(gentimeValueColumn.getColumn(), new ColumnWeightData(20));
gentimeValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date time = new Date(value.getGenerationTime());
String strDate = sdfDate.format(time);
return strDate;
}
});
TableViewerColumn aqutimeValueColumn = new TableViewerColumn(this, SWT.LEFT);
aqutimeValueColumn.getColumn().setText(COL_AQU_TIME);
tcl.setColumnData(aqutimeValueColumn.getColumn(), new ColumnWeightData(20));
aqutimeValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date time = new Date(value.getAcquisitionTime());
String strDate = sdfDate.format(time);
return strDate;
}
});
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(nameColumn);
columns.add(engValueColumn);
columns.add(rawValueColumn);
columns.add(gentimeValueColumn);
columns.add(aqutimeValueColumn);
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.ControlEvent in project yamcs-studio by yamcs.
the class CommandHistoryView method addFixedColumns.
private void addFixedColumns() {
TableViewerColumn stateColumn = new TableViewerColumn(tableViewer, SWT.NONE);
stateColumn.getColumn().setImage(headerCompleteImage);
stateColumn.getColumn().addSelectionListener(getSelectionAdapter(stateColumn.getColumn()));
stateColumn.getColumn().setToolTipText("Completion");
stateColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
switch(((CommandHistoryRecord) element).getCommandState()) {
case COMPLETED:
return checkmarkImage;
case FAILED:
return errorImage;
default:
return null;
}
}
@Override
public String getText(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
switch(((CommandHistoryRecord) element).getCommandState()) {
case COMPLETED:
return "Completed";
case FAILED:
return rec.getPTVInfo().getFailureMessage();
default:
return null;
}
}
});
tableLayout.addColumnData(new ColumnPixelData(90));
TableViewerColumn gentimeColumn = new TableViewerColumn(tableViewer, SWT.NONE);
gentimeColumn.getColumn().setText(COL_T);
gentimeColumn.getColumn().addSelectionListener(getSelectionAdapter(gentimeColumn.getColumn()));
gentimeColumn.getColumn().setToolTipText("Generation Time");
gentimeColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((CommandHistoryRecord) element).getGenerationTime();
}
});
tableLayout.addColumnData(new ColumnPixelData(150));
TableViewerColumn nameColumn = new TableViewerColumn(tableViewer, SWT.NONE);
nameColumn.getColumn().setText(COL_COMMAND);
nameColumn.getColumn().setToolTipText("Command String");
nameColumn.getColumn().addSelectionListener(getSelectionAdapter(nameColumn.getColumn()));
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
return rec.getCommandString();
}
});
tableLayout.addColumnData(new ColumnPixelData(500));
TableViewerColumn originColumn = new TableViewerColumn(tableViewer, SWT.NONE);
originColumn.getColumn().setText(COL_SRC);
originColumn.getColumn().setToolTipText("Source (user@origin)");
originColumn.getColumn().addSelectionListener(getSelectionAdapter(originColumn.getColumn()));
originColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
return rec.getUsername() + "@" + rec.getOrigin();
}
});
tableLayout.addColumnData(new ColumnPixelData(200));
TableViewerColumn seqIdColumn = new TableViewerColumn(tableViewer, SWT.CENTER);
seqIdColumn.getColumn().setText(COL_SRC_ID);
seqIdColumn.getColumn().addSelectionListener(getSelectionAdapter(seqIdColumn.getColumn()));
seqIdColumn.getColumn().setToolTipText("Client ID");
seqIdColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return String.valueOf(((CommandHistoryRecord) element).getSequenceNumber());
}
});
tableLayout.addColumnData(new ColumnPixelData(50));
TableViewerColumn ptvColumn = new TableViewerColumn(tableViewer, SWT.CENTER);
ptvColumn.getColumn().setText(COL_PTV);
ptvColumn.getColumn().addSelectionListener(getSelectionAdapter(ptvColumn.getColumn()));
ptvColumn.getColumn().setToolTipText("Pre-Transmission Verification");
ptvColumn.setLabelProvider(new CenteredImageLabelProvider() {
@Override
public Image getImage(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
switch(rec.getPTVInfo().getState()) {
case UNDEF:
return grayBubble;
case NA:
case OK:
return greenBubble;
case PENDING:
return waitingImage;
case NOK:
return redBubble;
default:
log.warning("Unexpected PTV state " + rec.getPTVInfo().getState());
return grayBubble;
}
}
@Override
public String getToolTipText(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
if (rec.getPTVInfo().getFailureMessage() != null) {
return rec.getPTVInfo().getFailureMessage();
} else {
return super.getToolTipText(element);
}
}
});
tableLayout.addColumnData(new ColumnPixelData(50));
TableViewerColumn finalSeqColumn = new TableViewerColumn(tableViewer, SWT.CENTER);
finalSeqColumn.getColumn().setText(COL_SEQ_ID);
finalSeqColumn.getColumn().addSelectionListener(getSelectionAdapter(finalSeqColumn.getColumn()));
finalSeqColumn.getColumn().setToolTipText("Final Sequence Count");
finalSeqColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
return (rec.getFinalSequenceCount() != null) ? String.valueOf(rec.getFinalSequenceCount()) : "-";
}
});
tableLayout.addColumnData(new ColumnPixelData(50));
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(gentimeColumn);
columns.add(nameColumn);
columns.add(originColumn);
columns.add(seqIdColumn);
columns.add(ptvColumn);
columns.add(finalSeqColumn);
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) {
checkMinWidth(column.getColumn());
}
});
}
// TODO use IMemento or something
tableViewer.getTable().setSortColumn(gentimeColumn.getColumn());
tableViewer.getTable().setSortDirection(SWT.DOWN);
getViewSite().setSelectionProvider(tableViewer);
}
use of org.eclipse.swt.events.ControlEvent in project yamcs-studio by yamcs.
the class CommandQueuesTableViewer method addFixedColumns.
private void addFixedColumns(TableColumnLayout tcl) {
TableViewerColumn nameColumn = new TableViewerColumn(this, SWT.NONE);
nameColumn.getColumn().setText(COL_QUEUE);
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(40));
TableViewerColumn stateColumn = new TableViewerColumn(this, SWT.CENTER);
stateColumn.getColumn().setText(COL_STATE);
stateColumn.getColumn().setWidth(250);
stateColumn.setEditingSupport(new StateEditingSupport(stateColumn.getViewer()));
tcl.setColumnData(stateColumn.getColumn(), new ColumnWeightData(30));
TableViewerColumn commandsColumn = new TableViewerColumn(this, SWT.CENTER);
commandsColumn.getColumn().setText(COL_COMMANDS);
tcl.setColumnData(commandsColumn.getColumn(), new ColumnWeightData(10));
TableViewerColumn sentColumn = new TableViewerColumn(this, SWT.CENTER);
sentColumn.getColumn().setText(COL_SENT);
tcl.setColumnData(sentColumn.getColumn(), new ColumnWeightData(10));
TableViewerColumn rejectedColumn = new TableViewerColumn(this, SWT.CENTER);
rejectedColumn.getColumn().setText(COL_REJECTED);
tcl.setColumnData(rejectedColumn.getColumn(), new ColumnWeightData(10));
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(nameColumn);
columns.add(stateColumn);
columns.add(commandsColumn);
columns.add(sentColumn);
columns.add(rejectedColumn);
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.ControlEvent in project translationstudio8 by heartsome.
the class QAResultViewPart method createTable.
public void createTable() {
table = new KTable(parent, SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWTX.FILL_WITH_LASTCOL | SWT.WRAP);
tableModel = new KtableModel();
table.setModel(tableModel);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
table.setColorRightBorder(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
table.setColorLeftBorder(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
table.setColorTopBorder(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
table.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
locationRow();
}
});
table.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.keyCode == QAConstant.QA_CENTERKEY_1 || e.keyCode == QAConstant.QA_CENTERKEY_2) {
locationRow();
}
}
});
table.addCellResizeListener(new KTableCellResizeListener() {
public void rowResized(int arg0, int arg1) {
tableModel.textRenderer.clearRowHeiMap();
table.redraw();
}
public void columnResized(int arg0, int arg1) {
tableModel.textRenderer.clearRowHeiMap();
table.redraw();
}
});
table.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
tableModel.textRenderer.clearRowHeiMap();
table.redraw();
}
});
table.addMouseWheelListener(new MouseWheelListener() {
public void mouseScrolled(MouseEvent e) {
tableModel.textRenderer.clearRowHeiMap();
table.redraw();
}
});
createPropMenu();
}
use of org.eclipse.swt.events.ControlEvent in project translationstudio8 by heartsome.
the class TerminologyViewPart method createPartControl.
/**
* 创建控件。
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
this.parent = parent;
createAction();
GridLayout parentGl = new GridLayout(1, false);
parentGl.marginWidth = 0;
parentGl.marginHeight = 0;
parent.setLayout(parentGl);
final Composite contentPanel = new Composite(parent, SWT.NONE);
GridLayout secondPageCompositeGl = new GridLayout(1, false);
secondPageCompositeGl.marginBottom = -1;
secondPageCompositeGl.marginLeft = -1;
secondPageCompositeGl.marginRight = -1;
secondPageCompositeGl.marginTop = -1;
secondPageCompositeGl.marginWidth = 0;
secondPageCompositeGl.marginHeight = 0;
contentPanel.setLayout(secondPageCompositeGl);
contentPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
contentPanel.setLayout(secondPageCompositeGl);
contentPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// firstPageComposite = new Composite(contentPanel, SWT.NONE);
// firstPageComposite.setLayout(new GridLayout(1, false));
// secondPageComposite = new Composite(contentPanel, SWT.NONE);
// GridLayout secondPageCompositeGl = new GridLayout(1, false);
// secondPageCompositeGl.marginBottom = -1;
// secondPageCompositeGl.marginLeft = -1;
// secondPageCompositeGl.marginRight = -1;
// secondPageCompositeGl.marginTop = -1;
// secondPageCompositeGl.marginWidth = 0;
// secondPageCompositeGl.marginHeight = 0;
// secondPageComposite.setLayout(secondPageCompositeGl);
// secondPageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
gridTable = new Grid(contentPanel, SWT.BORDER | SWT.V_SCROLL);
gridTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
gridTable.setHeaderVisible(true);
gridTable.setAutoHeight(true);
gridTable.setRowsResizeable(true);
gridTable.setData("selectedBgColor", selectedBgColor);
final GridColumn idItem = new GridColumn(gridTable, SWT.NONE);
idItem.setText(Messages.getString("view.TerminologyViewPart.idItem"));
idColumnCellRenderer.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));
idColumnCellRenderer.setVerticalAlignment(SWT.CENTER);
idItem.setCellRenderer(idColumnCellRenderer);
idItem.setWordWrap(true);
srcTableColumn = new GridColumn(gridTable, SWT.NONE);
srcTableColumn.setText(Messages.getString("view.TerminologyViewPart.srcTableColumn"));
srcColumnCellRenderer.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));
srcTableColumn.setCellRenderer(srcColumnCellRenderer);
srcTableColumn.setWordWrap(true);
tgtTableColumn = new GridColumn(gridTable, SWT.NONE);
tgtTableColumn.setText(Messages.getString("view.TerminologyViewPart.tgtTableColumn"));
tgtColumnCellRenderer.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));
tgtTableColumn.setCellRenderer(tgtColumnCellRenderer);
tgtTableColumn.setWordWrap(true);
final GridColumn propertyColumn = new GridColumn(gridTable, SWT.NONE);
propertyColumn.setText(Messages.getString("view.TerminologyViewPart.propertyColumn"));
propColumnCellRenderer.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));
propertyColumn.setCellRenderer(propColumnCellRenderer);
propertyColumn.setWordWrap(true);
copyEnable = new GridCopyEnable(gridTable);
srcColumnCellRenderer.setCopyEnable(copyEnable);
tgtColumnCellRenderer.setCopyEnable(copyEnable);
// 设置列宽按比例
contentPanel.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Rectangle area = contentPanel.getClientArea();
Point preferredSize = gridTable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// - 2 * gridTable.getBorderWidth();
int width = area.width;
if (preferredSize.y > area.height + gridTable.getHeaderHeight()) {
Point vBarSize = gridTable.getVerticalBar().getSize();
width -= vBarSize.x;
}
gridTable.setSize(area.width, area.height);
width -= 45;
idItem.setWidth(45);
srcTableColumn.setWidth((int) (width * 0.4));
tgtTableColumn.setWidth((int) (width * 0.4));
propertyColumn.setWidth((int) (width * 0.2));
}
});
Composite statusComposite = new Composite(contentPanel, SWT.NONE);
GridLayout statusComptGridLayout = new GridLayout(2, false);
statusComptGridLayout.marginBottom = -1;
statusComptGridLayout.marginLeft = -1;
statusComptGridLayout.marginRight = -1;
statusComptGridLayout.marginTop = -1;
statusComptGridLayout.marginWidth = 0;
statusComptGridLayout.marginHeight = 0;
statusComposite.setLayout(statusComptGridLayout);
statusComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
tipLabel = new CLabel(statusComposite, SWT.NONE);
tipLabel.setAlignment(SWT.LEFT);
CLabel label = new CLabel(statusComposite, SWT.None);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gd.heightHint = 20;
label.setLayoutData(gd);
gridTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectItem();
}
});
gridTable.addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event event) {
firstAction.run();
}
});
initHookMenu();
}
Aggregations