Author: scabanovich
Date: 2011-03-11 17:25:12 -0500 (Fri, 11 Mar 2011)
New Revision: 29718
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java
Log:
JBIDE-8515
https://issues.jboss.org/browse/JBIDE-8515
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
===================================================================
---
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2011-03-11
22:15:59 UTC (rev 29717)
+++
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2011-03-11
22:25:12 UTC (rev 29718)
@@ -82,6 +82,8 @@
public static String MESSAGE_QUALIFIER_NOT_SET;
+ public static String MESSAGE_BEAN_SHOULD_BE_SERIALIZABLE;
+
public static String MAKE_FIELD_STATIC_MARKER_RESOLUTION_TITLE;
public static String MAKE_METHOD_PUBLIC_MARKER_RESOLUTION_TITLE;
public static String MAKE_METHOD_BUSINESS_MARKER_RESOLUTION_TITLE;
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
===================================================================
---
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2011-03-11
22:15:59 UTC (rev 29717)
+++
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2011-03-11
22:25:12 UTC (rev 29718)
@@ -66,6 +66,8 @@
MESSAGE_QUALIFIER_NOT_SET=Qualifier is not set
+MESSAGE_BEAN_SHOULD_BE_SERIALIZABLE=Bean with selected scope should implement
java.io.Serializable.
+
MAKE_FIELD_STATIC_MARKER_RESOLUTION_TITLE=Make ''{0}'' field static
MAKE_METHOD_PUBLIC_MARKER_RESOLUTION_TITLE=Make ''{0}'' method public
MAKE_METHOD_BUSINESS_MARKER_RESOLUTION_TITLE=Add ''{0}'' method to
''{1}'' interface
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java
===================================================================
---
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java 2011-03-11
22:15:59 UTC (rev 29717)
+++
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java 2011-03-11
22:25:12 UTC (rev 29718)
@@ -55,9 +55,11 @@
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.ICDIAnnotation;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IQualifier;
+import org.jboss.tools.cdi.core.IScope;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUiImages;
import org.jboss.tools.common.ui.widget.editor.CheckBoxFieldEditor;
@@ -128,7 +130,7 @@
interfacesNames.add(name);
setDefaultTypeName(name);
}
- interfacesNames.add("java.io.Serializable");
+// interfacesNames.add("java.io.Serializable");
setSuperInterfaces(interfacesNames, true);
superInterfacesChanged();
}
@@ -394,9 +396,63 @@
ArrayList<String> values = new ArrayList<String>();
values.add("");
scope = createComboField("Scope", CDIUIMessages.FIELD_EDITOR_SCOPE_LABEL,
composite, values);
+ scope.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ onScopeModified();
+ }
+ });
setScopes(getPackageFragmentRoot());
}
+ void onScopeModified() {
+ fSuperInterfacesStatus = superInterfacesChanged();
+ doStatusUpdate();
+ }
+
+ protected IStatus superInterfacesChanged() {
+ StatusInfo result = (StatusInfo)super.superClassChanged();
+ if(!checkScopeAndSerializable())
+ if (!result.isError() && !result.isWarning() &&
!checkScopeAndSerializable()) {
+ result.setWarning(CDIUIMessages.MESSAGE_BEAN_SHOULD_BE_SERIALIZABLE);
+ }
+
+ return result;
+ }
+
+ boolean checkScopeAndSerializable() {
+ if(scope == null) return true;
+ IJavaProject jp = getJavaProject();
+ if(jp == null) return true;
+ boolean isPassivating = false;
+ String scopeName = scope.getValueAsString();
+ String qScopeName = scopes.get(scopeName);
+ if(CDIConstants.SESSION_SCOPED_ANNOTATION_TYPE_NAME.equals(qScopeName)) {
+ isPassivating = true;
+ } else {
+ ICDIProject cdi = NewCDIAnnotationWizardPage.getCDIProject(jp);
+ if(cdi != null) {
+ IScope s = cdi.getScope(qScopeName);
+ if(s != null && s.isNorlmalScope() &&
cdi.isPassivatingScope(s.getSourceType())) {
+ isPassivating = true;
+ }
+ }
+ }
+ if(isPassivating) {
+ boolean result = false;
+ List list = getSuperInterfaces();
+ if(list != null) {
+ for (int i = 0; i < list.size() && !result; i++) {
+ if("java.io.Serializable".equals(list.get(i).toString())) {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+ return true;
+ }
+
+
protected ITaggedFieldEditor createComboField(String name, String label, Composite
composite, List<String> values) {
ITaggedFieldEditor result = IFieldEditorFactory.INSTANCE.createComboEditor(name, label,
values, values.get(0));
((CompositeEditor)result).addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,
"")});
@@ -409,5 +465,16 @@
return result;
}
+ public void setScope(String qScopeName) {
+ String[] tags = scope.getTags();
+ for (String t: tags) {
+ String n = scopes.get(t);
+ if(qScopeName.equals(n)) {
+ scope.setValue(t);
+ doStatusUpdate();
+ return;
+ }
+ }
+ }
}
\ No newline at end of file