hzzz 6 years ago
parent
commit
6be840746a
  1. 4
      designer-base/src/com/fr/design/ExtraDesignClassManager.java
  2. 6
      designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java
  3. 8
      designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  4. 2
      designer-base/src/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java
  5. 3537
      designer-base/src/com/fr/design/javascript/beautify/beautify.js
  6. 4
      designer-base/src/com/fr/design/mainframe/App.java
  7. 3
      designer-base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java
  8. 3
      designer-base/src/com/fr/design/style/background/impl/ImageButtonBackgroundPane.java
  9. 6
      designer-base/src/com/fr/start/server/FineEmbedServerActivator.java
  10. 20
      designer-chart/src/com/fr/design/ChartTypeInterfaceManager.java
  11. 55
      designer-chart/src/com/fr/design/chart/ChartDesignerActivator.java
  12. 42
      designer-realize/src/com/fr/design/mainframe/app/AbstractWorkBookApp.java
  13. 136
      designer-realize/src/com/fr/design/mainframe/app/CptApp.java
  14. 47
      designer-realize/src/com/fr/design/mainframe/app/CptxApp.java
  15. 39
      designer-realize/src/com/fr/design/mainframe/app/DesignerAppActivator.java
  16. 66
      designer-realize/src/com/fr/design/mainframe/app/FormApp.java
  17. 31
      designer-realize/src/com/fr/design/mainframe/app/XlsApp.java
  18. 31
      designer-realize/src/com/fr/design/mainframe/app/XlsxApp.java
  19. 12
      designer-realize/src/com/fr/start/Designer.java
  20. 356
      designer-realize/src/com/fr/start/module/DesignerActivator.java
  21. 11
      designer-realize/src/com/fr/start/module/EnvBasedModule.java

4
designer-base/src/com/fr/design/ExtraDesignClassManager.java

@ -46,8 +46,8 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
private static ExtraDesignClassManager classManager = new ExtraDesignClassManager();
private Set<ShortCut> shortCuts = new CloseableContainedSet<>(HashSet.class);
public synchronized static ExtraDesignClassManager getInstance() {
public static ExtraDesignClassManager getInstance() {
return classManager;
}

6
designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java vendored

@ -1,5 +1,7 @@
package com.fr.design.env;
import com.fr.general.NameObject;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
@ -63,6 +65,8 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
@Override
public Object clone() throws CloneNotSupportedException {
return null;
LocalDesignerWorkspaceInfo object = (LocalDesignerWorkspaceInfo)super.clone();
return object;
}
}

8
designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -1,6 +1,7 @@
package com.fr.design.env;
import com.fr.security.SecurityToolbox;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
@ -75,7 +76,10 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
@Override
public Object clone() throws CloneNotSupportedException {
return null;
RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo)super.clone();
object.connection = (WorkspaceConnection)StableUtils.cloneObject(this.connection);
return object;
}
}

2
designer-base/src/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java

@ -40,7 +40,7 @@ public class JavaScriptFormatHelper {
Reader reader = new InputStreamReader(resourceAsStream);
scriptEngine.eval(reader);
Invocable invocable = (Invocable) scriptEngine;
result = (String) invocable.invokeFunction("js_beautify", jsCode, option.toFormatArgument());
result = (String) invocable.invokeFunction("js_beautify_global", jsCode, option.toFormatArgument());
} catch (ScriptException | NoSuchMethodException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}

3537
designer-base/src/com/fr/design/javascript/beautify/beautify.js

File diff suppressed because it is too large Load Diff

4
designer-base/src/com/fr/design/mainframe/App.java

