Search in sources :

Example 81 with IColumn

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

the class TableFacadeTest method testGetColumnIterator.

@Test
public void testGetColumnIterator() {
    Table table = new Table();
    ITable tableFacade = FACADE_FACTORY.createTable(table);
    Iterator<IColumn> columnIterator = tableFacade.getColumnIterator();
    Assert.assertFalse(columnIterator.hasNext());
    Column column = new Column("foo");
    table.addColumn(column);
    tableFacade = FACADE_FACTORY.createTable(table);
    columnIterator = tableFacade.getColumnIterator();
    IColumn columnFacade = columnIterator.next();
    Assert.assertSame(column, ((IFacade) columnFacade).getTarget());
}
Also used : Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) Column(org.hibernate.mapping.Column) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.Test)

Example 82 with IColumn

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

the class ValueFacadeTest method testAddColumn.

@Test
public void testAddColumn() {
    SimpleValue simpleValueTarget = new SimpleValue(null);
    valueFacade = FACADE_FACTORY.createValue(simpleValueTarget);
    Iterator<?> columnIterator = simpleValueTarget.getColumnIterator();
    Assert.assertFalse(columnIterator.hasNext());
    Column columnTarget = new Column();
    IColumn columnFacade = FACADE_FACTORY.createColumn(columnTarget);
    valueFacade.addColumn(columnFacade);
    columnIterator = simpleValueTarget.getColumnIterator();
    Assert.assertTrue(columnIterator.hasNext());
    Assert.assertSame(columnTarget, columnIterator.next());
}
Also used : IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) Column(org.hibernate.mapping.Column) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 83 with IColumn

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

the class TableFacadeTest method testGetColumnIterator.

@Test
public void testGetColumnIterator() {
    Table table = new Table();
    ITable tableFacade = FACADE_FACTORY.createTable(table);
    Iterator<IColumn> columnIterator = tableFacade.getColumnIterator();
    Assert.assertFalse(columnIterator.hasNext());
    Column column = new Column("foo");
    table.addColumn(column);
    tableFacade = FACADE_FACTORY.createTable(table);
    columnIterator = tableFacade.getColumnIterator();
    IColumn columnFacade = columnIterator.next();
    Assert.assertSame(column, ((IFacade) columnFacade).getTarget());
}
Also used : Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) Column(org.hibernate.mapping.Column) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.Test)

Example 84 with IColumn

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

the class TableWorkbenchAdapter method getChildren.

public Object[] getChildren(Object o) {
    ITable t = getTable(o);
    List<Object> items = new ArrayList<Object>();
    IPrimaryKey primaryKey = t.getPrimaryKey();
    if (primaryKey != null) {
        items.add(primaryKey);
    }
    Iterator<?> columnIterator = t.getColumnIterator();
    while (columnIterator.hasNext()) {
        IColumn col = (IColumn) columnIterator.next();
        if (primaryKey == null || !primaryKey.containsColumn(col)) {
            // only add non-pk columns here
            items.add(col);
        }
    }
    return items.toArray(new Object[items.size()]);
}
Also used : IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) ArrayList(java.util.ArrayList) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IPrimaryKey(org.jboss.tools.hibernate.runtime.spi.IPrimaryKey)

Example 85 with IColumn

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

the class ColumnEditPart method createFigure.

protected IFigure createFigure() {
    IColumn column = ((ColumnViewAdapter) getModel()).getcolumn();
    String label = column.getName();
    Label columnLabel = new EditableLabel(label);
    // columnLabel.setIcon(((ColumnViewAdapter)getModel()).getImage());
    return columnLabel;
}
Also used : ColumnViewAdapter(org.hibernate.eclipse.graph.model.ColumnViewAdapter) EditableLabel(org.hibernate.eclipse.graph.figures.EditableLabel) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) EditableLabel(org.hibernate.eclipse.graph.figures.EditableLabel) Label(org.eclipse.draw2d.Label)

Aggregations

IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)86 Test (org.junit.Test)69 Column (org.hibernate.mapping.Column)68 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)26 SimpleValue (org.hibernate.mapping.SimpleValue)16 Table (org.hibernate.mapping.Table)16 ArrayList (java.util.ArrayList)12 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)9 AbstractForeignKeyFacade (org.jboss.tools.hibernate.runtime.common.AbstractForeignKeyFacade)7 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)7 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)7 Iterator (java.util.Iterator)5 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)4 IPrimaryKey (org.jboss.tools.hibernate.runtime.spi.IPrimaryKey)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)3 Shape (org.jboss.tools.hibernate.ui.diagram.editors.model.Shape)3 FileNotFoundException (java.io.FileNotFoundException)2 HashMap (java.util.HashMap)2 List (java.util.List)2