Search in sources :

Example 1 with IRevEngGenerator

use of org.hibernate.eclipse.console.model.IRevEngGenerator in project jbosstools-hibernate by jbosstools.

the class TablePropertiesBlock method doDelete.

protected void doDelete() {
    ISelection sel = viewer.getSelection();
    if (sel.isEmpty() || !(sel instanceof TreeSelection)) {
        return;
    }
    boolean updateSelection = false;
    TreeSelection ts = (TreeSelection) sel;
    List<?> list = ts.toList();
    for (Iterator<?> it = list.iterator(); it.hasNext(); ) {
        Object obj = it.next();
        if (obj instanceof IRevEngTable) {
            IRevEngTable retable = (IRevEngTable) obj;
            if (retable instanceof RevEngTableAdapter) {
                updateSelection = true;
            }
            editor.getReverseEngineeringDefinition().removeTable(retable);
        } else if (obj instanceof IRevEngColumn) {
            IRevEngColumn recolumn = (IRevEngColumn) obj;
            if (recolumn instanceof RevEngColumnAdapter) {
                updateSelection = true;
            }
            editor.getReverseEngineeringDefinition().removeColumn(recolumn);
        } else if (obj instanceof IRevEngPrimaryKey) {
            IRevEngPrimaryKey reprimaryKey = (IRevEngPrimaryKey) obj;
            if (reprimaryKey instanceof RevEngPrimaryKeyAdapter) {
                updateSelection = true;
            }
            editor.getReverseEngineeringDefinition().removePrimaryKey(reprimaryKey);
        } else if (obj instanceof IRevEngGenerator) {
            IRevEngGenerator regenerator = (IRevEngGenerator) obj;
            if (regenerator instanceof RevEngGeneratorAdapter) {
                updateSelection = true;
            }
            editor.getReverseEngineeringDefinition().removeGenerator(regenerator);
        } else if (obj instanceof IRevEngParameter) {
            IRevEngParameter reparam = (IRevEngParameter) obj;
            if (reparam instanceof RevEngParamAdapter) {
                updateSelection = true;
            }
            editor.getReverseEngineeringDefinition().removeParameter(reparam);
        }
    }
    if (updateSelection) {
        // if it possible select first item
        TreeItem[] treeItems = viewer.getTree().getItems();
        if (treeItems.length > 0) {
            viewer.getTree().setSelection(treeItems[0]);
        }
    }
}
Also used : RevEngPrimaryKeyAdapter(org.hibernate.eclipse.mapper.model.RevEngPrimaryKeyAdapter) TreeItem(org.eclipse.swt.widgets.TreeItem) IRevEngGenerator(org.hibernate.eclipse.console.model.IRevEngGenerator) IRevEngColumn(org.hibernate.eclipse.console.model.IRevEngColumn) RevEngParamAdapter(org.hibernate.eclipse.mapper.model.RevEngParamAdapter) IRevEngParameter(org.hibernate.eclipse.console.model.IRevEngParameter) RevEngTableAdapter(org.hibernate.eclipse.mapper.model.RevEngTableAdapter) IRevEngPrimaryKey(org.hibernate.eclipse.console.model.IRevEngPrimaryKey) TreeSelection(org.eclipse.jface.viewers.TreeSelection) IRevEngTable(org.hibernate.eclipse.console.model.IRevEngTable) RevEngColumnAdapter(org.hibernate.eclipse.mapper.model.RevEngColumnAdapter) RevEngGeneratorAdapter(org.hibernate.eclipse.mapper.model.RevEngGeneratorAdapter) ISelection(org.eclipse.jface.viewers.ISelection)

Example 2 with IRevEngGenerator

use of org.hibernate.eclipse.console.model.IRevEngGenerator in project jbosstools-hibernate by jbosstools.

the class TablePropertiesContentProvider method getChildren.

public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof IRevEngTable) {
        IRevEngTable revEngTable = ((IRevEngTable) parentElement);
        IRevEngPrimaryKey primaryKey = revEngTable.getPrimaryKey();
        IRevEngColumn[] columns = revEngTable.getColumns();
        if (primaryKey != null) {
            Object[] des = new Object[columns.length + 1];
            des[0] = primaryKey;
            System.arraycopy(columns, 0, des, 1, columns.length);
            return des;
        } else {
            return columns;
        }
    } else if (parentElement instanceof IRevEngColumn) {
        return new Object[0];
    } else if (parentElement instanceof IRevEngPrimaryKey) {
        IRevEngPrimaryKey pk = (IRevEngPrimaryKey) parentElement;
        IRevEngGenerator generator = pk.getGenerator();
        IRevEngColumn[] columns = pk.getColumns();
        if (generator != null) {
            Object[] des = new Object[columns.length + 1];
            des[0] = generator;
            System.arraycopy(columns, 0, des, 1, columns.length);
            return des;
        } else {
            return columns;
        }
    } else if (parentElement instanceof IRevEngGenerator) {
        IRevEngGenerator generator = (IRevEngGenerator) parentElement;
        return generator.getParameters();
    } else {
        return new Object[0];
    }
}
Also used : IRevEngPrimaryKey(org.hibernate.eclipse.console.model.IRevEngPrimaryKey) IRevEngTable(org.hibernate.eclipse.console.model.IRevEngTable) IRevEngGenerator(org.hibernate.eclipse.console.model.IRevEngGenerator) IRevEngColumn(org.hibernate.eclipse.console.model.IRevEngColumn)

Example 3 with IRevEngGenerator

use of org.hibernate.eclipse.console.model.IRevEngGenerator in project jbosstools-hibernate by jbosstools.

the class GeneratorDetailsPage method selectionChanged.

public void selectionChanged(IFormPart part, ISelection selection) {
    IRevEngGenerator newTable = (IRevEngGenerator) ((IStructuredSelection) selection).getFirstElement();
    if (generator != null) {
        generator.removePropertyChangeListener(this);
    }
    if (newTable != null) {
        newTable.addPropertyChangeListener(this);
    }
    generator = newTable;
    update();
}
Also used : IRevEngGenerator(org.hibernate.eclipse.console.model.IRevEngGenerator)

Aggregations

IRevEngGenerator (org.hibernate.eclipse.console.model.IRevEngGenerator)3 IRevEngColumn (org.hibernate.eclipse.console.model.IRevEngColumn)2 IRevEngPrimaryKey (org.hibernate.eclipse.console.model.IRevEngPrimaryKey)2 IRevEngTable (org.hibernate.eclipse.console.model.IRevEngTable)2 ISelection (org.eclipse.jface.viewers.ISelection)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 IRevEngParameter (org.hibernate.eclipse.console.model.IRevEngParameter)1 RevEngColumnAdapter (org.hibernate.eclipse.mapper.model.RevEngColumnAdapter)1 RevEngGeneratorAdapter (org.hibernate.eclipse.mapper.model.RevEngGeneratorAdapter)1 RevEngParamAdapter (org.hibernate.eclipse.mapper.model.RevEngParamAdapter)1 RevEngPrimaryKeyAdapter (org.hibernate.eclipse.mapper.model.RevEngPrimaryKeyAdapter)1 RevEngTableAdapter (org.hibernate.eclipse.mapper.model.RevEngTableAdapter)1