@ -2,6 +2,8 @@ package com.fr.design.mainframe;
import com.fr.base.io.BaseBook;
import com.fr.file.FILE;
import com.fr.module.BaseStableKey;
import com.fr.module.StableKey;
import com.fr.stable.fun.mark.Aftermath;
import com.fr.stable.fun.mark.Mutable;
@ -11,6 +13,8 @@ import com.fr.stable.fun.mark.Mutable;
public interface App<T extends BaseBook> extends Mutable, Aftermath {
String MARK_STRING = "DesignerApp";
StableKey<App> KEY = new BaseStableKey<App>();
int CURRENT_LEVEL = 1;
/**

3
designer-base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java

@ -2,6 +2,7 @@ package com.fr.design.style.background.impl;
import com.fr.base.Style;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.ImageFileBackground;
import com.fr.design.gui.frpane.ImgChooseWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
@ -192,7 +193,7 @@ public class ImageBackgroundPane extends BackgroundDetailPane {
@Override
public Background update() throws Exception {
ImageBackground imageBackground = new ImageBackground(previewPane.getImageWithSuffix());
ImageBackground imageBackground = new ImageFileBackground(previewPane.getImageWithSuffix());
setImageStyle();
imageBackground.setLayout(imageStyle.getImageLayout());
return imageBackground;

3
designer-base/src/com/fr/design/style/background/impl/ImageButtonBackgroundPane.java

@ -2,6 +2,7 @@ package com.fr.design.style.background.impl;
import com.fr.base.Style;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.ImageFileBackground;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.general.Background;
import com.fr.general.Inter;
@ -81,6 +82,6 @@ public class ImageButtonBackgroundPane extends ImageBackgroundPane {
if (previewPane.getImage() == null) {
return null;
}
return new ImageBackground(previewPane.getImageWithSuffix());
return new ImageFileBackground(previewPane.getImageWithSuffix());
}
}

6
designer-base/src/com/fr/start/server/FineEmbedServerActivator.java

@ -13,8 +13,8 @@ import com.fr.workspace.WorkContext;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Wrapper;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.loader.VirtualWebappLoader;
import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.startup.Tomcat;
import java.io.File;
@ -112,7 +112,7 @@ public class FineEmbedServerActivator extends Activator {
* Created by juhaoyu on 2018/6/5.
* 自定义的tomcat loader主要用于防止内置服务器再加载一遍class
*/
private static class FRTomcatLoader extends VirtualWebappLoader {
private static class FRTomcatLoader extends WebappLoader {
@Override
public ClassLoader getClassLoader() {

20
designer-chart/src/com/fr/design/ChartTypeInterfaceManager.java

@ -37,9 +37,7 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.ChartEditor;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.plugin.chart.PiePlot4VanChart;
@ -64,7 +62,6 @@ import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.injectable.PluginSingleInjection;
import com.fr.plugin.solution.closeable.CloseableContainedMap;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.StringUtils;
import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider;
import com.fr.van.chart.area.AreaIndependentVanChartInterface;
@ -87,7 +84,7 @@ import com.fr.van.chart.structure.desinger.StructureIndependentVanChartInterface
import com.fr.van.chart.treemap.TreeMapIndependentVanChartInterface;
import com.fr.van.chart.wordcloud.designer.WordCloudIndependentVanChartInterface;
import javax.swing.Icon;
import javax.swing.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -95,9 +92,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static com.fr.chart.charttypes.ChartTypeManager.CHART_PRIORITY;
import static com.fr.chart.charttypes.ChartTypeManager.VAN_CHART_PRIORITY;
import static com.fr.chart.charttypes.ChartTypeManager.enabledChart;
import static com.fr.chart.charttypes.ChartTypeManager.*;
/**
* Created by eason on 14/12/29.
@ -123,17 +118,6 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
PluginModule.registerAgent(PluginModule.ExtraChartDesign, classManager);
}
static {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override
public void envChanged() {
//重新注册designModuleFactory
DesignModuleFactory.registerExtraWidgetOptions(initWidgetOption());
}
});
}
public static WidgetOption[] initWidgetOption() {
ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames();

55
designer-chart/src/com/fr/design/chart/ChartDesignerActivator.java

@ -0,0 +1,55 @@
package com.fr.design.chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.ChartPropertyPane;
import com.fr.design.module.ChartHyperlinkGroup;
import com.fr.design.module.ChartPreStyleAction;
import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.ChartEditor;
import com.fr.module.Activator;
import com.fr.plugin.chart.vanchart.imgevent.design.DesignImageEvent;
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;
/**
* Created by juhaoyu on 2018/6/27.
*/
public class ChartDesignerActivator extends Activator {
@Override
public void start() {
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());
}
@Override
public void stop() {
}
}

42
designer-realize/src/com/fr/design/mainframe/app/AbstractWorkBookApp.java

@ -0,0 +1,42 @@
package com.fr.design.mainframe.app;
import com.fr.design.mainframe.App;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JWorkBook;
import com.fr.file.FILE;
import com.fr.main.impl.WorkBook;
/**
* Created by juhaoyu on 2018/6/27.
*/
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() {
}
}

136
designer-realize/src/com/fr/design/mainframe/app/CptApp.java

@ -0,0 +1,136 @@
package com.fr.design.mainframe.app;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Style;
import com.fr.base.TempNameStyle;
import com.fr.base.extension.FileExtension;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.base.remote.RemoteDeziConstants;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.server.StyleListAction;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.DecodeDialog;
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.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.main.impl.WorkBook;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Iterator;
/**
* Created by juhaoyu on 2018/6/27.
*/
class CptApp extends 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:打开报表通知
FineLoggerFactory.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 = ComparatorUtils.equals(RemoteDeziConstants.INVALID_USER, checkStr) ? Inter.getLocText("FR-Designer_No-Privilege")
: Inter.getLocText("NS-exception_readError");
FineLoggerFactory.getLogger().error(errorMessage + file, exp);
}
checkNameStyle(namestyle);
return 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 (String name : namelist) {
ServerPreferenceConfig.getInstance().putStyle(name, 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);
}
}

