Example usage for org.eclipse.jface.preference StringFieldEditor VALIDATE_ON_KEY_STROKE

List of usage examples for org.eclipse.jface.preference StringFieldEditor VALIDATE_ON_KEY_STROKE

Introduction

In this page you can find the example usage for org.eclipse.jface.preference StringFieldEditor VALIDATE_ON_KEY_STROKE.

Prototype

int VALIDATE_ON_KEY_STROKE

To view the source code for org.eclipse.jface.preference StringFieldEditor VALIDATE_ON_KEY_STROKE.

Click Source Link

Document

Validation strategy constant (value 0) indicating that the editor should perform validation after every key stroke.

Usage

From source file:eclox.core.ui.CustomDoxygenDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) {
        @Override/*ww w .j av  a  2  s.  c o  m*/
        protected void createFieldEditors() {
            targetDirectoryEditor = new DirectoryFieldEditor("", "Custom Doxygen directory:",
                    getFieldEditorParent()) {
                /** The own control is the variableButton */
                private static final int NUMBER_OF_OWN_CONTROLS = 1;

                @Override
                protected boolean doCheckState() {
                    String dirName = getTextControl().getText();
                    dirName = dirName.trim();
                    if (dirName.length() == 0 && isEmptyStringAllowed())
                        return true;
                    IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
                    String substitutedDirName;
                    try {
                        substitutedDirName = manager.performStringSubstitution(dirName);
                    } catch (CoreException e) {
                        // It's apparently invalid
                        return false;
                    }
                    File dir = new File(substitutedDirName);
                    // require the file to exist
                    return dir.exists() && dir.isDirectory();
                }

                @Override
                public int getNumberOfControls() {
                    return super.getNumberOfControls() + NUMBER_OF_OWN_CONTROLS;
                }

                @Override
                protected void doFillIntoGrid(Composite parent, int numColumns) {
                    super.doFillIntoGrid(parent, numColumns - NUMBER_OF_OWN_CONTROLS);
                }

                @Override
                protected void adjustForNumColumns(int numColumns) {
                    super.adjustForNumColumns(numColumns - NUMBER_OF_OWN_CONTROLS);
                }

                @Override
                protected void createControl(Composite parent) {
                    // setting validate strategy using the setter method is too late
                    super.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
                    super.createControl(parent);
                    if (hasDebugUiBundle()) {
                        addVariablesButton(parent);
                    }
                }

                private void addVariablesButton(Composite parent) {
                    Button variableButton = new Button(parent, SWT.PUSH);
                    variableButton.setText("&Variable...");
                    variableButton.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
                            org.eclipse.debug.ui.StringVariableSelectionDialog dialog = new org.eclipse.debug.ui.StringVariableSelectionDialog(
                                    getShell());
                            int returnCode = dialog.open();
                            if (returnCode == Window.OK)
                                setStringValue(dialog.getVariableExpression());
                        }
                    });
                }
            };
            targetDirectoryEditor.setStringValue(targetDirectory == null ? "" : targetDirectory);
            addField(targetDirectoryEditor);
        }

        @Override
        public void createControl(Composite parentComposite) {
            noDefaultAndApplyButton();
            super.createControl(parentComposite);
        }

        @Override
        protected void updateApplyButton() {
            updateButtons(isValid());
            super.updateApplyButton();
        }

        // @Override
        // protected void createButtonsForButtonBar(Composite parent) {
        // super.createButtonsForButtonBar(parent);
        // updateButtons(page.isValid());
        // }
        private void updateButtons(boolean isValid) {
            Button okButton = getButton(IDialogConstants.OK_ID);
            if (okButton != null) {
                okButton.setEnabled(isValid);
            }
        }
    };
    page.createControl(composite);
    Control pageControl = page.getControl();
    pageControl.setLayoutData(new GridData(GridData.FILL_BOTH));
    return pageControl;
}

From source file:eu.esdihumboldt.hale.io.gml.ui.wfs.WfsUrlFieldEditor.java

License:Open Source License

/**
 * Constructor//from  w  ww.  j a  v a  2s . c o m
 * 
 * @param name the preference name
 * @param labelText the label text
 * @param parent the parent composite
 */
public WfsUrlFieldEditor(String name, String labelText, Composite parent) {
    super(name, labelText, parent);

    setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    setEmptyStringAllowed(false);

    this.schemaNamespace = null;
}

