Search in sources :

Example 1 with ComboBoxPropertyDescriptor

use of org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor in project jbosstools-hibernate by jbosstools.

the class ConsoleConfigurationPropertySource method createProjectDescriptor.

private IPropertyDescriptor createProjectDescriptor() {
    ComboBoxPropertyDescriptor projectDescriptor = new ComboBoxPropertyDescriptor(// $NON-NLS-1$
    "project", HibernateConsoleMessages.ConsoleConfigurationPropertySource_project, getSortedProjectNames());
    projectDescriptor.setValidator(new ICellEditorValidator() {

        public String isValid(Object value) {
            if (value instanceof Integer) {
                if (((Integer) value).intValue() < 0) {
                    try {
                        ILaunchConfiguration lc = HibernateConsolePlugin.getDefault().findLaunchConfig(cfg.getName());
                        if (lc != null) {
                            String projectName = lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
                            if (projectName != null) {
                                return NLS.bind(HibernateConsoleMessages.ConsoleConfigurationMainTab_the_java_project_does_not_exist, projectName);
                            }
                        } else {
                            // $NON-NLS-1$//$NON-NLS-2$
                            HibernateConsolePlugin.getDefault().log("Can't find Console Configuration \"" + cfg.getName() + "\"");
                        }
                    } catch (CoreException e) {
                        HibernateConsolePlugin.getDefault().log(e);
                    }
                }
            }
            return null;
        }
    });
    return projectDescriptor;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ICellEditorValidator(org.eclipse.jface.viewers.ICellEditorValidator) ComboBoxPropertyDescriptor(org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 ICellEditorValidator (org.eclipse.jface.viewers.ICellEditorValidator)1 ComboBoxPropertyDescriptor (org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor)1