Browse Source

Merging in latest from upstream (DESIGN/design:refs/heads/release/10.0)

* commit '822826117ba524f0e274ca1ff612da862e67a45f':
  无JIRA任务,复用原有代码
  REPORT-11590 环境切换执行完毕后关闭选择对话框,启动时环境切换和9保持一致
  REPORT-11257
final/10.0
Wim.Zhai 6 years ago
parent
commit
19f3b07ca6
  1. 92
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/OldShortCutFactory.java
  3. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java
  4. 14
      designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java
  5. 22
      designer-base/src/main/java/com/fr/design/gui/frpane/HyperLinkGroupFilter.java
  6. 16
      designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java
  7. 5
      designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java
  8. 22
      designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java

92
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -16,6 +16,7 @@ import com.fr.general.GeneralContext;
import com.fr.license.exception.RegistEditionException; import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
@ -51,19 +52,28 @@ public class EnvChangeEntrance {
}); });
} }
private boolean envListOkAction(EnvListPane envListPane) { private boolean envListOkAction(EnvListPane envListPane, PopTipStrategy strategy) {
final String selectedName = envListPane.updateEnvManager(); final String selectedName = envListPane.updateEnvManager();
return switch2Env(selectedName); return switch2Env(selectedName, strategy);
} }
/**
* 切换到指定名称的工作目录
*
* @param envName 目标工作目录名称
*/
public void switch2Env(final String envName) {
switch2Env(envName, PopTipStrategy.LATER);
}
/** /**
* 切换到新环境 * 切换到新环境
* *
* @param envName 新工作环境名称 * @param envName 新工作环境名称
* @return 是否成功 * @return 是否成功
*/ */
public boolean switch2Env(final String envName) { private boolean switch2Env(final String envName, PopTipStrategy strategy) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
@ -71,8 +81,13 @@ public class EnvChangeEntrance {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace != null && selectedEnv.checkValid(); boolean checkValid = workspace != null && selectedEnv.checkValid();
if (!checkValid) { if (!checkValid) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), strategy.showTip(new PopTip() {
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); @Override
public void show() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false; return false;
} }
WorkContext.switchTo(workspace, new WorkContextCallback() { WorkContext.switchTo(workspace, new WorkContextCallback() {
@ -85,19 +100,34 @@ public class EnvChangeEntrance {
template.refreshToolArea(); template.refreshToolArea();
} }
DesignTableDataManager.fireDSChanged(new HashMap<String, String>()); DesignTableDataManager.fireDSChanged(new HashMap<String, String>());
if (WorkContext.getCurrent().isLocal()) {
//初始化一下serverTray
ServerTray.init();
}
} }
}); });
} catch (AuthException | RegistEditionException e) { } catch (AuthException | RegistEditionException e) {
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
// String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote");
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), strategy.showTip(new PopTip() {
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); @Override
public void show() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false; return false;
} catch (Exception exception) { } catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception); FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), strategy.showTip(new PopTip() {
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); @Override
public void show() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false; return false;
} }
TemplateTreePane.getInstance().refreshDockingView(); TemplateTreePane.getInstance().refreshDockingView();
@ -131,13 +161,11 @@ public class EnvChangeEntrance {
@Override @Override
public void doOk() { public void doOk() {
envListDialog.dispose(); envListOkAction(envListPane, PopTipStrategy.LATER);
envListOkAction(envListPane);
} }
@Override @Override
public void doCancel() { public void doCancel() {
envListDialog.dispose(); envListDialog.dispose();
} }
}); });
@ -155,11 +183,9 @@ public class EnvChangeEntrance {
@Override @Override
public void doOk() { public void doOk() {
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
if (!envListOkAction(envListPane)) {
System.exit(0); System.exit(0);
} }
} }
@Override @Override
@ -170,4 +196,40 @@ public class EnvChangeEntrance {
envListDialog.setVisible(true); envListDialog.setVisible(true);
} }
/**
* 提示显示策略
*/
enum PopTipStrategy {
/**
* 切换失败就马上提示失败不关闭选择列表对话框
*/
NOW {
@Override
void showTip(PopTip tip) {
tip.show();
}
},
/**
* 切换失败自动关闭选择列表对话框然后提示切换失败
*/
LATER {
@Override
void showTip(final PopTip tip) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
tip.show();
}
});
}
};
abstract void showTip(PopTip tip);
}
interface PopTip {
void show();
}
} }

