Author: dazarov
Date: 2012-01-30 16:22:01 -0500 (Mon, 30 Jan 2012)
New Revision: 38300
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AddQualifiersToBeanWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java
Log:
Wizard 'Specify CDI Bean for the Injection Point' does not compute correctly
condition 'can finish'
https://issues.jboss.org/browse/JBIDE-10637
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AddQualifiersToBeanWizardPage.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AddQualifiersToBeanWizardPage.java 2012-01-30
20:12:47 UTC (rev 38299)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/AddQualifiersToBeanWizardPage.java 2012-01-30
21:22:01 UTC (rev 38300)
@@ -32,6 +32,7 @@
setTitle(pageName);
}
+ @Override
public void createControl(Composite parent) {
composite = new AddQualifiersToBeanComposite(parent, this);
setControl(composite);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java 2012-01-30
20:12:47 UTC (rev 38299)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java 2012-01-30
21:22:01 UTC (rev 38300)
@@ -21,6 +21,7 @@
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
@@ -48,7 +49,8 @@
import org.jboss.tools.common.model.ui.ModelUIImages;
public class SelectBeanWizard extends AbstractModifyInjectionPointWizard{
- private AddQualifiersToBeanWizardPage page;
+ private SelectBeanWizardPage selectBeanPage;
+ private AddQualifiersToBeanWizardPage addQualifiersPage;
private Text pattern;
public SelectBeanWizard(ProcessorBasedRefactoring refactoring){
@@ -58,30 +60,32 @@
setDefaultPageImageDescriptor(ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
}
- public void addUserInputPages() {
- addPage(new SelectBeanWizardPage(""));
- page = new AddQualifiersToBeanWizardPage("");
- addPage(page);
+ @Override
+ public void addUserInputPages() {
+ selectBeanPage = new SelectBeanWizardPage("");
+ addPage(selectBeanPage);
+ addQualifiersPage = new AddQualifiersToBeanWizardPage("");
+ addPage(addQualifiersPage);
}
public java.util.List<ValuedQualifier> getDeployedQualifiers(){
- return page.getDeployedQualifiers();
+ return addQualifiersPage.getDeployedQualifiers();
}
public java.util.List<IQualifier> getAvailableQualifiers(){
- return page.getAvailableQualifiers();
+ return addQualifiersPage.getAvailableQualifiers();
}
public void init(IBean bean){
- page.init(bean);
+ addQualifiersPage.init(bean);
}
public void deploy(ValuedQualifier qualifier){
- page.deploy(qualifier);
+ addQualifiersPage.deploy(qualifier);
}
public boolean checkBeans(){
- return page.checkBeans();
+ return addQualifiersPage.checkBeans();
}
class SelectBeanWizardPage extends UserInputWizardPage{
@@ -92,6 +96,7 @@
setPageComplete(false);
}
+ @Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
@@ -108,6 +113,7 @@
GridData data = new GridData(GridData.FILL_HORIZONTAL);
pattern.setLayoutData(data);
pattern.addModifyListener(new ModifyListener(){
+ @Override
public void modifyText(ModifyEvent e){
tableViewer.refresh();
}
@@ -123,16 +129,18 @@
availableList.setLayoutData(data);
tableViewer = new TableViewer(availableList);
- ILabelProvider labelProvider = new BeanListLabelProvider();
+ final ILabelProvider labelProvider = new BeanListLabelProvider();
tableViewer.setLabelProvider(labelProvider);
IContentProvider contentProvider = new BeanListContentProvider();
tableViewer.setContentProvider(contentProvider);
tableViewer.setComparator(new ViewerComparator() {
+ @Override
public int compare(Viewer viewer, Object o1, Object o2) {
if (o1 instanceof IBean && o2 instanceof IBean) {
IBean b1 = (IBean) o1;
IBean b2 = (IBean) o2;
- return
(b1.getBeanClass().getElementName().compareToIgnoreCase(b2.getBeanClass().getElementName()));
+
+ return labelProvider.getText(b1).compareToIgnoreCase(labelProvider.getText(b2));
}
return super.compare(viewer, o1, o2);
@@ -141,21 +149,22 @@
tableViewer.setInput(getBeans());
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
IBean bean = getSelection();
if(bean != null){
setPageComplete(true);
- IWizardPage next = getNextPage();
- if(next instanceof AddQualifiersToBeanWizardPage)
- ((AddQualifiersToBeanWizardPage)next).init(bean);
+ addQualifiersPage.init(bean);
setSelectedBean(bean);
- page.setDeployedQualifiers(page.getDeployedQualifiers());
+ addQualifiersPage.setDeployedQualifiers(addQualifiersPage.getDeployedQualifiers());
}else
setPageComplete(false);
}
});
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
public void doubleClick(DoubleClickEvent event) {
+
}
});
tableViewer.addFilter(new BeanFilter());
@@ -163,6 +172,20 @@
setControl(composite);
}
+ public void setDefaultSelection(){
+
+ if(getBeans().size() > 0){
+ IBean defaultBean = getBeans().get(0);
+ tableViewer.setSelection(new StructuredSelection(defaultBean));
+ tableViewer.getTable().select(0);
+ addQualifiersPage.init(defaultBean);
+ setSelectedBean(defaultBean);
+ addQualifiersPage.setDeployedQualifiers(addQualifiersPage.getDeployedQualifiers());
+ setPageComplete(true);
+ }
+
+ }
+
protected IBean getSelection() {
IStructuredSelection sel = (IStructuredSelection) tableViewer.getSelection();
if (sel.isEmpty())
@@ -178,6 +201,7 @@
return true;
}
+ @Override
public boolean select(Viewer viewer, Object parentElement,
Object element) {
@@ -205,19 +229,24 @@
class BeanListLabelProvider implements ILabelProvider{
+ @Override
public void addListener(ILabelProviderListener listener) {
}
+ @Override
public void dispose() {
}
+ @Override
public boolean isLabelProperty(Object element, String property) {
return false;
}
+ @Override
public void removeListener(ILabelProviderListener listener) {
}
+ @Override
public Image getImage(Object element) {
if(element instanceof IBean){
return CDIImages.getImageByElement((IBean)element);
@@ -225,6 +254,7 @@
return null;
}
+ @Override
public String getText(Object element) {
if(element instanceof IBean){
IBean bean = (IBean)element;
@@ -241,12 +271,15 @@
class BeanListContentProvider implements IStructuredContentProvider{
+ @Override
public void dispose() {
}
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
+ @Override
public Object[] getElements(Object inputElement) {
if(inputElement instanceof ArrayList){
return ((ArrayList)inputElement).toArray();
@@ -255,4 +288,10 @@
}
}
+
+ @Override
+ public void createPageControls(Composite pageContainer) {
+ super.createPageControls(pageContainer);
+ selectBeanPage.setDefaultSelection();
+ }
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java 2012-01-30
20:12:47 UTC (rev 38299)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java 2012-01-30
21:22:01 UTC (rev 38300)
@@ -228,6 +228,7 @@
public void refresh() {
Display.getDefault().syncExec(new Runnable() {
+ @Override
public void run() {
if (availableTableViewer == null || availableTableViewer.getControl().isDisposed())
return;
@@ -269,6 +270,7 @@
fd[i].setStyle(SWT.ITALIC);
font = new Font(display, fd);
addDisposeListener(new DisposeListener() {
+ @Override
public void widgetDisposed(DisposeEvent e) {
font.dispose();
}
@@ -290,6 +292,7 @@
data = new GridData(GridData.FILL_HORIZONTAL);
pattern.setLayoutData(data);
pattern.addModifyListener(new ModifyListener(){
+ @Override
public void modifyText(ModifyEvent e){
availableTableViewer.refresh();
}
@@ -323,6 +326,7 @@
IContentProvider contentProvider = new QualifiersListContentProvider();
availableTableViewer.setContentProvider(contentProvider);
availableTableViewer.setComparator(new ViewerComparator() {
+ @Override
public int compare(Viewer viewer, Object o1, Object o2) {
if (o1 instanceof IQualifier && o2 instanceof IQualifier) {
IQualifier q1 = (IQualifier) o1;
@@ -336,11 +340,13 @@
availableTableViewer.setInput(qualifiers);
availableTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
setEnablement();
}
});
availableTableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
public void doubleClick(DoubleClickEvent event) {
setEnablement();
if (add.isEnabled())
@@ -364,6 +370,7 @@
add.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_ADD);
add.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
add.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
add(false);
}
@@ -373,6 +380,7 @@
remove.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_REMOVE);
remove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
remove.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
remove(false);
}
@@ -385,6 +393,7 @@
addAll.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_ADD_ALL);
addAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
addAll.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
add(true);
}
@@ -394,6 +403,7 @@
removeAll.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_REMOVE_ALL);
removeAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
removeAll.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
remove(true);
}
@@ -408,6 +418,7 @@
deployedTableViewer.setLabelProvider(labelProvider);
deployedTableViewer.setContentProvider(contentProvider);
deployedTableViewer.setComparator(new ViewerComparator() {
+ @Override
public int compare(Viewer viewer, Object o1, Object o2) {
if (o1 instanceof IQualifier && o2 instanceof IQualifier) {
IQualifier q1 = (IQualifier) o1;
@@ -421,11 +432,13 @@
deployedTableViewer.setInput(originalQualifiers);
deployedTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
setEnablement();
}
});
deployedTableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
public void doubleClick(DoubleClickEvent event) {
setEnablement();
if (remove.isEnabled())
@@ -437,11 +450,13 @@
createQualifier.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_CREATE_NEW_QUALIFIER);
createQualifier.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
final IJobManager manager= Job.getJobManager();
// reload qualifiers
if (Display.getCurrent() != null) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable(){
+ @Override
public void run(){
NewQualifierCreationWizard wizard = new NewQualifierCreationWizard();
StructuredSelection selection = new StructuredSelection(new
Object[]{bean.getBeanClass()});
@@ -474,6 +489,7 @@
editQualifierValue.setText(CDIUIMessages.ADD_QUALIFIERS_TO_BEAN_WIZARD_EDIT_QUALIFIER_VALUE);
editQualifierValue.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent event) {
ValuedQualifier[] vq = getDeployedSelection();
ValueDialog d = new ValueDialog(getShell(), vq[0].getValue());
@@ -612,9 +628,9 @@
list.add(mods[i]);
}
- Iterator iterator = list.iterator();
+ Iterator<ValuedQualifier> iterator = list.iterator();
while (iterator.hasNext()) {
- ValuedQualifier qualifier = (ValuedQualifier) iterator.next();
+ ValuedQualifier qualifier = iterator.next();
if (add2) {
qualifiers.remove(qualifier);
deployed.add(qualifier);
@@ -649,9 +665,9 @@
public ArrayList<ValuedQualifier> getQualifiersToRemove() {
ArrayList<ValuedQualifier> list = new ArrayList<ValuedQualifier>();
- Iterator iterator = originalQualifiers.iterator();
+ Iterator<ValuedQualifier> iterator = originalQualifiers.iterator();
while (iterator.hasNext()) {
- ValuedQualifier qualifier = (ValuedQualifier) iterator.next();
+ ValuedQualifier qualifier = iterator.next();
if (!contains(deployed, qualifier))
list.add(qualifier);
}
@@ -660,9 +676,9 @@
public ArrayList<ValuedQualifier> getQualifiersToAdd() {
ArrayList<ValuedQualifier> list = new ArrayList<ValuedQualifier>();
- Iterator iterator = deployed.iterator();
+ Iterator<ValuedQualifier> iterator = deployed.iterator();
while (iterator.hasNext()) {
- ValuedQualifier qualifier = (ValuedQualifier) iterator.next();
+ ValuedQualifier qualifier = iterator.next();
if (!contains(originalQualifiers, qualifier))
list.add(qualifier);
}
@@ -702,19 +718,24 @@
class QualifiersListLabelProvider implements ILabelProvider, IColorProvider{
+ @Override
public void addListener(ILabelProviderListener listener) {
}
+ @Override
public void dispose() {
}
+ @Override
public boolean isLabelProperty(Object element, String property) {
return true;
}
+ @Override
public void removeListener(ILabelProviderListener listener) {
}
+ @Override
public Image getImage(Object element) {
if(element instanceof ValuedQualifier){
return CDIImages.getImageByElement(((ValuedQualifier) element).getQualifier());
@@ -722,6 +743,7 @@
return null;
}
+ @Override
public String getText(Object element) {
if(element instanceof ValuedQualifier){
ValuedQualifier vq = (ValuedQualifier)element;
@@ -734,6 +756,7 @@
return "";
}
+ @Override
public Color getForeground(Object element) {
if(element instanceof ValuedQualifier){
if(contains(originalQualifiers, (ValuedQualifier)element))
@@ -742,6 +765,7 @@
return ColorConstants.black;
}
+ @Override
public Color getBackground(Object element) {
return null;
}
@@ -749,12 +773,15 @@
class QualifiersListContentProvider implements IStructuredContentProvider{
+ @Override
public void dispose() {
}
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
+ @Override
public Object[] getElements(Object inputElement) {
if(inputElement instanceof ArrayList){
return ((ArrayList)inputElement).toArray();
@@ -770,6 +797,7 @@
return true;
}
+ @Override
public boolean select(Viewer viewer, Object parentElement,
Object element) {
@@ -806,6 +834,7 @@
this.value = value;
}
+ @Override
protected Control createCustomArea(Composite parent) {
Composite composite = new Composite(parent, 0);
GridLayout layout = new GridLayout();
@@ -825,6 +854,7 @@
text.setLayoutData(data);
text.setText(value);
text.addModifyListener(new ModifyListener(){
+ @Override
public void modifyText(ModifyEvent e) {
value = text.getText();
}