Search in sources :

Example 1 with RevEngGeneratorAdapter

use of org.hibernate.eclipse.mapper.model.RevEngGeneratorAdapter 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 RevEngGeneratorAdapter

use of org.hibernate.eclipse.mapper.model.RevEngGeneratorAdapter in project jbosstools-hibernate by jbosstools.

the class ObserverAdapterFactory method createAdapter.

protected INodeAdapter createAdapter(INodeNotifier target) {
    Node n = (Node) target;
    String nodeName = n.getNodeName();
    INodeAdapter result = null;
    Object key = DOMAdapter.class;
    if ("hibernate-reverse-engineering".equals(nodeName)) {
        // $NON-NLS-1$
        result = new UnknownNodeAdapter(key, revEngDefinition) {

            public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
                observer.hibernateMappingChanged();
            }
        };
    } else if ("table-filter".equals(nodeName)) {
        // $NON-NLS-1$
        result = new TableFilterAdapter((Node) target, revEngDefinition);
    } else if ("type-mapping".equals(nodeName)) {
        // $NON-NLS-1$
        result = new UnknownNodeAdapter(key, revEngDefinition) {

            public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
                observer.typeMappingChanged(notifier);
            }
        };
    } else if ("sql-type".equals(nodeName)) {
        // $NON-NLS-1$
        result = new TypeMappingAdapter((Node) target, revEngDefinition);
    } else if ("table".equals(nodeName)) {
        // $NON-NLS-1$
        result = new RevEngTableAdapter((Node) target, revEngDefinition);
    } else if ("column".equals(nodeName) || "key-column".equals(nodeName)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        result = new RevEngColumnAdapter((Node) target, revEngDefinition);
    } else if ("primary-key".equals(nodeName)) {
        // $NON-NLS-1$
        result = new RevEngPrimaryKeyAdapter((Node) target, revEngDefinition);
    } else if ("generator".equals(nodeName)) {
        // $NON-NLS-1$
        result = new RevEngGeneratorAdapter((Node) target, revEngDefinition);
    } else if ("param".equals(nodeName)) {
        // $NON-NLS-1$
        result = new RevEngParamAdapter((Node) target, revEngDefinition);
    } else if (// $NON-NLS-1$
    "foreign-key".equals(nodeName) || // $NON-NLS-1$
    "column-ref".equals(nodeName)) {
        result = new UnknownNodeAdapter(key, revEngDefinition) {

            public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
                observer.tablesChanged(notifier);
            }
        };
    }
    if (result == null) {
        result = new UnknownNodeAdapter(key, revEngDefinition);
    }
    if (result != null) {
        adaptChildren((Node) target);
    }
    return result;
}
Also used : INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) RevEngPrimaryKeyAdapter(org.hibernate.eclipse.mapper.model.RevEngPrimaryKeyAdapter) Node(org.w3c.dom.Node) TableFilterAdapter(org.hibernate.eclipse.mapper.model.TableFilterAdapter) TypeMappingAdapter(org.hibernate.eclipse.mapper.model.TypeMappingAdapter) RevEngParamAdapter(org.hibernate.eclipse.mapper.model.RevEngParamAdapter) DOMAdapter(org.hibernate.eclipse.mapper.model.DOMAdapter) RevEngTableAdapter(org.hibernate.eclipse.mapper.model.RevEngTableAdapter) RevEngColumnAdapter(org.hibernate.eclipse.mapper.model.RevEngColumnAdapter) RevEngGeneratorAdapter(org.hibernate.eclipse.mapper.model.RevEngGeneratorAdapter) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Aggregations

RevEngColumnAdapter (org.hibernate.eclipse.mapper.model.RevEngColumnAdapter)2 RevEngGeneratorAdapter (org.hibernate.eclipse.mapper.model.RevEngGeneratorAdapter)2 RevEngParamAdapter (org.hibernate.eclipse.mapper.model.RevEngParamAdapter)2 RevEngPrimaryKeyAdapter (org.hibernate.eclipse.mapper.model.RevEngPrimaryKeyAdapter)2 RevEngTableAdapter (org.hibernate.eclipse.mapper.model.RevEngTableAdapter)2 ISelection (org.eclipse.jface.viewers.ISelection)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 INodeAdapter (org.eclipse.wst.sse.core.internal.provisional.INodeAdapter)1 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)1 IRevEngColumn (org.hibernate.eclipse.console.model.IRevEngColumn)1 IRevEngGenerator (org.hibernate.eclipse.console.model.IRevEngGenerator)1 IRevEngParameter (org.hibernate.eclipse.console.model.IRevEngParameter)1 IRevEngPrimaryKey (org.hibernate.eclipse.console.model.IRevEngPrimaryKey)1 IRevEngTable (org.hibernate.eclipse.console.model.IRevEngTable)1 DOMAdapter (org.hibernate.eclipse.mapper.model.DOMAdapter)1 TableFilterAdapter (org.hibernate.eclipse.mapper.model.TableFilterAdapter)1 TypeMappingAdapter (org.hibernate.eclipse.mapper.model.TypeMappingAdapter)1 Node (org.w3c.dom.Node)1