From source file:eu.esdihumboldt.hale.io.gml.ui.wfs.WfsUrlFieldEditor.java

License:Open Source License

/**
 * Constructor//from   ww  w .  j  a v  a 2s  . c  o m
 * 
 * @param name the preference name
 * @param labelText the label text
 * @param parent the parent composite
 * @param schemaNamespace the schema namespace, may be <code>null</code>
 * @param getFeatures if the editor is for a GetFeature request instead of a
 *            DescribeFeature request
 */
public WfsUrlFieldEditor(String name, String labelText, Composite parent, String schemaNamespace,
        boolean getFeatures) {
    super(name, labelText, parent);
    this._getFeatures = getFeatures;

    setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    setEmptyStringAllowed(false);

    this.schemaNamespace = schemaNamespace;
}

From source file:eu.esdihumboldt.hale.ui.io.project.AbstractProjectDetailsPage.java

License:Open Source License

/**
 * @see HaleWizardPage#createContent(Composite)
 *//*from   w  w w.j  a va  2s.  c  om*/
@Override
protected void createContent(Composite page) {
    page.setLayout(new GridLayout(2, false));

    // name
    name = new StringFieldEditor("name", "Project name:", page);
    name.setEmptyStringAllowed(false);
    name.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    name.setErrorMessage("The project name must be specified.");
    name.setPage(this);

    // author
    author = new StringFieldEditor("author", "Project author:", page);
    author.setEmptyStringAllowed(false);
    author.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    author.setPage(this);

    // description
    Label descLabel = new Label(page, SWT.NONE);
    descLabel.setText("Description:");
    descLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).create());

    description = new Text(page, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
    description.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(500, SWT.DEFAULT).create());

    // listen for state changes on field editors
    IPropertyChangeListener stateListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(StringFieldEditor.IS_VALID)) {
                updateState();
            }
        }
    };
    name.setPropertyChangeListener(stateListener);
    author.setPropertyChangeListener(stateListener);

    // listen for provider changes
    getWizard().addIOWizardListener(new IOWizardListener<P, E>() {

        @Override
        public void providerDescriptorChanged(IOProviderDescriptor providerFactory) {
            // update fields as the provider will have changed
            updateFields();
        }

        @Override
        public void contentTypeChanged(IContentType contentType) {
            // ignore
        }
    });

    updateState();
    updateFields();
}

From source file:eu.esdihumboldt.hale.ui.io.project.SaveProjectDetailsPage.java

License:Open Source License

/**
 * @see HaleWizardPage#createContent(Composite)
 *///from   w w w.j  av a 2 s .  c o m
@Override
protected void createContent(Composite page) {
    page.setLayout(new GridLayout(2, false));

    // name
    name = new StringFieldEditor("name", "Project name:", page);
    name.setEmptyStringAllowed(false);
    name.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    name.setErrorMessage("The project name must be specified.");
    name.setPage(this);

    // author
    author = new StringFieldEditor("author", "Project author:", page);
    author.setEmptyStringAllowed(false);
    author.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    author.setPage(this);

    // description
    Label descLabel = new Label(page, SWT.NONE);
    descLabel.setText("Description:");
    descLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).create());

    description = new Text(page, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
    description.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(500, SWT.DEFAULT).create());

    // listen for state changes on field editors
    IPropertyChangeListener stateListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(StringFieldEditor.IS_VALID)) {
                updateState();
            }
        }
    };
    name.setPropertyChangeListener(stateListener);
    author.setPropertyChangeListener(stateListener);

    // listen for provider changes
    getWizard().addIOWizardListener(new IOWizardListener<ProjectWriter, SaveProjectWizard>() {

        @Override
        public void providerDescriptorChanged(IOProviderDescriptor providerFactory) {
            // update fields as the provider will have changed
            updateFields();
        }

        @Override
        public void contentTypeChanged(IContentType contentType) {
            // ignore
        }
    });

    updateState();
    updateFields();
}

From source file:eu.esdihumboldt.hale.ui.io.util.URIFieldEditor.java

License:Open Source License

/**
 * Default constructor
 */
public URIFieldEditor() {
    super();

    setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    setEmptyStringAllowed(false);
}

From source file:eu.esdihumboldt.hale.ui.io.util.URIFieldEditor.java

License:Open Source License

/**
 * @see StringFieldEditor#StringFieldEditor(String, String, Composite)
 *//* w ww. j av  a2 s .  co  m*/
