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();
}
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()]);
}
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();
}
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()]);
}
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;
}
Aggregations