Author: vyemialyanchyk
Date: 2009-02-18 12:52:17 -0500 (Wed, 18 Feb 2009)
New Revision: 13664
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java
Log:
JBIDE-3788
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java 2009-02-18
17:36:29 UTC (rev 13663)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java 2009-02-18
17:52:17 UTC (rev 13664)
@@ -49,6 +49,14 @@
if(path==null) return null;
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if(resource == null) {
+ File file = new File(path.toOSString());
+ if (file.exists()) {
+ if (file.isFile()) {
+ return file;
+ }
+ }
+ }
return pathToFile(path.toString(), resource);
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-02-18
17:36:29 UTC (rev 13663)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-02-18
17:52:17 UTC (rev 13664)
@@ -514,7 +514,9 @@
public static String PathHelper_does_not_exist;
public static String PathHelper_has_invalid_variable_references;
public static String PathHelper_not_directory;
+ public static String PathHelper_not_file;
public static String PathHelper_has_to_be_folder_or_project;
+ public static String PathHelper_has_to_be_file;
public static String PathHelper_project_for_is_closed;
//
public static String HibernateRefactoringUtil_error_during_refactoring;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-02-18
17:36:29 UTC (rev 13663)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-02-18
17:52:17 UTC (rev 13664)
@@ -505,8 +505,10 @@
GeneralExceptionStatusHandler_generating_code=Generating code
PathHelper_does_not_exist={0} does not exist [{1}]
PathHelper_not_directory=The path {0} is not a directory
+PathHelper_not_file=The path {0} is not a file
PathHelper_has_invalid_variable_references={0} has invalid variable references [{1}]
PathHelper_has_to_be_folder_or_project={0} has to be a folder or project [{1}]
+PathHelper_has_to_be_file={0} has to be a file [{1}]
PathHelper_project_for_is_closed=Project for {0} is closed [{1}]
HibernateRefactoringUtil_error_during_refactoring=Error during refactoring
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java 2009-02-18
17:36:29 UTC (rev 13663)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java 2009-02-18
17:52:17 UTC (rev 13664)
@@ -428,8 +428,9 @@
} */
if (propertyFilename.length() > 0) {
- IResource resource =
ResourcesPlugin.getWorkspace().getRoot().findMember(propertyFilename);
- String msg =
checkForFile(HibernateConsoleMessages.ConsoleConfigurationMainTab_property_file_2,
resource);
+ //IResource resource =
ResourcesPlugin.getWorkspace().getRoot().findMember(propertyFilename);
+ //String msg =
checkForFile(HibernateConsoleMessages.ConsoleConfigurationMainTab_property_file_2,
resource);
+ String msg = PathHelper.checkFile(configurationFilename,
HibernateConsoleMessages.ConsoleConfigurationMainTab_property_file_2, true);
if(msg!=null) {
setErrorMessage(msg);
return false;
@@ -437,8 +438,9 @@
}
if (!configurationFileWillBeCreated && configurationFilename.length() > 0)
{
- IResource resource =
ResourcesPlugin.getWorkspace().getRoot().findMember(configurationFilename);
- String msg =
checkForFile(HibernateConsoleMessages.ConsoleConfigurationMainTab_configuration_file_2,resource);
+ //IResource resource =
ResourcesPlugin.getWorkspace().getRoot().findMember(configurationFilename);
+ //String msg =
checkForFile(HibernateConsoleMessages.ConsoleConfigurationMainTab_configuration_file_2,resource);
+ String msg = PathHelper.checkFile(configurationFilename,
HibernateConsoleMessages.ConsoleConfigurationMainTab_configuration_file_2, true);
if(msg!=null) {
setErrorMessage(msg);
return false;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java 2009-02-18
17:36:29 UTC (rev 13663)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java 2009-02-18
17:52:17 UTC (rev 13664)
@@ -135,4 +135,57 @@
}
+ /**
+ * Checks if file exists.
+ * Handles variables replacement too.
+ *
+ * @param strpath
+ * @param name
+ * @param checkFilesystem
+ * @return
+ */
+ static public String checkFile(String strpath, String name, boolean checkFilesystem) {
+ if(strpath.indexOf("${") >= 0) { //$NON-NLS-1$
+ IStringVariableManager manager =
VariablesPlugin.getDefault().getStringVariableManager();
+ try {
+ manager.validateStringVariables(strpath);
+ }
+ catch (CoreException e) {
+ String out =
NLS.bind(HibernateConsoleMessages.PathHelper_has_invalid_variable_references, name,
e.getMessage());
+ return out;
+ }
+ }
+
+ IPath path = pathOrNull(resolve(strpath));
+
+ if (checkFilesystem && path != null) {
+ File file = new File(path.toOSString());
+ if (file.exists()) {
+ if (file.isFile()) {
+ return null;
+ }
+ String out = NLS.bind(HibernateConsoleMessages.PathHelper_not_file, path);
+ return out;
+ }
+ }
+
+ IResource res= ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (res != null) {
+ int resType= res.getType();
+ if (resType == IResource.FILE) {
+ IProject proj= res.getProject();
+ if (!proj.isOpen() ) {
+ String out =
NLS.bind(HibernateConsoleMessages.PathHelper_project_for_is_closed, name, path);
+ return out;
+ }
+ } else {
+ String out = NLS.bind(HibernateConsoleMessages.PathHelper_has_to_be_file, name,
path);
+ return out;
+ }
+ } else {
+ String out = NLS.bind(HibernateConsoleMessages.PathHelper_does_not_exist, name,
path);
+ return out;
+ }
+ return null;
+ }
}
Show replies by date