From 1261ddbaba46fe68b6d438ede2b5c57151ead7e8 Mon Sep 17 00:00:00 2001 From: vito Date: Mon, 1 Jul 2019 20:20:19 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-16346=20=E4=BC=98=E5=8C=96=E4=B8=80?= =?UTF-8?q?=E4=BA=9BUI=E4=B8=8A=E7=AA=81=E5=87=BA=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=87=8D=E5=A4=8D=E5=88=9B=E5=BB=BA=E7=9A=84=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/DesignState.java | 2 - .../actions/community/QuestionAction.java | 65 ++++++----- .../gui/iprogressbar/ProgressDialog.java | 20 ++-- .../fr/design/mainframe/DesignerFrame.java | 104 +++++++++++------- .../DesignerFrameFileDealerPane.java | 10 +- .../mainframe/toolbar/ToolBarMenuDock.java | 39 +++++-- .../mainframe/toolbar/UpdateActionModel.java | 19 +++- .../main/java/com/fr/start/BaseDesigner.java | 73 ++++++++---- .../start/server/FineEmbedServerMonitor.java | 56 +++++----- .../com/fr/design/mainframe/FormArea.java | 2 +- .../fr/design/mainframe/ElementCasePane.java | 22 ++-- .../com/fr/design/mainframe/JWorkBook.java | 1 - .../errorinfo/ErrorInfoUploader.java | 9 +- .../src/main/java/com/fr/start/Designer.java | 20 ++-- .../com/fr/start/module/DesignerStartup.java | 2 - .../module/DesignerWorkspaceActivator.java | 2 - 16 files changed, 271 insertions(+), 175 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignState.java b/designer-base/src/main/java/com/fr/design/DesignState.java index fcc971b7e..239093d3f 100644 --- a/designer-base/src/main/java/com/fr/design/DesignState.java +++ b/designer-base/src/main/java/com/fr/design/DesignState.java @@ -1,9 +1,7 @@ package com.fr.design; -import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; -import com.fr.workspace.WorkContext; /** * Created by IntelliJ IDEA. diff --git a/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java b/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java index 717537df6..9a19ef4cc 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java @@ -10,38 +10,37 @@ import javax.swing.*; import java.awt.event.ActionEvent; -public class QuestionAction extends UpdateAction -{ - - public QuestionAction() - { this.setMenuKeySet(QUESTIONS); - this.setName(getMenuKeySet().getMenuName()); - this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/question.png")); - -} - -@Override -public void actionPerformed(ActionEvent arg0) -{ - String url = CloudCenter.getInstance().acquireUrlByKind("bbs.questions"); - BrowseUtils.browser(url); -} - public static final MenuKeySet QUESTIONS = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'Q'; - } - - @Override - public String getMenuName() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Questions"); - } - - @Override - public KeyStroke getKeyStroke() { - return null; - } - }; +public class QuestionAction extends UpdateAction { + + public QuestionAction() { + this.setMenuKeySet(QUESTIONS); + this.setName(getMenuKeySet().getMenuName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/question.png")); + + } + + @Override + public void actionPerformed(ActionEvent arg0) { + String url = CloudCenter.getInstance().acquireUrlByKind("bbs.questions"); + BrowseUtils.browser(url); + } + + public static final MenuKeySet QUESTIONS = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'Q'; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Questions"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; } diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java index 049b868c4..d684e6a57 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java @@ -1,12 +1,10 @@ package com.fr.design.gui.iprogressbar; import com.fr.design.constants.UIConstants; -import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ilable.UILabel; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; - import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; @@ -19,7 +17,7 @@ import java.awt.Frame; /** * 加载进度弹窗 */ -public class ProgressDialog extends UIDialog { +public class ProgressDialog extends JDialog { private JProgressBar progressBar; private JDialog centerDialog; private JLabel text; @@ -47,6 +45,7 @@ public class ProgressDialog extends UIDialog { progressBar.setBorderPainted(false); progressBar.setOpaque(false); progressBar.setBorder(null); + progressBar.setMaximum(1000); panel.add(progressBar, BorderLayout.CENTER); text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.CENTER); FRFont font = FRFont.getInstance().applySize(14).applyForeground(new ColorUIResource(333334)); @@ -54,12 +53,6 @@ public class ProgressDialog extends UIDialog { panel.add(text, BorderLayout.SOUTH); panel.setVisible(true); centerDialog.getContentPane().add(panel); - - } - - @Override - public void checkValid() throws Exception { - } @Override @@ -72,11 +65,20 @@ public class ProgressDialog extends UIDialog { progressBar.setValue(value); } + public void setProgressMaximum(int value) { + progressBar.setMaximum(value); + } + + public int getProgressMaximum() { + return progressBar.getMaximum(); + } + @Override public void dispose() { centerDialog.dispose(); super.dispose(); } + public void updateLoadingText(String text) { this.text.setText(text); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 277ca93eb..f8f513870 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -63,6 +63,7 @@ import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceConnectionInfo; +import org.jetbrains.annotations.Nullable; import javax.swing.Icon; import javax.swing.JComponent; @@ -169,6 +170,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private WindowAdapter windowAdapter = new WindowAdapter() { + @Override public void windowOpened(WindowEvent e) { } @@ -194,6 +196,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private JComponent closeButton = new JComponent() { + @Override protected void paintComponent(Graphics g) { g.setColor(UIConstants.NORMAL_BACKGROUND); @@ -205,6 +208,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private MouseListener closeMouseListener = new MouseAdapter() { + @Override public void mousePressed(MouseEvent e) { closeMode = UIConstants.CLOSE_PRESS_AUTHORITY; @@ -212,6 +216,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta closeButton.repaint(); } + @Override public void mouseExited(MouseEvent e) { closeMode = UIConstants.CLOSE_OF_AUTHORITY; @@ -219,6 +224,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta closeButton.repaint(); } + @Override public void mouseMoved(MouseEvent e) { closeMode = UIConstants.CLOSE_OVER_AUTHORITY; @@ -226,12 +232,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta closeButton.repaint(); } + @Override public void mouseReleased(MouseEvent e) { if (DesignModeContext.isAuthorityEditing()) { closeAuthorityEditing(); } } + @Override public void mouseEntered(MouseEvent e) { closeMode = UIConstants.CLOSE_OVER_AUTHORITY; @@ -255,6 +263,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta basePane.setLayout(new BorderLayout()); toolbarPane = new JPanel() { + @Override public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); @@ -266,7 +275,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta JPanel eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); eastPane.add(ad.createLargeToolbar(), BorderLayout.WEST); eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - eastCenterPane.add(combineUp = combineUpTooBar(null), BorderLayout.NORTH); + combineUpTooBar(); + eastCenterPane.add(combineUp, BorderLayout.NORTH); JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); panel.add(newWorkBookPane = ad.getNewTemplatePane(), BorderLayout.WEST); panel.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER); @@ -300,6 +310,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.addComponentListener(new ComponentAdapter() { + @Override public void componentResized(ComponentEvent e) { reCalculateFrameSize(); @@ -316,14 +327,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta initMenuPane(); this.progressDialog = new ProgressDialog(this); } - + public void resizeFrame() { - + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite(); reCalculateFrameSize(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize(); } - + public void closeAuthorityEditing() { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); WestRegionContainerPane.getInstance().replaceDownPane( @@ -333,7 +344,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus()); needToAddAuhtorityPaint(); refreshDottedLine(); - fireAuthorityStateToNomal(); + fireAuthorityStateToNormal(); EventDispatcher.fire(DesignAuthorityEventType.StopEdit, DesignerFrame.this); } @@ -603,13 +614,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta /** * 退出权限编辑时,将所有的做过权限编辑的状态,作为一个状态赋给报、报表主体 */ - private void fireAuthorityStateToNomal() { + private void fireAuthorityStateToNormal() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); - for (int i = 0; i < opendedTemplate.size(); i++) { + for (JTemplate jTemplate : opendedTemplate) { // 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 - if (opendedTemplate.get(i).isDoSomethingInAuthority()) { - opendedTemplate.get(i).fireAuthorityStateToNomal(); + if (jTemplate.isDoSomethingInAuthority()) { + jTemplate.fireAuthorityStateToNomal(); } } } @@ -619,31 +630,47 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.closeMode = closeMode; } - private UIToolbar combineUpTooBar(JComponent[] toolbar4Form) { - + /** + * 创建上工具栏 + */ + private void combineUpTooBar() { combineUp = new UIToolbar(FlowLayout.LEFT); combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2)); + setUpUpToolBar(null); + + } + + /** + * 重置上工具栏 + */ + private void resetCombineUpTooBar(JComponent[] toolbar4Form) { + combineUp.removeAll(); + setUpUpToolBar(toolbar4Form); + } + + /** + * 填充上工具栏的中的工具 + * + * @param toolbar4Form 目标组件 + */ + private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) { UIButton[] fixButtons = ad.createUp(); - for (int i = 0; i < fixButtons.length; i++) { - combineUp.add(fixButtons[i]); + for (UIButton fixButton : fixButtons) { + combineUp.add(fixButton); } if (!DesignerMode.isAuthorityEditing()) { combineUp.addSeparator(new Dimension(2, 16)); if (toolbar4Form != null) { - for (int i = 0; i < toolbar4Form.length; i++) { - combineUp.add(toolbar4Form[i]); + for (JComponent jComponent : toolbar4Form) { + combineUp.add(jComponent); } } } - //添加分享按钮 addShareButton(); - //添加插件中的按钮 addExtraButtons(); - - return combineUp; } private void addExtraButtons() { @@ -655,8 +682,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta UIButton[] extraButtons = jt.createExtraButtons(); - for (int i = 0; i < extraButtons.length; i++) { - combineUp.add(extraButtons[i]); + for (UIButton extraButton : extraButtons) { + combineUp.add(extraButton); } if (extraButtons.length > 0) { combineUp.addSeparator(new Dimension(2, 16)); @@ -672,8 +699,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta combineUp.addSeparator(new Dimension(2, 16)); UIButton[] shareButtons = jt.createShareButton(); - for (int i = 0; i < shareButtons.length; i++) { - combineUp.add(shareButtons[i]); + for (UIButton shareButton : shareButtons) { + combineUp.add(shareButton); } } @@ -710,25 +737,20 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta DesignState designState = new DesignState(plus); MenuManager.getInstance().setMenus4Designer(designState); - if (menuBar != null) { - menuPane.remove(menuBar); - } - menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); - - if (combineUp != null) { - eastCenterPane.remove(combineUp); - combineUp = null; + if (menuBar == null) { + menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); + } else { + ad.resetJMenuBar(menuBar, plus); } - // 保存撤销那些按钮的面板 - eastCenterPane.add(combineUp = combineUpTooBar(ad.resetUpToolBar(plus)), BorderLayout.NORTH); - - if (toolbarComponent != null) { - toolbarPane.remove(toolbarComponent); - } + resetCombineUpTooBar(ad.resetUpToolBar(plus)); // 颜色,字体那些按钮的工具栏 - toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); + if (toolbarComponent == null) { + toolbarPane.add(toolbarComponent = ad.resetToolBar(null, plus), BorderLayout.CENTER); + } else { + ad.resetToolBar(toolbarComponent, plus); + } this.checkToolbarMenuEnable(); this.validate(); @@ -751,7 +773,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); for (ShortCut shortCut : extraShortCuts) { if (shortCut instanceof AbstractTemplateTreeShortCutProvider) { - ((AbstractTemplateTreeShortCutProvider) shortCut).notifyFromAuhtorityChange(DesignerMode.isAuthorityEditing()); + shortCut.notifyFromAuhtorityChange(DesignerMode.isAuthorityEditing()); } } } @@ -949,6 +971,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * * @param e 事件 */ + @Override public void targetModified(TargetModifiedEvent e) { this.checkToolbarMenuEnable(); @@ -959,6 +982,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * * @param jt 模板 */ + @Override public void templateClosed(JTemplate jt) { } @@ -968,6 +992,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * * @param jt 模板 */ + @Override public void templateOpened(JTemplate jt) { } @@ -977,6 +1002,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * * @param jt 模板 */ + @Override public void templateSaved(JTemplate jt) { this.checkToolbarMenuEnable(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index b48433c5c..458a0ef75 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -210,15 +210,17 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt /** * 添加VcsAction + * * @param toolbarDef */ private void addVcsAction(ToolBarDef toolbarDef) { if (VcsHelper.getInstance().needInit()) { vcsAction = new VcsAction(); - if (FineClusterConfig.getInstance().isCluster()) { - vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote")); - } else { + + if (WorkContext.getCurrent().isLocal()) { vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title")); + } else { + vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote")); } toolbarDef.addShortCut(vcsAction); @@ -367,8 +369,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } - - if (WorkContext.getCurrent() != null) { if (!WorkContext.getCurrent().isLocal()) { //当前环境为远程环境时 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 8a739f54f..262dbe6d5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -47,20 +47,20 @@ import com.fr.design.gui.imenu.UIMenu; import com.fr.design.gui.imenu.UIMenuBar; import com.fr.design.gui.itoolbar.UILargeToolbar; import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.locale.impl.SupportLocaleImpl; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.ToolBarNewTemplatePane; import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; -import com.fr.design.update.actions.SoftwareUpdateAction; import com.fr.design.remote.action.RemoteDesignAuthManagerAction; +import com.fr.design.update.actions.SoftwareUpdateAction; import com.fr.design.utils.ThemeUtils; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.locale.LocaleAction; import com.fr.general.locale.LocaleCenter; -import com.fr.design.locale.impl.SupportLocaleImpl; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; @@ -72,6 +72,7 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; +import org.jetbrains.annotations.Nullable; import javax.swing.JComponent; import javax.swing.JMenuBar; @@ -197,14 +198,30 @@ public abstract class ToolBarMenuDock { */ public final JMenuBar createJMenuBar(ToolBarMenuDockPlus plus) { UIMenuBar jMenuBar = new UIMenuBar() { + private Dimension dim; + @Override public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.height = MENUBAR_HEIGHT; + if (dim == null) { + dim = super.getPreferredSize(); + dim.height = MENUBAR_HEIGHT; + } return dim; } }; + resetJMenuBar(jMenuBar, plus); + return jMenuBar; + } + + /** + * 重置菜单栏 + * + * @param jMenuBar 当前菜单栏 + * @param plus 对象 + */ + public final void resetJMenuBar(JMenuBar jMenuBar, ToolBarMenuDockPlus plus) { + jMenuBar.removeAll(); this.menus = menus(plus); try { OemProcessor oemProcessor = OemHandler.findOem(); @@ -218,13 +235,12 @@ public abstract class ToolBarMenuDock { FineLoggerFactory.getLogger().error(e.getMessage(), e); this.menus = menus(plus); } - for (int i = 0; i < menus.length; i++) { - menus[i].setHasRecMenu(true); - UIMenu subMenu = menus[i].createJMenu(); + for (MenuDef menu : menus) { + menu.setHasRecMenu(true); + UIMenu subMenu = menu.createJMenu(); jMenuBar.add(subMenu); - menus[i].updateMenu(); + menu.updateMenu(); } - return jMenuBar; } ////////////////////////////////////////////////////////////////////////////////////////// @@ -585,7 +601,7 @@ public abstract class ToolBarMenuDock { * @param plus 对象 * @return 工具栏 */ - public JComponent resetToolBar(JComponent toolbarComponent, ToolBarMenuDockPlus plus) { + public JComponent resetToolBar(@Nullable JComponent toolbarComponent, ToolBarMenuDockPlus plus) { ToolBarDef[] plusToolBarDefs = plus.toolbars4Target(); UIToolbar toolBar; if (toolbarComponent instanceof UIToolbar) { @@ -599,8 +615,7 @@ public abstract class ToolBarMenuDock { toolBarDef = new ToolBarDef(); if (plusToolBarDefs != null) { - for (int i = 0; i < plusToolBarDefs.length; i++) { - ToolBarDef def = plusToolBarDefs[i]; + for (ToolBarDef def : plusToolBarDefs) { for (int di = 0, dlen = def.getShortCutCount(); di < dlen; di++) { toolBarDef.addShortCut(def.getShortCut(di)); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionModel.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionModel.java index cb16c62ee..e3af1bcba 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionModel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionModel.java @@ -32,15 +32,22 @@ public class UpdateActionModel { * @param action */ private void setSearchKey(String parentName, UpdateAction action) { - StringBuffer buffer = new StringBuffer(); if (actionName == null) { return; } - buffer.append(parentName).append(SEPARATOR).append(PinyinHelper.convertToPinyinString(parentName, "", PinyinFormat.WITHOUT_TONE)) - .append(SEPARATOR).append(PinyinHelper.getShortPinyin(parentName)).append(SEPARATOR) - .append(actionName).append(SEPARATOR).append(PinyinHelper.convertToPinyinString(actionName, "", PinyinFormat.WITHOUT_TONE)) - .append(SEPARATOR).append(PinyinHelper.getShortPinyin(actionName)).append(action.getSearchText()); - this.searchKey = buffer.toString().toLowerCase(); + String buffer = parentName + + SEPARATOR + + PinyinHelper.convertToPinyinString(parentName, "", PinyinFormat.WITHOUT_TONE) + + SEPARATOR + + PinyinHelper.getShortPinyin(parentName) + + SEPARATOR + + actionName + + SEPARATOR + + PinyinHelper.convertToPinyinString(actionName, "", PinyinFormat.WITHOUT_TONE) + + SEPARATOR + + PinyinHelper.getShortPinyin(actionName) + + action.getSearchText(); + this.searchKey = buffer.toLowerCase(); } /** diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 05d41a1e7..7bd6fbbd2 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -5,24 +5,27 @@ package com.fr.start; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerStartOpenFileProcessor; -import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.utils.DesignUtils; +import com.fr.event.Event; import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.event.Null; import com.fr.file.FILE; import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; -import com.fr.module.ModuleEvent; import com.fr.stable.OperatingSystem; +import javax.swing.SwingUtilities; import java.awt.Window; import java.io.File; import java.lang.reflect.Method; @@ -31,17 +34,17 @@ import java.lang.reflect.Method; * The main class of Report Designer. */ public abstract class BaseDesigner extends ToolBarMenuDock { - + private static final int LOAD_TREE_MAXNUM = 10; - + private final String[] args; public BaseDesigner(String[] args) { - + this.args = args; init(); } - + private void init() { // 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到 DesignUtils.initLookAndFeel(); @@ -49,27 +52,60 @@ public abstract class BaseDesigner extends ToolBarMenuDock { DesignerEnvManager.loadLogSetting(); createDesignerFrame(); } - + public void show() { - collectUserInformation(); - showDesignerFrame(false); - + if (DesignerLaunchStatus.getStatus() == DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { + refreshTemplateTree(); + } else { + EventDispatcher.listen(DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE, new Listener() { + @Override + public void on(Event event, Null param) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + refreshTemplateTree(); + } + }); + } + }); + } + + EventDispatcher.listen(DesignerLaunchStatus.DESIGNER_INIT_COMPLETE, new Listener() { + @Override + public void on(Event event, Null param) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + // 打开上次的文件 + showDesignerFrame(false); + DesignerContext.getDesignerFrame().resizeFrame(); + EventDispatcher.asyncFire(DesignerLaunchStatus.OPEN_LAST_FILE_COMPLETE); + } + }); + } + }); + EventDispatcher.listen(DesignerLaunchStatus.OPEN_LAST_FILE_COMPLETE, new Listener() { + @Override + public void on(Event event, Null param) { + collectUserInformation(); + } + }); + // 启动界面 + DesignerContext.getDesignerFrame().setVisible(true); + } + + private void refreshTemplateTree() { //TODO: 2019-06-14 这里有啥作用? DesignerContext.getDesignerFrame().refreshEnv(); for (int i = 0; !TemplateTreePane.getInstance().getTemplateFileTree().isTemplateShowing() && i < LOAD_TREE_MAXNUM; i++) { TemplateTreePane.getInstance().getTemplateFileTree().refresh(); } - DesignerContext.getDesignerFrame().setVisible(true); - DesignerContext.getDesignerFrame().resizeFrame(); } - private void createDesignerFrame() { - new DesignerFrame(this); } - - + private void showDesignerFrame(boolean isException) { try { FILE file = null; @@ -94,8 +130,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } } } else { - file = FILEFactory.createFILE(FILEFactory.ENV_PREFIX - + DesignerEnvManager.getEnvManager().getLastOpenFile()); + file = FILEFactory.createFILE(FILEFactory.ENV_PREFIX + DesignerEnvManager.getEnvManager().getLastOpenFile()); } DesignerFrame df = DesignerContext.getDesignerFrame(); isException = openFile(df, isException, file); @@ -134,7 +169,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { df.getSelectedJTemplate().requestGridFocus(); return isException; } - + private void enableFullScreenMode(Window window) { String className = "com.apple.eawt.FullScreenUtilities"; String methodName = "setWindowCanFullScreen"; diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java index 5807773bf..fe0c8ea86 100644 --- a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java +++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java @@ -1,25 +1,32 @@ package com.fr.start.server; import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.gui.iprogressbar.ProgressDialog; import com.fr.design.mainframe.DesignerContext; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.event.Null; -import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * 内置服务器启动监视器 - * Created by zack on 2018/8/21. + * + * @author zack + * @date 2018/8/21 */ public class FineEmbedServerMonitor { private int progress; - private static final int COMPLETE = 100;//启动完成 - private static final int STEP = 5;//随便设置一个假的进度条 - private static final int STEP_HEARTBEAT = 2000;//2秒更新进度 + private static final int STEP = 1; + /** + * 40ms更新进度 + */ + private static final int STEP_HEARTBEAT = 40; private static volatile FineEmbedServerMonitor monitor; + private static ProgressDialog progressBar = DesignerContext.getDesignerFrame().getProgressDialog(); private FineEmbedServerMonitor() { } @@ -29,7 +36,7 @@ public class FineEmbedServerMonitor { @Override public void on(Event event, Null aNull) { getInstance().reset(); - DesignerContext.getDesignerFrame().hideProgressDialog(); + DesignerContext.getDesignerFrame().disposeProgressDialog(); } }); } @@ -46,7 +53,7 @@ public class FineEmbedServerMonitor { } public int getProgress() { - if (progress == COMPLETE) { + if (progress == progressBar.getProgressMaximum()) { return progress; } else { progress += STEP; @@ -55,7 +62,7 @@ public class FineEmbedServerMonitor { } public void setComplete() { - this.progress = COMPLETE; + this.progress = progressBar.getProgressMaximum(); } public void reset() { @@ -63,29 +70,28 @@ public class FineEmbedServerMonitor { } public boolean isComplete() { - return this.progress == COMPLETE; + return this.progress >= progressBar.getProgressMaximum(); } public void monitor() { - ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("FineEmbedServerMonitor")); - service.submit(new Runnable() { - + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, + new NamedThreadFactory("FineEmbedServerMonitor")); + scheduler.scheduleAtFixedRate(new Runnable() { @Override public void run() { - while (!isComplete()) { - if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) { - DesignerContext.getDesignerFrame().showProgressDialog(); - DesignerContext.getDesignerFrame().getProgressDialog().updateLoadingText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server")); - } - DesignerContext.getDesignerFrame().updateProgress(getProgress()); - try { - Thread.sleep(STEP_HEARTBEAT); - } catch (InterruptedException ignore) { - } + if (isComplete()) { + scheduler.shutdown(); + DesignerContext.getDesignerFrame().hideProgressDialog(); + return; + } + if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) { + DesignerContext.getDesignerFrame().showProgressDialog(); + DesignerContext.getDesignerFrame().getProgressDialog() + .updateLoadingText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server")); } - DesignerContext.getDesignerFrame().hideProgressDialog(); + DesignerContext.getDesignerFrame().updateProgress(getProgress()); } - }); - service.shutdown(); + }, 0, STEP_HEARTBEAT, TimeUnit.MILLISECONDS); + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java index b42d1b41e..048d342ee 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java @@ -188,7 +188,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { value = value > SHOWVALMAX ? SHOWVALMAX : value; value = value < SHOWVALMIN ? SHOWVALMIN : value; JForm jf = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - jf.resolution = (int) value; + jf.setResolution((int) value); jf.getFormDesign().setResolution((int) value); jf.getFormDesign().getArea().resolution = (int) value; reCalculateRoot(value, true); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java index b68a5f72e..a28156110 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java @@ -117,6 +117,7 @@ import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollBar; import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; import java.awt.AWTEvent; import java.awt.Adjustable; import java.awt.Dimension; @@ -527,7 +528,7 @@ public abstract class ElementCasePane extends Tar try { //旧选中内容编辑器释放模板对象 QuickEditor editor = this.getCurrentEditor(); - if(editor != null){ + if (editor != null) { editor.release(); } } catch (UnsupportedOperationException e) { @@ -853,15 +854,20 @@ public abstract class ElementCasePane extends Tar */ public void fireSelectionChangeListener() { // Guaranteed to return a non-null array - Object[] listeners = listenerList.getListenerList(); + final Object[] listeners = listenerList.getListenerList(); - // Process the listeners last to first, notifying - // those that are interested in this event - for (int i = listeners.length - 2; i >= 0; i -= 2) { - if (listeners[i] == SelectionListener.class) { - ((SelectionListener) listeners[i + 1]).selectionChanged(new SelectionEvent(this)); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == SelectionListener.class) { + ((SelectionListener) listeners[i + 1]).selectionChanged(new SelectionEvent(this)); + } + } } - } + }); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 6e72e98fe..009197eee 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -90,7 +90,6 @@ import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.poly.PolyWorkSheet; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ArrayUtils; -import com.fr.stable.CoreGraphHelper; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.module.Module; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java index 737d47044..e22e1059e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.errorinfo; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.mainframe.SiteCenterToken; import com.fr.general.CloudCenter; import com.fr.general.CommonIOUtils; @@ -24,6 +25,8 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * Created by Administrator on 2017/7/24 0024. @@ -81,8 +84,8 @@ public class ErrorInfoUploader { return; } - - Thread updateThread = new Thread(new Runnable() { + ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("ErrorInfoUploader")); + es.submit(new Runnable() { @Override public void run() { String localCacheFilePath = StableUtils.pathJoin(ProductConstants.getEnvHome(), "solution", "solution.zip"); @@ -92,7 +95,7 @@ public class ErrorInfoUploader { } } }); - updateThread.start(); + es.shutdown(); } private void downloadSolution(File localCacheZip) { diff --git a/designer-realize/src/main/java/com/fr/start/Designer.java b/designer-realize/src/main/java/com/fr/start/Designer.java index 654f396c8..19c9a5dba 100644 --- a/designer-realize/src/main/java/com/fr/start/Designer.java +++ b/designer-realize/src/main/java/com/fr/start/Designer.java @@ -82,6 +82,7 @@ public class Designer extends BaseDesigner { private UIButton saveButton; private UIButton undo; private UIButton redo; + private UIButton[] upToolBar; private UIPreviewButton run; public Designer(String[] args) { @@ -94,7 +95,7 @@ public class Designer extends BaseDesigner { * @param args 参数 */ public static void main(String[] args) { - + StopWatch watch = new StopWatch(); watch.start(); //启动运行时 @@ -210,11 +211,17 @@ public class Designer extends BaseDesigner { */ @Override public UIButton[] createUp() { - return new UIButton[]{createSaveButton(), createUndoButton(), createRedoButton()}; + if (upToolBar == null) { + createSaveButton(); + createUndoButton(); + createRedoButton(); + return upToolBar = new UIButton[]{saveButton, undo, redo}; + } + return upToolBar; } - private UIButton createSaveButton() { + private void createSaveButton() { saveButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/save.png")); saveButton.setToolTipText(KeySetUtils.SAVE_TEMPLATE.getMenuKeySetName()); saveButton.set4ToolbarButton(); @@ -227,11 +234,10 @@ public class Designer extends BaseDesigner { jt.requestFocus(); } }); - return saveButton; } - private UIButton createUndoButton() { + private void createUndoButton() { undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png")); undo.setToolTipText(KeySetUtils.UNDO.getMenuKeySetName()); undo.set4ToolbarButton(); @@ -244,10 +250,9 @@ public class Designer extends BaseDesigner { } } }); - return undo; } - private UIButton createRedoButton() { + private void createRedoButton() { redo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/redo.png")); redo.setToolTipText(KeySetUtils.REDO.getMenuKeySetName()); redo.set4ToolbarButton(); @@ -260,7 +265,6 @@ public class Designer extends BaseDesigner { } } }); - return redo; } private void createRunButton(UILargeToolbar largeToolbar) { diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index b1ad72251..7c3a1e7a6 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -16,12 +16,10 @@ public class DesignerStartup extends Activator { @Override @Metrics public void start() { - startSub(PreStartActivator.class); getSub("parallel").start(); //designer模块启动好后,查看demo browserDemo(); - startSub(DesignerShowActivator.class); startSub(StartFinishActivator.class); FineRuntime.startFinish(); } diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java index e652cda6f..ab4448434 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java @@ -6,7 +6,6 @@ import com.fr.event.Event; import com.fr.event.Listener; import com.fr.module.Activator; import com.fr.start.server.FineEmbedServer; -import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; @@ -22,7 +21,6 @@ public class DesignerWorkspaceActivator extends Activator { public void start() { registerEnvListener(); - startServer(WorkContext.getCurrent()); } /**