From eca6b16c621fc2cba9b43fcecffe59408f0d216f Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Wed, 31 May 2017 17:20:17 +0800 Subject: [PATCH 1/4] merge chart : ba-9.0 => pf-9.0 --- .../ChartTypeInterfaceCloseableHandler.java | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java diff --git a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java b/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java deleted file mode 100644 index 8e9715574..000000000 --- a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.fr.design.extra; - -import com.fr.chart.charttypes.ChartTypeManager; -import com.fr.plugin.proxy.CloseableInvocationHandler; - -/** - * Created by juhaoyu on 2016/12/27. - */ -public class ChartTypeInterfaceCloseableHandler extends CloseableInvocationHandler { - - - private final String plotID; - - public ChartTypeInterfaceCloseableHandler(String plotID) throws NoSuchMethodException { - - super(); - this.plotID = plotID; - } - - @Override - protected boolean invokeIsClosed() { - - //UI对应的chart如果关闭或者不存在,则UI关闭 - return super.invokeIsClosed() || !containsChart(); - } - - private boolean containsChart() { - - return ChartTypeManager.getInstance().containsPlot(plotID); - } -} From b2bc24b9ff94d6dd7da52123d73a69992fccda6c Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Thu, 1 Jun 2017 18:27:01 +0800 Subject: [PATCH 2/4] merge --- .../fr/design/extra/exe/callback/InstallFromDiskCallback.java | 2 +- .../com/fr/design/extra/exe/callback/InstallOnlineCallback.java | 2 +- .../fr/design/extra/exe/callback/UpdateFromDiskCallback.java | 2 +- .../com/fr/design/extra/exe/callback/UpdateOnlineCallback.java | 2 +- .../design/extra/tradition/callback/UpdateOnlineCallback.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index aa74e9c02..26e767eae 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -33,7 +33,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { if (result.isSuccess()) { FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); - } else if (result.errorCode() == PluginErrorCode.OperationNotSupport.getCode()) { + } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { int rv = JOptionPane.showOptionDialog( null, Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), diff --git a/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index a1ee0ee4c..a399472bc 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -33,7 +33,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback { if (result.isSuccess()) { FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); - } else if (result.errorCode() == PluginErrorCode.OperationNotSupport.getCode()) { + } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { int rv = JOptionPane.showOptionDialog( null, Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), diff --git a/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java index 0f79a1614..4d028341d 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -33,7 +33,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { if (result.isSuccess()) { FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); - } else if (result.errorCode() == PluginErrorCode.OperationNotSupport.getCode()) { + } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { int rv = JOptionPane.showOptionDialog( null, Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), diff --git a/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index 65a71a80c..072c24762 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -33,7 +33,7 @@ public class UpdateOnlineCallback extends AbstractPluginTaskCallback { if (result.isSuccess()) { FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); - } else if (result.errorCode() == PluginErrorCode.OperationNotSupport.getCode()) { + } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { int rv = JOptionPane.showOptionDialog( null, Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), diff --git a/designer_base/src/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java b/designer_base/src/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java index bac8d080a..ff52efaa3 100644 --- a/designer_base/src/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java +++ b/designer_base/src/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java @@ -32,7 +32,7 @@ public class UpdateOnlineCallback implements ProgressCallback { if (result.isSuccess()) { FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); - } else if (result.errorCode() == PluginErrorCode.OperationNotSupport.getCode()) { + } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { int rv = JOptionPane.showOptionDialog( null, Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), From ec45d8457d3c897bb2a17f81f0a97883ee338a69 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 2 Jun 2017 16:20:51 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8D=E5=B7=B2?= =?UTF-8?q?=E5=8F=91=E7=8E=B0=E7=9A=84=E9=97=AE=E9=A2=98=202=E3=80=81?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=9B=91=E5=90=AC=E7=9B=B8=E5=85=B3=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=8F=98=E5=8A=A8=EF=BC=8C=E8=87=AA=E5=8A=A8=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=8F=9C=E5=8D=95=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/toolbar/ToolBarMenuDock.java | 84 +++++++++++++++++-- .../src/com/fr/design/menu/MenuDef.java | 9 +- 2 files changed, 83 insertions(+), 10 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index f80e20331..c6adb1d4b 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -11,9 +11,9 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.actions.community.*; import com.fr.design.actions.file.*; import com.fr.design.actions.help.AboutAction; -import com.fr.design.actions.help.alphafine.AlphafineAction; import com.fr.design.actions.help.TutorialAction; import com.fr.design.actions.help.WebDemoAction; +import com.fr.design.actions.help.alphafine.AlphafineAction; import com.fr.design.actions.server.*; import com.fr.design.file.NewTemplatePane; import com.fr.design.fun.MenuHandler; @@ -32,6 +32,13 @@ import com.fr.design.menu.ToolBarDef; import com.fr.env.RemoteEnv; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginRuntime; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import com.fr.plugin.observer.PluginEventType; +import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.ArrayUtils; import com.fr.stable.ProductConstants; @@ -570,17 +577,56 @@ public abstract class ToolBarMenuDock { protected void insertMenu(MenuDef menuDef, String anchor) { insertMenu(menuDef, anchor, new NoTargetAction()); } - + protected void insertMenu(MenuDef menuDef, String anchor, ShortCutMethodAction action) { - // 下面是插件接口接入点 - Set set = ExtraDesignClassManager.getInstance().getArray(MenuHandler.MARK_STRING); - java.util.List target = new ArrayList<>(); + + listenPluginMenuChange(menuDef, anchor, action); + addExtraMenus(menuDef, anchor, action, ExtraDesignClassManager.getInstance().getArray(MenuHandler.MARK_STRING)); + + } + + private void listenPluginMenuChange(MenuDef menuDef, String anchor, ShortCutMethodAction action) { + + PluginFilter filter = new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(MenuHandler.MARK_STRING); + } + }; + + PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeStop, new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + PluginRuntime runtime = event.getContext().getRuntime(); + Set menuHandlers = runtime.get(MenuHandler.MARK_STRING); + removeExtraMenus(menuDef, anchor, action, menuHandlers); + } + }, filter); + PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + PluginRuntime runtime = event.getContext().getRuntime(); + Set menuHandlers = runtime.get(MenuHandler.MARK_STRING); + addExtraMenus(menuDef, anchor, action, menuHandlers); + } + }, filter); + } + + private void removeExtraMenus(MenuDef menuDef, String anchor, ShortCutMethodAction action, Set set) { + + + List target = new ArrayList<>(); for (MenuHandler handler : set) { if (ComparatorUtils.equals(handler.category(), anchor)) { target.add(handler); } } - + for (MenuHandler handler : target) { int insertPosition = handler.insertPosition(menuDef.getShortCutCount()); if (insertPosition == MenuHandler.HIDE) { @@ -590,7 +636,29 @@ public abstract class ToolBarMenuDock { if (shortCut == null){ continue; } - + menuDef.removeShortCut(shortCut); + } + } + + private void addExtraMenus(MenuDef menuDef, String anchor, ShortCutMethodAction action, Set set) { + + List target = new ArrayList<>(); + for (MenuHandler handler : set) { + if (ComparatorUtils.equals(handler.category(), anchor)) { + target.add(handler); + } + } + + for (MenuHandler handler : target) { + int insertPosition = handler.insertPosition(menuDef.getShortCutCount()); + if (insertPosition == MenuHandler.HIDE) { + return; + } + ShortCut shortCut = action.methodAction(handler); + if (shortCut == null){ + continue; + } + if (insertPosition == MenuHandler.LAST) { if (handler.insertSeparatorBefore()) { menuDef.addShortCut(SeparatorDef.DEFAULT); @@ -609,7 +677,7 @@ public abstract class ToolBarMenuDock { } } } - + /** * 设计器退出时, 做的一些操作. * diff --git a/designer_base/src/com/fr/design/menu/MenuDef.java b/designer_base/src/com/fr/design/menu/MenuDef.java index 9de4dba4e..319b94f2e 100644 --- a/designer_base/src/com/fr/design/menu/MenuDef.java +++ b/designer_base/src/com/fr/design/menu/MenuDef.java @@ -117,6 +117,11 @@ public class MenuDef extends ShortCut { this.shortcutList.add(i); } } + + public void removeShortCut(ShortCut shortCut) { + + this.shortcutList.remove(shortCut); + } /** * 清理 @@ -349,6 +354,6 @@ public class MenuDef extends ShortCut { public void setPopupMenu(JPopupMenu popupMenu) { this.popupMenu = popupMenu; } - - + + } \ No newline at end of file From 89a2d4d08b109609587e19144b8c50cc687126c2 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 2 Jun 2017 16:35:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=85=81=E8=AE=B8=E9=80=9A=E8=BF=87GeneralContext?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=8F=92=E4=BB=B6=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/data/datapane/TableDataTreePane.java | 4 ++-- .../src/com/fr/design/mainframe/DesignerFrame.java | 3 +-- .../com/fr/design/mainframe/WestRegionContainerPane.java | 5 ++--- .../com/fr/design/mainframe/toolbar/ToolBarMenuDock.java | 8 ++++---- .../src/com/fr/design/ChartTypeInterfaceManager.java | 4 ++-- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java index ca49365e4..1507d77b5 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java @@ -27,6 +27,7 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ToolBarDef; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralContext; import com.fr.general.Inter; import com.fr.general.NameObject; import com.fr.plugin.context.PluginContext; @@ -34,7 +35,6 @@ import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; -import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.*; @@ -88,7 +88,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { createAddMenuDef(); - PluginListenerRegistration.getInstance().listenRunningChanged(new PluginEventListener(PLUGIN_LISTENER_PRIORITY) { + GeneralContext.listenPluginRunningChanged(new PluginEventListener(PLUGIN_LISTENER_PRIORITY) { @Override public void on(PluginEvent event) { diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java index 3b64c4b3f..6cdc72e2a 100644 --- a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java @@ -40,7 +40,6 @@ import com.fr.plugin.context.PluginContext; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; -import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.CoreConstants; import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; @@ -175,7 +174,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta //顶部日志+登陆按钮 final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - PluginListenerRegistration.getInstance().listenRunningChanged(new PluginEventListener() { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { @Override public void on(PluginEvent event) { diff --git a/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java index d1cb5a27f..e2a6d64d5 100644 --- a/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java @@ -5,12 +5,11 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.icontainer.UIResizableContainer; +import com.fr.general.GeneralContext; import com.fr.plugin.context.PluginContext; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; -import com.fr.plugin.observer.PluginListenerPriority; -import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.Constants; public class WestRegionContainerPane extends UIResizableContainer { @@ -35,7 +34,7 @@ public class WestRegionContainerPane extends UIResizableContainer { setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); - PluginListenerRegistration.getInstance().listenRunningChanged(new PluginEventListener(TableDataTreePane.PLUGIN_LISTENER_PRIORITY - 1) { + GeneralContext.listenPluginRunningChanged(new PluginEventListener(TableDataTreePane.PLUGIN_LISTENER_PRIORITY - 1) { @Override public void on(PluginEvent event) { diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index c6adb1d4b..b9bf0070a 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -31,6 +31,7 @@ import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.env.RemoteEnv; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralContext; import com.fr.general.Inter; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; @@ -38,7 +39,6 @@ import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventType; -import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.ArrayUtils; import com.fr.stable.ProductConstants; @@ -595,8 +595,8 @@ public abstract class ToolBarMenuDock { return context.contain(MenuHandler.MARK_STRING); } }; - - PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeStop, new PluginEventListener() { + + GeneralContext.listenPlugin(PluginEventType.BeforeStop, new PluginEventListener() { @Override public void on(PluginEvent event) { @@ -605,7 +605,7 @@ public abstract class ToolBarMenuDock { removeExtraMenus(menuDef, anchor, action, menuHandlers); } }, filter); - PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, new PluginEventListener() { + GeneralContext.listenPlugin(PluginEventType.AfterRun, new PluginEventListener() { @Override public void on(PluginEvent event) { diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index b77e1f399..b23954ab4 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -20,6 +20,7 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; 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.context.PluginContext; @@ -28,7 +29,6 @@ import com.fr.plugin.injectable.PluginSingleInjection; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; -import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import com.fr.stable.bridge.StableFactory; @@ -61,7 +61,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr static { - PluginListenerRegistration.getInstance().listenRunningChanged(new PluginEventListener() { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { @Override public void on(PluginEvent event) {