Search in sources :

Example 46 with VerifyEvent

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());
}
Also used : ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) VerifyListener(org.eclipse.swt.events.VerifyListener) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) Text(org.eclipse.swt.widgets.Text) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 47 with VerifyEvent

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();
        }
    });
}
Also used : Pattern(java.util.regex.Pattern) VerifyListener(org.eclipse.swt.events.VerifyListener) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) VerifyEvent(org.eclipse.swt.events.VerifyEvent) SampleDataShowWay(org.talend.dataquality.analysis.SampleDataShowWay)

Example 48 with VerifyEvent

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;
}
Also used : Pattern(java.util.regex.Pattern) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) VerifyListener(org.eclipse.swt.events.VerifyListener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 49 with VerifyEvent

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()));
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) VerifyListener(org.eclipse.swt.events.VerifyListener) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) GridData(org.eclipse.swt.layout.GridData) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 50 with VerifyEvent

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;
}
Also used : Dictionary(net.sourceforge.sqlexplorer.sessiontree.model.utility.Dictionary) Composite(org.eclipse.swt.widgets.Composite) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) ExecSQLAction(net.sourceforge.sqlexplorer.sqleditor.actions.ExecSQLAction) KeyAdapter(org.eclipse.swt.events.KeyAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) SQLTextViewer(net.sourceforge.sqlexplorer.sqleditor.SQLTextViewer) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) VerifyEvent(org.eclipse.swt.events.VerifyEvent) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

VerifyEvent (org.eclipse.swt.events.VerifyEvent)57 VerifyListener (org.eclipse.swt.events.VerifyListener)41 Text (org.eclipse.swt.widgets.Text)29 GridData (org.eclipse.swt.layout.GridData)21 ModifyEvent (org.eclipse.swt.events.ModifyEvent)19 ModifyListener (org.eclipse.swt.events.ModifyListener)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 Composite (org.eclipse.swt.widgets.Composite)18 Label (org.eclipse.swt.widgets.Label)18 GridLayout (org.eclipse.swt.layout.GridLayout)17 VerifyKeyListener (org.eclipse.swt.custom.VerifyKeyListener)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 Point (org.eclipse.swt.graphics.Point)14 KeyEvent (org.eclipse.swt.events.KeyEvent)12 Button (org.eclipse.swt.widgets.Button)11 FocusEvent (org.eclipse.swt.events.FocusEvent)10 StyledText (org.eclipse.swt.custom.StyledText)7 MouseEvent (org.eclipse.swt.events.MouseEvent)7 Font (org.eclipse.swt.graphics.Font)7 Pattern (java.util.regex.Pattern)6