forked from fanruan/finekit
131 lines
3.6 KiB
131 lines
3.6 KiB
package com.fanruan.api.design; |
|
|
|
import com.fr.base.io.BaseBook; |
|
import com.fr.design.DesignerEnvManager; |
|
import com.fr.design.mainframe.JTemplateProvider; |
|
import com.fr.design.mainframe.WidgetPropertyPane; |
|
import com.fr.base.TableData; |
|
import com.fr.design.DesignModelAdapter; |
|
import com.fr.design.data.datapane.preview.PreviewTablePane; |
|
import com.fr.design.file.HistoryTemplateListPane; |
|
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; |
|
import com.fr.design.i18n.Toolkit; |
|
import com.fr.design.mainframe.DesignerBean; |
|
import com.fr.design.mainframe.DesignerContext; |
|
import com.fr.design.mainframe.DesignerFrame; |
|
import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl; |
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
import javax.swing.JComponent; |
|
|
|
public class DesignKit { |
|
/** |
|
* 直接预览数据集,没有实际值及显示值 |
|
* |
|
* @param tableData 数据集 |
|
*/ |
|
public static void previewTableData(TableData tableData) { |
|
PreviewTablePane.previewTableData(tableData, -1, -1); |
|
} |
|
|
|
/** |
|
* 文本国际化 |
|
* |
|
* @param key 国际化键 |
|
* @return 国际化后的值 |
|
*/ |
|
public static String i18nText(String key) { |
|
return Toolkit.i18nText(key); |
|
} |
|
|
|
/** |
|
* 带参数的文本国际化 |
|
* |
|
* @param key 国际化键 |
|
* @param args 参数 |
|
* @return 国际化后的值 |
|
*/ |
|
public static String i18nText(String key, Object... args) { |
|
return Toolkit.i18nText(key, args); |
|
} |
|
|
|
/** |
|
* 单例模式,返回DesignerFrame对象 |
|
* |
|
* @return DesignerFrame对象 |
|
*/ |
|
public static DesignerFrame getDesignerFrame() { |
|
return DesignerContext.getDesignerFrame(); |
|
} |
|
|
|
/** |
|
* 得到当前在修改的模板 |
|
* |
|
* @return 返回当前正在编辑的模板 |
|
*/ |
|
public static JTemplate<?, ?> getCurrentEditingTemplate() { |
|
return HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
} |
|
|
|
/** |
|
* 获取当前正在编辑的模板的ID |
|
* |
|
* @return 正在编辑的模板的ID |
|
*/ |
|
public static String getCurrentEditingTemplateId() { |
|
return getCurrentEditingTemplate().getTarget().getTemplateID(); |
|
} |
|
|
|
/** |
|
* 获取指定模板的ID |
|
* |
|
* @param template 指定模板 |
|
* @return 模板ID |
|
*/ |
|
public static String getTemplateId(JTemplateProvider template) { |
|
return ((BaseBook) template.getTarget()).getTemplateID(); |
|
} |
|
|
|
/** |
|
* 获取设计器ID |
|
* |
|
* @return 设计器ID |
|
*/ |
|
public static String getDesignerId() { |
|
return DesignerEnvManager.getEnvManager().getUUID(); |
|
} |
|
|
|
/** |
|
* 根据名字获取已经定义的bean对象 |
|
* |
|
* @param name bean的名字 |
|
* @return bean对象 |
|
*/ |
|
public static DesignerBean getDesignerBean(String name) { |
|
return DesignerContext.getDesignerBean(name); |
|
} |
|
|
|
/** |
|
* 超链接面板操作 |
|
* @return 操作对象 |
|
*/ |
|
public static HyperlinkGroupPaneActionProvider getHyperlinkGroupPaneAction() { |
|
|
|
return HyperlinkGroupPaneActionImpl.getInstance(); |
|
} |
|
|
|
/** |
|
* 当前的设计模式 FormModel or WorkBookModel |
|
* @return 设计器模式 |
|
*/ |
|
public static DesignModelAdapter<?, ?> getCurrentModelAdapter() { |
|
return DesignModelAdapter.getCurrentModelAdapter(); |
|
} |
|
|
|
/** |
|
* 控件属性容器 |
|
*/ |
|
public static JComponent getWidgetComponent() { |
|
return (JComponent) (WidgetPropertyPane.getInstance().getEditingFormDesigner().getSelectionModel().getSelection().getSelectedCreator()).getComponent(0); |
|
} |
|
}
|
|
|