diff --git a/designer-base/src/com/fr/design/actions/file/WebPreviewUtils.java b/designer-base/src/com/fr/design/actions/file/WebPreviewUtils.java index 4dd6e412d..947fc67f6 100644 --- a/designer-base/src/com/fr/design/actions/file/WebPreviewUtils.java +++ b/designer-base/src/com/fr/design/actions/file/WebPreviewUtils.java @@ -20,7 +20,7 @@ import java.util.Map; public final class WebPreviewUtils { public static void preview(JTemplate jt) { - preview(jt, null); + preview(jt, jt.getPreviewType()); } @SuppressWarnings("unchecked") diff --git a/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index c5666b81f..e7e3ef820 100644 --- a/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -36,6 +36,7 @@ public abstract class DatabaseConnectionPane { FRContext.getLogger().error(e.getMessage(), e); } if (in == null) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Datasource-Connection_failed")); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Datasource-Connection_failed"), + null, 0, UIManager.getIcon("OptionPane.errorIcon")); } else { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Datasource-Connection_successfully")); try { diff --git a/designer-base/src/com/fr/design/hyperlink/WebHyperNorthPane.java b/designer-base/src/com/fr/design/hyperlink/WebHyperNorthPane.java index 925be16ef..91608d1ce 100644 --- a/designer-base/src/com/fr/design/hyperlink/WebHyperNorthPane.java +++ b/designer-base/src/com/fr/design/hyperlink/WebHyperNorthPane.java @@ -24,7 +24,7 @@ import java.awt.BorderLayout; public class WebHyperNorthPane extends AbstractHyperNorthPane { private UITextField itemNameTextField; private boolean needRenamePane = false; - private UITextArea urlTextField; + private UITextField urlTextField; public WebHyperNorthPane(boolean needRenamePane) { this.needRenamePane = needRenamePane; @@ -48,7 +48,7 @@ public class WebHyperNorthPane extends AbstractHyperNorthPane { protected JPanel setHeaderPanel() { JPanel headerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); - urlTextField = new UITextArea(1,headerPane.getWidth()); + urlTextField = new UITextField(headerPane.getWidth()); urlTextField.setText(ProductConstants.WEBSITE_URL); JPanel urlWithHelp = GUICoreUtils.createNamedPane(urlTextField, "URL:"); diff --git a/designer-base/src/com/fr/design/mainframe/TemplatePane.java b/designer-base/src/com/fr/design/mainframe/TemplatePane.java index fc165928b..4107a0538 100644 --- a/designer-base/src/com/fr/design/mainframe/TemplatePane.java +++ b/designer-base/src/com/fr/design/mainframe/TemplatePane.java @@ -137,7 +137,8 @@ public class TemplatePane extends JPanel implements MouseListener { @Override public void fail() { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}), + null, 0, UIManager.getIcon("OptionPane.errorIcon")); } @Override @@ -152,7 +153,8 @@ public class TemplatePane extends JPanel implements MouseListener { } setJLabel(selectedName); } catch (Exception e) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}), + null, 0, UIManager.getIcon("OptionPane.errorIcon")); return false; } TemplateTreePane.getInstance().refreshDockingView(); diff --git a/designer-base/src/com/fr/env/RemoteEnvPane.java b/designer-base/src/com/fr/env/RemoteEnvPane.java index 137db5ff6..a07e9996c 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane.java @@ -64,7 +64,7 @@ public class RemoteEnvPane extends BasicBeanPane { private UILabel message = new UILabel(); private UIButton okButton = new UIButton(Inter.getLocText("OK")); private UIButton cancelButton = new UIButton(Inter.getLocText("Cancel")); - ; + private UILabel uiLabel = new UILabel(); /** * 是否启用 https 勾选框 @@ -477,6 +477,7 @@ public class RemoteEnvPane extends BasicBeanPane { protected Boolean doInBackground() throws Exception { final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); + return WorkContext.getConnector().testConnection(remoteEnv.getConnection()); } @@ -486,11 +487,14 @@ public class RemoteEnvPane extends BasicBeanPane { try { if (get()) { message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); + uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon")); } else { message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); + uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); } } catch (InterruptedException | ExecutionException e) { message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); + uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); } } }; @@ -530,7 +534,7 @@ public class RemoteEnvPane extends BasicBeanPane { JPanel jp = new JPanel(); JPanel upPane = new JPanel(); JPanel downPane = new JPanel(); - UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon")); + uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon")); upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); upPane.add(uiLabel); upPane.add(message); diff --git a/designer-base/src/com/fr/start/server/FineEmbedServerActivator.java b/designer-base/src/com/fr/start/server/FineEmbedServerActivator.java index 61fd249cb..1d76fd3fe 100644 --- a/designer-base/src/com/fr/start/server/FineEmbedServerActivator.java +++ b/designer-base/src/com/fr/start/server/FineEmbedServerActivator.java @@ -5,6 +5,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; import com.fr.module.ModuleRole; +import com.fr.stable.EncodeConstants; import com.fr.startup.FineWebApplicationInitializer; import com.fr.third.springframework.web.SpringServletContainerInitializer; import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext; @@ -12,6 +13,7 @@ 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.startup.Tomcat; @@ -55,6 +57,8 @@ public class FineEmbedServerActivator extends Activator { tomcat = new Tomcat(); tomcat.setPort(DesignerEnvManager.getEnvManager().getEmbedServerPort()); + // 设置解码uri使用的字符编码 + tomcat.getConnector().setURIEncoding(EncodeConstants.ENCODING_UTF_8); String docBase = new File(WorkContext.getCurrent().getPath()).getParent(); String appName = "/" + FRContext.getCommonOperator().getAppName(); Context context = tomcat.addContext(appName, docBase); diff --git a/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java index 0122fc971..b66add8e6 100644 --- a/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -248,10 +248,10 @@ public class XWAbsoluteLayout extends XLayoutContainer { for (int i = 0; i < this.getComponentCount(); i++) { XCreator creator = getXCreator(i); Rectangle rec = new Rectangle(creator.getBounds()); - rec.x = (int) (rec.x / prevContainerPercent * containerPercent); - rec.y = (int) (rec.y / prevContainerPercent * containerPercent); - rec.height = (int) (rec.height / prevContainerPercent * containerPercent); - rec.width = (int) (rec.width / prevContainerPercent * containerPercent); + rec.x = (int)Math.round (rec.x / prevContainerPercent * containerPercent); + rec.y = (int)Math.round (rec.y / prevContainerPercent * containerPercent); + rec.height = (int)Math.round (rec.height / prevContainerPercent * containerPercent); + rec.width = (int)Math.round (rec.width / prevContainerPercent * containerPercent); BoundsWidget wgt = (BoundsWidget) toData().getBoundsWidget(creator.toData()); wgt.setBounds(rec); creator.setBounds(rec); diff --git a/designer-realize/src/com/fr/design/actions/file/export/AbstractExportAction.java b/designer-realize/src/com/fr/design/actions/file/export/AbstractExportAction.java index 526a80152..22059c35c 100644 --- a/designer-realize/src/com/fr/design/actions/file/export/AbstractExportAction.java +++ b/designer-realize/src/com/fr/design/actions/file/export/AbstractExportAction.java @@ -3,6 +3,7 @@ */ package com.fr.design.actions.file.export; +import com.fr.Message.ErrorMessage_; import com.fr.base.FRContext; import com.fr.base.Parameter; import com.fr.design.actions.JWorkBookAction; @@ -133,7 +134,8 @@ public abstract class AbstractExportAction extends JWorkBookAction { } catch (Exception exp) { this.setProgress(100); FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Export_failed") + "\n" + filePath); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Export_failed") + "\n" + filePath, + null, 0, UIManager.getIcon("OptionPane.errorIcon")); } return null; } diff --git a/designer-realize/src/com/fr/poly/PolyDesignUI.java b/designer-realize/src/com/fr/poly/PolyDesignUI.java index f63252fd4..7b98269ea 100644 --- a/designer-realize/src/com/fr/poly/PolyDesignUI.java +++ b/designer-realize/src/com/fr/poly/PolyDesignUI.java @@ -3,30 +3,23 @@ */ package com.fr.poly; -import java.awt.*; -import java.awt.geom.Rectangle2D; -import java.awt.image.BufferedImage; -import java.text.DecimalFormat; -import java.util.ArrayList; - -import javax.swing.JComponent; -import javax.swing.JScrollBar; -import javax.swing.plaf.ComponentUI; - import com.fr.base.GraphHelper; import com.fr.base.Margin; import com.fr.base.PaperSize; import com.fr.base.ScreenResolution; +import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.design.utils.ComponentUtils; import com.fr.general.Background; +import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import com.fr.main.FineBook; import com.fr.page.PaperSettingProvider; import com.fr.page.ReportSettingsProvider; +import com.fr.page.WatermarkPainter; import com.fr.poly.creator.BlockCreator; -import com.fr.poly.creator.ECBlockCreator; -import com.fr.poly.creator.ECBlockEditor; import com.fr.poly.model.AddedData; import com.fr.poly.model.AddingData; +import com.fr.report.core.ReportUtils; import com.fr.report.report.Report; import com.fr.report.report.TemplateReport; import com.fr.report.stable.ReportConstants; @@ -34,6 +27,21 @@ import com.fr.stable.Constants; import com.fr.stable.CoreGraphHelper; import com.fr.stable.unit.UNIT; +import javax.swing.JComponent; +import javax.swing.JScrollBar; +import javax.swing.plaf.ComponentUI; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.text.DecimalFormat; +import java.util.ArrayList; + /** * @author richer * @since 6.5.3 聚合报表设计块的ui类 @@ -48,6 +56,7 @@ public class PolyDesignUI extends ComponentUI { private PolyDesigner designer; private int resolution; private float time; + private WatermarkPainter watermarkPainter; public PolyDesignUI(int resolution) { if (resolution == 0){ @@ -97,6 +106,18 @@ public class PolyDesignUI extends ComponentUI { paintAddingData(g2d, addData); } paintPaginateLine(g2d); + paintWatermark(g2d, designer.getTarget().getBook(), c.getWidth(), c.getHeight()); + } + + // 绘制水印 + private void paintWatermark(Graphics2D g2d, FineBook book, int width, int height) { + WatermarkAttr watermark = ReportUtils.getWatermarkFromAttrMarkFile(book); + + // 不要每次都 new 一个 WatermarkPainter + if (watermarkPainter == null || !ComparatorUtils.equals(watermarkPainter.getWatermark(), watermark)) { + watermarkPainter = new WatermarkPainter(watermark); + } + watermarkPainter.paint(g2d, width, height); } private void paintAddedData(Graphics g) { diff --git a/designer-realize/src/com/fr/start/Designer.java b/designer-realize/src/com/fr/start/Designer.java index f164dcfa9..cc17dd692 100644 --- a/designer-realize/src/com/fr/start/Designer.java +++ b/designer-realize/src/com/fr/start/Designer.java @@ -35,6 +35,9 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; 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,6 +100,12 @@ public class Designer extends BaseDesigner { BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); preloadResource(); SplashContext.getInstance().registerSplash(createSplash()); + + // 如果端口被占用了 说明程序已经运行了一次,也就是说,已经建立一个监听服务器,现在只要给服务器发送命令就好了 + if (DesignUtils.isStarted()) { + DesignUtils.clientSend(args); + return; + } SplashContext.getInstance().show(); Module designerRoot = ModuleContext.parseRoot("designer-startup.xml"); //传递启动参数 diff --git a/designer-realize/src/com/fr/start/fx/FastGifImage.java b/designer-realize/src/com/fr/start/fx/FastGifImage.java index 9049850c3..69d74c8a4 100644 --- a/designer-realize/src/com/fr/start/fx/FastGifImage.java +++ b/designer-realize/src/com/fr/start/fx/FastGifImage.java @@ -97,17 +97,7 @@ public class FastGifImage extends WritableImage { } } - - private void finishImage(Exception e) { - e.printStackTrace(); - } - private void finishImage(ImageLoader loader) { - final Exception loadingException = loader.getException(); - if (loadingException != null) { - finishImage(loadingException); - return; - } initializeAnimatedImage(loader); } diff --git a/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java b/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java index a6dc7b6fb..e544fb0ce 100644 --- a/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java +++ b/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java @@ -48,6 +48,7 @@ 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.ChartPropertyPane; @@ -77,6 +78,7 @@ 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.general.ComparatorUtils; @@ -117,6 +119,7 @@ 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; @@ -134,16 +137,14 @@ 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 javax.swing.*; +import java.awt.*; 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.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -348,7 +349,8 @@ public class DesignerModuleActivator extends Activator implements Prepare { * @return 可以打开的模板类型的数组 */ private static App[] apps4TemplateOpener() { - return new App[]{getCptxApp(), getCptApp(), getXlsApp(), getXlsxApp()}; + + return new App[]{getCptxApp(), getCptApp(), getXlsApp(), getXlsxApp(), getFrmApp()}; } private static AbstractWorkBookApp getXlsxApp() { @@ -370,6 +372,57 @@ public class DesignerModuleActivator extends Activator implements Prepare { } }; } + + + private static AbstractAppProvider getFrmApp() { + + return new AbstractAppProvider
() { + + @Override + public String[] defaultExtensions() { + + return new String[]{"frm", "form"}; + } + + @Override + public JTemplate openTemplate(FILE tplFile) { + + HashMap classType = new HashMap(); + classType.put(Constants.ARG_0, Form.class); + classType.put(Constants.ARG_1, FILE.class); + + return (JTemplate) 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() { diff --git a/designer-realize/src/com/fr/start/module/EnvBasedModule.java b/designer-realize/src/com/fr/start/module/EnvBasedModule.java index 286fbe663..25ca8faae 100644 --- a/designer-realize/src/com/fr/start/module/EnvBasedModule.java +++ b/designer-realize/src/com/fr/start/module/EnvBasedModule.java @@ -1,5 +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; @@ -14,6 +15,7 @@ public class EnvBasedModule extends Activator { public void start() { //core和设计器启动 startSub(CoreActivator.class); + startSub(ChartBaseActivator.class); getSub("designer").start(); //这里不启动tomcat,由客户手动触发 } @@ -24,6 +26,7 @@ public class EnvBasedModule extends Activator { FineEmbedServer.stop(); //倒叙关闭其他模块 getSub("designer").stop(); + stopSub(ChartBaseActivator.class); stopSub(CoreActivator.class); } } diff --git a/designer-realize/src/com/fr/start/module/PreStartActivator.java b/designer-realize/src/com/fr/start/module/PreStartActivator.java index 85a9ff2ee..36a993bff 100644 --- a/designer-realize/src/com/fr/start/module/PreStartActivator.java +++ b/designer-realize/src/com/fr/start/module/PreStartActivator.java @@ -38,11 +38,7 @@ public class PreStartActivator extends Activator { } else { DesignUtils.setPort(getStartPort()); } - // 如果端口被占用了 说明程序已经运行了一次,也就是说,已经建立一个监听服务器,现在只要给服务器发送命令就好了 - if (DesignUtils.isStarted()) { - DesignUtils.clientSend(getModule().upFindSingleton(StartupArgs.class).get()); - return true; - } + return false; }