kerry
7 years ago
12 changed files with 647 additions and 882 deletions
@ -1,102 +0,0 @@ |
|||||||
package com.fr.design.module; |
|
||||||
|
|
||||||
import com.fr.design.ExtraDesignClassManager; |
|
||||||
import com.fr.design.actions.core.ActionFactory; |
|
||||||
import com.fr.design.fun.ElementUIProvider; |
|
||||||
import com.fr.design.gui.controlpane.NameObjectCreator; |
|
||||||
import com.fr.design.gui.controlpane.NameableCreator; |
|
||||||
import com.fr.design.hyperlink.ReportletHyperlinkPane; |
|
||||||
import com.fr.design.hyperlink.WebHyperlinkPane; |
|
||||||
import com.fr.design.javascript.EmailPane; |
|
||||||
import com.fr.design.javascript.JavaScriptImplPane; |
|
||||||
import com.fr.design.javascript.ParameterJavaScriptPane; |
|
||||||
import com.fr.design.mainframe.App; |
|
||||||
import com.fr.design.mainframe.DesignerFrame; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.general.ModuleContext; |
|
||||||
import com.fr.js.EmailJavaScript; |
|
||||||
import com.fr.js.JavaScriptImpl; |
|
||||||
import com.fr.js.ParameterJavaScript; |
|
||||||
import com.fr.js.ReportletHyperlink; |
|
||||||
import com.fr.js.WebHyperlink; |
|
||||||
import com.fr.module.TopModule; |
|
||||||
import com.fr.stable.bridge.StableFactory; |
|
||||||
import com.fr.stable.plugin.ExtraDesignClassManagerProvider; |
|
||||||
|
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.List; |
|
||||||
import java.util.Set; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by IntelliJ IDEA. |
|
||||||
* Author : Richer |
|
||||||
* Version: 6.5.6 |
|
||||||
* Date : 11-11-24 |
|
||||||
* Time : 下午2:52 |
|
||||||
* 所有设计器模块的父类 |
|
||||||
*/ |
|
||||||
public abstract class DesignModule extends TopModule { |
|
||||||
public static final String LOCALE_FILE_PATH = "com/fr/design/i18n/main"; |
|
||||||
|
|
||||||
public void start() { |
|
||||||
super.start(); |
|
||||||
App<?>[] apps = apps4TemplateOpener(); |
|
||||||
for (App<?> app : apps) { |
|
||||||
DesignerFrame.registApp(app); |
|
||||||
} |
|
||||||
ModuleContext.registerStartedModule(DesignModule.class.getName(), this); |
|
||||||
StableFactory.registerMarkedClass(ExtraDesignClassManagerProvider.XML_TAG, ExtraDesignClassManager.class); |
|
||||||
ActionFactory.registerCellInsertActionClass(actionsForInsertCellElement()); |
|
||||||
ActionFactory.registerFloatInsertActionClass(actionsForInsertFloatElement()); |
|
||||||
DesignModuleFactory.registerCreators4Hyperlink(hyperlinkTypes()); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isStarted() { |
|
||||||
return ModuleContext.isModuleStarted(DesignModule.class.getName()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 返回设计器能打开的模板类型的一个数组列表 |
|
||||||
* |
|
||||||
* @return 可以打开的模板类型的数组 |
|
||||||
*/ |
|
||||||
public abstract App<?>[] apps4TemplateOpener(); |
|
||||||
|
|
||||||
/** |
|
||||||
* 国际化文件路径 |
|
||||||
* |
|
||||||
* @return 国际化文件路径 |
|
||||||
*/ |
|
||||||
public String[] getLocaleFile() { |
|
||||||
return new String[]{LOCALE_FILE_PATH}; |
|
||||||
} |
|
||||||
|
|
||||||
public Class<?>[] actionsForInsertCellElement() { |
|
||||||
List<Class<?>> classes = new ArrayList<>(); |
|
||||||
Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); |
|
||||||
for (ElementUIProvider provider : providers) { |
|
||||||
classes.add(provider.actionForInsertCellElement()); |
|
||||||
} |
|
||||||
return classes.toArray(new Class<?>[classes.size()]); |
|
||||||
} |
|
||||||
|
|
||||||
public Class<?>[] actionsForInsertFloatElement() { |
|
||||||
List<Class<?>> classes = new ArrayList<>(); |
|
||||||
Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); |
|
||||||
for (ElementUIProvider provider : providers) { |
|
||||||
classes.add(provider.actionForInsertFloatElement()); |
|
||||||
} |
|
||||||
return classes.toArray(new Class<?>[classes.size()]); |
|
||||||
} |
|
||||||
|
|
||||||
public NameableCreator[] hyperlinkTypes() { |
|
||||||
return new NameableCreator[]{ |
|
||||||
new NameObjectCreator(Inter.getLocText("FR-Hyperlink_Reportlet"), ReportletHyperlink.class, ReportletHyperlinkPane.ChartNoRename.class), |
|
||||||
new NameObjectCreator(Inter.getLocText("FR-Designer_Email"), EmailJavaScript.class, EmailPane.class), |
|
||||||
new NameObjectCreator(Inter.getLocText("Hyperlink-Web_link"), WebHyperlink.class, WebHyperlinkPane.ChartNoRename.class), |
|
||||||
new NameObjectCreator(Inter.getLocText("JavaScript-Dynamic_Parameters"), ParameterJavaScript.class, ParameterJavaScriptPane.ChartNoRename.class), |
|
||||||
new NameObjectCreator(Inter.getLocText("FR-Designer_JavaScript"), JavaScriptImpl.class, JavaScriptImplPane.ChartNoRename.class) |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,90 +0,0 @@ |
|||||||
package com.fr.design.module; |
|
||||||
|
|
||||||
import com.fr.chart.base.ChartInternationalNameContentBean; |
|
||||||
import com.fr.chart.chartattr.Chart; |
|
||||||
import com.fr.chart.chartattr.ChartCollection; |
|
||||||
import com.fr.chart.charttypes.ChartTypeManager; |
|
||||||
import com.fr.design.ChartTypeInterfaceManager; |
|
||||||
import com.fr.design.actions.core.ActionFactory; |
|
||||||
import com.fr.design.chart.ChartDialog; |
|
||||||
import com.fr.design.chart.gui.ChartComponent; |
|
||||||
import com.fr.design.chart.gui.ChartWidgetOption; |
|
||||||
import com.fr.design.file.HistoryTemplateListPane; |
|
||||||
import com.fr.design.gui.core.WidgetOption; |
|
||||||
import com.fr.design.mainframe.App; |
|
||||||
import com.fr.design.mainframe.ChartPropertyPane; |
|
||||||
import com.fr.form.ui.ChartEditor; |
|
||||||
import com.fr.general.IOUtils; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.plugin.chart.vanchart.imgevent.design.DesignImageEvent; |
|
||||||
import com.fr.stable.ArrayUtils; |
|
||||||
import com.fr.stable.bridge.StableFactory; |
|
||||||
import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; |
|
||||||
import com.fr.van.chart.DownloadOnlineSourcesHelper; |
|
||||||
import com.fr.van.chart.map.server.ChartMapEditorAction; |
|
||||||
|
|
||||||
import javax.swing.Icon; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by IntelliJ IDEA. |
|
||||||
* Author : Richer |
|
||||||
* Version: 7.0.3 |
|
||||||
* Date: 13-7-8 |
|
||||||
* Time: 上午9:13 |
|
||||||
*/ |
|
||||||
public class ChartDesignerModule extends DesignModule { |
|
||||||
|
|
||||||
public static void register(){ |
|
||||||
StableFactory.registerMarkedClass(ExtraChartDesignClassManagerProvider.XML_TAG, ChartTypeInterfaceManager.class); |
|
||||||
StableFactory.getStaticMarkedInstanceObjectFromClass(ExtraChartDesignClassManagerProvider.XML_TAG, ExtraChartDesignClassManagerProvider.class); |
|
||||||
|
|
||||||
DesignModuleFactory.registerHyperlinkGroupType(new ChartHyperlinkGroup()); |
|
||||||
|
|
||||||
DesignModuleFactory.registerChartEditorClass(ChartEditor.class); |
|
||||||
DesignModuleFactory.registerChartComponentClass(ChartComponent.class); |
|
||||||
|
|
||||||
DesignModuleFactory.registerChartDialogClass(ChartDialog.class); |
|
||||||
|
|
||||||
DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); |
|
||||||
|
|
||||||
ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); |
|
||||||
ActionFactory.registerChartMapEditorAction(new ChartMapEditorAction()); |
|
||||||
|
|
||||||
ActionFactory.registerChartCollection(ChartCollection.class); |
|
||||||
|
|
||||||
DesignModuleFactory.registerExtraWidgetOptions(ChartTypeInterfaceManager.initWidgetOption()); |
|
||||||
|
|
||||||
DesignImageEvent.registerDefaultCallbackEvent(HistoryTemplateListPane.getInstance()); |
|
||||||
DesignImageEvent.registerDownloadSourcesEvent(new DownloadOnlineSourcesHelper()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 返回设计器能打开的模板类型的一个数组列表 |
|
||||||
* |
|
||||||
* @return 可以打开的模板类型的数组 |
|
||||||
*/ |
|
||||||
public App<?>[] apps4TemplateOpener() { |
|
||||||
return new App[0]; |
|
||||||
} |
|
||||||
protected WidgetOption[] options4Show() { |
|
||||||
ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); |
|
||||||
ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; |
|
||||||
for (int i = 0; i < typeName.length; i++) { |
|
||||||
String plotID = typeName[i].getPlotID(); |
|
||||||
Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); |
|
||||||
if (ArrayUtils.isEmpty(rowChart)) { |
|
||||||
continue; |
|
||||||
} |
|
||||||
String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); |
|
||||||
Icon icon = IOUtils.readIcon(iconPath); |
|
||||||
child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); |
|
||||||
} |
|
||||||
return child; |
|
||||||
} |
|
||||||
|
|
||||||
public String getInterNationalName() { |
|
||||||
return Inter.getLocText("FR-Chart-Design_ChartModule"); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -1,105 +0,0 @@ |
|||||||
package com.fr.design.module; |
|
||||||
|
|
||||||
import com.fr.base.FRContext; |
|
||||||
import com.fr.base.io.XMLEncryptUtils; |
|
||||||
import com.fr.design.DesignerEnvManager; |
|
||||||
import com.fr.design.bridge.DesignToolbarProvider; |
|
||||||
import com.fr.design.form.parameter.FormParaDesigner; |
|
||||||
import com.fr.design.mainframe.*; |
|
||||||
import com.fr.design.mainframe.actions.NewFormAction; |
|
||||||
import com.fr.design.parameter.FormParameterReader; |
|
||||||
import com.fr.design.parameter.ParameterPropertyPane; |
|
||||||
import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane; |
|
||||||
import com.fr.file.FILE; |
|
||||||
import com.fr.form.main.Form; |
|
||||||
import com.fr.form.stable.ElementCaseThumbnailProcessor; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.general.ModuleContext; |
|
||||||
import com.fr.stable.Constants; |
|
||||||
import com.fr.stable.bridge.StableFactory; |
|
||||||
|
|
||||||
import java.util.HashMap; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by IntelliJ IDEA. Author : Richer Version: 6.5.6 Date : 11-11-24 Time |
|
||||||
* : 下午3:43 |
|
||||||
*/ |
|
||||||
public class FormDesignerModule extends DesignModule { |
|
||||||
|
|
||||||
public void start() { |
|
||||||
super.start(); |
|
||||||
ModuleContext.startModule(CHART_DESIGNER_MODULE); |
|
||||||
|
|
||||||
StableFactory.registerMarkedObject(DesignToolbarProvider.STRING_MARKED, WidgetToolBarPane.getInstance()); |
|
||||||
|
|
||||||
DesignModuleFactory.registerNewFormActionClass(NewFormAction.class); |
|
||||||
DesignModuleFactory.registerFormParaDesignerClass(FormParaDesigner.class); |
|
||||||
DesignModuleFactory.registerParaPropertyPaneClass(ParameterPropertyPane.class); |
|
||||||
DesignModuleFactory.registerFormHierarchyPaneClass(FormHierarchyTreePane.class); |
|
||||||
DesignModuleFactory.registerWidgetPropertyPaneClass(WidgetPropertyPane.class); |
|
||||||
DesignModuleFactory.registerButtonDetailPaneClass(FormSubmitButtonDetailPane.class); |
|
||||||
DesignModuleFactory.registerParameterReader(new FormParameterReader()); |
|
||||||
|
|
||||||
registerData4Designer(); |
|
||||||
|
|
||||||
StableFactory.registerMarkedObject(ElementCaseThumbnailProcessor.MARK_STRING, new ElementCaseThumbnail()); |
|
||||||
} |
|
||||||
|
|
||||||
private void registerData4Designer(){ |
|
||||||
StableFactory.registerMarkedClass(BaseJForm.XML_TAG, JForm.class); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
*apps模板的Opener |
|
||||||
* @return 返回app |
|
||||||
*/ |
|
||||||
public App<?>[] apps4TemplateOpener() { |
|
||||||
return new App[]{new AbstractAppProvider<Form>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String[] defaultExtensions() { |
|
||||||
return new String[]{"frm", "form"}; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public JTemplate<Form, ?> openTemplate(FILE tplFile) { |
|
||||||
HashMap<String, Class> classType = new HashMap<String, Class>(); |
|
||||||
classType.put(Constants.ARG_0, Form.class); |
|
||||||
classType.put(Constants.ARG_1, FILE.class); |
|
||||||
|
|
||||||
return (JTemplate<Form, ?>) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, |
|
||||||
new Object[]{asIOFile(tplFile), tplFile}, classType, BaseJForm.class); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Form asIOFile(FILE file) { |
|
||||||
if (XMLEncryptUtils.isCptEncoded() && |
|
||||||
!XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { |
|
||||||
if (!new DecodeDialog(file).isPwdRight()) { |
|
||||||
FRContext.getLogger().error(Inter.getLocText("FR-Engine_ECP_error_pwd")); |
|
||||||
return new Form(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
// peter:打开新报表.
|
|
||||||
Form tpl = new Form(); |
|
||||||
// richer:打开报表通知
|
|
||||||
// FRContext.getLogger().info(Inter.getLocText("LOG-Is_Being_Openned") + "\"" + file.getName() + "\"" + "," + Inter.getLocText("LOG-Please_Wait") + "...");
|
|
||||||
FRContext.getLogger().info(Inter.getLocText(new String[]{"LOG-Is_Being_Openned", "LOG-Please_Wait"}, |
|
||||||
new String[]{"\"" + file.getName() + "\"" + ",", "..."})); |
|
||||||
try { |
|
||||||
tpl.readStream(file.asInputStream()); |
|
||||||
} catch (Exception exp) { |
|
||||||
FRContext.getLogger().error("Failed to generate frm from " + file, exp); |
|
||||||
return null; |
|
||||||
} |
|
||||||
return tpl; |
|
||||||
} |
|
||||||
}}; |
|
||||||
} |
|
||||||
|
|
||||||
public String getInterNationalName() { |
|
||||||
return Inter.getLocText("FR-Designer_formDesignerModule"); |
|
||||||
} |
|
||||||
} |
|
@ -1,36 +0,0 @@ |
|||||||
package com.fr.start; |
|
||||||
|
|
||||||
import com.fr.design.mainframe.actions.NewFormAction; |
|
||||||
import com.fr.design.menu.ShortCut; |
|
||||||
import com.fr.design.module.FormDesignerModule; |
|
||||||
|
|
||||||
|
|
||||||
public class Designer4Form extends BaseDesigner { |
|
||||||
|
|
||||||
/** |
|
||||||
* 主函数 |
|
||||||
* @param args 入口参数 |
|
||||||
*/ |
|
||||||
public static void main(String[] args) { |
|
||||||
new Designer4Form(args); |
|
||||||
} |
|
||||||
|
|
||||||
public Designer4Form(String[] args) { |
|
||||||
super(args); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected String module2Start() { |
|
||||||
return FormDesignerModule.class.getName(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 创建新建文件菜单 |
|
||||||
* @return 菜单 |
|
||||||
*/ |
|
||||||
public ShortCut[] createNewFileShortCuts() { |
|
||||||
return new ShortCut[]{ |
|
||||||
new NewFormAction() |
|
||||||
}; |
|
||||||
} |
|
||||||
} |
|
@ -1,504 +0,0 @@ |
|||||||
package com.fr.design.module; |
|
||||||
|
|
||||||
import com.fr.base.BaseFormula; |
|
||||||
import com.fr.base.BaseUtils; |
|
||||||
import com.fr.base.FRContext; |
|
||||||
import com.fr.base.Formula; |
|
||||||
import com.fr.base.MultiFieldParameter; |
|
||||||
import com.fr.base.Style; |
|
||||||
import com.fr.base.TempNameStyle; |
|
||||||
import com.fr.base.extension.FileExtension; |
|
||||||
import com.fr.base.frpx.exception.FRPackageRunTimeException; |
|
||||||
import com.fr.base.frpx.exception.InvalidWorkBookException; |
|
||||||
import com.fr.base.io.XMLEncryptUtils; |
|
||||||
import com.fr.base.process.ProcessOperator; |
|
||||||
import com.fr.base.remote.RemoteDeziConstants; |
|
||||||
import com.fr.chart.chartattr.ChartCollection; |
|
||||||
import com.fr.config.ServerPreferenceConfig; |
|
||||||
import com.fr.design.DesignerEnvManager; |
|
||||||
import com.fr.design.ExtraDesignClassManager; |
|
||||||
import com.fr.design.actions.core.ActionFactory; |
|
||||||
import com.fr.design.actions.insert.cell.BiasCellAction; |
|
||||||
import com.fr.design.actions.insert.cell.ChartCellAction; |
|
||||||
import com.fr.design.actions.insert.cell.DSColumnCellAction; |
|
||||||
import com.fr.design.actions.insert.cell.FormulaCellAction; |
|
||||||
import com.fr.design.actions.insert.cell.GeneralCellAction; |
|
||||||
import com.fr.design.actions.insert.cell.ImageCellAction; |
|
||||||
import com.fr.design.actions.insert.cell.RichTextCellAction; |
|
||||||
import com.fr.design.actions.insert.cell.SubReportCellAction; |
|
||||||
import com.fr.design.actions.insert.flot.ChartFloatAction; |
|
||||||
import com.fr.design.actions.insert.flot.FormulaFloatAction; |
|
||||||
import com.fr.design.actions.insert.flot.ImageFloatAction; |
|
||||||
import com.fr.design.actions.insert.flot.TextBoxFloatAction; |
|
||||||
import com.fr.design.actions.server.StyleListAction; |
|
||||||
import com.fr.design.fun.ElementUIProvider; |
|
||||||
import com.fr.design.gui.ibutton.UIButton; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.javascript.ProcessTransitionAdapter; |
|
||||||
import com.fr.design.mainframe.App; |
|
||||||
import com.fr.design.mainframe.DecodeDialog; |
|
||||||
import com.fr.design.mainframe.InformationCollector; |
|
||||||
import com.fr.design.mainframe.JTemplate; |
|
||||||
import com.fr.design.mainframe.JWorkBook; |
|
||||||
import com.fr.design.mainframe.bbs.BBSGuestPane; |
|
||||||
import com.fr.design.mainframe.form.FormECCompositeProvider; |
|
||||||
import com.fr.design.mainframe.form.FormECDesignerProvider; |
|
||||||
import com.fr.design.mainframe.form.FormElementCaseDesigner; |
|
||||||
import com.fr.design.mainframe.form.FormReportComponentComposite; |
|
||||||
import com.fr.design.mainframe.loghandler.DesignerLogImpl; |
|
||||||
import com.fr.design.parameter.WorkBookParameterReader; |
|
||||||
import com.fr.design.utils.gui.GUICoreUtils; |
|
||||||
import com.fr.file.FILE; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.general.ModuleContext; |
|
||||||
import com.fr.general.xml.GeneralXMLTools; |
|
||||||
import com.fr.io.importer.Excel2007ReportImporter; |
|
||||||
import com.fr.io.importer.ExcelReportImporter; |
|
||||||
import com.fr.io.utils.ResourceIOUtils; |
|
||||||
import com.fr.log.FineLoggerFactory; |
|
||||||
import com.fr.main.impl.WorkBook; |
|
||||||
import com.fr.main.impl.WorkBookAdapter; |
|
||||||
import com.fr.main.impl.WorkBookX; |
|
||||||
import com.fr.quickeditor.cellquick.CellBiasTextPainterEditor; |
|
||||||
import com.fr.quickeditor.cellquick.CellDSColumnEditor; |
|
||||||
import com.fr.quickeditor.cellquick.CellFormulaQuickEditor; |
|
||||||
import com.fr.quickeditor.cellquick.CellImageQuickEditor; |
|
||||||
import com.fr.quickeditor.cellquick.CellRichTextEditor; |
|
||||||
import com.fr.quickeditor.cellquick.CellStringQuickEditor; |
|
||||||
import com.fr.quickeditor.cellquick.CellSubReportEditor; |
|
||||||
import com.fr.quickeditor.chartquick.BasicChartQuickEditor; |
|
||||||
import com.fr.quickeditor.chartquick.FloatChartQuickEditor; |
|
||||||
import com.fr.quickeditor.floatquick.FloatImageQuickEditor; |
|
||||||
import com.fr.quickeditor.floatquick.FloatStringQuickEditor; |
|
||||||
import com.fr.report.cell.CellElementValueConverter; |
|
||||||
import com.fr.report.cell.cellattr.core.RichText; |
|
||||||
import com.fr.report.cell.cellattr.core.SubReport; |
|
||||||
import com.fr.report.cell.cellattr.core.group.DSColumn; |
|
||||||
import com.fr.report.cell.painter.BiasTextPainter; |
|
||||||
import com.fr.report.cell.painter.CellImagePainter; |
|
||||||
import com.fr.stable.ArrayUtils; |
|
||||||
import com.fr.stable.ParameterProvider; |
|
||||||
import com.fr.stable.StringUtils; |
|
||||||
import com.fr.stable.bridge.StableFactory; |
|
||||||
import com.fr.stable.fun.LogProvider; |
|
||||||
import com.fr.stable.script.CalculatorProviderContext; |
|
||||||
import com.fr.stable.script.ValueConverter; |
|
||||||
import com.fr.stable.web.ServletContext; |
|
||||||
import com.fr.stable.web.ServletContextAdapter; |
|
||||||
import com.fr.stable.xml.ObjectTokenizer; |
|
||||||
import com.fr.stable.xml.ObjectXMLWriterFinder; |
|
||||||
import com.fr.start.BBSGuestPaneProvider; |
|
||||||
import com.fr.xml.ReportXMLUtils; |
|
||||||
|
|
||||||
import javax.swing.JDialog; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import javax.swing.SwingConstants; |
|
||||||
import java.awt.BorderLayout; |
|
||||||
import java.awt.Image; |
|
||||||
import java.awt.event.ActionEvent; |
|
||||||
import java.awt.event.ActionListener; |
|
||||||
import java.awt.image.BufferedImage; |
|
||||||
import java.io.InputStream; |
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.Set; |
|
||||||
|
|
||||||
public class DesignerModule extends DesignModule { |
|
||||||
|
|
||||||
static { |
|
||||||
ServletContext.addServletContextListener(new ServletContextAdapter() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void onServletStart() { |
|
||||||
ModuleContext.startModule(DesignerModule.class.getName()); |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 启动设计器模块 |
|
||||||
*/ |
|
||||||
@Override |
|
||||||
public void start() { |
|
||||||
super.start(); |
|
||||||
|
|
||||||
justStartModules4Engine(); |
|
||||||
justStartModules4Designer(); |
|
||||||
|
|
||||||
CalculatorProviderContext.setValueConverter(valueConverter()); |
|
||||||
GeneralXMLTools.Object_Tokenizer = startXMLReadObjectTokenizer(); |
|
||||||
GeneralXMLTools.Object_XML_Writer_Finder = startObjectXMLWriterFinder(); |
|
||||||
addAdapterForPlate(); |
|
||||||
|
|
||||||
InformationCollector.getInstance().collectStartTime(); |
|
||||||
|
|
||||||
ExtraDesignClassManager.getInstance().getFeedback().didFeedback(); |
|
||||||
StableFactory.registerMarkedObject(LogProvider.MARK_STRING, DesignerLogImpl.getInstance()); |
|
||||||
} |
|
||||||
|
|
||||||
public static void register() { |
|
||||||
registerCellEditor(); |
|
||||||
registerFloatEditor(); |
|
||||||
registerData4Form(); |
|
||||||
registerOtherPane(); |
|
||||||
} |
|
||||||
|
|
||||||
private static void registerOtherPane() { |
|
||||||
StableFactory.registerMarkedClass(BBSGuestPaneProvider.XML_TAG, BBSGuestPane.class); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* kunsnat:注册单元格选中Editor |
|
||||||
*/ |
|
||||||
private static void registerCellEditor() { |
|
||||||
|
|
||||||
ActionFactory.registerCellEditor(String.class, new CellStringQuickEditor()); |
|
||||||
ActionFactory.registerCellEditor(Number.class, new CellStringQuickEditor()); |
|
||||||
ActionFactory.registerCellEditor(BaseFormula.class, new CellFormulaQuickEditor()); |
|
||||||
ActionFactory.registerCellEditor(SubReport.class, new CellSubReportEditor()); |
|
||||||
ActionFactory.registerCellEditor(RichText.class, new CellRichTextEditor()); |
|
||||||
ActionFactory.registerCellEditor(DSColumn.class, new CellDSColumnEditor()); |
|
||||||
ActionFactory.registerCellEditor(Image.class, new CellImageQuickEditor()); |
|
||||||
ActionFactory.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor()); |
|
||||||
ActionFactory.registerCellEditor(BufferedImage.class, new CellImageQuickEditor()); |
|
||||||
ActionFactory.registerCellEditor(CellImagePainter.class, new CellImageQuickEditor()); |
|
||||||
//todo 图表编辑器populate没能实现刷新面板显示
|
|
||||||
ActionFactory.registerCellEditorClass(ChartCollection.class, BasicChartQuickEditor.class); |
|
||||||
|
|
||||||
Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); |
|
||||||
for (ElementUIProvider provider : providers) { |
|
||||||
try { |
|
||||||
ActionFactory.registerCellEditor(provider.targetObjectClass(), provider.quickEditor().newInstance()); |
|
||||||
} catch (Exception e) { |
|
||||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public String getInterNationalName() { |
|
||||||
return Inter.getLocText("FR-Module_Designer"); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* kunnat: 注册悬浮选中Editor |
|
||||||
*/ |
|
||||||
private static void registerFloatEditor() { |
|
||||||
|
|
||||||
ActionFactory.registerFloatEditor(String.class, new FloatStringQuickEditor()); |
|
||||||
ActionFactory.registerFloatEditor(Formula.class, new FloatStringQuickEditor()); |
|
||||||
ActionFactory.registerFloatEditor(Image.class, new FloatImageQuickEditor()); |
|
||||||
ActionFactory.registerFloatEditor(BufferedImage.class, new FloatImageQuickEditor()); |
|
||||||
ActionFactory.registerFloatEditor(CellImagePainter.class, new FloatImageQuickEditor()); |
|
||||||
//todo 图表编辑器populate没能实现刷新面板显示
|
|
||||||
ActionFactory.registerFloatEditorClass(ChartCollection.class, FloatChartQuickEditor.class); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* kunsnat: 一些模块信息 必须跟随设计器启动, |
|
||||||
* 比如 读取CC.XML, 设计器启动之后, 马上会读取XML, 需要Chart_Module中的注册信息 |
|
||||||
*/ |
|
||||||
private void justStartModules4Engine() { |
|
||||||
ModuleContext.startModule(ENGINE_MODULE); |
|
||||||
} |
|
||||||
|
|
||||||
private void justStartModules4Designer() { |
|
||||||
ModuleContext.startModule(CHART_DESIGNER_MODULE); |
|
||||||
ModuleContext.startModule(FORM_DESIGNER_MODULE); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* CellElementValueConverter用来处理设计器格子里的值,将公式/数组/其他元素转换成对应的值。 |
|
||||||
* |
|
||||||
* @return 返回处理格子值的转换器 |
|
||||||
*/ |
|
||||||
@Override |
|
||||||
public ValueConverter valueConverter() { |
|
||||||
return new CellElementValueConverter(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
/* |
|
||||||
* 针对不同的对象,在读取Object对象的xml的时候需要使用不同的对象生成器 |
|
||||||
* @return 返回对象生成器 |
|
||||||
*/ |
|
||||||
public ObjectTokenizer startXMLReadObjectTokenizer() { |
|
||||||
return new ReportXMLUtils.ReportObjectTokenizer(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 针对不同的对象,在写对象的XML时需要使用不同的XML生成器 |
|
||||||
* |
|
||||||
* @return 返回xml生成器 |
|
||||||
*/ |
|
||||||
@Override |
|
||||||
public ObjectXMLWriterFinder startObjectXMLWriterFinder() { |
|
||||||
return new ReportXMLUtils.ReportObjectXMLWriterFinder(); |
|
||||||
} |
|
||||||
|
|
||||||
//wei:fs的模块中可能有需要设计器界面做设置的地方,在这边添加
|
|
||||||
private void addAdapterForPlate() { |
|
||||||
|
|
||||||
ProcessTransitionAdapter.setProcessTransitionAdapter(new ProcessTransitionAdapter() { |
|
||||||
|
|
||||||
@Override |
|
||||||
protected String[] getTransitionNamesByBook(String book) { |
|
||||||
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getTransitionNamesByBook(book); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected String[] getParaNames(String book) { |
|
||||||
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getParaNames(book); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected ParameterProvider[] getParas(String book) { |
|
||||||
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getParas(book); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected MultiFieldParameter[] getAllMultiFieldParas(String book) { |
|
||||||
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getAllMultiFieldParas(book); |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
private static abstract class AbstractWorkBookApp implements App<WorkBook> { |
|
||||||
|
|
||||||
@Override |
|
||||||
public int currentAPILevel() { |
|
||||||
return CURRENT_LEVEL; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public JTemplate<WorkBook, ?> openTemplate(FILE tplFile) { |
|
||||||
return new JWorkBook(asIOFile(tplFile), tplFile); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String mark4Provider() { |
|
||||||
return getClass().getName(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void process() { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void undo() { |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
/* |
|
||||||
* 返回设计器能打开的模板类型的一个数组列表 |
|
||||||
* @return 可以打开的模板类型的数组 |
|
||||||
*/ |
|
||||||
public App[] apps4TemplateOpener() { |
|
||||||
return new App[]{getCptxApp(), getCptApp(), getXlsApp(), getXlsxApp()}; |
|
||||||
} |
|
||||||
|
|
||||||
private AbstractWorkBookApp getXlsxApp() { |
|
||||||
return new AbstractWorkBookApp() { |
|
||||||
@Override |
|
||||||
public String[] defaultExtensions() { |
|
||||||
return new String[]{FileExtension.XLSX.getExtension()}; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public WorkBook asIOFile(FILE tplFile) { |
|
||||||
WorkBook workbook = null; |
|
||||||
try { |
|
||||||
workbook = new Excel2007ReportImporter().generateWorkBookByStream(tplFile.asInputStream()); |
|
||||||
} catch (Exception exp) { |
|
||||||
FRContext.getLogger().error("Failed to generate xlsx from " + tplFile, exp); |
|
||||||
} |
|
||||||
return workbook; |
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
private AbstractWorkBookApp getXlsApp() { |
|
||||||
return new AbstractWorkBookApp() { |
|
||||||
@Override |
|
||||||
public String[] defaultExtensions() { |
|
||||||
return new String[]{FileExtension.XLS.getExtension()}; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public WorkBook asIOFile(FILE tplFile) { |
|
||||||
WorkBook workbook = null; |
|
||||||
try { |
|
||||||
workbook = new ExcelReportImporter().generateWorkBookByStream(tplFile.asInputStream()); |
|
||||||
} catch (Exception exp) { |
|
||||||
FRContext.getLogger().error("Failed to generate xls from " + tplFile, exp); |
|
||||||
} |
|
||||||
return workbook; |
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
private AbstractWorkBookApp getCptApp() { |
|
||||||
return new AbstractWorkBookApp() { |
|
||||||
@Override |
|
||||||
public String[] defaultExtensions() { |
|
||||||
return new String[]{FileExtension.CPT.getExtension()}; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public WorkBook asIOFile(FILE file) { |
|
||||||
if (XMLEncryptUtils.isCptEncoded() && |
|
||||||
!XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { |
|
||||||
if (!new DecodeDialog(file).isPwdRight()) { |
|
||||||
FRContext.getLogger().error(Inter.getLocText("ECP-error_pwd")); |
|
||||||
return new WorkBook(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
WorkBook tpl = new WorkBook(); |
|
||||||
// richer:打开报表通知
|
|
||||||
FRContext.getLogger().info(Inter.getLocText(new String[]{"LOG-Is_Being_Openned", "LOG-Please_Wait"}, new String[]{"\"" + file.getName() + "\"" + ",", "..."})); |
|
||||||
TempNameStyle namestyle = TempNameStyle.getInstance(); |
|
||||||
namestyle.clear(); |
|
||||||
String checkStr = StringUtils.EMPTY; |
|
||||||
try { |
|
||||||
checkStr = ResourceIOUtils.inputStream2String(file.asInputStream()); |
|
||||||
tpl.readStream(file.asInputStream()); |
|
||||||
} catch (Exception exp) { |
|
||||||
String errorMessage = StringUtils.EMPTY; |
|
||||||
errorMessage = ComparatorUtils.equals(RemoteDeziConstants.INVALID_USER, checkStr) ? Inter.getLocText("FR-Designer_No-Privilege") |
|
||||||
: Inter.getLocText("NS-exception_readError"); |
|
||||||
FRContext.getLogger().error(errorMessage + file, exp); |
|
||||||
} |
|
||||||
checkNameStyle(namestyle); |
|
||||||
return tpl; |
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
private AbstractWorkBookApp getCptxApp() { |
|
||||||
return new AbstractWorkBookApp() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String[] defaultExtensions() { |
|
||||||
return new String[]{FileExtension.CPTX.getExtension()}; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public WorkBook asIOFile(FILE file) { |
|
||||||
FRContext.getLogger().info(Inter.getLocText(new String[]{"LOG-Is_Being_Openned", "LOG-Please_Wait"}, new String[]{"\"" + file.getName() + "\"" + ",", "..."})); |
|
||||||
WorkBookX tpl; |
|
||||||
InputStream inputStream; |
|
||||||
try { |
|
||||||
inputStream = file.asInputStream(); |
|
||||||
long time = System.currentTimeMillis(); |
|
||||||
tpl = new WorkBookX(inputStream); |
|
||||||
FRContext.getLogger().error("cost: " + (System.currentTimeMillis() - time) + " ms"); |
|
||||||
} catch (Exception exp) { |
|
||||||
if (exp instanceof FRPackageRunTimeException) { |
|
||||||
throw (FRPackageRunTimeException) exp; |
|
||||||
} |
|
||||||
throw new InvalidWorkBookException(file + ":" + exp.getMessage(), exp); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
return new WorkBookAdapter(tpl); |
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
private static void checkNameStyle(TempNameStyle namestyle) { |
|
||||||
Iterator it = namestyle.getIterator(); |
|
||||||
ArrayList<String> al = new ArrayList<String>(); |
|
||||||
while (it.hasNext()) { |
|
||||||
al.add((String) it.next()); |
|
||||||
} |
|
||||||
if (!al.isEmpty()) { |
|
||||||
showConfirmDialog(al); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private static void showConfirmDialog(final ArrayList<String> namelist) { |
|
||||||
|
|
||||||
final JDialog jd = new JDialog(); |
|
||||||
// 模态一下,因为可能会多个样式丢失
|
|
||||||
// jd.setModal(true);
|
|
||||||
jd.setAlwaysOnTop(true); |
|
||||||
jd.setSize(450, 150); |
|
||||||
jd.setResizable(false); |
|
||||||
jd.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); |
|
||||||
String message = namelist.toString().replaceAll("\\[", "").replaceAll("\\]", ""); |
|
||||||
UILabel jl = new UILabel(Inter.getLocText(new String[]{"Current_custom_global", "Has_been_gone"}, new String[]{message})); |
|
||||||
jl.setHorizontalAlignment(SwingConstants.CENTER); |
|
||||||
jd.add(jl, BorderLayout.CENTER); |
|
||||||
JPanel jp = new JPanel(); |
|
||||||
|
|
||||||
// ”是“按钮,点击之后将生成一个全局样式,并写入xml
|
|
||||||
UIButton confirmButton = new UIButton(Inter.getLocText("FR-Designer_Yes")); |
|
||||||
confirmButton.addActionListener(new ActionListener() { |
|
||||||
@Override |
|
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
try { |
|
||||||
for (int i = 0; i < namelist.size(); i++) { |
|
||||||
ServerPreferenceConfig.getInstance().putStyle(namelist.get(i), Style.DEFAULT_STYLE); |
|
||||||
} |
|
||||||
} catch (Exception ex) { |
|
||||||
FineLoggerFactory.getLogger().error(ex.getMessage()); |
|
||||||
} |
|
||||||
jd.dispose(); |
|
||||||
new StyleListAction().actionPerformed(e);// 弹窗
|
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
UIButton noButton = new UIButton(Inter.getLocText("FR-Designer_No")); |
|
||||||
noButton.addActionListener(new ActionListener() { |
|
||||||
@Override |
|
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
jd.dispose(); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
jp.add(confirmButton); |
|
||||||
jp.add(noButton); |
|
||||||
jd.setTitle(Inter.getLocText("FR-Custom_styles_lost")); |
|
||||||
jd.add(jp, BorderLayout.SOUTH); |
|
||||||
GUICoreUtils.centerWindow(jd); |
|
||||||
jd.setVisible(true); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Class<?>[] actionsForInsertCellElement() { |
|
||||||
return (Class<?>[]) ArrayUtils.addAll(new Class<?>[]{ |
|
||||||
DSColumnCellAction.class, |
|
||||||
GeneralCellAction.class, |
|
||||||
RichTextCellAction.class, |
|
||||||
FormulaCellAction.class, |
|
||||||
ChartCellAction.class, |
|
||||||
ImageCellAction.class, |
|
||||||
BiasCellAction.class, |
|
||||||
SubReportCellAction.class |
|
||||||
}, super.actionsForInsertCellElement()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Class<?>[] actionsForInsertFloatElement() { |
|
||||||
return (Class<?>[]) ArrayUtils.addAll(new Class<?>[]{ |
|
||||||
TextBoxFloatAction.class, |
|
||||||
FormulaFloatAction.class, |
|
||||||
ChartFloatAction.class, |
|
||||||
ImageFloatAction.class |
|
||||||
}, super.actionsForInsertFloatElement()); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private static void registerData4Form() { |
|
||||||
StableFactory.registerMarkedClass(FormECDesignerProvider.XML_TAG, FormElementCaseDesigner.class); |
|
||||||
StableFactory.registerMarkedClass(FormECCompositeProvider.XML_TAG, FormReportComponentComposite.class); |
|
||||||
DesignModuleFactory.registerParameterReader(new WorkBookParameterReader()); |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue