Search in sources :

Example 1 with ConfigVerifyer

use of org.mybatis.generator.eclipse.ui.content.ConfigVerifyer in project generator by mybatis.

the class ConfigurationComposite method getViewerFilter.

@Override
protected ViewerFilter getViewerFilter() {
    return new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IContainer) {
                return true;
            }
            if (element instanceof IFile) {
                IFile file = (IFile) element;
                ConfigVerifyer cv = new ConfigVerifyer(file);
                return cv.isConfigurationFile();
            }
            return false;
        }
    };
}
Also used : IFile(org.eclipse.core.resources.IFile) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Viewer(org.eclipse.jface.viewers.Viewer) ConfigVerifyer(org.mybatis.generator.eclipse.ui.content.ConfigVerifyer) IContainer(org.eclipse.core.resources.IContainer)

Example 2 with ConfigVerifyer

use of org.mybatis.generator.eclipse.ui.content.ConfigVerifyer in project generator by mybatis.

the class ConfigurationComposite method isValid.

public boolean isValid() {
    try {
        String fileName = txtFileName.getText();
        String fullPath = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fileName);
        File file = new File(fullPath);
        if (file.exists()) {
            ConfigVerifyer cv = new ConfigVerifyer(file);
            if (cv.isConfigurationFile()) {
                configurationTab.setErrorMessage(null);
                return true;
            } else {
                configurationTab.setErrorMessage(Messages.CONFIGURATION_TAB_INVALID_MESSAGE);
                return false;
            }
        } else {
            configurationTab.setErrorMessage(Messages.FILE_PICKER_FILE_DOESNT_EXIST);
            return false;
        }
    } catch (CoreException e) {
        return false;
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ConfigVerifyer(org.mybatis.generator.eclipse.ui.content.ConfigVerifyer) File(java.io.File) IFile(org.eclipse.core.resources.IFile)

Aggregations

IFile (org.eclipse.core.resources.IFile)2 ConfigVerifyer (org.mybatis.generator.eclipse.ui.content.ConfigVerifyer)2 File (java.io.File)1 IContainer (org.eclipse.core.resources.IContainer)1 CoreException (org.eclipse.core.runtime.CoreException)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1