16 package net.squiz.matrix.matrixtree;
19 import java.awt.Color;
20 import javax.swing.tree.*;
21 import javax.swing.event.*;
22 import net.squiz.matrix.core.*;
33 private static List trees =
new ArrayList();
38 private static TreeExpansionHandler teHandler =
new TreeExpansionHandler();
40 private static MatrixTreeComm comm =
new MatrixTreeComm();
41 private static String[] restrictedTypes =
new String[0];
46 public static MatrixTree getLastExpandedTree() {
47 return lastExpandedTree;
50 public static MatrixTree getLastCollapsedTree() {
51 return lastCollapsedTree;
58 private static class TreeExpansionHandler
implements TreeWillExpandListener {
59 public void treeWillExpand(TreeExpansionEvent evt) {
60 lastExpandedTree = (
MatrixTree) evt.getSource();
63 public void treeWillCollapse(TreeExpansionEvent evt) {
64 lastCollapsedTree = (
MatrixTree) evt.getSource();
68 public static void setActiveTree(
MatrixTree tree) {
73 if (activeTree == null) {
74 if (trees.size() > 0) {
83 public static void startAssetFinderMode(String[] assetTypes) {
84 restrictedTypes = assetTypes;
85 Iterator iterator = trees.iterator();
86 while (iterator.hasNext()) {
93 public static void stopAssetFinderMode() {
94 restrictedTypes =
new String[0];
95 Iterator iterator = trees.iterator();
96 while (iterator.hasNext()) {
103 public static void startAssetLocator(String[] assetIds, String[] sort_orders) {
106 if (trees.size() <= 0) {
114 public static void startSimpleAssetLocator(String[] assetIds, String[] sort_orders) {
119 startAssetLocator(assetIds, sort_orders);
128 DefaultTreeModel model =
new DefaultTreeModel(root);
134 tree.addTreeWillExpandListener(teHandler);
137 tree.setRootVisible(
false);
138 tree.setShowsRootHandles(
true);
150 DefaultTreeModel model =
new DefaultTreeModel(root);
157 tree.setRootVisible(
false);
158 tree.setShowsRootHandles(
true);
161 tree.setMoveEnabled(
false);
162 tree.removeKeyStroke(
"DELETE");
170 public static boolean typeIsRestricted(AssetType type) {
174 if (restrictedTypes.length == 0)
176 for (
int i = 0; i < restrictedTypes.length; i++) {
177 if (type.isAncestor(AssetManager.getAssetType(restrictedTypes[i])))
183 public static void destroyTree(MatrixTree tree) {
184 MatrixTreeModelBus.removeFromBus((DefaultTreeModel) tree.getModel());
189 public static Iterator getTrees() {
190 return trees.iterator();