Search in sources :

Example 1 with HibernateNature

use of org.hibernate.eclipse.nature.HibernateNature in project jbosstools-hibernate by jbosstools.

the class JPAPostInstallFasetListener method getConnectionProperties.

public Properties getConnectionProperties(IProject project) {
    IJavaProject javaProject = JavaCore.create(project);
    IService service = null;
    if (javaProject != null) {
        HibernateNature hibNat = HibernateNature.getHibernateNature(javaProject);
        if (hibNat != null) {
            ConsoleConfiguration cc = hibNat.getDefaultConsoleConfiguration();
            if (cc != null) {
                service = cc.getHibernateExtension().getHibernateService();
            }
        }
    }
    String cpName = HibernateEclipseUtils.getConnectionProfileName(project);
    if (cpName != null && service != null) {
        return ConnectionProfileUtil.getHibernateConnectionProperties(service, ProfileManager.getInstance().getProfileByName(cpName));
    }
    return new Properties();
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) HibernateNature(org.hibernate.eclipse.nature.HibernateNature) Properties(java.util.Properties) IService(org.jboss.tools.hibernate.runtime.spi.IService)

Example 2 with HibernateNature

use of org.hibernate.eclipse.nature.HibernateNature in project jbosstools-hibernate by jbosstools.

the class ColumnNameHandler method attributeCompletionProposals.

public ICompletionProposal[] attributeCompletionProposals(IJavaProject javaProject, Node node, String attributeName, String start, int offset) {
    List columns = new ArrayList();
    HibernateNature nature = HibernateNature.getHibernateNature(javaProject);
    if (nature != null) {
        String nearestTableName = extractor.getNearestTableName(node);
        if (nearestTableName != null) {
            ITable table = nature.getTable(nearestTableName);
            if (table != null) {
                Iterator tableMappings = table.getColumnIterator();
                while (tableMappings.hasNext()) {
                    IColumn column = (IColumn) tableMappings.next();
                    if (column.getName().toUpperCase().startsWith(start.toUpperCase())) {
                        columns.add(column);
                    }
                }
            }
        }
    }
    List proposals = new ArrayList();
    for (Iterator iter = columns.iterator(); iter.hasNext(); ) {
        IColumn element = (IColumn) iter.next();
        proposals.add(new CompletionProposal(element.getName(), offset, start.length(), element.getName().length(), null, null, null, null));
    }
    return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
}
Also used : ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) CompletionProposal(org.eclipse.jface.text.contentassist.CompletionProposal) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) HibernateNature(org.hibernate.eclipse.nature.HibernateNature)

Example 3 with HibernateNature

use of org.hibernate.eclipse.nature.HibernateNature in project jbosstools-hibernate by jbosstools.

the class StructuredTextViewerConfigurationUtil method getService.

public static IService getService(ISourceViewer sourceViewer) {
    IJavaProject javaProject = findJavaProject(sourceViewer);
    HibernateNature hibnat = HibernateNature.getHibernateNature(javaProject);
    if (hibnat != null) {
        ConsoleConfiguration cc = hibnat.getDefaultConsoleConfiguration();
        if (cc != null) {
            HibernateExtension extension = cc.getHibernateExtension();
            if (extension != null) {
                return extension.getHibernateService();
            }
        }
    }
    return ServiceLookup.getDefault();
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) HibernateExtension(org.hibernate.eclipse.console.common.HibernateExtension) HibernateNature(org.hibernate.eclipse.nature.HibernateNature)

Example 4 with HibernateNature

use of org.hibernate.eclipse.nature.HibernateNature in project jbosstools-hibernate by jbosstools.

the class TableNameHandler method attributeCompletionProposals.

public ICompletionProposal[] attributeCompletionProposals(IJavaProject javaProject, Node node, String attributeName, String start, int offset) {
    List tables = new ArrayList();
    HibernateNature nature = HibernateNature.getHibernateNature(javaProject);
    if (nature != null) {
        tables = nature.getMatchingTables(start);
    }
    List proposals = new ArrayList();
    for (Iterator iter = tables.iterator(); iter.hasNext(); ) {
        ITable element = (ITable) iter.next();
        proposals.add(new CompletionProposal(element.getName(), offset, start.length(), element.getName().length(), null, null, null, null));
    }
    return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
}
Also used : ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) CompletionProposal(org.eclipse.jface.text.contentassist.CompletionProposal) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) HibernateNature(org.hibernate.eclipse.nature.HibernateNature)

Example 5 with HibernateNature

use of org.hibernate.eclipse.nature.HibernateNature in project jbosstools-hibernate by jbosstools.

the class BasicQuickAssistProcessor method hasAssists.

public boolean hasAssists(IInvocationContext context) throws CoreException {
    IJavaProject javaProject = context.getCompilationUnit().getJavaProject();
    HibernateNature nature = HibernateNature.getHibernateNature(javaProject);
    return nature != null;
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) HibernateNature(org.hibernate.eclipse.nature.HibernateNature)

Aggregations

HibernateNature (org.hibernate.eclipse.nature.HibernateNature)5 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 CompletionProposal (org.eclipse.jface.text.contentassist.CompletionProposal)2 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)2 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)2 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)2 Properties (java.util.Properties)1 HibernateExtension (org.hibernate.eclipse.console.common.HibernateExtension)1 IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)1 IService (org.jboss.tools.hibernate.runtime.spi.IService)1