Author: dazarov
Date: 2009-04-23 13:17:15 -0400 (Thu, 23 Apr 2009)
New Revision: 14874
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameComponentWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1077
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2009-04-23
15:02:45 UTC (rev 14873)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2009-04-23
17:17:15 UTC (rev 14874)
@@ -281,6 +281,8 @@
public static String VALIDATOR_FACTORY_LOCAL_INTERFACE_NAME_IS_NOT_VALID;
public static String VALIDATOR_FACTORY_NAME_IS_NOT_VALID;
+
+ public static String VALIDATOR_FACTORY_COMPONENT_ALREADY_EXISTS;
public static String VALIDATOR_FACTORY_PATH_POINTS_TO_FILE;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2009-04-23
15:02:45 UTC (rev 14873)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2009-04-23
17:17:15 UTC (rev 14874)
@@ -35,6 +35,7 @@
import org.eclipse.jdt.internal.corext.util.Messages;
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
@@ -246,8 +247,15 @@
public static final IValidator SEAM_COMPONENT_NAME_VALIDATOR = new IValidator() {
public Map<String, IStatus> validate(Object value, Object context) {
- IStatus status = JavaConventions.validateClassFileName(value
- .toString()
+ String name = value.toString();
+ if(context != null && context instanceof ISeamProject){
+ ISeamProject seamProject = (ISeamProject)context;
+ ISeamComponent component = seamProject.getComponent(name);
+ if(component != null)
+ return createErrormessage(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID,
SeamUIMessages.bind(SeamUIMessages.VALIDATOR_FACTORY_COMPONENT_ALREADY_EXISTS, name)));
+ }
+
+ IStatus status = JavaConventions.validateClassFileName(name
+ ".class", "5.0", "5.0"); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
if (status.isOK()) {
return NO_ERRORS;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2009-04-23
15:02:45 UTC (rev 14873)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2009-04-23
17:17:15 UTC (rev 14874)
@@ -110,6 +110,7 @@
VALIDATOR_FACTORY_JBOSS_AS_HOME_FOLDER_POINT_TO_LOCATION_THAT_DOES_NOT_LOOK_LIKE_JBOSS_AS_HOME_FOLDER=JBoss
AS Home Folder field points to location that doesn't look like JBoss AS home folder
VALIDATOR_FACTORY_COMPONENT_NAME_IS_NOT_VALID=Component name is not invalid.
VALIDATOR_FACTORY_NAME_IS_NOT_VALID={0} name is not valid.
+VALIDATOR_FACTORY_COMPONENT_ALREADY_EXISTS=Component {0} already exists.
VALIDATOR_FACTORY_LOCAL_INTERFACE_NAME_IS_NOT_VALID=Local Interface name is not valid.\n
VALIDATOR_FACTORY_NAME_IS_NOT_VALID2=\ name is not valid.
VALIDATOR_FACTORY_PROJECT_DOES_NOT_EXIST=Project ''{0}'' doesn''t
exist.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameComponentWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameComponentWizard.java 2009-04-23
15:02:45 UTC (rev 14873)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameComponentWizard.java 2009-04-23
17:17:15 UTC (rev 14874)
@@ -14,7 +14,9 @@
import java.beans.PropertyChangeListener;
import java.util.Map;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
@@ -26,6 +28,8 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.refactoring.RenameComponentProcessor;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
@@ -42,10 +46,12 @@
private ISeamComponent component;
private String componentName;
private IFieldEditor editor;
+ private ISeamProject seamProject;
public RenameComponentWizard(Refactoring refactoring, ISeamComponent component) {
super(refactoring, WIZARD_BASED_USER_INTERFACE);
this.component = component;
+ seamProject = SeamCorePlugin.getSeamProject((IProject)component.getResource(), true);
}
/* (non-Javadoc)
@@ -83,10 +89,11 @@
}
});
setControl(container);
+ setPageComplete(false);
}
protected final void validatePage() {
- Map<String, IStatus> errors =
ValidatorFactory.SEAM_COMPONENT_NAME_VALIDATOR.validate(editor.getValueAsString(), null);
+ Map<String, IStatus> errors =
ValidatorFactory.SEAM_COMPONENT_NAME_VALIDATOR.validate(editor.getValueAsString(),
seamProject);
if(errors.size()>0) {
setErrorMessage(NLS.bind(errors.get(IValidator.DEFAULT_ERROR).getMessage(),SeamUIMessages.SEAM_BASE_WIZARD_PAGE_SEAM_COMPONENTS));
setPageComplete(false);