diff --git a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java index 3fc3f1d72b..4974e53e4a 100644 --- a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -43,18 +43,22 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C private JTemplate editingTemplate; private FileToolbarStateChangeListener toobarStateChangeListener; - private static HistoryTemplateListPane THIS; + private static volatile HistoryTemplateListPane THIS; private UIList list; public static final HistoryTemplateListPane getInstance() { if (THIS == null) { - THIS = new HistoryTemplateListPane(); + synchronized (HistoryTemplateListPane.class) { + if (THIS == null) { + THIS = new HistoryTemplateListPane(); + } + } } return THIS; } - public HistoryTemplateListPane() { + private HistoryTemplateListPane() { setLayout(new BorderLayout()); historyList = new ArrayList>(); list = new UIList(new HistoryListDataMode()) { diff --git a/designer-base/src/com/fr/design/gui/iprogressbar/ProgressDialog.java b/designer-base/src/com/fr/design/gui/iprogressbar/ProgressDialog.java index dab3a2e023..f5a1c3c775 100644 --- a/designer-base/src/com/fr/design/gui/iprogressbar/ProgressDialog.java +++ b/designer-base/src/com/fr/design/gui/iprogressbar/ProgressDialog.java @@ -52,6 +52,7 @@ public class ProgressDialog extends UIDialog { FRFont font = FRFont.getInstance().applySize(14).applyForeground(new ColorUIResource(333334)); text.setFont(font); panel.add(text, BorderLayout.SOUTH); + panel.setVisible(true); centerDialog.getContentPane().add(panel); } @@ -63,9 +64,8 @@ public class ProgressDialog extends UIDialog { @Override public void setVisible(boolean b) { - super.setVisible(b); centerDialog.setVisible(b); - centerDialog.setResizable(false); + super.setVisible(b); } public void setProgressValue(int value) { diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index c35e7e3591..fddf359c53 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -53,7 +53,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt private static final String FILE = "file"; - private static DesignerFrameFileDealerPane THIS; + private static volatile DesignerFrameFileDealerPane THIS; private CardLayout card; @@ -81,11 +81,15 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt selectedOperation.refresh(); } - + public static final DesignerFrameFileDealerPane getInstance() { - + if (THIS == null) { - THIS = new DesignerFrameFileDealerPane(); + synchronized (DesignerFrameFileDealerPane.class) { + if (THIS == null) { + THIS = new DesignerFrameFileDealerPane(); + } + } } return THIS; } diff --git a/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java index ef8729ddc3..0adf8785cd 100644 --- a/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -30,7 +30,7 @@ import java.util.Map; import java.util.Set; public class EastRegionContainerPane extends UIEastResizableContainer { - private static EastRegionContainerPane THIS; + private static volatile EastRegionContainerPane THIS; private Map propertyItemMap; private CardLayout propertyCard; private JPanel leftPane; @@ -84,13 +84,17 @@ public class EastRegionContainerPane extends UIEastResizableContainer { */ public static EastRegionContainerPane getInstance() { if (THIS == null) { - THIS = new EastRegionContainerPane(); - THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastEastRegionContainerWidth()); + synchronized (EastRegionContainerPane.class) { + if (THIS == null) { + THIS = new EastRegionContainerPane(); + THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastEastRegionContainerWidth()); + } + } } return THIS; } - public EastRegionContainerPane() { + private EastRegionContainerPane() { super(); initPropertyItemList(); defaultPane = getDefaultPane(Inter.getLocText("FR-Designer_No_Settings_Available")); diff --git a/designer-base/src/com/fr/design/mainframe/loghandler/LogMessageBar.java b/designer-base/src/com/fr/design/mainframe/loghandler/LogMessageBar.java index 71a7a7e642..8f6034f776 100644 --- a/designer-base/src/com/fr/design/mainframe/loghandler/LogMessageBar.java +++ b/designer-base/src/com/fr/design/mainframe/loghandler/LogMessageBar.java @@ -1,27 +1,29 @@ package com.fr.design.mainframe.loghandler; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import javax.swing.JFrame; - import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.general.Inter; +import javax.swing.JFrame; import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; public class LogMessageBar extends JPanel { private UILabel messageLabel; private int width = 600; - public static LogMessageBar THIS; + public static volatile LogMessageBar THIS; private JFrame dlg = new LogDetailPane().showDialog(); public static LogMessageBar getInstance() { if (THIS == null) { - THIS = new LogMessageBar(); + synchronized (LogMessageBar.class) { + if (THIS == null) { + THIS = new LogMessageBar(); + } + } } return THIS; } @@ -32,7 +34,7 @@ public class LogMessageBar extends JPanel { return bar; } - public LogMessageBar() { + private LogMessageBar() { messageLabel = new UILabel(); setLayout(new BorderLayout()); add(messageLabel, BorderLayout.CENTER); diff --git a/designer-base/src/com/fr/start/BaseDesigner.java b/designer-base/src/com/fr/start/BaseDesigner.java index 1e15cbff55..87d87e7ba4 100644 --- a/designer-base/src/com/fr/start/BaseDesigner.java +++ b/designer-base/src/com/fr/start/BaseDesigner.java @@ -11,9 +11,6 @@ import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerStartOpenFileProcessor; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; -import com.fr.design.mainframe.EastRegionContainerPane; -import com.fr.design.mainframe.WestRegionContainerPane; -import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.utils.DesignUtils; import com.fr.event.EventDispatcher; @@ -29,8 +26,6 @@ import com.fr.stable.OperatingSystem; import java.awt.Window; import java.io.File; import java.lang.reflect.Method; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; /** * The main class of Report Designer. @@ -49,44 +44,11 @@ public abstract class BaseDesigner extends ToolBarMenuDock { EventDispatcher.fire(ModuleEvent.MajorModuleStarting, InterProviderFactory.getProvider().getLocText("FR-Designer_Initializing")); // 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到 DesignUtils.initLookAndFeel(); - // 预加载一些耗时的单例面板 - preLoadPane(); - // 初始化Log Handler DesignerEnvManager.loadLogSetting(); createDesignerFrame(); } - private void preLoadPane() { - ExecutorService service = Executors.newCachedThreadPool(); - service.submit(new Runnable() { - @Override - public void run() { - LogMessageBar.getInstance(); - } - }); - - service.submit(new Runnable() { - @Override - public void run() { - HistoryTemplateListPane.getInstance(); - } - }); - service.submit(new Runnable() { - @Override - public void run() { - WestRegionContainerPane.getInstance(); - } - }); - service.submit(new Runnable() { - @Override - public void run() { - EastRegionContainerPane.getInstance(); - } - }); - service.shutdown(); - } - public void show(final String[] args) { collectUserInformation(); DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(10); diff --git a/designer-realize/src/com/fr/design/mainframe/CellElementPropertyPane.java b/designer-realize/src/com/fr/design/mainframe/CellElementPropertyPane.java index 68b1134f7b..f87ff4a838 100644 --- a/designer-realize/src/com/fr/design/mainframe/CellElementPropertyPane.java +++ b/designer-realize/src/com/fr/design/mainframe/CellElementPropertyPane.java @@ -65,16 +65,20 @@ public class CellElementPropertyPane extends DockingView { } }); } - - + + public synchronized static CellElementPropertyPane getInstance() { if (singleton == null) { - singleton = new CellElementPropertyPane(); + synchronized (CellElementPropertyPane.class) { + if (singleton == null) { + singleton = new CellElementPropertyPane(); + } + } } return singleton; } - private static CellElementPropertyPane singleton; + private static volatile CellElementPropertyPane singleton; private CellElementEditPane cellElementEditPane; diff --git a/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java b/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java index e544fb0ce4..ecde873db6 100644 --- a/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java +++ b/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java @@ -51,9 +51,12 @@ 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; @@ -69,6 +72,7 @@ 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.mainframe.loghandler.LogMessageBar; import com.fr.design.module.ChartHyperlinkGroup; import com.fr.design.module.ChartPreStyleAction; import com.fr.design.module.DesignModuleFactory; @@ -81,6 +85,7 @@ 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; @@ -137,8 +142,11 @@ import com.fr.van.chart.DownloadOnlineSourcesHelper; import com.fr.van.chart.map.server.ChartMapEditorAction; import com.fr.xml.ReportXMLUtils; -import javax.swing.*; -import java.awt.*; +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; @@ -148,6 +156,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import static com.fr.stable.module.Module.ENGINE_MODULE; @@ -204,6 +214,50 @@ 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(); + service.submit(new Runnable() { + @Override + public void run() { + LogMessageBar.getInstance(); + } + }); + + service.submit(new Runnable() { + @Override + public void run() { + HistoryTemplateListPane.getInstance(); + } + }); + service.submit(new Runnable() { + @Override + public void run() { + WidgetInfoConfig.getInstance(); + } + }); + service.submit(new Runnable() { + @Override + public void run() { + CellElementPropertyPane.getInstance(); + } + }); + service.submit(new Runnable() { + @Override + public void run() { + DesignerFrameFileDealerPane.getInstance();//这边会涉及到TemplateTreePane + } + }); + + service.submit(new Runnable() { + @Override + public void run() { + EastRegionContainerPane.getInstance(); + } + }); + service.shutdown(); } private static Class[] actionsForInsertCellElement() { diff --git a/designer-realize/src/com/fr/start/module/DesignerStartup.java b/designer-realize/src/com/fr/start/module/DesignerStartup.java index 2b0fe4335f..1936451f26 100644 --- a/designer-realize/src/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/com/fr/start/module/DesignerStartup.java @@ -1,15 +1,11 @@ package com.fr.start.module; -import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.event.Event; import com.fr.event.Listener; -import com.fr.form.ui.WidgetInfoConfig; import com.fr.module.Activator; import com.fr.start.Designer; import com.fr.start.EnvSwitcher; -import com.fr.start.ServerStarter; import com.fr.start.SplashContext; import com.fr.startup.activators.BasicActivator; import com.fr.workspace.Workspace; @@ -30,12 +26,12 @@ public class DesignerStartup extends Activator { startSub(BasicActivator.class); final String[] args = getModule().upFindSingleton(StartupArgs.class).get(); final Designer designer = new Designer(args); - preLoadSomething(); //启动env startSub(DesignerWorkspaceProvider.class); startSub(EnvBasedModule.class); getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); ExecutorService service = Executors.newSingleThreadExecutor(); + registerEnvListener(); service.submit(new Runnable() { @Override public void run() { @@ -44,7 +40,6 @@ public class DesignerStartup extends Activator { } }); service.shutdown(); - registerEnvListener(); DesignerContext.getDesignerFrame().setVisible(true); //启动画面结束 SplashContext.getInstance().hide(); @@ -53,32 +48,6 @@ public class DesignerStartup extends Activator { startSub(StartFinishActivator.class); } - /** - * 基础模块结束后可以提前加载一部分依赖基础模块(国际化,图标样式之类)的东西 - */ - private void preLoadSomething(){ - ExecutorService service = Executors.newCachedThreadPool(); - service.submit(new Runnable() { - @Override - public void run() { - CellElementPropertyPane.getInstance(); - } - }); - service.submit(new Runnable() { - @Override - public void run() { - DesignerFrameFileDealerPane.getInstance();//这边会涉及到TemplateTreePane - } - }); - service.submit(new Runnable() { - @Override - public void run() { - WidgetInfoConfig.getInstance(); - } - }); - service.shutdown(); - } - /** * 切换环境时,重新启动所有相关模块 */