use of org.eclipse.core.runtime.CoreException 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;
}
}
use of org.eclipse.core.runtime.CoreException in project generator by mybatis.
the class RunGeneratorAction method handleException.
private void handleException(Exception exception, Shell shell) {
IStatus status;
Throwable exceptionToHandle;
if (exception instanceof InvocationTargetException) {
exceptionToHandle = ((InvocationTargetException) exception).getCause();
} else {
exceptionToHandle = exception;
}
if (exceptionToHandle instanceof InterruptedException) {
status = new Status(IStatus.CANCEL, Activator.PLUGIN_ID, IStatus.CANCEL, "Cancelled by User", exceptionToHandle);
} else if (exceptionToHandle instanceof CoreException) {
status = ((CoreException) exceptionToHandle).getStatus();
} else {
String message = "Unexpected error while running MyBatis Generator.";
status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, message, exceptionToHandle);
Activator.getDefault().getLog().log(status);
}
ErrorDialog.openError(shell, "MyBatis Generator", "Generation Failed", status, IStatus.ERROR | IStatus.CANCEL);
}
use of org.eclipse.core.runtime.CoreException in project generator by mybatis.
the class RunGeneratorThread method getJavaProject.
private IJavaProject getJavaProject() {
IJavaProject answer = null;
IProject project = inputFile.getProject();
try {
if (project.hasNature(JavaCore.NATURE_ID)) {
answer = JavaCore.create(project);
}
} catch (CoreException e) {
// ignore - something is wrong
;
}
return answer;
}
use of org.eclipse.core.runtime.CoreException in project generator by mybatis.
the class EclipseShellCallback method getSpecificSourceFolder.
private IPackageFragmentRoot getSpecificSourceFolder(IJavaProject javaProject, String targetProject) throws ShellException {
try {
Path path = new Path("/" + targetProject);
IPackageFragmentRoot pfr = javaProject.findPackageFragmentRoot(path);
if (pfr == null) {
StringBuffer sb = new StringBuffer();
sb.append("Cannot find source folder ");
sb.append(targetProject);
throw new ShellException(sb.toString());
}
return pfr;
} catch (CoreException e) {
throw new ShellException(e.getStatus().getMessage(), e);
}
}
use of org.eclipse.core.runtime.CoreException in project generator by mybatis.
the class EclipseShellCallback method getJavaProject.
private IJavaProject getJavaProject(String javaProjectName) throws ShellException {
IJavaProject javaProject = projects.get(javaProjectName);
if (javaProject == null) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(javaProjectName);
if (project.exists()) {
boolean isJavaProject;
try {
isJavaProject = project.hasNature(JavaCore.NATURE_ID);
} catch (CoreException e) {
throw new ShellException(e.getStatus().getMessage(), e);
}
if (isJavaProject) {
javaProject = JavaCore.create(project);
} else {
StringBuffer sb = new StringBuffer();
sb.append("Project ");
sb.append(javaProjectName);
sb.append(" is not a Java project");
throw new ShellException(sb.toString());
}
} else {
StringBuffer sb = new StringBuffer();
sb.append("Project ");
sb.append(javaProjectName);
sb.append(" does not exist");
throw new ShellException(sb.toString());
}
projects.put(javaProjectName, javaProject);
}
return javaProject;
}
Aggregations