7
designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/OldShortCutFactory.java

@ -5,13 +5,14 @@ import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ShortCut4JControlPane; import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.ShortCutListenerProvider; import com.fr.design.gui.controlpane.ShortCutListenerProvider;
import com.fr.design.gui.frpane.HyperLinkGroupFilter;
import com.fr.design.menu.LineSeparator; import com.fr.design.menu.LineSeparator;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.js.JavaScript;
import com.fr.stable.Filter;
import javax.swing.Icon; import javax.swing.Icon;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -84,8 +85,8 @@ public class OldShortCutFactory extends AbstractShortCutFactory {
private void wrapActionListener(NameableCreator[] creators) { private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) { for (final NameableCreator creator : creators) {
HyperLinkGroupFilter filter = DesignModuleFactory.getHyperlinkGroupType().getFilter(); Filter<Class<? extends JavaScript>> filter = DesignModuleFactory.getHyperlinkGroupType().getFilter();
if (!filter.filter(creator.getHyperlink())) { if (!filter.accept(creator.getHyperlink())) {
continue; continue;
} }
boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) || boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) ||

7
designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java

@ -6,13 +6,14 @@ import com.fr.design.actions.core.ActionFactory;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ShortCut4JControlPane; import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.ShortCutListenerProvider; import com.fr.design.gui.controlpane.ShortCutListenerProvider;
import com.fr.design.gui.frpane.HyperLinkGroupFilter;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.menu.LineSeparator; import com.fr.design.menu.LineSeparator;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.js.JavaScript;
import com.fr.stable.Filter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.AbstractButton; import javax.swing.AbstractButton;
@ -141,8 +142,8 @@ public class ShortCutFactory extends AbstractShortCutFactory {
private void wrapActionListener(NameableCreator[] creators) { private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) { for (final NameableCreator creator : creators) {
HyperLinkGroupFilter filter = DesignModuleFactory.getHyperlinkGroupType().getFilter(); Filter<Class<? extends JavaScript>> filter = DesignModuleFactory.getHyperlinkGroupType().getFilter();
if (!filter.filter(creator.getHyperlink())) { if (!filter.accept(creator.getHyperlink())) {
continue; continue;
} }
boolean isTrue = ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Datasource-Stored_Procedure")) || boolean isTrue = ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Datasource-Stored_Procedure")) ||

14
designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java

@ -3,6 +3,7 @@ package com.fr.design.gui.frpane;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.stable.Filter;
/** /**
* 基础的超级链接类型, 不包括图表相关超链. * 基础的超级链接类型, 不包括图表相关超链.
@ -22,15 +23,20 @@ public class BaseHyperlinkGroup implements HyperlinkGroupType {
} }
@Override @Override
public HyperLinkGroupFilter getFilter() { public Filter<Class<? extends JavaScript>> getFilter() {
return new HyperLinkGroupFilter() { return new Filter<Class<? extends JavaScript>>() {
@Override @Override
public boolean filter(Class<? extends JavaScript> clazz) { public boolean accept(Class<? extends JavaScript> aClass) {
return true; return true;
} }
};
}
@Override
public Filter<Object> getOldFilter() {
return new Filter<Object>() {
@Override @Override
public boolean filter(Object object) { public boolean accept(Object object) {
return true; return true;
} }
}; };

22
designer-base/src/main/java/com/fr/design/gui/frpane/HyperLinkGroupFilter.java

@ -1,22 +0,0 @@
package com.fr.design.gui.frpane;
import com.fr.js.JavaScript;
public interface HyperLinkGroupFilter {
/**
* @param clazz clazz
* @return 是否可用返回true表示可用返回false表示不可用
*/
boolean filter(Class<? extends JavaScript> clazz);
/**
* 兼容老图表
*
* @param object object
* @return 是否可用返回true表示可用返回false表示不可用
* @see HyperLinkGroupFilter#filter(Class)
*/
boolean filter(Object object);
}

16
designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java

@ -1,6 +1,8 @@
package com.fr.design.gui.frpane; package com.fr.design.gui.frpane;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.js.JavaScript;
import com.fr.stable.Filter;
/** /**
* 超级链接 支持的类型 种类. * 超级链接 支持的类型 种类.
@ -18,6 +20,18 @@ public interface HyperlinkGroupType {
NameableCreator[] getHyperlinkCreators(); NameableCreator[] getHyperlinkCreators();
HyperLinkGroupFilter getFilter(); /**
* 图表超链过滤
*
* @return 图表超链过滤
*/
Filter<Class<? extends JavaScript>> getFilter();
/**
* 老图表超链的过滤
*
* @return 老图表超链的过滤
*/
Filter<Object> getOldFilter();
} }

