Search in sources :

Example 1 with SimpleWranglerRefactoring

use of org.erlide.wrangler.refactoring.core.SimpleWranglerRefactoring in project erlide_eclipse by erlang.

the class ComboInputPage method createControl.

@Override
public void createControl(final Composite parent) {
    composite = new Composite(parent, SWT.NONE);
    inputLabel = new Label(composite, SWT.LEFT);
    inputLabel.setText(labelText);
    // GridData gridData = new GridData();
    // gridData.horizontalAlignment = GridData.FILL;
    // gridData.horizontalSpan = 2;
    // inputLabel.setLayoutData(gridData);
    selectionList = new Combo(composite, SWT.DROP_DOWN);
    for (final String s : moduleNames) {
        selectionList.add(s);
    }
    // gridData = new GridData();
    // gridData.horizontalAlignment = GridData.FILL;
    // gridData.horizontalSpan = 2;
    // selectionList.setLayoutData(gridData);
    // GridLayout layout = new GridLayout();
    final RowLayout layout = new RowLayout();
    layout.spacing = 5;
    layout.center = true;
    composite.setLayout(layout);
    setControl(composite);
    selectionList.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
        }

        @Override
        @SuppressWarnings("synthetic-access")
        public void widgetSelected(final SelectionEvent e) {
            ((SimpleOneStepWranglerRefactoring) getRefactoring()).setUserInput(selectionList.getText());
            setPageComplete(true);
        }
    });
    final IValidator validator = new AtomValidator();
    selectionList.addModifyListener(e -> {
        if (validator.isValid(selectionList.getText())) {
            ((SimpleWranglerRefactoring) getRefactoring()).setUserInput(selectionList.getText());
            setErrorMessage(null);
            setPageComplete(true);
        } else {
            setPageComplete(false);
            setErrorMessage("Module name must be a a valid atom!");
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) IValidator(org.erlide.wrangler.refactoring.ui.validator.IValidator) RowLayout(org.eclipse.swt.layout.RowLayout) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Combo(org.eclipse.swt.widgets.Combo) SimpleWranglerRefactoring(org.erlide.wrangler.refactoring.core.SimpleWranglerRefactoring) SelectionListener(org.eclipse.swt.events.SelectionListener) AtomValidator(org.erlide.wrangler.refactoring.ui.validator.AtomValidator)

Example 2 with SimpleWranglerRefactoring

use of org.erlide.wrangler.refactoring.core.SimpleWranglerRefactoring in project erlide_eclipse by erlang.

the class SimpleInputPage method createControl.

@Override
public void createControl(final Composite parent) {
    composite = new Composite(parent, SWT.NONE);
    inputLabel = new Label(composite, SWT.LEFT);
    inputLabel.setText(labelText);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.horizontalSpan = 2;
    inputLabel.setLayoutData(gridData);
    inputText = new Text(composite, SWT.NONE);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.horizontalSpan = 2;
    gridData.grabExcessHorizontalSpace = true;
    inputText.setLayoutData(gridData);
    final GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    composite.setLayout(layout);
    setControl(composite);
    inputText.addModifyListener(e -> isInputValid());
    inputText.setText(defaultInput);
    inputText.setFocus();
    inputText.setSelection(0, defaultInput.length());
    ((SimpleWranglerRefactoring) getRefactoring()).setUserInput(inputText.getText());
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) SimpleWranglerRefactoring(org.erlide.wrangler.refactoring.core.SimpleWranglerRefactoring)

Aggregations

Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 SimpleWranglerRefactoring (org.erlide.wrangler.refactoring.core.SimpleWranglerRefactoring)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Combo (org.eclipse.swt.widgets.Combo)1 Text (org.eclipse.swt.widgets.Text)1 AtomValidator (org.erlide.wrangler.refactoring.ui.validator.AtomValidator)1 IValidator (org.erlide.wrangler.refactoring.ui.validator.IValidator)1