[327369] EAR Library Directory field should not have preceding slash
diff --git a/features/org.eclipse.jst.enterprise_ui.feature.patch/buildnotes_org.eclipse.jst.enterprise_ui.feature.patch.html b/features/org.eclipse.jst.enterprise_ui.feature.patch/buildnotes_org.eclipse.jst.enterprise_ui.feature.patch.html
index d1d3642..2dd3b39 100644
--- a/features/org.eclipse.jst.enterprise_ui.feature.patch/buildnotes_org.eclipse.jst.enterprise_ui.feature.patch.html
+++ b/features/org.eclipse.jst.enterprise_ui.feature.patch/buildnotes_org.eclipse.jst.enterprise_ui.feature.patch.html
@@ -19,6 +19,7 @@
<p>Bug <a href='https://bugs.eclipse.org/326468'>326468</a>. Duplicate accelerator key in new web project wizard</p>
<p>Bug <a href='https://bugs.eclipse.org/326549'>326549</a>. Web Service Wizard Can Default to invalid project type</p>
<p>Bug <a href='https://bugs.eclipse.org/326963'>326963</a>. NPE when running Servlet on server if servlet-class is not defined</p>
+<p>Bug <a href='https://bugs.eclipse.org/327369'>327369</a>. EAR Library Directory field should not have preceding slash</p>
</body>
</html>
\ No newline at end of file
diff --git a/features/org.eclipse.jst.enterprise_ui.feature.patch/feature.properties b/features/org.eclipse.jst.enterprise_ui.feature.patch/feature.properties
index 8fc5680..bddd9d2 100644
--- a/features/org.eclipse.jst.enterprise_ui.feature.patch/feature.properties
+++ b/features/org.eclipse.jst.enterprise_ui.feature.patch/feature.properties
@@ -34,6 +34,7 @@
Bug https://bugs.eclipse.org/326468 Duplicate accelerator key in new web project wizard\n\
Bug https://bugs.eclipse.org/326549 Web Service Wizard Can Default to invalid project type\n\
Bug https://bugs.eclipse.org/326963 NPE when running Servlet on server if <servlet-class> is not defined\n\
+Bug https://bugs.eclipse.org/327369 EAR Library Directory field should not have preceding slash\n\
\n\
# "copyright" property - text of the "Feature Update Copyright"
diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/EarModuleDependenciesPropertyPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/EarModuleDependenciesPropertyPage.java
index 2817a44..4a5ed7f 100644
--- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/EarModuleDependenciesPropertyPage.java
+++ b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/EarModuleDependenciesPropertyPage.java
@@ -17,9 +17,12 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jst.j2ee.application.internal.operations.AddReferenceToEnterpriseApplicationDataModelProvider;
import org.eclipse.jst.j2ee.application.internal.operations.RemoveReferenceFromEnterpriseApplicationDataModelProvider;
import org.eclipse.jst.j2ee.internal.J2EEConstants;
@@ -29,11 +32,10 @@
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.jst.j2ee.internal.ui.JavaEEComponentDependencyContentProvider;
import org.eclipse.jst.j2ee.internal.ui.J2EEModuleDependenciesPropertyPage.ClasspathEntryProxy;
+import org.eclipse.jst.j2ee.internal.ui.JavaEEComponentDependencyContentProvider;
import org.eclipse.jst.j2ee.model.IEARModelProvider;
import org.eclipse.jst.j2ee.model.ModelProviderManager;
-import org.eclipse.jst.j2ee.project.EarUtilities;
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.jst.javaee.application.Application;
import org.eclipse.jst.jee.project.facet.EarCreateDeploymentFilesDataModelProvider;
@@ -68,6 +70,10 @@
AddModuleDependenciesPropertiesPage {
private String libDir = null;
private Text libDirText;
+ private ControlDecoration libDirTextErrorDecoration = null;
+ private static String earDefaultLirDir = new Path(J2EEConstants.EAR_DEFAULT_LIB_DIR).makeRelative().toString();
+ boolean previousLibDirIsValid = true;
+
public EarModuleDependenciesPropertyPage(IProject project,
ModuleAssemblyRootPage page) {
super(project, page);
@@ -84,7 +90,17 @@
}
private String loadLibDirString() {
- return EarUtilities.getEARLibDir(rootComponent);
+ String oldLibDir = null;
+ if(JavaEEProjectUtilities.isJEEComponent(rootComponent, JavaEEProjectUtilities.DD_VERSION) && JavaEEProjectUtilities.isJEEComponent(rootComponent, JavaEEProjectUtilities.FACET_VERSION)) {
+ final IEARModelProvider earModel = (IEARModelProvider)ModelProviderManager.getModelProvider(project);
+ Application app = (Application)earModel.getModelObject();
+ if(app != null)
+ oldLibDir = app.getLibraryDirectory();
+ }
+ if(oldLibDir != null) {
+ return oldLibDir;
+ }
+ return earDefaultLirDir;
}
protected void addLibDirComposite(Composite parent) {
@@ -102,8 +118,11 @@
l.setText(Messages.EarModuleDependenciesPropertyPage_LIBDIR);
libDirText = new Text(c, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- libDirText.setLayoutData(gd);
+ gd.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
libDirText.setText(libDir);
+ libDirText.setLayoutData(gd);
+ libDirTextErrorDecoration = new ControlDecoration(libDirText, SWT.TOP | SWT.LEAD);
+ libDirTextErrorDecoration.hide();
libDirText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
libDirTextModified();
@@ -113,6 +132,34 @@
protected void libDirTextModified() {
libDir = libDirText.getText();
+ validatelibDirText();
+ }
+
+ protected void validatelibDirText() {
+ if(libDirTextErrorDecoration != null) {
+ if(!isValidLibDir(libDir)) {
+ libDirTextErrorDecoration.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
+ libDirTextErrorDecoration.setDescriptionText(Messages.EarModuleDependenciesPropertyPage_ERROR_INVALID_LIBDIR);
+ libDirTextErrorDecoration.show();
+ propPage.setValid(false);
+ propPage.setMessage(Messages.EarModuleDependenciesPropertyPage_ERROR_HOVER_FOR_DETAILS,IStatus.ERROR);
+ propPage.setErrorMessage(Messages.EarModuleDependenciesPropertyPage_ERROR_HOVER_FOR_DETAILS);
+ previousLibDirIsValid = false;
+ } else if(!previousLibDirIsValid){
+ previousLibDirIsValid = true;
+ libDirTextErrorDecoration.setImage(null);
+ libDirTextErrorDecoration.setDescriptionText(null);
+ libDirTextErrorDecoration.hide();
+ super.verify();
+ }
+ }
+ }
+
+ private boolean isValidLibDir(String libraryDirectory) {
+ if(libraryDirectory != null && libraryDirectory.length() > 0 && libraryDirectory.trim().startsWith("/")) { //$NON-NLS-1$
+ return false;
+ }
+ return true;
}
protected IDataModelOperation generateEARDDOperation() {
@@ -200,7 +247,7 @@
}
private void updateLibDir() {
- if (!libDir.equals(J2EEConstants.EAR_DEFAULT_LIB_DIR)) {
+ if (!libDir.equals(earDefaultLirDir)) {
IVirtualFile vFile = rootComponent.getRootFolder().getFile(new Path(J2EEConstants.APPLICATION_DD_URI));
if (!vFile.exists()) {
if (!MessageDialog.openQuestion(null,
@@ -214,7 +261,7 @@
final IEARModelProvider earModel = (IEARModelProvider)ModelProviderManager.getModelProvider(project);
Application app = (Application)earModel.getModelObject();
String oldLibDir = app.getLibraryDirectory();
- if (libDir.equals(J2EEConstants.EAR_DEFAULT_LIB_DIR)) {
+ if (libDir.equals(earDefaultLirDir)) {
if(oldLibDir != null) {
earModel.modify(new Runnable() {
public void run() {
@@ -264,4 +311,16 @@
return super.canRemove(selectedObject) && !(selectedObject instanceof JavaEEComponentDependencyContentProvider.ConsumedClasspathEntryProxy);
}
+ @Override
+ protected void verify() {
+ super.verify();
+ validatelibDirText();
+ }
+
+ @Override
+ public void performDefaults() {
+ libDir = loadLibDirString();
+ libDirText.setText(libDir);
+ super.performDefaults();
+ }
}
diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/Messages.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/Messages.java
index 3feab37..407ccfb 100644
--- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/Messages.java
+++ b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/Messages.java
@@ -9,6 +9,8 @@
public static String EarModuleDependenciesPropertyPage_2;
public static String EarModuleDependenciesPropertyPage_3;
public static String EarModuleDependenciesPropertyPage_LIBDIR;
+ public static String EarModuleDependenciesPropertyPage_ERROR_INVALID_LIBDIR;
+ public static String EarModuleDependenciesPropertyPage_ERROR_HOVER_FOR_DETAILS;
public static String EarModuleDependencyPageProvider_0;
public static String WebDependencyPropertyPage_0;
public static String WebDependencyPropertyPage_1;
diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/messages.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/messages.properties
index 1ec9c38..e6f065a 100644
--- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/messages.properties
+++ b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/messages.properties
@@ -3,6 +3,8 @@
EarModuleDependenciesPropertyPage_2=Edit Ear Module Reference...
EarModuleDependenciesPropertyPage_3=Define packaging structure for this Java EE Application project.
EarModuleDependenciesPropertyPage_LIBDIR=EAR &library directory:
+EarModuleDependenciesPropertyPage_ERROR_INVALID_LIBDIR=Library directory value cannot begin with a slash ('/') character. Specify as relative path to the root of the project.
+EarModuleDependenciesPropertyPage_ERROR_HOVER_FOR_DETAILS=Library directory cannot begin with slash. Hover over error below for details.
EarModuleDependencyPageProvider_0=Ear Module Assembly
WebDependencyPropertyPage_0=Add Web Library Reference...
WebDependencyPropertyPage_1=Define packaging structure for this Java EE Web Application project.