Example usage for org.eclipse.jdt.core IType getFullyQualifiedName

List of usage examples for org.eclipse.jdt.core IType getFullyQualifiedName

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IType getFullyQualifiedName.

Prototype

String getFullyQualifiedName();

Source Link

Document

Returns the fully qualified name of this type, including qualification for any containing types and packages.

Usage

From source file:ar.com.tadp.xml.rinzo.jdt.JDTUtils.java

License:Open Source License

public static boolean isSuperType(String className, String superType) {
    IType[] supertypes = JDTUtils.getAllSuperTypes(className);
    for (IType iType : supertypes) {
        if (iType.getFullyQualifiedName().equals(superType)) {
            return true;
        }//from  w ww  .  ja  v  a 2s .  c  om
    }
    return false;
}

From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.contentassist.FXGraphProposalProvider.java

License:Open Source License

private void createCollectionClassProposals(IFXCollectionProperty prop, final EObject model,
        ContentAssistContext context, EReference typeReference, ICompletionProposalAcceptor acceptor) {
    IType jdtSuperType = prop.getElementType();
    if (jdtSuperType != null) {
        JvmType superType = jdtTypeProvider.findOrCreateTypeProvider(model.eResource().getResourceSet())
                .findTypeByName(jdtSuperType.getFullyQualifiedName());
        Filter f = new FXClassFilter(projectProvider.getJavaProject(model.eResource().getResourceSet()));
        typeProposalProviders.createSubTypeProposals(superType, this, context, typeReference, f, acceptor);
    }//from w ww  .ja v  a  2s.  c  o  m
}

From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.contentassist.FXGraphProposalProvider.java

License:Open Source License

private void createObjectPropvalueProposals(IFXObjectProperty prop, final EObject model,
        ContentAssistContext context, EReference typeReference, ICompletionProposalAcceptor acceptor) {
    String type = prop.getElementTypeAsString(true);

    if ("java.lang.Boolean".equals(type)) {
        ICompletionProposal p = createCompletionProposal("true", context);
        if (p instanceof ConfigurableCompletionProposal) {
            ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
            cp.setAdditionalProposalInfo(model);
            cp.setHover(new HoverImpl(prop.getValueOfMethod()));
        }//from ww  w.  j  av  a2  s  .  co m
        acceptor.accept(p);

        p = createCompletionProposal("false", context);
        if (p instanceof ConfigurableCompletionProposal) {
            ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
            cp.setAdditionalProposalInfo(model);
            cp.setHover(new HoverImpl(prop.getValueOfMethod()));
        }
        acceptor.accept(p);
    } else if (isIntegerType(type)) {
        ICompletionProposal p = createCompletionProposal("1", context);

        if (p instanceof ConfigurableCompletionProposal) {
            ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
            cp.setAdditionalProposalInfo(model);
            cp.setHover(new HoverImpl(prop.getJavaElement()));
        }
        acceptor.accept(p);
    } else if (isDoubleType(type)) {
        ICompletionProposal p = createCompletionProposal("1.0", context);

        if (p instanceof ConfigurableCompletionProposal) {
            ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
            cp.setAdditionalProposalInfo(model);
            cp.setHover(new HoverImpl(prop.getJavaElement()));
        }
        acceptor.accept(p);
    } else {
        if (prop.hasValueOf()) {
            ICompletionProposal p = createCompletionProposal("\"\"", new StyledString("\"<String>\""), null,
                    getPriorityHelper().getDefaultPriority() + 1, context.getPrefix(), context);

            if (p instanceof ConfigurableCompletionProposal) {
                ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
                cp.setAdditionalProposalInfo(model);
                cp.setHover(new HoverImpl(prop.getValueOfMethod()));
            }

            acceptor.accept(p);

            for (IValueOfContributor contrib : valueOfCollector
                    .getContributors(prop.getElementTypeAsString(true))) {
                for (Proposal vProp : contrib.getProposals()) {
                    int prio = getPriorityHelper().getDefaultPriority() + vProp.getPriority() + 2;
                    p = createCompletionProposal("\"" + vProp.getValue() + "\"",
                            new StyledString(vProp.getValue()), IconKeys.getIcon(IconKeys.VALUE_OF_KEY), prio,
                            "\"" + context.getPrefix(), context);

                    if (p instanceof ConfigurableCompletionProposal) {
                        if (vProp instanceof DialogProposal) {
                            ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
                            final DialogProposal dProp = (DialogProposal) vProp;
                            cp.setTextApplier(new ReplacementTextApplier() {
                                @Override
                                public String getActualReplacementString(
                                        ConfigurableCompletionProposal proposal) {
                                    return "\"" + dProp.openDialogValue() + "\"";
                                }
                            });
                        }
                    }
                    acceptor.accept(p);
                }
            }

        }

        IType jdtSuperType = prop.getElementType();
        if (jdtSuperType != null) {
            final IJvmTypeProvider tProvider = jdtTypeProvider
                    .findOrCreateTypeProvider(model.eResource().getResourceSet());
            JvmType superType = tProvider.findTypeByName(jdtSuperType.getFullyQualifiedName());
            Filter f = new FXClassFilter(projectProvider.getJavaProject(model.eResource().getResourceSet()));
            typeProposalProviders.createSubTypeProposals(superType, this, context, typeReference, f, acceptor);
        }
    }
}

