use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class Cfg2HbmToolFacadeTest method testGetPropertyTag.
public void testGetPropertyTag() throws Exception {
RootClass rc = new RootClass(null);
Property p = new Property();
MetadataImplementor m = (MetadataImplementor) Proxy.newProxyInstance(FACADE_FACTORY.getClassLoader(), new Class[] { MetadataImplementor.class }, new TestInvocationHandler());
SimpleValue sv = new SimpleValue(m);
sv.setTypeName("foobar");
p.setValue(sv);
p.setPersistentClass(rc);
rc.setVersion(p);
IProperty property = new AbstractPropertyFacade(FACADE_FACTORY, p) {
};
Assert.assertEquals("version", cfg2HbmToolFacade.getTag(property));
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class Cfg2HbmToolFacadeTest method testGetPropertyTag.
public void testGetPropertyTag() throws Exception {
RootClass rc = new RootClass(null);
Property p = new Property();
MetadataImplementor m = (MetadataImplementor) Proxy.newProxyInstance(FACADE_FACTORY.getClassLoader(), new Class[] { MetadataImplementor.class }, new TestInvocationHandler());
SimpleValue sv = new SimpleValue(m);
sv.setTypeName("foobar");
p.setValue(sv);
p.setPersistentClass(rc);
rc.setVersion(p);
IProperty property = new AbstractPropertyFacade(FACADE_FACTORY, p) {
};
Assert.assertEquals("version", cfg2HbmToolFacade.getTag(property));
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class ServiceImplTest method testNewProperty.
@Test
public void testNewProperty() {
IProperty property = service.newProperty();
Assert.assertNotNull(property);
Object target = ((IFacade) property).getTarget();
Assert.assertNotNull(target);
Assert.assertTrue(target instanceof Property);
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class ConfigurationsViewActionGroup method fillContextMenu.
public void fillContextMenu(IMenuManager menu) {
if (getContext() == null) {
return;
}
IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
if (selection == null) {
return;
}
Object first = selection.getFirstElement();
menu.add(new Separator(GROUP_PRIMAL_EDITORS));
menu.appendToGroup(GROUP_PRIMAL_EDITORS, hqlEditorAction);
menu.appendToGroup(GROUP_PRIMAL_EDITORS, criteriaEditorAction);
menu.add(new GroupMarker(GROUP_PRIMAL_EDITORS_LAST));
menu.add(new Separator(GROUP_CONSOLE_CONFIG));
menu.appendToGroup(GROUP_CONSOLE_CONFIG, addConfigurationAction);
if (first instanceof ConsoleConfiguration) {
menu.appendToGroup(GROUP_CONSOLE_CONFIG, reloadConfigurationAction);
menu.appendToGroup(GROUP_CONSOLE_CONFIG, editConfigurationAction);
menu.appendToGroup(GROUP_CONSOLE_CONFIG, closeConfigAction);
menu.appendToGroup(GROUP_CONSOLE_CONFIG, deleteConfigurationAction);
}
menu.add(new GroupMarker(GROUP_CONSOLE_CONFIG_LAST));
menu.add(new Separator(GROUP_ADDITION));
menu.appendToGroup(GROUP_ADDITION, refreshAction);
if (first instanceof ConsoleConfiguration) {
menu.appendToGroup(GROUP_ADDITION, schemaExportAction);
}
menu.add(new GroupMarker(GROUP_ADDITION_LAST));
menu.add(new Separator(GROUP_OTHER_EDITORS));
// TODO: shouldn't these and maybe the others not be defined via menu extension points ?
if (first != null && (first instanceof IPersistentClass || (first instanceof IProperty && ((IProperty) first).classIsPropertyClass()))) {
menu.appendToGroup(GROUP_OTHER_EDITORS, openSourceAction);
menu.appendToGroup(GROUP_OTHER_EDITORS, openMappingAction);
}
menu.add(new GroupMarker(GROUP_OTHER_EDITORS_LAST));
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class KnownConfigurationsView method makeActions.
/**
*/
private void makeActions() {
this.actionGroup = new ConfigurationsViewActionGroup(this, viewer);
this.doubleAction = new Action() {
public void run() {
// TODO: make action dependent on having a connected console configuration!
ISelection selection = viewer.getSelection();
if (selection == null || selection.isEmpty()) {
return;
}
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
if (firstElement instanceof ConsoleConfiguration) {
new EditConsoleConfiguration((ConsoleConfiguration) firstElement).run();
} else if (firstElement instanceof BaseNode) {
BaseNode node = (BaseNode) firstElement;
ConsoleConfiguration consoleConfiguration = node.getConsoleConfiguration();
if (consoleConfiguration.isSessionFactoryCreated()) {
String hql = node.getHQL();
// open HQL Editor
HibernateConsolePlugin.getDefault().openScratchHQLEditor(consoleConfiguration.getName(), hql);
/**
* /
* // execute query and show results in
* // Hibernate Query result view - commented cause old version
* if(StringHelper.isNotEmpty( hql )) {
* try {
* if (getSite() != null && getSite().getPage() != null) {
* getSite().getPage().showView(QueryPageTabView.ID);
* }
* } catch (PartInitException e) {
* HibernateConsolePlugin.getDefault().logErrorMessage("Can't show QueryPageTabView.", e); //$NON-NLS-1$
* }
* consoleConfiguration.executeHQLQuery( hql );
* }
* /*
*/
}
} else if (selection instanceof TreeSelection) {
TreePath[] paths = ((TreeSelection) selection).getPaths();
TreePath path = paths[0];
Object last = path.getLastSegment();
ConsoleConfiguration consoleConfig = (ConsoleConfiguration) (path.getSegment(0));
if (last instanceof IPersistentClass || (last instanceof IProperty && ((IProperty) last).classIsPropertyClass())) {
try {
OpenMappingAction.run(consoleConfig, path);
} catch (PartInitException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e);
} catch (JavaModelException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e);
} catch (FileNotFoundException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e);
}
} else {
for (int i = 0; i < paths.length; i++) {
if (viewer.getExpandedState(paths[i])) {
viewer.collapseToLevel(paths[i], 1);
} else {
viewer.expandToLevel(paths[i], 1);
}
}
}
}
}
};
}
Aggregations