mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
fixes
This commit is contained in:
@@ -61,6 +61,10 @@ public class CustomTreeModel implements TreeModel {
|
|||||||
private List<String> recentComponents;
|
private List<String> recentComponents;
|
||||||
private List<String> blocks;
|
private List<String> blocks;
|
||||||
|
|
||||||
|
private TreeNode favoritesNode;
|
||||||
|
private TreeNode recentNode;
|
||||||
|
private TreeNode blocksNode;
|
||||||
|
|
||||||
private EventListenerList listenerList = new EventListenerList();
|
private EventListenerList listenerList = new EventListenerList();
|
||||||
|
|
||||||
private static final String FAVORITES = "(Favorites)";
|
private static final String FAVORITES = "(Favorites)";
|
||||||
@@ -233,8 +237,16 @@ public class CustomTreeModel implements TreeModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getChild(Object parent, int index) {
|
public Object getChild(Object parent, int index) {
|
||||||
if (parent == root)
|
if (parent == root) {
|
||||||
return visibleCategories.get(index);
|
TreeNode node = visibleCategories.get(index);
|
||||||
|
if (RECENTLY_USED.equals(node.getCategory()))
|
||||||
|
recentNode = node;
|
||||||
|
if (FAVORITES.equals(node.getCategory()))
|
||||||
|
favoritesNode = node;
|
||||||
|
if (BUILDING_BLOCKS.equals(node.getCategory()))
|
||||||
|
blocksNode = node;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
List<TreeNode> typesFor = getLeavesFor(parent.toString());
|
List<TreeNode> typesFor = getLeavesFor(parent.toString());
|
||||||
Object obj = typesFor.get(index);
|
Object obj = typesFor.get(index);
|
||||||
@@ -303,7 +315,7 @@ public class CustomTreeModel implements TreeModel {
|
|||||||
LOG.info("Detected favorites change");
|
LOG.info("Detected favorites change");
|
||||||
CustomTreeModel.this.favorites = new ArrayList<Favorite>(newFavorites);
|
CustomTreeModel.this.favorites = new ArrayList<Favorite>(newFavorites);
|
||||||
CustomTreeModel.this.visibleLeaves.remove(FAVORITES);
|
CustomTreeModel.this.visibleLeaves.remove(FAVORITES);
|
||||||
fireTreeStructureChanged(new Object[] { root, CustomTreeModel.this.visibleCategories.get(0) });
|
fireTreeStructureChanged(new Object[] { root, CustomTreeModel.this.favoritesNode });
|
||||||
} else
|
} else
|
||||||
LOG.info("Detected no favorites change");
|
LOG.info("Detected no favorites change");
|
||||||
}
|
}
|
||||||
@@ -322,7 +334,7 @@ public class CustomTreeModel implements TreeModel {
|
|||||||
LOG.info("Detected recent component change");
|
LOG.info("Detected recent component change");
|
||||||
CustomTreeModel.this.recentComponents = new ArrayList<String>(newComponents);
|
CustomTreeModel.this.recentComponents = new ArrayList<String>(newComponents);
|
||||||
CustomTreeModel.this.visibleLeaves.remove(RECENTLY_USED);
|
CustomTreeModel.this.visibleLeaves.remove(RECENTLY_USED);
|
||||||
fireTreeStructureChanged(new Object[] { root, CustomTreeModel.this.visibleCategories.get(1) });
|
fireTreeStructureChanged(new Object[] { root, CustomTreeModel.this.recentNode });
|
||||||
} else
|
} else
|
||||||
LOG.info("Detected no recent component change");
|
LOG.info("Detected no recent component change");
|
||||||
}
|
}
|
||||||
@@ -344,7 +356,7 @@ public class CustomTreeModel implements TreeModel {
|
|||||||
LOG.info("Detected block change");
|
LOG.info("Detected block change");
|
||||||
CustomTreeModel.this.blocks = blockNames;
|
CustomTreeModel.this.blocks = blockNames;
|
||||||
CustomTreeModel.this.visibleLeaves.remove(BUILDING_BLOCKS);
|
CustomTreeModel.this.visibleLeaves.remove(BUILDING_BLOCKS);
|
||||||
fireTreeStructureChanged(new Object[] { root, CustomTreeModel.this.visibleCategories.get(2 )});
|
fireTreeStructureChanged(new Object[] { root, CustomTreeModel.this.blocksNode});
|
||||||
} else
|
} else
|
||||||
LOG.info("Detected no block change");
|
LOG.info("Detected no block change");
|
||||||
} else
|
} else
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ public class TreeNode {
|
|||||||
return componentType;
|
return componentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
public MouseListener getClickListener() {
|
public MouseListener getClickListener() {
|
||||||
return clickListener;
|
return clickListener;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user