From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.util.JDTHelper.java

License:Open Source License

public TypeData getTypeData(IJavaProject jproject, IType jdtType) {
    if (jdtType == null) {
        return null;
    }//from w ww.ja v a  2  s .c  om

    TypeData data = typeCache.get(jdtType.getFullyQualifiedName());
    if (data == null) {
        try {
            List<IMethod> allMethods = new ArrayList<IMethod>();
            allMethods.addAll(Arrays.asList(jdtType.getMethods()));

            IType parentType = jdtType;

            while (parentType != null && parentType.getSuperclassName() != null) {
                if (parentType instanceof SourceType) {
                    String[][] typeDefs = parentType.resolveType(parentType.getSuperclassName());
                    if (typeDefs != null) {
                        for (String[] type : typeDefs) {
                            parentType = jproject.findType(type[0] + "." + type[1]);
                        }
                    }
                } else {
                    parentType = jproject.findType(parentType.getSuperclassName());
                }

                if (parentType != null) {
                    allMethods.addAll(Arrays.asList(parentType.getMethods()));
                }
            }
            data = createData(allMethods, jproject);
            if (!(jdtType instanceof SourceType)) {
                typeCache.put(jdtType.getFullyQualifiedName(), data);
            }
        } catch (JavaModelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return data;
}

From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.util.JDTHelper.java

License:Open Source License

private TypeData createData(List<IMethod> allMethods, IJavaProject jproject) throws JavaModelException {
    TypeData d = new TypeData();
    for (IMethod m : allMethods) {
        if (!Flags.isPublic(m.getFlags())) {
            continue;
        }/*from   w  w w . j  a  v  a2  s  .com*/

        if (m.getElementName().startsWith("impl_") || m.getElementName().startsWith("getImpl_")) {
            continue;
        }

        if (m.getElementName().startsWith("get") && m.getParameterNames().length == 0) {
            String returnSignature = Signature.toString(m.getReturnType());
            if (returnSignature.startsWith("javafx.event.EventHandler<? super ")
                    || returnSignature.startsWith("javafx.event.EventHandler<")) {
                String eventType;
                if (returnSignature.startsWith("javafx.event.EventHandler<? super ")) {
                    eventType = returnSignature.substring("javafx.event.EventHandler<? super ".length(),
                            returnSignature.length() - 1);
                } else {
                    eventType = returnSignature.substring("javafx.event.EventHandler<".length(),
                            returnSignature.length() - 1);
                }

                EventValueProperty p = new EventValueProperty(m, extractAttributename(m.getElementName()),
                        m.getParent().getElementName(), eventType);
                d.properties.add(p);

            } else {
                String propName = extractAttributename(m.getElementName());
                String ownerName = m.getParent().getElementName();
                boolean isReadonly = isReadonlySetter(propName, allMethods);

                if ("double".equals(returnSignature) || "float".equals(returnSignature)) {
                    if (!isReadonly) {
                        FloatingValueProperty p = new FloatingValueProperty(m, propName, ownerName,
                                returnSignature);
                        d.properties.add(p);
                    }
                } else if ("int".equals(returnSignature) || "long".equals(returnSignature)
                        || "short".equals(returnSignature) || "byte".equals(returnSignature)
                        || "char".equals(returnSignature)) {
                    if (!isReadonly) {
                        IntegerValueProperty p = new IntegerValueProperty(m, propName, ownerName,
                                returnSignature);
                        d.properties.add(p);
                    }
                } else {
                    IType type;
                    if (returnSignature.indexOf('<') == -1) {
                        type = jproject.findType(returnSignature);
                    } else {
                        type = jproject.findType(returnSignature.substring(0, returnSignature.indexOf('<')));
                    }

                    if (type == null) {
                        continue;
                    }

                    if (type.isEnum()) {
                        if (!isReadonly) {
                            EnumValueProperty p = new EnumValueProperty(m, propName, ownerName, returnSignature,
                                    type);
                            d.properties.add(p);
                        }
                    } else {
                        boolean isLists = false;
                        boolean isMap = false;
                        if ("java.util.List".equals(type.getFullyQualifiedName())) {
                            isLists = true;
                        } else {
                            for (String i : type.getSuperInterfaceNames()) {
                                if (i.equals("java.util.List")) {
                                    isLists = true;
                                }
                            }
                        }

                        if (!isLists) {
                            if ("java.util.Map".equals(type.getFullyQualifiedName())) {
                                isMap = true;
                            } else {
                                for (String i : type.getSuperInterfaceNames()) {
                                    if (i.equals("java.util.Map")) {
                                        isMap = true;
                                    }
                                }
                            }
                        }

                        if (isLists) {
                            String listType;
                            if (returnSignature.indexOf('<') != -1) {
                                listType = returnSignature.substring(returnSignature.indexOf('<') + 1,
                                        returnSignature.lastIndexOf('>'));
                            } else {
                                listType = "?";
                            }

                            if (!propName.endsWith("Unmodifiable")) {
                                ListValueProperty p = new ListValueProperty(m, propName, ownerName, listType,
                                        isReadonly);
                                d.properties.add(p);
                            }
                        } else if (isMap) {
                            MapValueProperty p = new MapValueProperty(m, propName, ownerName);
                            d.properties.add(p);
                        } else if (type.getFullyQualifiedName().equals("java.lang.String")) {
                            if (!isReadonly) {
                                StringValueProperty p = new StringValueProperty(m, propName, ownerName,
                                        returnSignature);
                                d.properties.add(p);
                            }
                        } else {
                            if (!isReadonly) {
                                List<Proposal> props = getProposals(type, jproject);
                                ElementValueProperty p = new ElementValueProperty(m, propName, ownerName,
                                        returnSignature, props);
                                d.properties.add(p);
                            }
                        }
                    }
                }
            }
        } else if (m.getElementName().startsWith("is") && m.getParameterNames().length == 0
                && "Z".equals(m.getReturnType())) {
            String propName = extractAttributename(m.getElementName());
            boolean isReadonly = isReadonlySetter(propName, allMethods);

            if (!isReadonly) {
                BooleanValueProperty p = new BooleanValueProperty(m, propName, m.getParent().getElementName(),
                        "boolean");
                d.properties.add(p);
            }
        }
    }
    return d;
}

From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.util.JDTHelper.java

License:Open Source License

private List<Proposal> getProposals(IType type, IJavaProject jp) {
    if (PROVIDERS.containsKey(type.getFullyQualifiedName())) {
        return PROVIDERS.get(type.getFullyQualifiedName()).getProposals(jp);
    } else {/*from   w ww .  j  av a  2s . co  m*/
        try {
            for (IMethod m : type.getMethods()) {
                if (Flags.isStatic(m.getFlags()) && "valueOf".equals(m.getElementName())) {
                    Proposal p = new Proposal("\"<string>\"");
                    p.hover = new HoverImpl(m);
                    return Collections.singletonList(p);
                }
            }
        } catch (JavaModelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return Collections.emptyList();
}

From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.JFXBuildConfigurationEditor.java

License:Open Source License

private String handleRootclassSelection(Shell parent) {
    IFileEditorInput i = (IFileEditorInput) getEditorInput();
    IJavaProject project = JavaCore.create(i.getFile().getProject());
    if (project == null) {
        return null;
    }//from  w  w  w  .  ja  v a  2  s. com

    IJavaElement[] elements = new IJavaElement[] { project };

    int constraints = IJavaSearchScope.SOURCES;
    constraints |= IJavaSearchScope.APPLICATION_LIBRARIES;

    IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(elements, constraints);
    BusyIndicatorRunnableContext context = new BusyIndicatorRunnableContext();

    MainTypeSelectionDialog dialog = new MainTypeSelectionDialog(parent, context, searchScope, 0);
    dialog.setTitle("Find class");
    dialog.setMessage("Find the class used to launch the application");
    if (dialog.open() == Window.CANCEL) {
        return null;
    }
    Object[] results = dialog.getResult();
    IType type = (IType) results[0];
    if (type != null) {
        return type.getFullyQualifiedName();
    }

    return null;
}

From source file:at.bestsolution.efxclipse.tooling.model.internal.FXClass.java

License:Open Source License

public FXClass(IJavaProject jp, IType type) {
    this.type = type;
    this.javaProject = jp;

    try {/*  w w  w  .j a  va 2 s. com*/
        String s = type.getSuperclassName();

        if (s != null) {
            s = getFQNType(type, Signature.getTypeErasure(s));
            superClass = FXPlugin.getClassmodel().findClass(jp, jp.findType(s));
        }
    } catch (JavaModelException e) {
        FXPlugin.getLogger().log(LogService.LOG_ERROR,
                "Unable to retrieve superclass name of '" + type.getFullyQualifiedName() + "'", e);
    }
}

From source file:at.bestsolution.efxclipse.tooling.model.internal.FXClassmodel.java

License:Open Source License

public IFXClass findClass(IJavaProject javaProject, IType type) {
    IFXClass rv = fxClassCache.get(type.getFullyQualifiedName());

    if (rv == null) {
        FXClass c = new FXClass(javaProject, type);
        fxClassCache.put(c.getFQN(), c);
        rv = c;//from   www.ja  va2  s .  c  om
    }
    return rv;
}

From source file:at.bestsolution.efxclipse.tooling.model.internal.FXClassmodel.java

License:Open Source License

@Override
public IFXCtrlClass findCtrlClass(IJavaProject javaProject, IType type) {
    IFXCtrlClass rv = fxCtrlClassCache.get(type.getFullyQualifiedName());

    if (rv == null) {
        FXCtrlClass c = new FXCtrlClass(javaProject, type);
        fxCtrlClassCache.put(c.getFQN(), c);
        rv = c;/*  www .jav  a  2  s  .  c  o m*/
    }
    return rv;
}