Author: vrubezhny
Date: 2011-08-10 16:37:49 -0400 (Wed, 10 Aug 2011)
New Revision: 33787
Removed:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDINamedBeanReferencedFilter.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/OpenCDINamedBeanDialog.java
Log:
JBIDE-7892
Search for @Named beans.
Open CDI Named Bean Dialog is added
Deleted:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDINamedBeanReferencedFilter.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDINamedBeanReferencedFilter.java 2011-08-10
20:07:03 UTC (rev 33786)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDINamedBeanReferencedFilter.java 2011-08-10
20:37:49 UTC (rev 33787)
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.ui.wizard;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.jboss.tools.cdi.core.CDICorePlugin;
-import org.jboss.tools.cdi.core.IBean;
-import org.jboss.tools.cdi.core.ICDIProject;
-import org.jboss.tools.common.text.ITextSourceReference;
-
-/**
- * CDI Named Bean Filter
- *
- * @author Victor V. Rubezhny
- */
-public class CDINamedBeanReferencedFilter extends ViewerFilter {
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if(element instanceof IBean) {
- IBean bean = (IBean)element;
- return isBeanDeclaredInThisProject(bean);
- }
-
- return true;
- }
-
- public static boolean isBeanDeclaredInThisProject(IBean bean) {
- ICDIProject beanProject = bean.getCDIProject();
- IResource beanResource = null;
-
- //1. Get @Named declared directly, not in stereotype.
- ITextSourceReference nameLocation = bean.getNameLocation(false);
- //2. Get stereotype declaration declaring @Named, if @Named is not declared directly.
- ITextSourceReference stereotypeLocation = nameLocation != null ? null :
bean.getNameLocation(true);
- if (nameLocation != null) {
- beanResource = nameLocation.getResource();
- } else if (stereotypeLocation != null) {
- beanResource = stereotypeLocation.getResource();
- }
- if (beanResource == null)
- return false;
-
- ICDIProject cdiProject = CDICorePlugin.getCDIProject(beanResource.getProject(),
- true);
- return cdiProject == beanProject;
- }
-}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/OpenCDINamedBeanDialog.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/OpenCDINamedBeanDialog.java 2011-08-10
20:07:03 UTC (rev 33786)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/OpenCDINamedBeanDialog.java 2011-08-10
20:37:49 UTC (rev 33787)
@@ -16,6 +16,7 @@
import java.io.IOException;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -42,6 +43,7 @@
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.internal.core.impl.CDIElement;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.cdi.ui.CDIUiImages;
@@ -125,16 +127,15 @@
IProject project = projects[i];
progressMonitor.subTask(project.getName());
- ICDIProject cdiProject = CDICorePlugin.getCDIProject(project,
- true);
+ ICDIProject cdiProject = CDICorePlugin.getCDIProject(project, true);
if (cdiProject != null) {
Set<IBean> iter = cdiProject.getNamedBeans(false);
for (IBean bean: iter) {
- if (CDINamedBeanReferencedFilter
- .isBeanDeclaredInThisProject(bean))
+ if (bean instanceof CDIElement && cdiProject ==
((CDIElement)bean).getDeclaringProject()) {
contentProvider.add(new CDINamedBeanWrapper(bean
.getName(), project.getName(), bean),
itemsFilter);
+ }
}
}
progressMonitor.worked(1);