diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index cfe0840af1..ce32e2323c 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -53,6 +53,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.HashSet; @@ -385,7 +386,7 @@ public class EnvChangeEntrance { public void doOk() { envListOkAction(envListPane, PopTipStrategy.LATER); // 切换完成后清理密码 - updateSelectEnv(DesignerEnvManager.getEnvManager().getCurEnvName()); + updateNotRememberPwdEnv(); } @Override @@ -416,7 +417,7 @@ public class EnvChangeEntrance { if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { DesignerExiter.getInstance().execute(); } else { - updateSelectEnv(DesignerEnvManager.getEnvManager().getCurEnvName()); + updateNotRememberPwdEnv(); } } @@ -428,17 +429,19 @@ public class EnvChangeEntrance { envListDialog.setVisible(true); } - /** + /** * 切换环境后 刷新远程目录需要忘记密码的情况 - * @param envName 环境名 */ - private void updateSelectEnv(String envName) { + private void updateNotRememberPwdEnv() { DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); - DesignerWorkspaceInfo info = mgr.getWorkspaceInfo(envName); - if (info != null) { - WorkspaceConnectionInfo connection = info.getConnection(); - if (connection != null && !connection.isRememberPwd()) { + Iterator iterator = mgr.getEnvNameIterator(); + while (iterator.hasNext()) { + String envName = iterator.next(); + DesignerWorkspaceInfo info = mgr.getWorkspaceInfo(envName); + + if (isNotRememberPwd(info)) { + WorkspaceConnectionInfo connection = info.getConnection(); DesignerWorkspaceInfo workspaceInfo = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo( connection.getUrl(), connection.getUserName(), StringUtils.EMPTY, connection.getCertPath(), connection.getCertSecretKey(), false)); mgr.putEnv(envName, workspaceInfo); @@ -446,6 +449,14 @@ public class EnvChangeEntrance { } } + private boolean isNotRememberPwd(DesignerWorkspaceInfo info) { + if (info != null && info.getType() == DesignerWorkspaceType.Remote) { + WorkspaceConnectionInfo connection = info.getConnection(); + return connection != null && !connection.isRememberPwd(); + } + return false; + } + /** * 提示显示策略 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 66d7216c91..f29e22698c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -28,6 +28,7 @@ import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.PreviewProvider; +import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; @@ -55,6 +56,14 @@ import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginRuntime; +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.PluginEventType; +import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.stable.ArrayUtils; @@ -100,7 +109,10 @@ public abstract class JTemplate> protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); public int resolution = ScreenResolution.getScreenResolution(); + private PluginEventListener pluginListener; + public JTemplate() { + initAndStartPlugin(); } public JTemplate(T t, String defaultFileName) { @@ -129,8 +141,50 @@ public abstract class JTemplate> designModel = createDesignModel(); consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile)); + initAndStartPlugin(); + } + + private void initAndStartPlugin() { + initPluginPane(); + startListenPlugin(); + } + + private void startListenPlugin() { + + PluginFilter filter = new PluginFilter() { + @Override + public boolean accept(PluginContext context) { + return context.contain(PropertyItemPaneProvider.XML_TAG); + } + }; + this.pluginListener = new PluginEventListener(PropertyItemPaneProvider.LAST) { + @Override + public void on(PluginEvent event) { + PluginContext context = event.getContext(); + PluginRuntime runtime = context.getRuntime(); + Set providers = runtime.get(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPane(provider); + } + } + }; + PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginListener, filter); + } + + private void initPluginPane() { + + ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign); + Set providers = classManager.getArray(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPane(provider); + } } + protected void addPane(PropertyItemPaneProvider provider) { + // do nothing + } + + void onGetFocus() { consumeTimer.start(); } @@ -251,7 +305,8 @@ public abstract class JTemplate> * 模板关闭时 */ public void whenClose() { - // do nothing + // stop的时候 pluginListener 和 PluginFilter 都会移除 + PluginListenerRegistration.getInstance().stopListen(this.pluginListener); } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java index 2c18186147..64a10c88f2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java @@ -211,6 +211,8 @@ public class JVirtualTemplate extends JTemplate { List> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); historyList.set(index, jt); DesignerContext.getDesignerFrame().addAndActivateJTemplate(jt); + // 虚拟模板JVirtualTemplate被激活后 由真实的JTemplate替换 此时调用whenClose 防止JVirtualTemplate无法释放 + this.whenClose(); } @Override diff --git a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java index 672f17e374..d9d6e44844 100644 --- a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java +++ b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java @@ -2,6 +2,7 @@ package com.fr.design; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; +import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.env.CheckServiceDialog; import com.fr.invoke.Reflect; @@ -58,7 +59,7 @@ public class EnvChangeEntranceTest { } @Test - public void testUpdateSelectEnv() { + public void testUpdateNotRememberPwdEnv() { DesignerEnvManager manager = new DesignerEnvManager(); @@ -71,16 +72,32 @@ public class EnvChangeEntranceTest { manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true))); manager.putEnv("test2", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", false))); + manager.putEnv("test3", LocalDesignerWorkspaceInfo.create("name", "path")); - Reflect.on(entrance).call("updateSelectEnv", "test1"); - Reflect.on(entrance).call("updateSelectEnv", "test2"); - + Reflect.on(entrance).call("updateNotRememberPwdEnv"); Assert.assertEquals(manager.getWorkspaceInfo("test1").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)).getConnection()); Assert.assertEquals(manager.getWorkspaceInfo("test2").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "", "", "", false)).getConnection()); + Assert.assertEquals(manager.getWorkspaceInfo("test3").getName(), "name"); + Assert.assertEquals(manager.getWorkspaceInfo("test3").getPath(), "path"); PowerMock.verifyAll(); } + @Test + public void testIsNotRememberPwd() { + EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); + + DesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)); + DesignerWorkspaceInfo info2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "111", "", "", false)); + DesignerWorkspaceInfo info3 = LocalDesignerWorkspaceInfo.create("name", "path"); + DesignerWorkspaceInfo info4 = null; + + Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info1).get()); + Assert.assertTrue((boolean) Reflect.on(entrance).call("isNotRememberPwd", info2).get()); + Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info3).get()); + Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info4).get()); + } + } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java index 43084ef234..a73ea2a168 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java @@ -27,7 +27,7 @@ import java.awt.Component; public class MeterPlotReportDataContentPane extends AbstractReportDataContentPane { private static final String CATENAME = Toolkit.i18nText("Fine-Design_Chart_Category_Name"); - private static final String NVALUE = Toolkit.i18nText("Fine-Design_Chart_Pointer_Value"); + private static final String NVALUE = Toolkit.i18nText("Fine-Design_Chart_Value_Pointer"); private static final String TARGET_VALUE = Toolkit.i18nText("Fine-Design_Chart_Target_Value"); private TinyFormulaPane singCatePane; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java index 3566ab263c..c7830f246e 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java @@ -35,8 +35,8 @@ import java.awt.event.ItemListener; * @version 创建时间:2012-12-21 下午04:51:50 */ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane { - private static final String METER_NAME = Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name"); - private static final String METER_VALUE = Toolkit.i18nText("Fine-Design_Chart_Pointer_Value"); + private static final String METER_NAME = Toolkit.i18nText("Fine-Design_Chart_Category_Name"); + private static final String METER_VALUE = Toolkit.i18nText("Fine-Design_Chart_Value_Pointer"); private static final String TARGET_VALUE = Toolkit.i18nText("Fine-Design_Chart_Target_Value"); private static final int COMBOBOX_WIDTH = 115; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java index b6f073f10b..32d217adc1 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java @@ -41,11 +41,14 @@ abstract class ModelUtil { if (StringUtils.isEmpty(widgetName)) { widgetName = xCreator.createDefaultName(); } + //先保存默认名字 String raw = widgetName; int i = 0; + //先初始化加上索引。 + widgetName = widgetName + i; while (form.isNameExist(widgetName) || duplicated.contains(widgetName)) { - widgetName = raw + i; i++; + widgetName = raw + i; } //将名字加入重复集合中 duplicated.add(widgetName); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index e2112f4f37..041705fb6d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -70,14 +70,7 @@ import com.fr.form.ui.container.WLayout; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.page.PaperSettingProvider; -import com.fr.plugin.context.PluginContext; -import com.fr.plugin.context.PluginRuntime; -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.PluginEventType; -import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.report.worksheet.FormElementCase; @@ -104,7 +97,6 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Set; public class JForm extends JTemplate implements BaseJForm
{ private static final String FORM_CARD = "FORM"; @@ -132,51 +124,15 @@ public class JForm extends JTemplate implements BaseJForm providers = runtime.get(PropertyItemPaneProvider.XML_TAG); - for (PropertyItemPaneProvider provider : providers) { - addPane(provider); - } - } - }; - PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginListener, filter); - } - - private void initPluginPane() { - - ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign); - Set providers = classManager.getArray(PropertyItemPaneProvider.XML_TAG); - for (PropertyItemPaneProvider provider : providers) { - addPane(provider); - } } - private void addPane(PropertyItemPaneProvider provider) { + @Override + protected void addPane(PropertyItemPaneProvider provider) { PaneHolder holder = provider.getPaneHolder(FormDesigner.class); if (holder != null) { @@ -1040,10 +996,4 @@ public class JForm extends JTemplate implements BaseJForm { populateReportParameterAttr(); } + @Override + protected void addPane(PropertyItemPaneProvider provider) { + PaneHolder holder = provider.getPaneHolder(JWorkBook.class); + if (holder != null) { + JPanel panel = holder.getInstance(this); + EastRegionContainerPane.getInstance().replaceKeyPane(provider.key(), panel); + } + } + @Override public void refreshEastPropertiesPane() { if (isEditingPolySheet()) { @@ -1191,6 +1201,7 @@ public class JWorkBook extends JTemplate { @Override public void whenClose() { + super.whenClose(); reportComposite.doRemoveAction(); } }