Search in sources :

Example 1 with EditNodeAction

use of org.apache.cayenne.modeler.action.dbimport.EditNodeAction in project cayenne by apache.

the class DbImportTreeCellEditor method cancelCellEditing.

@Override
public void cancelCellEditing() {
    if (tree.getSelectionPath() == null) {
        return;
    }
    if (!Util.isEmptyString(super.getCellEditorValue().toString()) && !insertableNodeExist() && (isValidReverseEngineering())) {
        EditNodeAction action = projectController.getApplication().getActionManager().getAction(EditNodeAction.class);
        action.setActionName(super.getCellEditorValue().toString());
        action.actionPerformed(null);
    } else {
        DbImportTreeNode selectedNode = (DbImportTreeNode) tree.getSelectionPath().getLastPathComponent();
        if (Util.isEmptyString(selectedNode.getSimpleNodeName()) || (insertableNodeExist())) {
            DeleteNodeAction action = projectController.getApplication().getActionManager().getAction(DeleteNodeAction.class);
            TreePath parentPath = tree.getSelectionPath().getParentPath();
            action.actionPerformed(null);
            tree.setSelectionPath(parentPath);
        } else {
            tree.startEditingAtPath(tree.getSelectionPath());
        }
    }
    DbImportTreeNode selectedNode = (DbImportTreeNode) tree.getSelectionPath().getLastPathComponent();
    ((DbImportModel) tree.getModel()).reload(selectedNode);
}
Also used : DeleteNodeAction(org.apache.cayenne.modeler.action.dbimport.DeleteNodeAction) TreePath(javax.swing.tree.TreePath) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) EditNodeAction(org.apache.cayenne.modeler.action.dbimport.EditNodeAction)

Aggregations

TreePath (javax.swing.tree.TreePath)1 DeleteNodeAction (org.apache.cayenne.modeler.action.dbimport.DeleteNodeAction)1 EditNodeAction (org.apache.cayenne.modeler.action.dbimport.EditNodeAction)1 DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)1