47
designer-realize/src/com/fr/design/mainframe/app/CptxApp.java

@ -0,0 +1,47 @@
package com.fr.design.mainframe.app;
import com.fr.base.extension.FileExtension;
import com.fr.base.frpx.exception.FRPackageRunTimeException;
import com.fr.base.frpx.exception.InvalidWorkBookException;
import com.fr.file.FILE;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.main.impl.WorkBook;
import com.fr.main.impl.WorkBookAdapter;
import com.fr.main.impl.WorkBookX;
import java.io.InputStream;
/**
* Created by juhaoyu on 2018/6/27.
*/
class CptxApp extends AbstractWorkBookApp {
@Override
public String[] defaultExtensions() {
return new String[]{FileExtension.CPTX.getExtension()};
}
@Override
public WorkBook asIOFile(FILE file) {
FineLoggerFactory.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);
FineLoggerFactory.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);
}
}

39
designer-realize/src/com/fr/design/mainframe/app/DesignerAppActivator.java

@ -0,0 +1,39 @@
package com.fr.design.mainframe.app;
import com.fr.design.mainframe.App;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.module.Activator;
import com.fr.module.extension.Prepare;
import java.util.List;
/**
* Created by juhaoyu on 2018/6/27.
*/
public class DesignerAppActivator extends Activator implements Prepare {
@Override
public void start() {
List<App> appList = rightCollectMutable(App.KEY);
for (App app : appList) {
DesignerFrame.registApp(app);
}
}
@Override
public void stop() {
List<App> appList = rightCollectMutable(App.KEY);
for (App app : appList) {
DesignerFrame.removeApp(app);
}
}
@Override
public void prepare() {
addMutable(App.KEY, new CptApp(), new FormApp(), new XlsApp(), new XlsxApp());
}
}

66
designer-realize/src/com/fr/design/mainframe/app/FormApp.java

@ -0,0 +1,66 @@
package com.fr.design.mainframe.app;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.AbstractAppProvider;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DecodeDialog;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.form.main.Form;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.stable.bridge.StableFactory;
import java.util.HashMap;
/**
* Created by juhaoyu on 2018/6/27.
*/
class FormApp extends AbstractAppProvider {
@Override
public String[] defaultExtensions() {
return new String[]{"frm", "form"};
}
@Override
@SuppressWarnings("unchecked")
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()) {
FineLoggerFactory.getLogger().error(Inter.getLocText("FR-Engine_ECP_error_pwd"));
return new Form();
}
}
// peter:打开新报表.
Form tpl = new Form();
// richer:打开报表通知
FineLoggerFactory.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) {
FineLoggerFactory.getLogger().error("Failed to generate frm from " + file, exp);
return null;
}
return tpl;
}
}

