use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportTree method findNodeInParent.
DbImportTreeNode findNodeInParent(DbImportTreeNode parent, Object object) {
for (int i = 0; i < parent.getChildCount(); i++) {
DbImportTreeNode node = (DbImportTreeNode) parent.getChildAt(i);
Object userObject = node.getUserObject();
if (object instanceof Catalog) {
Catalog catalog = (Catalog) object;
if (!(userObject instanceof Catalog)) {
continue;
}
Catalog currentCatalog = (Catalog) userObject;
if (currentCatalog.getName().equals(catalog.getName())) {
return node;
}
}
if (object instanceof Schema) {
Schema schema = (Schema) object;
if (!(userObject instanceof Schema)) {
continue;
}
Schema currentSchema = (Schema) userObject;
if (currentSchema.getName().equals(schema.getName())) {
return node;
}
}
if (object instanceof IncludeTable) {
IncludeTable table = (IncludeTable) object;
if (!(userObject instanceof IncludeTable)) {
continue;
}
IncludeTable currentTable = (IncludeTable) userObject;
if (currentTable.getPattern().equals(table.getPattern())) {
return node;
}
}
if (object instanceof ExcludeTable) {
ExcludeTable table = (ExcludeTable) object;
if (!(userObject instanceof ExcludeTable)) {
continue;
}
ExcludeTable currentTable = (ExcludeTable) userObject;
if (currentTable.getPattern().equals(table.getPattern())) {
return node;
}
}
}
return null;
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportTree method expandBeginningWithNode.
private void expandBeginningWithNode(DbImportTreeNode rootNode, ArrayList<DbImportTreeNode> list) {
for (int i = 0; i < rootNode.getChildCount(); i++) {
DbImportTreeNode childNode = (DbImportTreeNode) rootNode.getChildAt(i);
list.forEach((element) -> {
if (element.equals(childNode)) {
this.expandPath(new TreePath(childNode.getPath()));
}
});
if (childNode.getChildCount() > 0) {
expandBeginningWithNode(childNode, list);
}
}
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportTree method createTreeExpandListener.
private void createTreeExpandListener() {
TreeExpansionListener treeExpansionListener = new TreeExpansionListener() {
@Override
public void treeExpanded(TreeExpansionEvent event) {
TreePath path = event.getPath();
Object lastPathComponent = path.getLastPathComponent();
if (!(lastPathComponent instanceof TransferableNode)) {
return;
}
DbImportTreeNode node = (DbImportTreeNode) lastPathComponent;
if ((node.isIncludeTable() || node.isSchema() || node.isCatalog()) && !node.isLoaded()) {
// reload tables and columns action.
LoadDbSchemaAction action = Application.getInstance().getActionManager().getAction(LoadDbSchemaAction.class);
action.performAction(null, path);
}
}
@Override
public void treeCollapsed(TreeExpansionEvent event) {
}
};
this.addTreeExpansionListener(treeExpansionListener);
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportTree method createTreeExpandList.
// Create list of expanded elements
private ArrayList<DbImportTreeNode> createTreeExpandList(DbImportTreeNode rootNode, ArrayList<DbImportTreeNode> resultList) {
for (int i = 0; i < rootNode.getChildCount(); i++) {
DbImportTreeNode childNode = (DbImportTreeNode) rootNode.getChildAt(i);
TreePath childPath = new TreePath(childNode.getPath());
if (isExpanded(childPath)) {
resultList.add(childNode);
}
if (childNode.getChildCount() > 0) {
createTreeExpandList(childNode, resultList);
}
}
return resultList;
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportTree method printSchemas.
private void printSchemas(Collection<Schema> schemas, DbImportTreeNode parent) {
for (Schema schema : schemas) {
DbImportTreeNode node = !isTransferable ? new DbImportTreeNode(schema) : new TransferableNode(schema);
if (!"".equals(node.getSimpleNodeName())) {
if (isTransferable && schema.getIncludeTables().isEmpty() && schema.getExcludeTables().isEmpty()) {
printParams(Collections.singletonList(new IncludeTable("Loading...")), node);
}
printChildren(schema, node);
parent.add(node);
}
}
}
Aggregations