Search in sources :

Example 81 with IProperty

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));
}
Also used : RootClass(org.hibernate.mapping.RootClass) AbstractPropertyFacade(org.jboss.tools.hibernate.runtime.common.AbstractPropertyFacade) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) Property(org.hibernate.mapping.Property) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) SimpleValue(org.hibernate.mapping.SimpleValue)

Example 82 with IProperty

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));
}
Also used : RootClass(org.hibernate.mapping.RootClass) AbstractPropertyFacade(org.jboss.tools.hibernate.runtime.common.AbstractPropertyFacade) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) Property(org.hibernate.mapping.Property) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) SimpleValue(org.hibernate.mapping.SimpleValue)

Example 83 with IProperty

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);
}
Also used : IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Property(org.hibernate.mapping.Property) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) Test(org.junit.Test)

Example 84 with IProperty

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));
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) EditConsoleConfiguration(org.hibernate.eclipse.console.actions.EditConsoleConfiguration) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) GroupMarker(org.eclipse.jface.action.GroupMarker) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Separator(org.eclipse.jface.action.Separator) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 85 with IProperty

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);
                        }
                    }
                }
            }
        }
    };
}
Also used : Action(org.eclipse.jface.action.Action) OpenMappingAction(org.hibernate.eclipse.console.actions.OpenMappingAction) JavaModelException(org.eclipse.jdt.core.JavaModelException) EditConsoleConfiguration(org.hibernate.eclipse.console.actions.EditConsoleConfiguration) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) BaseNode(org.hibernate.console.node.BaseNode) FileNotFoundException(java.io.FileNotFoundException) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) TreePath(org.eclipse.jface.viewers.TreePath) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ISelection(org.eclipse.jface.viewers.ISelection) EditConsoleConfiguration(org.hibernate.eclipse.console.actions.EditConsoleConfiguration) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)93 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)53 Property (org.hibernate.mapping.Property)40 Test (org.junit.Test)33 RootClass (org.hibernate.mapping.RootClass)27 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)20 PersistentClass (org.hibernate.mapping.PersistentClass)18 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)12 SimpleValue (org.hibernate.mapping.SimpleValue)12 AbstractPropertyFacade (org.jboss.tools.hibernate.runtime.common.AbstractPropertyFacade)12 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)12 FileNotFoundException (java.io.FileNotFoundException)9 IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)9 Component (org.hibernate.mapping.Component)8 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)8 IEditorPart (org.eclipse.ui.IEditorPart)7 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)7 JavaModelException (org.eclipse.jdt.core.JavaModelException)6 Mappings (org.hibernate.cfg.Mappings)6 PartInitException (org.eclipse.ui.PartInitException)5