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.
103 lines
3.4 KiB
103 lines
3.4 KiB
7 years ago
|
package com.fr.plugin.widget.grid;
|
||
|
|
||
|
import com.fr.design.designer.creator.CRPropertyDescriptor;
|
||
|
import com.fr.design.designer.creator.XLayoutContainer;
|
||
|
import com.fr.design.designer.creator.XWScaleLayout;
|
||
|
import com.fr.design.designer.creator.XWriteAbleRepeatEditor;
|
||
|
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.stable.ArrayUtils;
|
||
|
|
||
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
import java.beans.IntrospectionException;
|
||
|
|
||
|
/**
|
||
|
* @author richie
|
||
|
* @date 2015-03-16
|
||
|
* @since 8.0
|
||
|
*/
|
||
|
public class XComboGrid extends XWriteAbleRepeatEditor {
|
||
|
|
||
|
LimpidButton btn;
|
||
|
|
||
|
public XComboGrid(ComboGrid widget, Dimension initSize) {
|
||
|
super(widget, initSize);
|
||
|
}
|
||
|
|
||
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
|
||
|
|
||
|
return (CRPropertyDescriptor[]) ArrayUtils.addAll(
|
||
|
super.supportedDescriptor(),
|
||
|
new CRPropertyDescriptor[]{
|
||
|
new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName(Inter.getLocText(new String[]{"Widget", "Value"})).setEditorClass(WidgetValueEditor.class),
|
||
|
new CRPropertyDescriptor("tableData", this.data.getClass())
|
||
|
.setI18NName("数据集")
|
||
|
.setEditorClass(TableDataEditor.class).setRendererClass(TableDataRenderer.class),
|
||
|
new CRPropertyDescriptor("keyIndex", this.data.getClass()).setI18NName("实际值索引"),
|
||
|
new CRPropertyDescriptor("valueIndex", this.data.getClass()).setI18NName("显示值索引")
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public ComboGrid toData() {
|
||
|
return (ComboGrid) this.data;
|
||
|
}
|
||
|
|
||
|
public String getIconPath() {
|
||
|
return "/com/fr/plugin/widget/grid/images/table.png";
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
protected void makeVisible(boolean visible) {
|
||
|
btn.makeVisible(visible);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取当前XCreator的一个封装父容器
|
||
|
*
|
||
|
* @param widgetName 当前组件名
|
||
|
* @return 封装的父容器
|
||
|
* @date 2014-11-25-下午4:47:23
|
||
|
*/
|
||
|
protected XLayoutContainer getCreatorWrapper(String widgetName) {
|
||
|
return new XWScaleLayout();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 将当前对象添加到父容器中
|
||
|
*
|
||
|
* @param parentPanel 父容器组件
|
||
|
* @date 2014-11-25-下午4:57:55
|
||
|
*/
|
||
|
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight) {
|
||
|
this.setSize(width, minHeight);
|
||
|
parentPanel.add(this);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 此控件在自适应布局要保持原样高度
|
||
|
*
|
||
|
* @return 是则返回true
|
||
|
*/
|
||
|
@Override
|
||
|
public boolean shouldScaleCreator() {
|
||
|
return true;
|
||
|
}
|
||
|
}
|