Author: vyemialyanchyk
Date: 2008-10-17 09:42:06 -0400 (Fri, 17 Oct 2008)
New Revision: 10924
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java
Log:
JBIDE-2077 popup menu enable bugfix, null pointer bugfix
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java 2008-10-17
13:36:44 UTC (rev 10923)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java 2008-10-17
13:42:06 UTC (rev 10924)
@@ -31,7 +31,7 @@
public class JPAMapToolActionDelegate implements IObjectActionDelegate,
IEditorActionDelegate, IViewActionDelegate, IHandler {
- public JPAMapToolActor actor = new JPAMapToolActor();
+ public JPAMapToolActor actor = JPAMapToolActor.getInstance();
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java 2008-10-17
13:36:44 UTC (rev 10923)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java 2008-10-17
13:42:06 UTC (rev 10924)
@@ -42,7 +42,7 @@
private Menu fMenu;
protected boolean fRecreateMenu = false;
- public JPAMapToolActor actor = new JPAMapToolActor();
+ public JPAMapToolActor actor = JPAMapToolActor.getInstance();
public Menu getMenu(Menu parent) {
setMenu(new Menu(parent));
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-10-17
13:36:44 UTC (rev 10923)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-10-17
13:42:06 UTC (rev 10924)
@@ -48,11 +48,21 @@
*/
public class JPAMapToolActor {
+ protected static JPAMapToolActor actor = null;
protected Set<ICompilationUnit> selectionCU = new
HashSet<ICompilationUnit>();
protected AllEntitiesInfoCollector collector = new AllEntitiesInfoCollector();
protected AllEntitiesProcessor processor = new AllEntitiesProcessor();
+ protected JPAMapToolActor() {
+ }
+ public static JPAMapToolActor getInstance() {
+ if (actor == null) {
+ actor = new JPAMapToolActor();
+ }
+ return actor;
+ }
+
protected org.eclipse.jdt.core.dom.CompilationUnit getCompilationUnit(ICompilationUnit
source) {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setSource(source);
@@ -127,7 +137,7 @@
return selectionCU.size();
}
- public void updateSelectedItems(ISelection selection) {
+ synchronized public void updateSelectedItems(ISelection selection) {
//System.out.println("Blah! " + selection); //$NON-NLS-1$
if (selection instanceof TextSelection) {
String fullyQualifiedName = ""; //$NON-NLS-1$
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java 2008-10-17
13:36:44 UTC (rev 10923)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java 2008-10-17
13:42:06 UTC (rev 10924)
@@ -216,17 +216,19 @@
Type superType = node.getSuperclassType();
if (superType != null) {
ITypeBinding tb = superType.resolveBinding();
- String entityFullyQualifiedName = ""; //$NON-NLS-1$
- if (tb.getJavaElement() instanceof SourceType) {
- SourceType sourceT = (SourceType)tb.getJavaElement();
- try {
- entityFullyQualifiedName = sourceT.getFullyQualifiedParameterizedName();
- } catch (JavaModelException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage("error", e);
+ if (tb != null) {
+ String entityFullyQualifiedName = ""; //$NON-NLS-1$
+ if (tb.getJavaElement() instanceof SourceType) {
+ SourceType sourceT = (SourceType)tb.getJavaElement();
+ try {
+ entityFullyQualifiedName = sourceT.getFullyQualifiedParameterizedName();
+ } catch (JavaModelException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("error", e);
+ }
}
+ entityInfo.addDependency(entityFullyQualifiedName);
+ entityInfo.setFullyQualifiedParentName(entityFullyQualifiedName);
}
- entityInfo.addDependency(entityFullyQualifiedName);
- entityInfo.setFullyQualifiedParentName(entityFullyQualifiedName);
}
List superInterfaces = node.superInterfaceTypes();
Iterator it = superInterfaces.iterator();
@@ -266,33 +268,35 @@
} else if (node.getType().isSimpleType()) {
SimpleType st = (SimpleType)node.getType();
ITypeBinding tb = st.resolveBinding();
- String entityFullyQualifiedName = ""; //$NON-NLS-1$
- if (tb.getJavaElement() instanceof SourceType) {
- SourceType sourceT = (SourceType)tb.getJavaElement();
- try {
- entityFullyQualifiedName = sourceT.getFullyQualifiedParameterizedName();
- } catch (JavaModelException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
- }
- entityInfo.addDependency(entityFullyQualifiedName);
- Iterator itVarNames = node.fragments().iterator();
- while (itVarNames.hasNext()) {
- VariableDeclarationFragment var = (VariableDeclarationFragment)itVarNames.next();
- String name = var.getName().getIdentifier();
- entityInfo.addReference(name, entityFullyQualifiedName, RefType.ONE2ONE);
- }
- }
- else if (tb.getJavaElement() instanceof BinaryType) {
- ITypeBinding tbParent = tb.getTypeDeclaration().getSuperclass();
- if (tbParent != null &&
"java.lang.Number".equals(tbParent.getBinaryName())) { //$NON-NLS-1$
- // this is candidate for primary id
+ if (tb != null) {
+ String entityFullyQualifiedName = ""; //$NON-NLS-1$
+ if (tb.getJavaElement() instanceof SourceType) {
+ SourceType sourceT = (SourceType)tb.getJavaElement();
+ try {
+ entityFullyQualifiedName = sourceT.getFullyQualifiedParameterizedName();
+ } catch (JavaModelException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
+ }
+ entityInfo.addDependency(entityFullyQualifiedName);
Iterator itVarNames = node.fragments().iterator();
while (itVarNames.hasNext()) {
VariableDeclarationFragment var = (VariableDeclarationFragment)itVarNames.next();
String name = var.getName().getIdentifier();
- entityInfo.addPrimaryIdCandidate(name);
+ entityInfo.addReference(name, entityFullyQualifiedName, RefType.ONE2ONE);
}
}
+ else if (tb.getJavaElement() instanceof BinaryType) {
+ ITypeBinding tbParent = tb.getTypeDeclaration().getSuperclass();
+ if (tbParent != null &&
"java.lang.Number".equals(tbParent.getBinaryName())) { //$NON-NLS-1$
+ // this is candidate for primary id
+ Iterator itVarNames = node.fragments().iterator();
+ while (itVarNames.hasNext()) {
+ VariableDeclarationFragment var = (VariableDeclarationFragment)itVarNames.next();
+ String name = var.getName().getIdentifier();
+ entityInfo.addPrimaryIdCandidate(name);
+ }
+ }
+ }
}
} else if (node.getType().isArrayType()) {
ArrayType at = (ArrayType)node.getType();
@@ -301,38 +305,40 @@
ParameterizedType pt = (ParameterizedType)node.getType();
Type type = (Type)pt.getType();
ITypeBinding tb = type.resolveBinding();
- ITypeBinding[] interfaces = tb.getTypeDeclaration().getInterfaces();
- String fullyQualifiedNameTypeName = ""; //$NON-NLS-1$
- for (int i = 0; i < interfaces.length; i++) {
- if (interfaces[i].getJavaElement() instanceof BinaryType) {
- BinaryType binaryT = (BinaryType)interfaces[i].getJavaElement();
- String tmp = binaryT.getFullyQualifiedName('.');
- if (0 == "java.util.Collection".compareTo(tmp)) { //$NON-NLS-1$
- fullyQualifiedNameTypeName = tmp;
- break;
+ if (tb != null) {
+ ITypeBinding[] interfaces = tb.getTypeDeclaration().getInterfaces();
+ String fullyQualifiedNameTypeName = ""; //$NON-NLS-1$
+ for (int i = 0; i < interfaces.length; i++) {
+ if (interfaces[i].getJavaElement() instanceof BinaryType) {
+ BinaryType binaryT = (BinaryType)interfaces[i].getJavaElement();
+ String tmp = binaryT.getFullyQualifiedName('.');
+ if (0 == "java.util.Collection".compareTo(tmp)) { //$NON-NLS-1$
+ fullyQualifiedNameTypeName = tmp;
+ break;
+ }
}
}
- }
- if (fullyQualifiedNameTypeName.length() > 0) {
- Iterator typeArgsIt = pt.typeArguments().iterator();
- while (typeArgsIt.hasNext()) {
- type = (Type)typeArgsIt.next();
- tb = type.resolveBinding();
- String entityFullyQualifiedName = ""; //$NON-NLS-1$
- if (tb.getJavaElement() instanceof SourceType) {
- SourceType sourceT = (SourceType)tb.getJavaElement();
- try {
- entityFullyQualifiedName = sourceT.getFullyQualifiedParameterizedName();
- } catch (JavaModelException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
+ if (fullyQualifiedNameTypeName.length() > 0) {
+ Iterator typeArgsIt = pt.typeArguments().iterator();
+ while (typeArgsIt.hasNext()) {
+ type = (Type)typeArgsIt.next();
+ tb = type.resolveBinding();
+ String entityFullyQualifiedName = ""; //$NON-NLS-1$
+ if (tb.getJavaElement() instanceof SourceType) {
+ SourceType sourceT = (SourceType)tb.getJavaElement();
+ try {
+ entityFullyQualifiedName = sourceT.getFullyQualifiedParameterizedName();
+ } catch (JavaModelException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
+ }
+ entityInfo.addDependency(entityFullyQualifiedName);
+ Iterator itVarNames = node.fragments().iterator();
+ while (itVarNames.hasNext()) {
+ VariableDeclarationFragment var =
(VariableDeclarationFragment)itVarNames.next();
+ String name = var.getName().getIdentifier();
+ entityInfo.addReference(name, entityFullyQualifiedName, RefType.ONE2MANY);
+ }
}
- entityInfo.addDependency(entityFullyQualifiedName);
- Iterator itVarNames = node.fragments().iterator();
- while (itVarNames.hasNext()) {
- VariableDeclarationFragment var = (VariableDeclarationFragment)itVarNames.next();
- String name = var.getName().getIdentifier();
- entityInfo.addReference(name, entityFullyQualifiedName, RefType.ONE2MANY);
- }
}
}
}
Show replies by date