31
designer-realize/src/com/fr/design/mainframe/app/XlsApp.java

@ -0,0 +1,31 @@
package com.fr.design.mainframe.app;
import com.fr.base.extension.FileExtension;
import com.fr.file.FILE;
import com.fr.io.importer.ExcelReportImporter;
import com.fr.log.FineLoggerFactory;
import com.fr.main.impl.WorkBook;
/**
* Created by juhaoyu on 2018/6/27.
*/
class XlsApp extends 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) {
FineLoggerFactory.getLogger().error("Failed to generate xls from " + tplFile, exp);
}
return workbook;
}
}

31
designer-realize/src/com/fr/design/mainframe/app/XlsxApp.java

@ -0,0 +1,31 @@
package com.fr.design.mainframe.app;
import com.fr.base.extension.FileExtension;
import com.fr.file.FILE;
import com.fr.io.importer.Excel2007ReportImporter;
import com.fr.log.FineLoggerFactory;
import com.fr.main.impl.WorkBook;
/**
* Created by juhaoyu on 2018/6/27.
*/
class XlsxApp extends 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) {
FineLoggerFactory.getLogger().error("Failed to generate xlsx from " + tplFile, exp);
}
return workbook;
}
}

12
designer-realize/src/com/fr/start/Designer.java

@ -37,7 +37,6 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
@ -97,15 +96,20 @@ public class Designer extends BaseDesigner {
* @param args 参数
*/
public static void main(String[] args) {
BuildContext.setBuildFilePath("/com/fr/stable/build.properties");
preloadResource();
SplashContext.getInstance().registerSplash(createSplash());
// 如果端口被占用了 说明程序已经运行了一次,也就是说,已经建立一个监听服务器,现在只要给服务器发送命令就好了
if (DesignUtils.isStarted()) {
DesignUtils.clientSend(args);
return;
}
preloadResource();
SplashContext.getInstance().registerSplash(createSplash());
SplashContext.getInstance().show();
Module designerRoot = ModuleContext.parseRoot("designer-startup.xml");
//传递启动参数
@ -168,7 +172,7 @@ public class Designer extends BaseDesigner {
@Override
public ShortCut[] createNewFileShortCuts() {
ArrayList<ShortCut> shortCuts = new ArrayList<ShortCut>();
shortCuts.add(new NewWorkBookXAction());
// shortCuts.add(new NewWorkBookXAction());
shortCuts.add(new NewWorkBookAction());
shortCuts.add(new NewPolyReportAction());
try {

356
designer-realize/src/com/fr/start/module/DesignerModuleActivator.java → designer-realize/src/com/fr/start/module/DesignerActivator.java

@ -1,22 +1,11 @@
package com.fr.start.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.ChartTypeInterfaceManager;
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;
@ -31,7 +20,6 @@ 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.bridge.DesignToolbarProvider;
import com.fr.design.chart.ChartDialog;
import com.fr.design.chart.gui.ChartComponent;
@ -40,29 +28,21 @@ import com.fr.design.form.parameter.FormParaDesigner;
import com.fr.design.fun.ElementUIProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
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.javascript.ProcessTransitionAdapter;
import com.fr.design.mainframe.AbstractAppProvider;
import com.fr.design.mainframe.App;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.design.mainframe.ChartPropertyPane;
import com.fr.design.mainframe.DecodeDialog;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.ElementCaseThumbnail;
import com.fr.design.mainframe.FormHierarchyTreePane;
import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.actions.NewFormAction;
@ -79,20 +59,13 @@ import com.fr.design.module.DesignModuleFactory;
import com.fr.design.parameter.FormParameterReader;
import com.fr.design.parameter.ParameterPropertyPane;
import com.fr.design.parameter.WorkBookParameterReader;
import com.fr.design.utils.gui.GUICoreUtils;
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.form.ui.ChartEditor;
import com.fr.form.ui.WidgetInfoConfig;
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.js.EmailJavaScript;
import com.fr.js.JavaScriptImpl;
import com.fr.js.ParameterJavaScript;
@ -100,9 +73,6 @@ import com.fr.js.ReportletHyperlink;
import com.fr.js.WebHyperlink;
import com.fr.locale.InterMutableKey;
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.module.Activator;
import com.fr.module.extension.Prepare;
import com.fr.plugin.chart.vanchart.imgevent.design.DesignImageEvent;
@ -124,17 +94,13 @@ 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.Constants;
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.plugin.ExtraChartDesignClassManagerProvider;
import com.fr.stable.plugin.ExtraDesignClassManagerProvider;
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;
@ -142,18 +108,9 @@ import com.fr.van.chart.DownloadOnlineSourcesHelper;
import com.fr.van.chart.map.server.ChartMapEditorAction;
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.*;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
@ -166,34 +123,16 @@ import static com.fr.stable.module.Module.ENGINE_MODULE;
* 触发原来的DesignerModule的启动
* 之后慢慢将DesignerModule拆成Activator
*/
public class DesignerModuleActivator extends Activator implements Prepare {
static {
ServletContext.addServletContextListener(new ServletContextAdapter() {
@Override
public void onServletStart() {
designerModuleStart();
}
});
}
public class DesignerActivator extends Activator implements Prepare {
@Override
public void start() {
designerModuleStart();
preLoadPane();
}
private static void designerModuleStart() {
if (com.fr.module.ModuleContext.getModule(DesignerModuleActivator.class).isRunning()) {
return;
}
App<?>[] apps = apps4TemplateOpener();
for (App<?> app : apps) {
DesignerFrame.registApp(app);
}
StableFactory.registerMarkedClass(ExtraDesignClassManagerProvider.XML_TAG, ExtraDesignClassManager.class);
ActionFactory.registerCellInsertActionClass(actionsForInsertCellElement());
ActionFactory.registerFloatInsertActionClass(actionsForInsertFloatElement());
@ -213,9 +152,6 @@ public class DesignerModuleActivator extends Activator implements Prepare {
ExtraDesignClassManager.getInstance().getFeedback().didFeedback();
StableFactory.registerMarkedObject(LogProvider.MARK_STRING, DesignerLogImpl.getInstance());
preLoadPane();
}
private static void preLoadPane() {
ExecutorService service = Executors.newCachedThreadPool();
@ -312,7 +248,6 @@ public class DesignerModuleActivator extends Activator implements Prepare {
}
private static void justStartModules4Designer() {
chartDesignerRegister();
formDesignerRegister();
}
@ -370,263 +305,6 @@ public class DesignerModuleActivator extends Activator implements Prepare {
});
}
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() {
}
}
/*
* 返回设计器能打开的模板类型的一个数组列表
* @return 可以打开的模板类型的数组
*/
private static App[] apps4TemplateOpener() {
return new App[]{getCptxApp(), getCptApp(), getXlsApp(), getXlsxApp(), getFrmApp()};
}
private static 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 static AbstractAppProvider getFrmApp() {
return 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;
}
};
}
private static 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 static 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 static 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);
}
private static void designerRegister() {
registerCellEditor();
registerFloatEditor();
@ -688,30 +366,6 @@ public class DesignerModuleActivator extends Activator implements Prepare {
DesignModuleFactory.registerParameterReader(new WorkBookParameterReader());
}
private static void chartDesignerRegister() {
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());
}
private static void formDesignerRegister() {

11
designer-realize/src/com/fr/start/module/EnvBasedModule.java

@ -1,8 +1,6 @@
package com.fr.start.module;
import com.fr.chart.activator.ChartBaseActivator;
import com.fr.module.Activator;
import com.fr.stable.CoreActivator;
import com.fr.start.server.FineEmbedServer;
/**
@ -13,20 +11,11 @@ public class EnvBasedModule extends Activator {
@Override
public void start() {
//core和设计器启动
startSub(CoreActivator.class);
startSub(ChartBaseActivator.class);
getSub("designer").start();
//这里不启动tomcat,由客户手动触发
}
@Override
public void stop() {
//先关闭tomcat(如果已经启动了的话)
FineEmbedServer.stop();
//倒叙关闭其他模块
getSub("designer").stop();
stopSub(ChartBaseActivator.class);
stopSub(CoreActivator.class);
}
}

Loading…
Cancel
Save