Author: scabanovich
Date: 2012-02-22 13:12:38 -0500 (Wed, 22 Feb 2012)
New Revision: 39008
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewDSXMLWizard.java
Log:
JBIDE-10787
https://issues.jboss.org/browse/JBIDE-10787
Fixes in validation and messages.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2012-02-22 18:09:16 UTC (rev
39007)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2012-02-22 18:12:38 UTC (rev
39008)
@@ -192,13 +192,13 @@
</selection>
</wizard>
<wizard
- name="New JBoss Datasource"
+ name="JBoss Datasource"
icon="$nl$/images/xstudio/wizards/new_properties_file.gif"
category="org.jboss.tools.jst.web"
class="org.jboss.tools.jst.web.ui.wizards.newfile.NewDSXMLWizard"
id="org.jboss.tools.jst.web.ui.wizards.newfile.NewDSXMLWizard">
<description>
- Creates New DS XML file
+ Creates New JBoss Datasource file
</description>
<selection
class="org.eclipse.core.resources.IResource">
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java 2012-02-22
18:09:16 UTC (rev 39007)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/Messages.java 2012-02-22
18:12:38 UTC (rev 39008)
@@ -86,11 +86,19 @@
public static String NewXHTMLTemplatesWizardPage_7;
public static String NewDSXMLWizard_TITLE;
+ public static String NewDSXMLWizard_SUBTITLE;
public static String NewDSXMLWizard_DESCRIPTION;
public static String NewDSXMLWizard_CONNECTION_PROFILE_FIELD;
public static String NewDSXMLWizard_TEMPLATE_FIELD;
public static String NewDSXMLWizard_EDIT_BUTTON;
public static String NewDSXMLWizard_NEW_BUTTON;
+ public static String NewDSXMLWizard_FILE_EXISTS;
+ public static String NewDSXMLWizard_PROJECT_NOT_EXISTS;
+ public static String NewDSXMLWizard_PROJECT_NOT_ACCESSIBLE;
+ public static String NewDSXMLWizard_PROFILE_NOT_SET;
+ public static String NewDSXMLWizard_FOLDER_NOT_SET;
+ public static String NewDSXMLWizard_PARENT_FOLDER_LABEL;
+ public static String NewDSXMLWizard_FILE_NAME_LABEL;
static {
// initialize resource bundle
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties 2012-02-22
18:09:16 UTC (rev 39007)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/messages.properties 2012-02-22
18:12:38 UTC (rev 39008)
@@ -79,8 +79,16 @@
UI_WIZARD_XHTML_NEW_Description=Create New XHTML Page
NewDSXMLWizard_TITLE=New JBoss Datasource
+NewDSXMLWizard_SUBTITLE=JBoss Datasource
NewDSXMLWizard_DESCRIPTION=Create New JBoss Datasource
NewDSXMLWizard_CONNECTION_PROFILE_FIELD=Connection profile:
NewDSXMLWizard_TEMPLATE_FIELD=Template:
NewDSXMLWizard_EDIT_BUTTON=Edit...
NewDSXMLWizard_NEW_BUTTON=New...
+NewDSXMLWizard_FILE_EXISTS=''{0}'' already exists.
+NewDSXMLWizard_PROJECT_NOT_EXISTS=Selected project does not exist.
+NewDSXMLWizard_PROJECT_NOT_ACCESSIBLE=Selected project is not accessible.
+NewDSXMLWizard_PROFILE_NOT_SET=Select connenction profile.
+NewDSXMLWizard_FOLDER_NOT_SET=Select parent folder.
+NewDSXMLWizard_PARENT_FOLDER_LABEL=Parent fold&er:
+NewDSXMLWizard_FILE_NAME_LABEL=File na&me:
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewDSXMLWizard.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewDSXMLWizard.java 2012-02-22
18:09:16 UTC (rev 39007)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewDSXMLWizard.java 2012-02-22
18:12:38 UTC (rev 39008)
@@ -123,7 +123,7 @@
public void addPages() {
super.addPages();
mainPage = new WizardNewDSXMLFileCreationPage("newFilePage1",
getSelection()); //$NON-NLS-1$
- mainPage.setTitle(Messages.NewDSXMLWizard_TITLE);
+ mainPage.setTitle(Messages.NewDSXMLWizard_SUBTITLE);
mainPage.setDescription(Messages.NewDSXMLWizard_DESCRIPTION);
mainPage.setFileName("ds.xml"); //$NON-NLS-1$
@@ -199,7 +199,7 @@
private IFieldEditor connProfileSelEditor;
private IFieldEditor templateSelEditor;
private IFieldEditor folderEditor;
- private String initialFileName = "";
+ private String initialFileName = ""; //$NON-NLS-1$
private IFieldEditor fileNameEditor;
IDataModel model;
@@ -345,12 +345,12 @@
}
});
- String defaultFolder = "";
+ String defaultFolder = ""; //$NON-NLS-1$
IContainer c = getInitialContainer();
if(c != null) {
defaultFolder = c.getFullPath().toString();
}
- folderEditor =
IFieldEditorFactory.INSTANCE.createBrowseWorkspaceFolderEditor("folder",
"Parent fold&er:", defaultFolder);
+ folderEditor =
IFieldEditorFactory.INSTANCE.createBrowseWorkspaceFolderEditor("folder",
Messages.NewDSXMLWizard_PARENT_FOLDER_LABEL, defaultFolder); //$NON-NLS-1$
folderEditor.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
setPageComplete(validatePage());
@@ -358,10 +358,10 @@
});
folderEditor.doFillIntoGrid(q);
- String prefix = toDatasourceName(mainPage.connProfileSelEditor.getValueAsString());
+ String prefix = toDatasourceName(connProfileSelEditor.getValueAsString());
String defaultFileName = prefix + "-ds.xml"; //$NON-NLS-1$
- fileNameEditor = IFieldEditorFactory.INSTANCE.createTextEditor("name",
"File na&me:", defaultFileName);
+ fileNameEditor = IFieldEditorFactory.INSTANCE.createTextEditor("name",
Messages.NewDSXMLWizard_FILE_NAME_LABEL, defaultFileName); //$NON-NLS-1$
fileNameEditor.doFillIntoGrid(q);
fileNameEditor.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
@@ -375,6 +375,10 @@
protected boolean validatePage() {
IPath path = getContainerFullPath();
+ if(path.segmentCount() == 0) {
+ setErrorMessage(Messages.NewDSXMLWizard_FOLDER_NOT_SET);
+ return false;
+ }
String fileName = fileNameEditor.getValueAsString();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
@@ -393,14 +397,22 @@
}
IPath filePath = path.append(fileName);
if(workspace.getRoot().getFile(filePath).exists()) {
- setErrorMessage("'" + fileName + "'" + " already
exists.");
+ setErrorMessage(NLS.bind(Messages.NewDSXMLWizard_FILE_EXISTS, fileName));
return false;
}
-
+ IProject selectedProject = workspace.getRoot().getProject(path.segment(0));
+ if(!selectedProject.exists()) {
+ setErrorMessage(Messages.NewDSXMLWizard_PROJECT_NOT_EXISTS);
+ return false;
+ } else if(!selectedProject.isAccessible()) {
+ setErrorMessage(Messages.NewDSXMLWizard_PROJECT_NOT_ACCESSIBLE);
+ return false;
+ }
+
if(connProfileSelEditor != null) {
String p = connProfileSelEditor.getValueAsString();
if(p == null || p.length() == 0) {
- setErrorMessage("Connenction profile must be set.");
+ setErrorMessage(Messages.NewDSXMLWizard_PROFILE_NOT_SET);
return false;
}
}
@@ -411,8 +423,7 @@
IFile newFile = null;
protected IFile createFileHandle(IPath filePath) {
- return IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getFile(
- filePath);
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
}
public IFile createNewFile() {
if (newFile != null) {
@@ -469,8 +480,7 @@
} catch (InvocationTargetException e) {
// Execution Exceptions are handled above but we may still get
// unexpected runtime errors.
- IDEWorkbenchPlugin.log(getClass(),
- "createNewFile()", e.getTargetException()); //$NON-NLS-1$
+ IDEWorkbenchPlugin.log(getClass(), "createNewFile()",
e.getTargetException()); //$NON-NLS-1$
MessageDialog.open(MessageDialog.ERROR,
getContainer().getShell(),
IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
@@ -481,8 +491,6 @@
newFile = newFileHandle;
return newFile;
}
-
-
}
/**