public URIFieldEditor(String name, String labelText, Composite parent) {
    super(name, labelText, parent);

    setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    setEmptyStringAllowed(false);
}

From source file:eu.esdihumboldt.hale.ui.io.util.URLFieldEditor.java

License:Open Source License

/**
 * Default constructor
 */
public URLFieldEditor() {
    super();

    setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    setEmptyStringAllowed(false);
}

From source file:eu.esdihumboldt.hale.ui.io.util.URLFieldEditor.java

License:Open Source License

/**
 * @see StringFieldEditor#StringFieldEditor(String, String, Composite)
 *//*w  w  w.  j a va  2s  .  c om*/
public URLFieldEditor(String name, String labelText, Composite parent) {
    super(name, labelText, parent);

    setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    setEmptyStringAllowed(false);
}

From source file:eu.hydrologis.jgrass.beegisutils.project.newprojectwizard.NewBeegisProjectWizardPage.java

License:Open Source License

/**
 * Set up this page for use.//from  w  ww.j a va 2  s.com
 * 
 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
 * @param parent
 */
public void createControl(Composite parent) {

    Composite composite = new Composite(parent, SWT.NONE);

    // PROJECT NAME
    projectNameEditor = new StringFieldEditor("newproject.name", "Name of the new project", composite) {
        protected boolean doCheckState() {
            return validate();
        }
    };
    projectNameEditor.setPage(this);
    projectNameEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    projectNameEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST);
    Text textControl = projectNameEditor.getTextControl(composite);
    GridData gd = new GridData(SWT.LEFT, SWT.NONE, false, false);
    gd.widthHint = 100;
    gd.horizontalSpan = 2;
    textControl.setLayoutData(gd);

    // PROJECT PARENT FOLDER
    projectDirectoryEditor = new DirectoryFieldEditor("newproject.directory", "Base folder for the new project", //$NON-NLS-1$
            composite) {
        protected boolean doCheckState() {
            updatePathsAndLabels();
            return validate();
        }
    };
    projectDirectoryEditor.setPage(this);
    projectDirectoryEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    projectDirectoryEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST);
    projectDirectoryEditor.fillIntoGrid(composite, 3);

    Label dummyLabel = new Label(composite, SWT.NONE);
    GridData dummyGD = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
    dummyGD.horizontalSpan = 3;
    dummyLabel.setLayoutData(dummyGD);
    dummyLabel.setText("");

    Group resultGroup = new Group(composite, SWT.NONE);
    GridData resultGroupGD = new GridData(SWT.FILL, SWT.FILL, true, false);
    resultGroupGD.horizontalSpan = 3;
    resultGroup.setLayoutData(resultGroupGD);
    resultGroup.setLayout(new GridLayout(1, false));
    resultGroup.setText("Resulting folders summary");

    overallProjectFolderGroup = new Group(resultGroup, SWT.SHADOW_ETCHED_IN);
    overallProjectFolderGroup.setLayout(new GridLayout(1, false));
    overallProjectFolderGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    overallProjectFolderLabel = new Label(overallProjectFolderGroup, SWT.NONE);
    overallProjectFolderLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    overallProjectFolderLabel.setText("");

    udigProjectFolderGroup = new Group(resultGroup, SWT.SHADOW_ETCHED_IN);
    udigProjectFolderGroup.setLayout(new GridLayout(1, false));
    udigProjectFolderGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    udigProjectFolderLabel = new Label(udigProjectFolderGroup, SWT.NONE);
    udigProjectFolderLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    udigProjectFolderLabel.setText("");

    projectDatabaseFolderGroup = new Group(resultGroup, SWT.SHADOW_ETCHED_IN);
    projectDatabaseFolderGroup.setLayout(new GridLayout(1, false));
    projectDatabaseFolderGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    projectDatabaseFolderLabel = new Label(projectDatabaseFolderGroup, SWT.NONE);
    projectDatabaseFolderLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    projectDatabaseFolderLabel.setText("");

    String defaultProjectName = Messages.NewProjectWizardPage_default_name;
    String projectPath = BeegisUtilsPlugin.getDefault().getLastFolderChosen();
    projectNameEditor.setStringValue(defaultProjectName);
    projectDirectoryEditor.setStringValue(projectPath);

    updatePathsAndLabels();

    composite.pack();

    setControl(composite);
    setPageComplete(true);
}