|
|
|
package com.fr.plugin.widget.ztree.ui;
|
|
|
|
|
|
|
|
import com.fanruan.api.design.ui.component.UITextField;
|
|
|
|
|
|
|
|
//import com.fr.design.designer.creator.*;
|
|
|
|
import com.fanruan.api.design.util.GUICoreKit;
|
|
|
|
import com.fanruan.api.design.work.form.creator.XFieldEditor;
|
|
|
|
import com.fanruan.api.design.work.form.editor.WidgetValueEditor;
|
|
|
|
import com.fanruan.api.design.work.form.macro.XCreatorConstants;
|
|
|
|
import com.fanruan.api.i18n.I18nKit;
|
|
|
|
import com.fanruan.api.util.ArrayKit;
|
|
|
|
import com.fr.design.designer.creator.XLayoutContainer;
|
|
|
|
import com.fr.design.designer.creator.XWScaleLayout;
|
|
|
|
|
|
|
|
import com.fr.plugin.widget.ztree.core.ZTree;
|
|
|
|
import com.fr.plugin.widget.ztree.ui.editor.ZTreeCascadeEditor;
|
|
|
|
import com.fr.plugin.widget.ztree.ui.editor.ZTreeModelEditor;
|
|
|
|
import com.fr.plugin.widget.ztree.ui.editor.ZTreeStyleEditor;
|
|
|
|
import com.fr.plugin.widget.ztree.ui.renderer.ZTreeCascadeRenderer;
|
|
|
|
import com.fr.plugin.widget.ztree.ui.renderer.ZTreeModelRenderer;
|
|
|
|
import com.fr.plugin.widget.ztree.ui.renderer.ZTreeStyleRenderer;
|
|
|
|
//import com.fr.stable.ArrayUtils;
|
|
|
|
|
|
|
|
//有问题
|
|
|
|
import com.fr.design.designer.creator.CRPropertyDescriptor;
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.beans.IntrospectionException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by richie on 15/11/17.
|
|
|
|
*/
|
|
|
|
public class XZTree extends XFieldEditor {
|
|
|
|
|
|
|
|
private LimpidButton btn;
|
|
|
|
|
|
|
|
public XZTree(ZTree widget, Dimension initSize) {
|
|
|
|
super(widget, initSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
|
|
|
|
CRPropertyDescriptor[] crp = new CRPropertyDescriptor[]{
|
|
|
|
new CRPropertyDescriptor("widgetValue", this.toData().getClass()).setI18NName(
|
|
|
|
I18nKit.getLocText("Plugin-ZTree_Widget_Value")).setEditorClass(WidgetValueEditor.class),
|
|
|
|
new CRPropertyDescriptor("treeNode", this.toData().getClass()).setI18NName(
|
|
|
|
I18nKit.getLocText("Plugin-ZTree_Widget_Data")).setEditorClass(ZTreeModelEditor.class).setRendererClass(
|
|
|
|
ZTreeModelRenderer.class),
|
|
|
|
new CRPropertyDescriptor("popupHeight", this.data.getClass())
|
|
|
|
.setI18NName(I18nKit.getLocText("Plugin-ZTree_Widget_Popup_Height"))
|
|
|
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
|
|
|
|
new CRPropertyDescriptor("selectStyle", this.toData().getClass())
|
|
|
|
.setI18NName(I18nKit.getLocText("Plugin-ZTree_Mode"))
|
|
|
|
.setEditorClass(ZTreeStyleEditor.class)
|
|
|
|
.setRendererClass(ZTreeStyleRenderer.class)
|
|
|
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
|
|
|
|
new CRPropertyDescriptor("cascade", this.data.getClass())
|
|
|
|
.setI18NName(I18nKit.getLocText("Plugin-ZTree_Cascade"))
|
|
|
|
.setEditorClass(ZTreeCascadeEditor.class)
|
|
|
|
.setRendererClass(ZTreeCascadeRenderer.class)
|
|
|
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
|
|
|
|
};
|
|
|
|
return (CRPropertyDescriptor[]) ArrayKit.addAll(super.supportedDescriptor(), crp);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected JComponent initEditor() {
|
|
|
|
if (editor == null) {
|
|
|
|
editor = GUICoreKit.createBorderLayoutPane();
|
|
|
|
UITextField textField = new UITextField(5);
|
|
|
|
textField.setOpaque(false);
|
|
|
|
editor.add(textField, BorderLayout.CENTER);
|
|
|
|
btn = new LimpidButton("", this.getIconPath(), toData().isVisible() ? FULL_OPACITY : HALF_OPACITY);
|
|
|
|
btn.setPreferredSize(new Dimension(21, 21));
|
|
|
|
btn.setOpaque(true);
|
|
|
|
editor.add(btn, BorderLayout.EAST);
|
|
|
|
editor.setBackground(Color.WHITE);
|
|
|
|
}
|
|
|
|
return editor;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ZTree toData() {
|
|
|
|
return (ZTree)data;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void makeVisible(boolean visible) {
|
|
|
|
btn.makeVisible(visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 控件的预定义大小
|
|
|
|
* @return 控件的预定义大小
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Dimension initEditorSize() {
|
|
|
|
return SMALL_PREFERRED_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getIconPath() {
|
|
|
|
return "/com/fr/plugin/widget/ztree/images/drop_down_tree.png";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取当前XCreator的一个封装父容器
|
|
|
|
*
|
|
|
|
* @param widgetName 当前组件名
|
|
|
|
*
|
|
|
|
* @return 封装的父容器
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @date 2014-11-25-下午4:47:23
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
protected XLayoutContainer getCreatorWrapper(String widgetName){
|
|
|
|
return new XWScaleLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 将当前对象添加到父容器中
|
|
|
|
*
|
|
|
|
* @param parentPanel 父容器组件
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @date 2014-11-25-下午4:57:55
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){
|
|
|
|
this.setSize(width, minHeight);
|
|
|
|
parentPanel.add(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 此控件在自适应布局要保持原样高度
|
|
|
|
*
|
|
|
|
* @return 是则返回true
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean shouldScaleCreator() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|