use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class MappingTestHelper method getConsoleConfig.
private ConsoleConfiguration getConsoleConfig() {
KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
String consoleConfigName = testProject.getIProject().getName();
final ConsoleConfiguration consCFG = knownConfigurations.find(consoleConfigName);
Assert.assertNotNull(consCFG);
return consCFG;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class MappingTestHelper method testOpenMappingFileTest.
public void testOpenMappingFileTest() {
final Object[] persClasses = getPersistenceClasses(true);
final ConsoleConfiguration consCFG = getConsoleConfig();
// $NON-NLS-1$
final String testClass = "class";
for (int i = 0; i < persClasses.length; i++) {
Assert.assertTrue(persClasses[i] instanceof IPersistentClass);
IPersistentClass persClass = (IPersistentClass) persClasses[i];
openTest(persClass, consCFG);
Object[] props = pcWorkbenchAdapter.getChildren(persClass);
for (int j = 0; j < props.length; j++) {
if (!(props[j] instanceof IProperty && ((IProperty) props[j]).classIsPropertyClass())) {
continue;
}
openTest(props[j], consCFG);
Object[] compProperties = propertyWorkbenchAdapter.getChildren(props[j]);
for (int k = 0; k < compProperties.length; k++) {
// test Composite properties
if (!(compProperties[k] instanceof IProperty && ((IProperty) props[j]).classIsPropertyClass())) {
continue;
}
final IProperty prop = (IProperty) compProperties[k];
if (testClass.equals(prop.getName()) || testClass.equals(prop.getName())) {
continue;
}
openPropertyTest((IProperty) compProperties[k], (IProperty) props[j], consCFG);
}
}
}
// close all editors
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class SearchTabBuilder method createEntityCombo.
protected void createEntityCombo(Composite parent, final ConsoleConfiguration consoleConfig) {
if (!ConsoleConfigurationUtils.loadSessionFactorySafely(consoleConfig)) {
return;
}
;
Composite entitiesComposite = new Composite(parent, SWT.NONE);
entitiesComposite.setLayout(new RowLayout());
this.entityCombo = new Combo(entitiesComposite, SWT.NONE | SWT.READ_ONLY);
for (Class<?> entity : ConsoleConfigurationUtils.getIndexedEntities(consoleConfig)) {
entityCombo.add(entity.getName());
}
if (entityCombo.getItemCount() == 0) {
new Label(entitiesComposite, SWT.NONE).setText("No entity classes anntotated @Indexed");
return;
}
Label defaultFieldLabel = new Label(entitiesComposite, SWT.CENTER);
defaultFieldLabel.setText("Default field:");
this.fieldsCombo = new Combo(entitiesComposite, SWT.NONE | SWT.READ_ONLY);
this.entityCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
ClassLoader classloader = ConsoleConfigurationUtils.getClassLoader(consoleConfig);
try {
fieldsCombo.removeAll();
Class<?> clazz = Class.forName(((Combo) e.getSource()).getText(), true, classloader);
Set<String> fields = ConsoleConfigurationUtils.getHSearchService(consoleConfig).getIndexedFields(consoleConfig.getSessionFactory(), clazz);
fields.stream().filter(s -> !"_hibernate_class".equals(s)).forEach(s -> fieldsCombo.add(s));
fieldsCombo.select(0);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
}
});
entityCombo.select(0);
entitiesComposite.pack();
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class IndexRebuildHandler method execute.
@SuppressWarnings("unchecked")
@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) {
indexRebuildForConfiguration(selection.iterator());
}
if (selection.getFirstElement() instanceof IPersistentClass) {
indexRebuildForPersistentClass((ConsoleConfiguration) selection.getPaths()[0].getFirstSegment(), selection.iterator());
}
return null;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class HibernateSearchEnabledPropertyTesterTest method containsHibernateSearchLib.
@Test
public void containsHibernateSearchLib() throws MalformedURLException {
ConsoleConfiguration consoleConfiguration = mock(ConsoleConfiguration.class);
ConsoleConfigurationPreferences prefs = mock(ConsoleConfigurationPreferences.class);
when(consoleConfiguration.getPreferences()).thenReturn(prefs);
when(prefs.getCustomClassPathURLS()).thenReturn(new URL[] { new URL("file", "", "hibernate-search-orm-version") });
TreePath treePath = new TreePath(new Object[] { consoleConfiguration });
ITreeSelection receiver = new TreeSelection(treePath);
HibernateSearchEnabledPropertyTester tester = new HibernateSearchEnabledPropertyTester();
assertTrue(tester.test(receiver, "doesn't matter", null, null));
}
Aggregations