use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class CriteriaEditor method getImports.
private String[] getImports() {
final ConsoleConfiguration consoleConfiguration = getConsoleConfiguration();
if (!consoleConfiguration.hasConfiguration()) {
try {
consoleConfiguration.build();
consoleConfiguration.buildMappings();
} catch (Exception e) {
String mess = NLS.bind(HibernateConsoleMessages.CompletionHelper_error_could_not_build_cc, consoleConfiguration.getName());
HibernateConsolePlugin.getDefault().logErrorMessage(mess, e);
}
}
Set<String> imports = new HashSet<String>();
IConfiguration configuration = consoleConfiguration.getConfiguration();
if (configuration != null) {
Iterator<IPersistentClass> classMappings = configuration.getClassMappings();
while (classMappings.hasNext()) {
IPersistentClass clazz = classMappings.next();
String className = clazz.getClassName();
if (className != null) {
imports.add(className);
}
}
}
// $NON-NLS-1$
imports.add("org.hibernate.*");
// $NON-NLS-1$
imports.add("org.hibernate.criterion.*");
return imports.toArray(new String[imports.size()]);
}
use of org.hibernate.console.ConsoleConfiguration 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.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class IndexToolkitView method createPartControl.
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new GridLayout(1, true));
this.consoleConfigCombo = new ConfigurationCombo(parent, initialConsoleConfig == null ? null : initialConsoleConfig.getName());
final CTabFolder folder = new CTabFolder(parent, SWT.TOP);
folder.setLayoutData(new GridData(GridData.FILL, SWT.FILL, true, true));
ConsoleConfiguration consoleConfig = KnownConfigurations.getInstance().find(this.consoleConfigCombo.getConsoleConfigSelected());
final CTabItem analyzersTab = new CTabItem(folder, SWT.NONE);
analyzersTab.setText(ANALYZERS_TAB_NAME);
final AnalyzersTabBuilder analyzersBuilder = AnalyzersTabBuilder.getInstance();
analyzersTab.setControl(analyzersBuilder.getTab(folder, consoleConfig));
final CTabItem exploreDocsTab = new CTabItem(folder, SWT.NONE);
exploreDocsTab.setText(EXPLORE_DOCS_TAB_NAME);
final ExploreDocsTabBuilder exploreDocsBuilder = ExploreDocsTabBuilder.getInstance();
exploreDocsTab.setControl(exploreDocsBuilder.getTab(folder, consoleConfig));
final CTabItem searchTab = new CTabItem(folder, SWT.NONE);
searchTab.setText(SEARCH_TAB_NAME);
final SearchTabBuilder searchBuilder = SearchTabBuilder.getInstance();
searchTab.setControl(searchBuilder.getTab(folder, consoleConfig));
folder.setSelection(0);
this.consoleConfigCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
ConsoleConfiguration consoleConfig = KnownConfigurations.getInstance().find(((Combo) e.getSource()).getText());
analyzersTab.setControl(analyzersBuilder.getTab(folder, consoleConfig));
exploreDocsTab.setControl(exploreDocsBuilder.getTab(folder, consoleConfig));
searchTab.setControl(searchBuilder.getTab(folder, consoleConfig));
}
});
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class IndexToolkitViewLaunchHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection sel = HandlerUtil.getActiveMenuSelection(event);
if (sel.isEmpty()) {
return null;
}
ITreeSelection selection = (ITreeSelection) sel;
if (selection.getFirstElement() instanceof ConsoleConfiguration) {
ConsoleConfiguration consoleConfig = (ConsoleConfiguration) selection.getFirstElement();
if (ConsoleConfigurationUtils.isConnectionExist(consoleConfig)) {
HibernateSearchConsolePlugin.getDefault().showIndexToolkitView(consoleConfig);
}
}
return null;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class HibernateSearchEnabledPropertyTester method test.
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (!(receiver instanceof ITreeSelection)) {
return false;
}
ITreeSelection selection = (ITreeSelection) receiver;
Set<ConsoleConfiguration> consoleConfigs = new HashSet<ConsoleConfiguration>();
for (TreePath path : selection.getPaths()) {
if (path.getFirstSegment() instanceof ConsoleConfiguration) {
consoleConfigs.add((ConsoleConfiguration) path.getFirstSegment());
} else {
return false;
}
}
for (ConsoleConfiguration consoleConfig : consoleConfigs) {
boolean isHibernateSearch = false;
URL[] classPathURLs = PreferencesClassPathUtils.getCustomClassPathURLs(consoleConfig.getPreferences());
for (URL url : classPathURLs) {
if (url.getFile().contains("hibernate-search")) {
isHibernateSearch = true;
break;
}
}
if (!isHibernateSearch) {
return false;
}
}
return true;
}
Aggregations