Browse Source

Pull request #2409: REPORT-38376 & REPORT-39308 设计器目录树等树控件JDK11下显示不全

Merge in DESIGN/design from ~VITO/c-design:release/10.0 to release/10.0

* commit '9af539cbbd2bd7b73258fe12489325991b09079a':
  REPORT-39308 参数输入面板参数名显示不完整
  REPORT-38376 设计器目录树等树控件JDK11下显示不全
feature/big-screen
vito 4 years ago
parent
commit
8b5af0141b
  1. 21
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java
  2. 12
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  3. 232
      designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java
  4. 48
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java
  5. 87
      designer-form/src/main/java/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java

21
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java

@ -1,21 +1,22 @@
package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.general.NameObject;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree;
import com.fr.design.icon.IconPathConstants;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.Color;
import java.awt.Component;
/**
* TableData Tree
@ -31,6 +32,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
this.setCellRenderer(tableDataTreeCellRenderer);
this.setEditable(false);
}
// CellRenderer
private DefaultTreeCellRenderer tableDataTreeCellRenderer = new DefaultTreeCellRenderer() {
private static final long serialVersionUID = 1L;
@ -66,14 +68,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
this.setIcon(null);
this.setText(PENDING.toString());
}
// 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..."
UILabel label = new UILabel();
label.setText(getText());
label.setIcon(getIcon());
Dimension dim = label.getPreferredSize();
dim.height += 2;
this.setSize(dim);
this.setPreferredSize(dim);
this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
this.setTextSelectionColor(Color.WHITE);
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE);
@ -152,7 +147,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
/*
* p:获得选中的NameObject = name + tabledata.
*/
*/
public NameObject getSelectedNameObject() {
TreePath selectedTreePath = this.getSelectionPath();
if (selectedTreePath == null) {

12
designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -2,7 +2,6 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.FRContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.RefreshableJTree;
import com.fr.design.i18n.Toolkit;
@ -14,13 +13,13 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@ -79,14 +78,7 @@ public class EnvFileTree extends RefreshableJTree {
this.setIcon(null);
this.setText(PENDING.toString());
}
// 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..."
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.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
this.setTextSelectionColor(Color.WHITE);
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE);

232
designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java

@ -20,14 +20,18 @@ import com.fr.design.editor.editor.TextEditor;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
@ -37,31 +41,34 @@ import java.util.Map.Entry;
/**
* The dialog used to input parameter.
*
* @editor zhou
* @since 2012-3-26上午11:09:45
*/
public class ParameterInputPane extends BasicPane {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
private static final long serialVersionUID = 1L;
// alex:保存编辑器对应的参数的名字
private java.util.Map<ValueEditorPane, String> editorNameMap; // Map<Editor, Name>
// alex:保存编辑器对应的参数的名字
private java.util.Map<ValueEditorPane,String> editorNameMap; // Map<Editor, Name>
private boolean allowBlank = true;
private boolean allowBlank = true;
private FlowTableLayoutHelper flowTableLayoutHelper;
/**
/**
* Constructor.
*/
public ParameterInputPane(ParameterProvider[] parameters) {
this.initComponents(parameters);
}
public ParameterInputPane(ParameterProvider[] parameters, boolean allowBlank) {
this.allowBlank = allowBlank;
this.initComponents(parameters);
}
public ParameterInputPane(ParameterProvider[] parameters, boolean allowBlank) {
this.allowBlank = allowBlank;
this.initComponents(parameters);
}
private void initComponents(ParameterProvider[] parameters) {
this.setLayout(new BorderLayout(0, 4));
@ -71,9 +78,9 @@ public class ParameterInputPane extends BasicPane {
this.add(new JScrollPane(contentPane), BorderLayout.CENTER);
contentPane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters") + ":"));
FlowTableLayoutHelper flowTableLayoutHelper = new FlowTableLayoutHelper();
flowTableLayoutHelper = new FlowTableLayoutHelper();
editorNameMap = new java.util.HashMap<ValueEditorPane,String>();
editorNameMap = new java.util.HashMap<ValueEditorPane, String>();
//Parameter list.
java.util.List<String> nameAddedList = new java.util.ArrayList<String>(); // alex:已经加到界面中去的参数名
@ -83,12 +90,12 @@ public class ParameterInputPane extends BasicPane {
// alex:已经在界面中的参数,不加了
if (nameAddedList.contains(parameter.getName())) {
continue;
}
if(parameter instanceof StoreProcedureParameter
&& ((StoreProcedureParameter) parameter).getSchema() == StoreProcedureConstants.OUT) {
continue;
}
continue;
}
if (parameter instanceof StoreProcedureParameter
&& ((StoreProcedureParameter) parameter).getSchema() == StoreProcedureConstants.OUT) {
continue;
}
final Object pv = parameter.getValue();
Editor[] editors = makeEditorByValue(pv);
@ -100,135 +107,140 @@ public class ParameterInputPane extends BasicPane {
editPane.setPreferredSize(new Dimension(180, editPane.getPreferredSize().height));
String parameterDisplayName = parameter.getName();
if(StringUtils.isNotBlank(parameter.getName())) {
parameterDisplayName = parameter.getName();
if (StringUtils.isNotBlank(parameter.getName())) {
parameterDisplayName = parameter.getName();
}
contentPane.add(flowTableLayoutHelper.createLabelFlowPane(parameterDisplayName + ":", editPane));
//add editor to parameter hashtable.
initTextListener(textF);
initTextListener(textF);
this.editorNameMap.put(textF, parameter.getName());
nameAddedList.add(parameter.getName());
}
}
}
@Override
public void addNotify() {
super.addNotify();
// windows 高DPI下,使用getPreferredSize必须在添加到容器之后,否则得到的数值不准确,因此先放到这调整大小
flowTableLayoutHelper.adjustLabelWidth();
}
protected void initTextListener(ValueEditorPane textF) {
textF.getCurrentEditor().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified();
}
});
}
private Editor[] makeEditorByValue(Object pv) {
Editor[] editors = {null};
if (pv instanceof Integer) {
editors[0] = new IntegerEditor();
} else if (pv instanceof Double || pv instanceof Float) {
editors[0] = new DoubleEditor();
} else if (pv instanceof Float) {
editors[0] = new FloatEditor();
} else if (pv instanceof Date) {
editors[0] = new DateEditor(true, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Date"));
} else if (pv instanceof Boolean) {
editors[0] = new BooleanEditor();
} else if (pv instanceof BaseFormula) {
editors = ValueEditorPaneFactory.basicEditors();
} else {
editors[0] = new TextEditor();
}
return editors;
}
textF.getCurrentEditor().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified();
}
});
}
private Editor[] makeEditorByValue(Object pv) {
Editor[] editors = {null};
if (pv instanceof Integer) {
editors[0] = new IntegerEditor();
} else if (pv instanceof Double || pv instanceof Float) {
editors[0] = new DoubleEditor();
} else if (pv instanceof Float) {
editors[0] = new FloatEditor();
} else if (pv instanceof Date) {
editors[0] = new DateEditor(true, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Date"));
} else if (pv instanceof Boolean) {
editors[0] = new BooleanEditor();
} else if (pv instanceof BaseFormula) {
editors = ValueEditorPaneFactory.basicEditors();
} else {
editors[0] = new TextEditor();
}
return editors;
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters");
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters");
}
/**
* Update
*/
public Map<String,Object> update() {
public Map<String, Object> update() {
java.util.Map<String,Object> nameValueMap = new java.util.HashMap<String,Object>();
java.util.Map<String, Object> nameValueMap = new java.util.HashMap<String, Object>();
Iterator<Entry<ValueEditorPane, String>> entryIt = this.editorNameMap.entrySet().iterator();
while(entryIt.hasNext()) {
java.util.Map.Entry<ValueEditorPane, String> entry = entryIt.next();
ValueEditorPane editor = entry.getKey();
String parameterName = entry.getValue();
Iterator<Entry<ValueEditorPane, String>> entryIt = this.editorNameMap.entrySet().iterator();
while (entryIt.hasNext()) {
java.util.Map.Entry<ValueEditorPane, String> entry = entryIt.next();
ValueEditorPane editor = entry.getKey();
String parameterName = entry.getValue();
Object editorStringValue = editor.update();
nameValueMap.put(parameterName, editorStringValue);
}
Object editorStringValue = editor.update();
nameValueMap.put(parameterName, editorStringValue);
}
return nameValueMap;
return nameValueMap;
}
public void checkValid() throws Exception {
if (!allowBlank) {
boolean valid = true;
String error = "";
Iterator<Entry<ValueEditorPane, String>> entryIt = this.editorNameMap.entrySet().iterator();
while (entryIt.hasNext()) {
java.util.Map.Entry<ValueEditorPane, String> entry = entryIt.next();
ValueEditorPane editor = entry.getKey();
String parameterName = entry.getValue();
Object editorStringValue = editor.update();
if (editorStringValue == null || StringUtils.isEmpty(Utils.objectToString(editorStringValue))) {
valid = false;
error += parameterName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Not_Null_Des") + "\n";
}
}
if (!valid) {
throw new Exception(error);
}
}
}
public void checkValid() throws Exception {
if (!allowBlank) {
boolean valid = true;
String error = "";
Iterator<Entry<ValueEditorPane, String>> entryIt = this.editorNameMap.entrySet().iterator();
while (entryIt.hasNext()) {
java.util.Map.Entry<ValueEditorPane, String> entry = entryIt.next();
ValueEditorPane editor = entry.getKey();
String parameterName = entry.getValue();
Object editorStringValue = editor.update();
if (editorStringValue == null || StringUtils.isEmpty(Utils.objectToString(editorStringValue))) {
valid = false;
error += parameterName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Not_Null_Des") + "\n";
}
}
if (!valid) {
throw new Exception(error);
}
}
}
/**
* The class help to flowlayout components
*/
private static class FlowTableLayoutHelper {
private List<UILabel> labelList = new ArrayList<UILabel>();
private List<UILabel> labelList = new ArrayList<UILabel>();
public FlowTableLayoutHelper() {
}
public FlowTableLayoutHelper() {
}
public JPanel createLabelFlowPane(String text, JComponent comp) {
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
public JPanel createLabelFlowPane(String text, JComponent comp) {
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
UILabel textLabel = new UILabel(text);
centerPane.add(textLabel);
textLabel.setHorizontalAlignment(SwingConstants.LEFT);
UILabel textLabel = new UILabel(text);
centerPane.add(textLabel);
textLabel.setHorizontalAlignment(SwingConstants.LEFT);
this.labelList.add(textLabel);
centerPane.add(comp);
this.labelList.add(textLabel);
centerPane.add(comp);
return centerPane;
}
return centerPane;
}
public void adjustLabelWidth() {
int maxWidth = 0;
public void adjustLabelWidth() {
int maxWidth = 0;
for (int i = 0; i < labelList.size(); i++) {
maxWidth = Math.max(maxWidth, labelList.get(i).getPreferredSize().width);
}
for (int i = 0; i < labelList.size(); i++) {
maxWidth = Math.max(maxWidth, labelList.get(i).getPreferredSize().width);
}
for (int i = 0; i < labelList.size(); i++) {
UILabel label = labelList.get(i);
for (int i = 0; i < labelList.size(); i++) {
UILabel label = labelList.get(i);
Dimension labelDim = new Dimension(maxWidth, label.getPreferredSize().height);
Dimension labelDim = new Dimension(maxWidth, label.getPreferredSize().height);
label.setPreferredSize(labelDim);
label.setSize(labelDim);
label.setMinimumSize(labelDim);
}
}
label.setPreferredSize(labelDim);
label.setSize(labelDim);
label.setMinimumSize(labelDim);
}
}
}
}

48
designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java

@ -1,13 +1,13 @@
package com.fr.van.chart.drillmap.designer.data.comp;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
@ -15,7 +15,6 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.Component;
import java.awt.Dimension;
import java.util.Enumeration;
/**
@ -23,7 +22,7 @@ import java.util.Enumeration;
*/
public class MapDataTree extends JTree {
public MapDataTree(TreeNode root){
public MapDataTree(TreeNode root) {
super();
this.setModel(model);
model.setRoot(root);
@ -49,54 +48,54 @@ public class MapDataTree extends JTree {
if (children.hasMoreElements()) {
DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
if(GEOJSONTreeHelper.getInstance().isSelectableTreeNode(child)){
if (GEOJSONTreeHelper.isSelectableTreeNode(child)) {
selectTreeNode(child, m_model);
}else{
} else {
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();
if (children.hasMoreElements()){
if (children.hasMoreElements()) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement();
selectTreeNode(node, m_model);
}
}
public void changeRootNode(TreeNode node){
public void changeRootNode(TreeNode node) {
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel();
m_model.setRoot(node);
}
public String getSelectNodeJSONPath() {
if(this.getLastSelectedPathComponent() == null){
if (this.getLastSelectedPathComponent() == null) {
return StringUtils.EMPTY;
}
DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode)this.getLastSelectedPathComponent();
DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode) this.getLastSelectedPathComponent();
return CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(currentSel.getUserObject().toString());
}
//根据路径精确查找
public DefaultMutableTreeNode setSelectNodePath(String jsonUrl) {
if(StringUtils.isEmpty(jsonUrl) || CompatibleGEOJSONHelper.isDeprecated(jsonUrl)){
if (StringUtils.isEmpty(jsonUrl) || CompatibleGEOJSONHelper.isDeprecated(jsonUrl)) {
return null;
}
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) m_model.getRoot();
Enumeration<TreeNode> els = root.postorderEnumeration();
while(els.hasMoreElements()){
while (els.hasMoreElements()) {
DefaultMutableTreeNode el = (DefaultMutableTreeNode) els.nextElement();
if(el == null || el.getUserObject() == null){
if (el == null || el.getUserObject() == null) {
return null;
}
String dirPath = el.getUserObject().toString();
String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath);
String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath);
//先equals再valid原因:valid 远程下实时去服务器看有没有json文件
if (ComparatorUtils.equals(jsonUrl, url) && GEOJSONTreeHelper.isValidDirPath(dirPath)) {
selectTreeNode(el, m_model);
@ -115,14 +114,7 @@ public class MapDataTree extends JTree {
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value;
String name = getPresentName(treeNode);
this.setText(name);
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.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND);
this.setForeground(UIConstants.FONT_COLOR);
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE);
@ -131,25 +123,25 @@ public class MapDataTree extends JTree {
};
protected String getPresentName(DefaultMutableTreeNode treeNode) {
if(treeNode == null || treeNode.getUserObject() == null){
if (treeNode == null || treeNode.getUserObject() == null) {
return StringUtils.EMPTY;
}
return ChartGEOJSONHelper.getPresentNameWithPath(treeNode.getUserObject().toString());
}
//模糊搜索 深度优先.
public void search(String text){
if(StringUtils.isEmpty(text)){
public void search(String text) {
if (StringUtils.isEmpty(text)) {
return;
}
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) m_model.getRoot();
Enumeration<TreeNode> els = root.postorderEnumeration();
while(els.hasMoreElements()){
while (els.hasMoreElements()) {
DefaultMutableTreeNode el = (DefaultMutableTreeNode) els.nextElement();
String path = el.getUserObject().toString();
String path = el.getUserObject().toString();
String fileName = ChartGEOJSONHelper.getPresentNameWithPath(path);
if (StringUtils.contains(fileName, text) && GEOJSONTreeHelper.isValidDirPath(path)) {
selectTreeNode(el, m_model);
@ -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);
TreePath treePath = new TreePath(nodes);
setSelectionPath(treePath);

87
designer-form/src/main/java/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java

@ -3,60 +3,53 @@ package com.fr.design.designer.treeview;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.gui.ilable.UILabel;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import java.awt.Component;
import java.awt.Dimension;
public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
public ComponentTreeCellRenderer() {
}
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof XCreator) {
String name = ((XCreator) value).toData().getWidgetName();
setText(name);
Icon icon = null;
try {
icon = XCreatorUtils.getCreatorIcon((XCreator) value);
} catch (Exception e) {
FineLoggerFactory.getLogger().info("{} has not icon or has been deleted", name);
}
if (icon != null) {
setIcon(icon);
}
}
UILabel label = new UILabel();
label.setText(getText());
label.setIcon(getIcon());
Dimension dim = label.getPreferredSize();
dim.height += 2;
this.setSize(dim);
this.setPreferredSize(dim);
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
return this;
}
@Override
public Icon getClosedIcon() {
return getIcon();
}
@Override
public Icon getLeafIcon() {
return getIcon();
}
@Override
public Icon getOpenIcon() {
return getIcon();
}
public ComponentTreeCellRenderer() {
}
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof XCreator) {
String name = ((XCreator) value).toData().getWidgetName();
setText(name);
Icon icon = null;
try {
icon = XCreatorUtils.getCreatorIcon((XCreator) value);
} catch (Exception e) {
FineLoggerFactory.getLogger().info("{} has not icon or has been deleted", name);
}
if (icon != null) {
setIcon(icon);
}
}
this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
return this;
}
@Override
public Icon getClosedIcon() {
return getIcon();
}
@Override
public Icon getLeafIcon() {
return getIcon();
}
@Override
public Icon getOpenIcon() {
return getIcon();
}
}
Loading…
Cancel
Save