use of org.eclipse.swt.events.VerifyEvent in project mdw-designer by CenturyLinkCloud.
the class LoadTestLaunchTab method createTableViewer.
protected void createTableViewer() {
testCasesTableViewer = new TableViewer(testCasesTable);
testCasesTableViewer.setUseHashlookup(true);
testCasesTableViewer.setColumnProperties(testCasesColumnProps);
CellEditor[] editors = new CellEditor[testCasesColumnSpecs.size()];
for (int i = 0; i < testCasesColumnSpecs.size(); i++) {
ColumnSpec colSpec = testCasesColumnSpecs.get(i);
CellEditor cellEditor = null;
if (colSpec.type.equals(PropertyEditor.TYPE_TEXT)) {
if (i == 1)
cellEditor = new TextCellEditor(testCasesTable);
else {
// Text with digits only for 3rd column
cellEditor = new TextCellEditor(testCasesTable);
((Text) cellEditor.getControl()).addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent e) {
e.doit = "0123456789".indexOf(e.text) >= 0;
}
});
}
} else if (colSpec.type.equals(PropertyEditor.TYPE_CHECKBOX)) {
cellEditor = new CheckboxCellEditor(testCasesTable);
}
editors[i] = cellEditor;
}
testCasesTableViewer.setCellEditors(editors);
testCasesTableViewer.setCellModifier(new TestCaseCellModifier());
testCasesTableViewer.setLabelProvider(new TestCaseLabelProvider());
testCasesTableViewer.setContentProvider(new TestCaseContentProvider());
}
use of org.eclipse.swt.events.VerifyEvent in project tdq-studio-se by Talend.
the class AbstractAnalysisMetadataPage method createRefreshDataButtonComp.
/**
* create "Refresh Button", and the row control input.
*
* @param buttonComposite
*/
private void createRefreshDataButtonComp(Composite parent) {
Composite dataQueryComp = toolkit.createComposite(parent, SWT.NONE);
GridLayout dataQueryCompLayout = new GridLayout(4, Boolean.FALSE);
dataQueryComp.setLayout(dataQueryCompLayout);
// create the input to control how many rows will be loaded.
Label rowLoadedLabel = toolkit.createLabel(dataQueryComp, DefaultMessagesImpl.getString("MatchMasterDetailsPage.ControlRowsLabel"), // $NON-NLS-1$
SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(rowLoadedLabel);
rowLoadedText = toolkit.createText(dataQueryComp, null, SWT.BORDER);
// $NON-NLS-1$
rowLoadedText.setToolTipText(DefaultMessagesImpl.getString("ColumnAnalysisDetailsPage.ControlRowsLabelTooltip"));
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(rowLoadedText);
// fix the width of the text field
GridData textData = new GridData();
textData.widthHint = 100;
rowLoadedText.setLayoutData(textData);
int number = Integer.valueOf(getAnalysisHandler().getDefaultLoadedRowCount()) > PREVIEW_MAX_ROW_COUNT ? PREVIEW_SUGGEST_ROW_COUNT : Integer.valueOf(getAnalysisHandler().getDefaultLoadedRowCount());
rowLoadedText.setText(String.valueOf(number));
rowLoadedText.setTextLimit(3);
rowLoadedText.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent e) {
String inputValue = e.text;
// $NON-NLS-1$
Pattern pattern = Pattern.compile("^[0-9]");
char[] charArray = inputValue.toCharArray();
for (char c : charArray) {
if (!pattern.matcher(String.valueOf(c)).matches()) {
e.doit = false;
}
}
}
});
rowLoadedText.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
setDirty(true);
}
});
// ADD msjian TDQ-8428: add random way to show data
sampleDataShowWayCombo = new CCombo(dataQueryComp, SWT.BORDER);
sampleDataShowWayCombo.setEditable(false);
for (SampleDataShowWay value : SampleDataShowWay.VALUES) {
sampleDataShowWayCombo.add(value.getLiteral());
}
SampleDataShowWay sampleDataShowWay = getCurrentModelElement().getParameters().getSampleDataShowWay();
sampleDataShowWayCombo.setText(sampleDataShowWay.getLiteral());
sampleDataShowWayCombo.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
setDirty(true);
}
});
// TDQ-8428~
Button refreshDataBtn = toolkit.createButton(dataQueryComp, DefaultMessagesImpl.getString("MatchMasterDetailsPage.RefreshDataButton"), // $NON-NLS-1$
SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(refreshDataBtn);
refreshDataBtn.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
refreshPreviewData();
}
});
}
use of org.eclipse.swt.events.VerifyEvent in project tdq-studio-se by Talend.
the class AbstractAnalysisMetadataPage method createAnalysisLimitComposite.
/**
* DOC xqliu Comment method "createAnalysisLimitComposite".
*
* @param pComp
* @return
*/
protected Composite createAnalysisLimitComposite(Composite pComp) {
Composite comp = pComp;
comp.setLayout(new GridLayout(2, false));
this.toolkit.createLabel(comp, // $NON-NLS-1$
DefaultMessagesImpl.getString("AnalysisTuningPreferencePage.NumberOfConnectionsPerAnalysis"));
this.numberOfConnectionsPerAnalysisText = this.toolkit.createText(comp, AnalysisHandler.createHandler(getCurrentModelElement()).getNumberOfConnectionsPerAnalysisWithContext(), SWT.BORDER);
GridDataFactory.fillDefaults().grab(false, true).applyTo(this.numberOfConnectionsPerAnalysisText);
((GridData) this.numberOfConnectionsPerAnalysisText.getLayoutData()).widthHint = 240;
installProposals(numberOfConnectionsPerAnalysisText);
this.numberOfConnectionsPerAnalysisText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
setDirty(true);
}
});
this.numberOfConnectionsPerAnalysisText.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent e) {
String inputValue = e.text;
// if it is context variable, do not check
if (!ContextHelper.isContextVar(inputValue)) {
// $NON-NLS-1$
Pattern pattern = Pattern.compile("^[0-9]");
char[] charArray = inputValue.toCharArray();
for (char c : charArray) {
if (!pattern.matcher(String.valueOf(c)).matches()) {
e.doit = false;
}
}
}
}
});
return comp;
}
use of org.eclipse.swt.events.VerifyEvent in project tdq-studio-se by Talend.
the class IndicatorDefinitionMaterPage method buildAggregateDateComp.
/**
* DOC xqliu Comment method "buildAggregateDateComp".
*
* @param expressionBodyComp
* @param aggregateDateExpression
* @param style
* @param title
* @param headers
* @param widths
*/
private void buildAggregateDateComp(final Composite expressionBodyComp, final AggregateDateExpression aggregateDateExpression, int style, String title, String[] headers, int[] widths) {
Label label = new Label(expressionBodyComp, SWT.LEFT);
label.setText(title);
Table table = new Table(expressionBodyComp, style);
table.setHeaderVisible(true);
table.setLinesVisible(true);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
for (int i = 0; i < headers.length; ++i) {
TableColumn tableColumn = new TableColumn(table, SWT.LEFT, i);
tableColumn.setText(headers[i]);
tableColumn.setWidth(widths[i]);
}
TableViewer tableViewer = new TableViewer(table);
tableViewer.setUseHashlookup(true);
tableViewer.setColumnProperties(headers);
CellEditor[] editors = new CellEditor[headers.length];
for (int i = 0; i < editors.length; ++i) {
editors[i] = new TextCellEditor(table);
((Text) editors[i].getControl()).addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent e) {
e.doit = !ADDITIONAL_FUNCTIONS_SPLIT.equals(e.text);
}
});
}
tableViewer.setCellEditors(editors);
if (aggregateDateExpression.haveAggregateExpression()) {
tableViewer.setCellModifier(new AggregateCellModifier(headers, tableViewer));
tableViewer.setContentProvider(new CommonContentProvider());
tableViewer.setLabelProvider(new AggregateLabelProvider());
tableViewer.setInput(new AggregateVO(aggregateDateExpression.getAggregateExpression()));
}
if (aggregateDateExpression.haveDateExpression()) {
tableViewer.setCellModifier(new DateCellModifier(headers, tableViewer));
tableViewer.setContentProvider(new CommonContentProvider());
tableViewer.setLabelProvider(new DateLabelProvider());
tableViewer.setInput(new DateVO(aggregateDateExpression.getDateExpression()));
}
}
use of org.eclipse.swt.events.VerifyEvent in project tdq-studio-se by Talend.
the class SQLTextEditor method createSourceViewer.
@Override
protected ISourceViewer createSourceViewer(final Composite parent, IVerticalRuler ruler, int style) {
parent.setLayout(new FillLayout());
final Composite myParent = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = layout.marginWidth = layout.horizontalSpacing = layout.verticalSpacing = 0;
myParent.setLayout(layout);
// create divider line
Composite div1 = new Composite(myParent, SWT.NONE);
GridData lgid = new GridData();
lgid.grabExcessHorizontalSpace = true;
lgid.horizontalAlignment = GridData.FILL;
lgid.heightHint = 1;
lgid.verticalIndent = 1;
div1.setLayoutData(lgid);
div1.setBackground(editor.getSite().getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
// create text viewer
GridData gid = new GridData();
gid.grabExcessHorizontalSpace = gid.grabExcessVerticalSpace = true;
gid.horizontalAlignment = gid.verticalAlignment = GridData.FILL;
Dictionary dictionary = null;
if (editor.getSession() != null && _enableContentAssist) {
dictionary = editor.getSession().getUser().getMetaDataSession().getDictionary();
}
sqlTextViewer = new SQLTextViewer(myParent, style, store, dictionary, ruler);
sqlTextViewer.getControl().setLayoutData(gid);
// create bottom divider line
Composite div2 = new Composite(myParent, SWT.NONE);
lgid = new GridData();
lgid.grabExcessHorizontalSpace = true;
lgid.horizontalAlignment = GridData.FILL;
lgid.heightHint = 1;
lgid.verticalIndent = 0;
div2.setLayoutData(lgid);
div2.setBackground(editor.getSite().getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
final SQLEditor thisEditor = editor;
sqlTextViewer.getTextWidget().addVerifyKeyListener(new VerifyKeyListener() {
private ExecSQLAction _execSQLAction = new ExecSQLAction(thisEditor);
@Override
public void verifyKey(VerifyEvent event) {
if (event.stateMask == SWT.CTRL && event.keyCode == 13) {
event.doit = false;
_execSQLAction.run();
}
}
});
sqlTextViewer.getTextWidget().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
SQLTextEditor.this.editor.getEditorSite().getPage().activate(SQLTextEditor.this.editor.getEditorSite().getPart());
}
});
myParent.layout();
IDocument dc = new Document();
sqlTextViewer.setDocument(dc);
mcl.install(sqlTextViewer);
return sqlTextViewer;
}
Aggregations