Author: scabanovich
Date: 2011-02-11 08:51:11 -0500 (Fri, 11 Feb 2011)
New Revision: 29114
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java
Log:
JBIDE-8264
https://issues.jboss.org/browse/JBIDE-8264
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java 2011-02-11
13:41:22 UTC (rev 29113)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java 2011-02-11
13:51:11 UTC (rev 29114)
@@ -11,8 +11,25 @@
package org.jboss.tools.cdi.ui.wizard;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.ui.wizards.NewClassWizardPage;
import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.common.meta.action.XActionInvoker;
+import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
+import org.jboss.tools.common.model.options.PreferenceModelUtilities;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
/**
*
@@ -29,6 +46,7 @@
super.initPageFromAdapter();
if(adapter != null) {
((NewBeanWizardPage)fPage).setAlternative(true);
+ ((NewBeanWizardPage)fPage).setMayBeRegisteredInBeansXML(false);
}
}
/*
@@ -50,5 +68,58 @@
protected boolean canRunForked() {
return !fPage.isEnclosingTypeSelected();
}
+
+ public boolean performFinish() {
+ boolean res = super.performFinish();
+ if(res && ((NewBeanWizardPage)fPage).isToBeRegisteredInBeansXML()) {
+ IProject project = fPage.getCreatedType().getResource().getProject();
+ registerInBeansXML(project, fPage.getCreatedType().getFullyQualifiedName(),
"Alternatives", "CDIClass", "class");
+ }
+ return res;
+ }
+ public static void registerInBeansXML(IProject project, String typeName, String
folderName, String entity, String attribute) {
+ IPath path = NewBeansXMLCreationWizard.getContainerForBeansXML(project);
+ if(path != null) {
+ path = path.append("beans.xml").removeFirstSegments(1);
+ IFile beansxml = project.getFile(path);
+ if(!beansxml.exists()) {
+ try {
+ createBeansXML(beansxml);
+ } catch (CoreException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
+ }
+ if(beansxml.exists()) {
+ XModelObject o = EclipseResourceUtil.createObjectForResource(beansxml);
+ if(o != null) {
+ XModelObject as = o.getChildByPath(folderName);
+ XModelObject c = as.getModel().createModelObject(entity, new Properties());
+ c.setAttributeValue(attribute, typeName);
+ try {
+ DefaultCreateHandler.addCreatedObject(as, c, 0);
+ XActionInvoker.invoke("SaveActions.Save", o, new Properties());
+ } catch (CoreException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
+ }
+ }
+ }
+ }
+
+ public static void createBeansXML(IFile f) throws CoreException {
+ if(f.exists()) return;
+ IFolder folder = (IFolder)f.getParent();
+ if(!folder.exists()) {
+ folder.create(true, true, new NullProgressMonitor());
+ }
+ f.create(getBeansXMLInitialContents(), true, new NullProgressMonitor());
+ }
+
+ public static InputStream getBeansXMLInitialContents() {
+ FileAnyImpl file =
(FileAnyImpl)PreferenceModelUtilities.getPreferenceModel().createModelObject("FileCDIBeans",
new Properties());
+ return new ByteArrayInputStream(file.getAsText().getBytes());
+ }
+
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java 2011-02-11
13:41:22 UTC (rev 29113)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java 2011-02-11
13:51:11 UTC (rev 29114)
@@ -76,6 +76,8 @@
*/
public class NewBeanWizardPage extends NewClassWizardPage {
protected CheckBoxEditorWrapper alternative = null;
+ protected boolean mayBeRegisteredInBeansXML = true;
+ protected CheckBoxEditorWrapper registerInBeansXML = null;
protected CheckBoxEditorWrapper isNamed;
protected BeanNameEditorWrapper beanName;
@@ -96,6 +98,10 @@
setImageDescriptor(CDIUiImages.getImageDescriptor(CDIUiImages.WELD_WIZARD_IMAGE_PATH));
}
+ public void setMayBeRegisteredInBeansXML(boolean b) {
+ mayBeRegisteredInBeansXML = b;
+ }
+
public void init(IStructuredSelection selection) {
super.init(selection);
if (selection != null && !selection.isEmpty()) {
@@ -256,6 +262,7 @@
protected void createCustomFields(Composite composite) {
createBeanNameField(composite);
createAlternativeField(composite);
+ createRegisterInBeansXML(composite);
createScopeField(composite);
createQualifiersField(composite);
}
@@ -378,13 +385,28 @@
beanName.composite.setEnabled(named);
}});
}
-
protected void createAlternativeField(Composite composite) {
String label = "Add @Alternative";
alternative = createCheckBoxField(composite, "isAlternative", label,
isAlternativeInitialValue);
+ if(mayBeRegisteredInBeansXML) {
+ alternative.checkBox.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ boolean isAlternative =
"true".equals(alternative.checkBox.getValueAsString());
+ if(registerInBeansXML != null) {
+ registerInBeansXML.composite.setEnabled(isAlternative);
+ }
+ }});
+ }
}
- protected CheckBoxEditorWrapper createCheckBoxField(Composite composite, String name,
String label, boolean defaultValue) {
+ protected void createRegisterInBeansXML(Composite composite) {
+ if(!mayBeRegisteredInBeansXML) return;
+ String label = "Register in beans.xml";
+ registerInBeansXML = createCheckBoxField(composite, "register", label,
isAlternativeInitialValue);
+ registerInBeansXML.composite.setEnabled(isAlternativeInitialValue);
+ }
+
+ protected static CheckBoxEditorWrapper createCheckBoxField(Composite composite, String
name, String label, boolean defaultValue) {
CheckBoxEditorWrapper wrapper = new CheckBoxEditorWrapper();
wrapper.checkBox = new
CheckBoxFieldEditor(name,"",Boolean.valueOf(defaultValue));
CompositeEditor editor = new CompositeEditor(name,"", defaultValue);
@@ -433,4 +455,11 @@
}
}
+ public boolean isToBeRegisteredInBeansXML() {
+ if(registerInBeansXML != null && alternative != null ) {
+ return alternative.composite.getValue() == Boolean.TRUE &&
registerInBeansXML.composite.getValue() == Boolean.TRUE;
+ }
+ return false;
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java 2011-02-11
13:41:22 UTC (rev 29113)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java 2011-02-11
13:51:11 UTC (rev 29114)
@@ -196,4 +196,24 @@
}
+ public static IPath getContainerForBeansXML(IProject p) {
+ IPath path = ProjectHome.getWebInfPath(p);
+ if(path == null) {
+ boolean needMetaInf = false;
+ Set<IFolder> fs = EclipseResourceUtil.getSourceFolders(p);
+ if(fs != null) for (IFolder f: fs) {
+ IFolder fm = f.getFolder("META-INF");
+ IPath pth = fm.getFullPath();
+ if(path == null) {
+ path = pth;
+ needMetaInf = !fm.exists();
+ } else if(needMetaInf && fm.exists()) {
+ path = pth;
+ needMetaInf = false;
+ }
+ }
+ }
+ return path;
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java 2011-02-11
13:41:22 UTC (rev 29113)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java 2011-02-11
13:51:11 UTC (rev 29114)
@@ -11,6 +11,7 @@
package org.jboss.tools.cdi.ui.wizard;
+import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.ui.wizards.NewClassWizardPage;
import org.jboss.tools.cdi.ui.CDIUIMessages;
@@ -34,6 +35,9 @@
fPage = new NewDecoratorWizardPage();
((NewClassWizardPage)fPage).init(getSelection());
initPageFromAdapter();
+ if(adapter != null) {
+ ((NewDecoratorWizardPage)fPage).setMayBeRegisteredInBeansXML(false);
+ }
}
addPage(fPage);
}
@@ -45,4 +49,13 @@
return !fPage.isEnclosingTypeSelected();
}
+ public boolean performFinish() {
+ boolean res = super.performFinish();
+ if(res && ((NewDecoratorWizardPage)fPage).isToBeRegisteredInBeansXML()) {
+ IProject project = fPage.getCreatedType().getResource().getProject();
+ NewBeanCreationWizard.registerInBeansXML(project,
fPage.getCreatedType().getFullyQualifiedName(), "Decorators",
"CDIClass", "class");
+ }
+ return res;
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java 2011-02-11
13:41:22 UTC (rev 29113)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java 2011-02-11
13:51:11 UTC (rev 29114)
@@ -51,6 +51,7 @@
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUiImages;
+import org.jboss.tools.cdi.ui.wizard.NewBeanWizardPage.CheckBoxEditorWrapper;
import org.jboss.tools.common.java.generation.JavaBeanGenerator;
import org.jboss.tools.common.ui.widget.editor.CompositeEditor;
import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
@@ -70,12 +71,19 @@
protected StatusInfo fieldNameStatus = new StatusInfo();
+ protected boolean mayBeRegisteredInBeansXML = true;
+ protected CheckBoxEditorWrapper registerInBeansXML = null;
+
public NewDecoratorWizardPage() {
setTitle(CDIUIMessages.NEW_DECORATOR_WIZARD_PAGE_NAME);
setDescription(CDIUIMessages.NEW_DECORATOR_WIZARD_DESCRIPTION);
setImageDescriptor(CDIUiImages.getImageDescriptor(CDIUiImages.WELD_WIZARD_IMAGE_PATH));
}
+ public void setMayBeRegisteredInBeansXML(boolean b) {
+ mayBeRegisteredInBeansXML = b;
+ }
+
public void init(IStructuredSelection selection) {
super.init(selection);
defaultTypeName = null;
@@ -227,6 +235,7 @@
protected void createCustomFields(Composite composite) {
createFieldNameField(composite);
+ createRegisterInBeansXML(composite);
}
protected void createFieldNameField(Composite composite) {
@@ -277,6 +286,12 @@
}
+ protected void createRegisterInBeansXML(Composite composite) {
+ if(!mayBeRegisteredInBeansXML) return;
+ String label = "Register in beans.xml";
+ registerInBeansXML = NewBeanWizardPage.createCheckBoxField(composite,
"register", label, true);
+ }
+
protected IField createDelegateField(IType type, ImportsManager imports,
IProgressMonitor monitor, String lineDelimiter)
throws CoreException {
@@ -417,4 +432,11 @@
}
+ public boolean isToBeRegisteredInBeansXML() {
+ if(registerInBeansXML != null) {
+ return registerInBeansXML.composite.getValue() == Boolean.TRUE;
+ }
+ return false;
+ }
+
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java 2011-02-11
13:41:22 UTC (rev 29113)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java 2011-02-11
13:51:11 UTC (rev 29114)
@@ -11,6 +11,7 @@
package org.jboss.tools.cdi.ui.wizard;
+import org.eclipse.core.resources.IProject;
import org.jboss.tools.cdi.ui.CDIUIMessages;
/**
@@ -33,6 +34,9 @@
fPage = new NewInterceptorWizardPage();
((NewInterceptorWizardPage)fPage).init(getSelection());
initPageFromAdapter();
+ if(adapter != null) {
+ ((NewInterceptorWizardPage)fPage).setMayBeRegisteredInBeansXML(false);
+ }
}
addPage(fPage);
}
@@ -44,4 +48,13 @@
return !fPage.isEnclosingTypeSelected();
}
+ public boolean performFinish() {
+ boolean res = super.performFinish();
+ if(res && ((NewInterceptorWizardPage)fPage).isToBeRegisteredInBeansXML()) {
+ IProject project = fPage.getCreatedType().getResource().getProject();
+ NewBeanCreationWizard.registerInBeansXML(project,
fPage.getCreatedType().getFullyQualifiedName(), "Interceptors",
"CDIClass", "class");
+ }
+ return res;
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorWizardPage.java 2011-02-11
13:41:22 UTC (rev 29113)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorWizardPage.java 2011-02-11
13:51:11 UTC (rev 29114)
@@ -63,6 +63,7 @@
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUiImages;
+import org.jboss.tools.cdi.ui.wizard.NewBeanWizardPage.CheckBoxEditorWrapper;
import org.jboss.tools.common.java.generation.JavaBeanGenerator;
import org.jboss.tools.common.ui.widget.editor.CompositeEditor;
import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
@@ -83,6 +84,13 @@
protected StatusInfo methodNameStatus = new StatusInfo();
protected StatusInfo interceptorBindingsStatus = new StatusInfo();
+ protected boolean mayBeRegisteredInBeansXML = true;
+ protected CheckBoxEditorWrapper registerInBeansXML = null;
+
+ public void setMayBeRegisteredInBeansXML(boolean b) {
+ mayBeRegisteredInBeansXML = b;
+ }
+
public NewInterceptorWizardPage() {
setTitle(CDIUIMessages.NEW_INTERCEPTOR_WIZARD_PAGE_NAME);
setDescription(CDIUIMessages.NEW_INTERCEPTOR_WIZARD_DESCRIPTION);
@@ -181,6 +189,7 @@
protected void createCustomFields(Composite composite) {
createInterceptorBindingField(composite);
createMethodNameField(composite);
+ createRegisterInBeansXML(composite);
}
protected void createInterceptorBindingField(Composite composite) {
@@ -217,6 +226,12 @@
});
}
+ protected void createRegisterInBeansXML(Composite composite) {
+ if(!mayBeRegisteredInBeansXML) return;
+ String label = "Register in beans.xml";
+ registerInBeansXML = NewBeanWizardPage.createCheckBoxField(composite,
"register", label, true);
+ }
+
void setInterceptorBindings(IPackageFragmentRoot root) {
interceptorBindingsProvider.setProject(null);
if(root != null) {
@@ -326,4 +341,11 @@
return result;
}
+ public boolean isToBeRegisteredInBeansXML() {
+ if(registerInBeansXML != null) {
+ return registerInBeansXML.composite.getValue() == Boolean.TRUE;
+ }
+ return false;
+ }
+
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java 2011-02-11
13:41:22 UTC (rev 29113)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java 2011-02-11
13:51:11 UTC (rev 29114)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.ui.wizard;
+import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.ui.wizards.NewAnnotationWizardPage;
import org.jboss.tools.cdi.ui.CDIUIMessages;
@@ -32,7 +33,17 @@
super.initPageFromAdapter();
if(adapter != null) {
((NewStereotypeWizardPage)fPage).setAlternative(true);
+ ((NewStereotypeWizardPage)fPage).setMayBeRegisteredInBeansXML(false);
}
}
+ public boolean performFinish() {
+ boolean res = super.performFinish();
+ if(res && ((NewStereotypeWizardPage)fPage).isToBeRegisteredInBeansXML()) {
+ IProject project = fPage.getCreatedType().getResource().getProject();
+ NewBeanCreationWizard.registerInBeansXML(project,
fPage.getCreatedType().getFullyQualifiedName(), "Alternatives",
"CDIStereotype", "stereotype");
+ }
+ return res;
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java 2011-02-11
13:41:22 UTC (rev 29113)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java 2011-02-11
13:51:11 UTC (rev 29114)
@@ -36,6 +36,7 @@
import org.jboss.tools.cdi.internal.core.validation.AnnotationValidationDelegate;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.cdi.ui.wizard.NewBeanWizardPage.CheckBoxEditorWrapper;
import org.jboss.tools.common.ui.widget.editor.ITaggedFieldEditor;
import org.jboss.tools.common.ui.widget.editor.ListFieldEditor;
@@ -46,6 +47,9 @@
*/
public class NewStereotypeWizardPage extends NewCDIAnnotationWizardPage {
protected CheckBoxEditorWrapper alternative = null;
+ protected boolean mayBeRegisteredInBeansXML = true;
+ protected CheckBoxEditorWrapper registerInBeansXML = null;
+
protected CheckBoxEditorWrapper named = null;
protected ITaggedFieldEditor scope = null;
protected Map<String, String> scopes = new TreeMap<String, String>();
@@ -62,6 +66,10 @@
setTitle(CDIUIMessages.NEW_STEREOTYPE_WIZARD_PAGE_NAME);
}
+ public void setMayBeRegisteredInBeansXML(boolean b) {
+ mayBeRegisteredInBeansXML = b;
+ }
+
protected void addAnnotations(ImportsManager imports, StringBuffer sb, String
lineDelimiter) {
addStereotypeAnnotation(imports, sb, lineDelimiter);
addInheritedAnnotation(imports, sb, lineDelimiter);
@@ -131,6 +139,7 @@
protected void createCustomFields(Composite composite) {
createInheritedField(composite, false);
createAlternativeField(composite);
+ createRegisterInBeansXML(composite);
createNamedField(composite);
createScopeField(composite);
createTargetField(composite);
@@ -141,8 +150,24 @@
protected void createAlternativeField(Composite composite) {
String label = "Add @Alternative";
alternative = createCheckBoxField(composite, "isAlternative", label,
isAlternativeInitialValue);
+ if(mayBeRegisteredInBeansXML) {
+ alternative.checkBox.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ boolean isAlternative =
"true".equals(alternative.checkBox.getValueAsString());
+ if(registerInBeansXML != null) {
+ registerInBeansXML.composite.setEnabled(isAlternative);
+ }
+ }});
+ }
}
+ protected void createRegisterInBeansXML(Composite composite) {
+ if(!mayBeRegisteredInBeansXML) return;
+ String label = "Register in beans.xml";
+ registerInBeansXML = createCheckBoxField(composite, "register", label,
isAlternativeInitialValue);
+ registerInBeansXML.composite.setEnabled(isAlternativeInitialValue);
+ }
+
protected void createNamedField(Composite composite) {
String label = "Add @Named";
named = createCheckBoxField(composite, "isNamed", label, false);
@@ -335,4 +360,17 @@
}
}
+ public void setToBeRegisteredInBeansXML(boolean value) {
+ if(registerInBeansXML != null) {
+ registerInBeansXML.composite.setValue(Boolean.valueOf(value));
+ }
+ }
+
+ public boolean isToBeRegisteredInBeansXML() {
+ if(registerInBeansXML != null && alternative != null ) {
+ return alternative.composite.getValue() == Boolean.TRUE &&
registerInBeansXML.composite.getValue() == Boolean.TRUE;
+ }
+ return false;
+ }
+
}