You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
4.7 KiB
137 lines
4.7 KiB
9 years ago
|
package com.fr.plugin.widget.ztree.ui;
|
||
|
|
||
|
import com.fr.design.designer.creator.*;
|
||
|
import com.fr.design.form.util.XCreatorConstants;
|
||
|
import com.fr.design.gui.itextfield.UITextField;
|
||
|
import com.fr.design.layout.FRGUIPaneFactory;
|
||
|
import com.fr.design.mainframe.widget.editors.WidgetValueEditor;
|
||
|
import com.fr.general.Inter;
|
||
|
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 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(
|
||
|
Inter.getLocText("Plugin-ZTree_Widget_Value")).setEditorClass(WidgetValueEditor.class),
|
||
|
new CRPropertyDescriptor("treeNode", this.toData().getClass()).setI18NName(
|
||
|
Inter.getLocText("Plugin-ZTree_Widget_Data")).setEditorClass(ZTreeModelEditor.class).setRendererClass(
|
||
|
ZTreeModelRenderer.class),
|
||
|
new CRPropertyDescriptor("popupHeight", this.data.getClass())
|
||
|
.setI18NName(Inter.getLocText("Plugin-ZTree_Widget_Popup_Height"))
|
||
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
|
||
|
new CRPropertyDescriptor("selectStyle", this.toData().getClass())
|
||
|
.setI18NName(Inter.getLocText("Plugin-ZTree_Mode"))
|
||
|
.setEditorClass(ZTreeStyleEditor.class)
|
||
|
.setRendererClass(ZTreeStyleRenderer.class)
|
||
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
|
||
|
new CRPropertyDescriptor("cascade", this.data.getClass())
|
||
|
.setI18NName(Inter.getLocText("Plugin-ZTree_Cascade"))
|
||
|
.setEditorClass(ZTreeCascadeEditor.class)
|
||
|
.setRendererClass(ZTreeCascadeRenderer.class)
|
||
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
|
||
|
};
|
||
|
return (CRPropertyDescriptor[])ArrayUtils.addAll(super.supportedDescriptor(), crp);
|
||
|
}
|
||
|
|
||
|
protected JComponent initEditor() {
|
||
|
if (editor == null) {
|
||
|
editor = FRGUIPaneFactory.createBorderLayout_S_Pane();
|
||
|
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;
|
||
|
}
|
||
|
}
|