|
|
@ -1,13 +1,13 @@ |
|
|
|
package com.fr.van.chart.drillmap.designer.data.comp; |
|
|
|
package com.fr.van.chart.drillmap.designer.data.comp; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; |
|
|
|
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; |
|
|
|
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; |
|
|
|
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; |
|
|
|
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; |
|
|
|
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.JTree; |
|
|
|
import javax.swing.JTree; |
|
|
|
import javax.swing.tree.DefaultMutableTreeNode; |
|
|
|
import javax.swing.tree.DefaultMutableTreeNode; |
|
|
|
import javax.swing.tree.DefaultTreeCellRenderer; |
|
|
|
import javax.swing.tree.DefaultTreeCellRenderer; |
|
|
@ -15,7 +15,6 @@ import javax.swing.tree.DefaultTreeModel; |
|
|
|
import javax.swing.tree.TreeNode; |
|
|
|
import javax.swing.tree.TreeNode; |
|
|
|
import javax.swing.tree.TreePath; |
|
|
|
import javax.swing.tree.TreePath; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Dimension; |
|
|
|
|
|
|
|
import java.util.Enumeration; |
|
|
|
import java.util.Enumeration; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -23,7 +22,7 @@ import java.util.Enumeration; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class MapDataTree extends JTree { |
|
|
|
public class MapDataTree extends JTree { |
|
|
|
|
|
|
|
|
|
|
|
public MapDataTree(TreeNode root){ |
|
|
|
public MapDataTree(TreeNode root) { |
|
|
|
super(); |
|
|
|
super(); |
|
|
|
this.setModel(model); |
|
|
|
this.setModel(model); |
|
|
|
model.setRoot(root); |
|
|
|
model.setRoot(root); |
|
|
@ -49,50 +48,50 @@ public class MapDataTree extends JTree { |
|
|
|
if (children.hasMoreElements()) { |
|
|
|
if (children.hasMoreElements()) { |
|
|
|
DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement(); |
|
|
|
DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement(); |
|
|
|
|
|
|
|
|
|
|
|
if(GEOJSONTreeHelper.getInstance().isSelectableTreeNode(child)){ |
|
|
|
if (GEOJSONTreeHelper.isSelectableTreeNode(child)) { |
|
|
|
selectTreeNode(child, m_model); |
|
|
|
selectTreeNode(child, m_model); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
setFirstChildTreeNode(child, m_model); |
|
|
|
setFirstChildTreeNode(child, m_model); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setFirstChildTreeNode(DefaultMutableTreeNode parent, DefaultTreeModel m_model){ |
|
|
|
private void setFirstChildTreeNode(DefaultMutableTreeNode parent, DefaultTreeModel m_model) { |
|
|
|
Enumeration<TreeNode> children = parent.children(); |
|
|
|
Enumeration<TreeNode> children = parent.children(); |
|
|
|
if (children.hasMoreElements()){ |
|
|
|
if (children.hasMoreElements()) { |
|
|
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement(); |
|
|
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement(); |
|
|
|
selectTreeNode(node, m_model); |
|
|
|
selectTreeNode(node, m_model); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void changeRootNode(TreeNode node){ |
|
|
|
public void changeRootNode(TreeNode node) { |
|
|
|
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); |
|
|
|
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); |
|
|
|
m_model.setRoot(node); |
|
|
|
m_model.setRoot(node); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getSelectNodeJSONPath() { |
|
|
|
public String getSelectNodeJSONPath() { |
|
|
|
if(this.getLastSelectedPathComponent() == null){ |
|
|
|
if (this.getLastSelectedPathComponent() == null) { |
|
|
|
return StringUtils.EMPTY; |
|
|
|
return StringUtils.EMPTY; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode)this.getLastSelectedPathComponent(); |
|
|
|
DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode) this.getLastSelectedPathComponent(); |
|
|
|
|
|
|
|
|
|
|
|
return CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(currentSel.getUserObject().toString()); |
|
|
|
return CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(currentSel.getUserObject().toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据路径精确查找
|
|
|
|
//根据路径精确查找
|
|
|
|
public DefaultMutableTreeNode setSelectNodePath(String jsonUrl) { |
|
|
|
public DefaultMutableTreeNode setSelectNodePath(String jsonUrl) { |
|
|
|
if(StringUtils.isEmpty(jsonUrl) || CompatibleGEOJSONHelper.isDeprecated(jsonUrl)){ |
|
|
|
if (StringUtils.isEmpty(jsonUrl) || CompatibleGEOJSONHelper.isDeprecated(jsonUrl)) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); |
|
|
|
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); |
|
|
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) m_model.getRoot(); |
|
|
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) m_model.getRoot(); |
|
|
|
|
|
|
|
|
|
|
|
Enumeration<TreeNode> els = root.postorderEnumeration(); |
|
|
|
Enumeration<TreeNode> els = root.postorderEnumeration(); |
|
|
|
while(els.hasMoreElements()){ |
|
|
|
while (els.hasMoreElements()) { |
|
|
|
DefaultMutableTreeNode el = (DefaultMutableTreeNode) els.nextElement(); |
|
|
|
DefaultMutableTreeNode el = (DefaultMutableTreeNode) els.nextElement(); |
|
|
|
if(el == null || el.getUserObject() == null){ |
|
|
|
if (el == null || el.getUserObject() == null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
String dirPath = el.getUserObject().toString(); |
|
|
|
String dirPath = el.getUserObject().toString(); |
|
|
@ -115,14 +114,7 @@ public class MapDataTree extends JTree { |
|
|
|
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value; |
|
|
|
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value; |
|
|
|
String name = getPresentName(treeNode); |
|
|
|
String name = getPresentName(treeNode); |
|
|
|
this.setText(name); |
|
|
|
this.setText(name); |
|
|
|
|
|
|
|
this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); |
|
|
|
UILabel label = new UILabel(); |
|
|
|
|
|
|
|
label.setText(getText()); |
|
|
|
|
|
|
|
label.setIcon(getIcon()); |
|
|
|
|
|
|
|
this.setSize(label.getPreferredSize()); |
|
|
|
|
|
|
|
Dimension dim = label.getPreferredSize(); |
|
|
|
|
|
|
|
dim.height += 2; |
|
|
|
|
|
|
|
this.setPreferredSize(dim); |
|
|
|
|
|
|
|
this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND); |
|
|
|
this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND); |
|
|
|
this.setForeground(UIConstants.FONT_COLOR); |
|
|
|
this.setForeground(UIConstants.FONT_COLOR); |
|
|
|
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE); |
|
|
|
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE); |
|
|
@ -131,22 +123,22 @@ public class MapDataTree extends JTree { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
protected String getPresentName(DefaultMutableTreeNode treeNode) { |
|
|
|
protected String getPresentName(DefaultMutableTreeNode treeNode) { |
|
|
|
if(treeNode == null || treeNode.getUserObject() == null){ |
|
|
|
if (treeNode == null || treeNode.getUserObject() == null) { |
|
|
|
return StringUtils.EMPTY; |
|
|
|
return StringUtils.EMPTY; |
|
|
|
} |
|
|
|
} |
|
|
|
return ChartGEOJSONHelper.getPresentNameWithPath(treeNode.getUserObject().toString()); |
|
|
|
return ChartGEOJSONHelper.getPresentNameWithPath(treeNode.getUserObject().toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//模糊搜索 深度优先.
|
|
|
|
//模糊搜索 深度优先.
|
|
|
|
public void search(String text){ |
|
|
|
public void search(String text) { |
|
|
|
if(StringUtils.isEmpty(text)){ |
|
|
|
if (StringUtils.isEmpty(text)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); |
|
|
|
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); |
|
|
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) m_model.getRoot(); |
|
|
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) m_model.getRoot(); |
|
|
|
|
|
|
|
|
|
|
|
Enumeration<TreeNode> els = root.postorderEnumeration(); |
|
|
|
Enumeration<TreeNode> els = root.postorderEnumeration(); |
|
|
|
while(els.hasMoreElements()){ |
|
|
|
while (els.hasMoreElements()) { |
|
|
|
|
|
|
|
|
|
|
|
DefaultMutableTreeNode el = (DefaultMutableTreeNode) els.nextElement(); |
|
|
|
DefaultMutableTreeNode el = (DefaultMutableTreeNode) els.nextElement(); |
|
|
|
String path = el.getUserObject().toString(); |
|
|
|
String path = el.getUserObject().toString(); |
|
|
@ -158,7 +150,7 @@ public class MapDataTree extends JTree { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void selectTreeNode(DefaultMutableTreeNode node, DefaultTreeModel m_model){ |
|
|
|
public void selectTreeNode(DefaultMutableTreeNode node, DefaultTreeModel m_model) { |
|
|
|
TreeNode[] nodes = m_model.getPathToRoot(node); |
|
|
|
TreeNode[] nodes = m_model.getPathToRoot(node); |
|
|
|
TreePath treePath = new TreePath(nodes); |
|
|
|
TreePath treePath = new TreePath(nodes); |
|
|
|
setSelectionPath(treePath); |
|
|
|
setSelectionPath(treePath); |
|
|
|