Search in sources :

Example 11 with ITable

use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.

the class ToggleShapeVisibleStateAction method canPerformAction.

@SuppressWarnings("unchecked")
private boolean canPerformAction() {
    boolean res = false;
    if (getSelectedObjects().isEmpty()) {
        return res;
    }
    Iterator it = getSelectedObjects().iterator();
    while (it.hasNext() && !res) {
        Object firstElement = it.next();
        Object obj = null;
        if (firstElement instanceof OrmEditPart) {
            obj = ((OrmEditPart) firstElement).getModel();
        } else if (firstElement instanceof AbstractTreeEditPart) {
            obj = ((AbstractTreeEditPart) firstElement).getModel();
        }
        if (null != obj && obj instanceof OrmShape) {
            Object ormElement = ((OrmShape) obj).getOrmElement();
            if (ormElement instanceof IPersistentClass || ormElement instanceof ITable) {
                res = true;
            }
        }
    }
    return res;
}
Also used : OrmShape(org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape) AbstractTreeEditPart(org.eclipse.gef.editparts.AbstractTreeEditPart) OrmEditPart(org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart) Iterator(java.util.Iterator) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 12 with ITable

use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.

the class OrmLabelMap method getParticularLabel.

/**
 * the label for hierarchy:
 * PersistentClass
 * |-- RootClass
 * |   |-- SpecialRootClass
 * |
 * |-- Subclass
 *     |-- JoinedSubclass
 *     |-- SingleTableSubclass
 *     |-- UnionSubclass
 * @param persistentClass
 * @return
 */
public static String getParticularLabel(IPersistentClass persistentClass) {
    StringBuffer name = new StringBuffer();
    name.append(persistentClass.getEntityName() != null ? persistentClass.getEntityName() : persistentClass.getClassName());
    ITable table = persistentClass.getTable();
    if (table != null) {
        final String tableName = Utils.getTableName(table);
        if (tableName != null) {
            name.append(POINTER);
            name.append(tableName);
        }
    }
    return name.toString();
}
Also used : ITable(org.jboss.tools.hibernate.runtime.spi.ITable)

Example 13 with ITable

use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.

the class ShapeEditPart method getSelectionColor.

protected Color getSelectionColor() {
    Color result = ResourceManager.getInstance().getColor(new RGB(255, 0, 0));
    final Object el = getElement();
    if (el instanceof IPersistentClass || el instanceof IProperty) {
        result = ResourceManager.getInstance().getColor(new RGB(112, 161, 99));
    } else if (el instanceof IValue) {
        IValue value = (IValue) el;
        if (value.isSimpleValue() || value.isOneToMany()) {
            result = ResourceManager.getInstance().getColor(new RGB(112, 161, 99));
        }
    } else if (el instanceof ITable || el instanceof IColumn) {
        result = ResourceManager.getInstance().getColor(new RGB(66, 173, 247));
    }
    return result;
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) Color(org.eclipse.swt.graphics.Color) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) RGB(org.eclipse.swt.graphics.RGB) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 14 with ITable

use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateTable.

@Test
public void testCreateTable() {
    Table table = new Table();
    ITable facade = facadeFactory.createTable(table);
    Assert.assertSame(table, ((IFacade) facade).getTarget());
}
Also used : ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.Test)

Example 15 with ITable

use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.

the class ForeignKeyFacadeTest method testGetReferencedTable.

@Test
public void testGetReferencedTable() {
    ITable first = foreignKeyFacade.getReferencedTable();
    Assert.assertEquals("getReferencedTable", methodName);
    Assert.assertArrayEquals(new Object[] {}, arguments);
    Assert.assertNull(first);
    Table table = new Table();
    foreignKey.setReferencedTable(table);
    reset();
    ITable second = foreignKeyFacade.getReferencedTable();
    Assert.assertEquals("getReferencedTable", methodName);
    Assert.assertArrayEquals(new Object[] {}, arguments);
    Assert.assertNotNull(second);
    Assert.assertSame(table, ((IFacade) second).getTarget());
    reset();
    ITable third = foreignKeyFacade.getReferencedTable();
    Assert.assertNull(methodName);
    Assert.assertNull(arguments);
    Assert.assertSame(second, third);
}
Also used : Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.Test)

Aggregations

ITable (org.jboss.tools.hibernate.runtime.spi.ITable)209 Table (org.hibernate.mapping.Table)180 Test (org.junit.Test)173 IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)26 SimpleValue (org.hibernate.mapping.SimpleValue)24 Method (java.lang.reflect.Method)17 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)17 Column (org.hibernate.mapping.Column)16 PrimaryKey (org.hibernate.mapping.PrimaryKey)16 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)14 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)12 IPrimaryKey (org.jboss.tools.hibernate.runtime.spi.IPrimaryKey)11 Connection (java.sql.Connection)8 Statement (java.sql.Statement)8 Collection (org.hibernate.mapping.Collection)8 KeyValue (org.hibernate.mapping.KeyValue)8 Set (org.hibernate.mapping.Set)8 ArrayList (java.util.ArrayList)7 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)7 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)7