5
designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java

@ -23,6 +23,7 @@ import com.fr.js.EmailJavaScript;
import com.fr.js.ReportletHyperlink; import com.fr.js.ReportletHyperlink;
import com.fr.js.WebHyperlink; import com.fr.js.WebHyperlink;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Filter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -95,8 +96,8 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver {
if (values.size() > 1) { if (values.size() > 1) {
for (UIMenuNameableCreator value : values) { for (UIMenuNameableCreator value : values) {
final String itemName = value.getName(); final String itemName = value.getName();
HyperLinkGroupFilter filter = DesignModuleFactory.getHyperlinkGroupType().getFilter(); Filter<Object> filter = DesignModuleFactory.getHyperlinkGroupType().getOldFilter();
if (!filter.filter(value.getObj())) { if (!filter.accept(value.getObj())) {
continue; continue;
} }
UIMenuItem item = new UIMenuItem(itemName); UIMenuItem item = new UIMenuItem(itemName);

22
designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java

@ -11,13 +11,13 @@ import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.frpane.BaseHyperlinkGroup; import com.fr.design.gui.frpane.BaseHyperlinkGroup;
import com.fr.design.gui.frpane.HyperLinkGroupFilter;
import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.js.FormHyperlinkProvider; import com.fr.js.FormHyperlinkProvider;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Filter;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
/** /**
@ -46,10 +46,10 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup {
} }
@Override @Override
public HyperLinkGroupFilter getFilter() { public Filter<Class<? extends JavaScript>> getFilter() {
return new HyperLinkGroupFilter() { return new Filter<Class<? extends JavaScript>>() {
@Override @Override
public boolean filter(Class<? extends JavaScript> clazz) { public boolean accept(Class<? extends JavaScript> clazz) {
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template == null) { if (template == null) {
return false; return false;
@ -78,25 +78,23 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup {
} }
return true; return true;
} }
};
}
/** @Override
* 兼容老图表 public Filter<Object> getOldFilter() {
* @param object return new Filter<Object>() {
* @return
*/
@Override @Override
public boolean filter(Object object) { public boolean accept(Object object) {
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template == null) { if (template == null) {
return false; return false;
} }
if (template.isJWorkBook()) { if (template.isJWorkBook()) {
// 如果是普通报表单元格,那么没有 FormHyperlink 选项 // 如果是普通报表单元格,那么没有 FormHyperlink 选项
FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class);
//返回true表示可用,返回false表示不可用 //返回true表示可用,返回false表示不可用
return !ComparatorUtils.equals(object.getClass(), formHyperlink.getClass()); return !ComparatorUtils.equals(object.getClass(), formHyperlink.getClass());
} else { } else {
// 如果是决策报表 // 如果是决策报表
Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class};

Loading…
Cancel
Save