Browse Source

Merge remote-tracking branch 'origin/release/10.0' into release/10.0

final/10.0
Jinbokai 6 years ago
parent
commit
e7c14f033f
  1. 128
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 4
      designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java
  3. 84
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  4. 15
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  5. 28
      designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java
  6. 3
      designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java
  7. 8
      designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java
  8. 2
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java
  9. 3
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  10. 4
      designer-base/src/main/java/com/fr/design/formula/FunctionNAD.java
  11. 7
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  12. 20
      designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java
  13. 7
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  14. 2
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  15. 23
      designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java
  16. 11
      designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java
  17. 2
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  18. 15
      designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java
  19. 5
      designer-realize/src/main/java/com/fr/start/Designer.java
  20. 5
      designer-realize/src/main/java/com/fr/start/SplashContext.java
  21. 2
      designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

128
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -22,10 +22,9 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter; import com.fr.general.FRLogFormatter;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.xml.GeneralXMLTools; import com.fr.general.xml.GeneralXMLTools;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.stable.ListMap; import com.fr.stable.ListMap;
@ -43,10 +42,9 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.connect.AuthException; import com.fr.workspace.connect.AuthException;
import javax.swing.SwingWorker; import javax.swing.*;
import javax.swing.SwingWorker.StateValue; import javax.swing.SwingWorker.StateValue;
import java.awt.Color; import java.awt.*;
import java.awt.Rectangle;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileReader; import java.io.FileReader;
@ -111,7 +109,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private Color paginationLineColor = Color.black; // line color of paper private Color paginationLineColor = Color.black; // line color of paper
private boolean supportCellEditorDef = false; private boolean supportCellEditorDef = false;
private boolean isDragPermited = false; private boolean isDragPermited = false;
private int language; private Locale language = Locale.SIMPLIFIED_CHINESE;
//2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容 //2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容
private boolean useOracleSystemSpace = true; private boolean useOracleSystemSpace = true;
private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT; private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT;
@ -554,7 +552,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
try { try {
final String envName = getDefaultEnvName(); final String envName = getDefaultEnvName();
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(getDefaultConfig()),new WorkContextCallback() { WorkContext.switchTo(DesignerWorkspaceGenerator.generate(getDefaultConfig()), new WorkContextCallback() {
@Override @Override
public void done() { public void done() {
@ -713,37 +711,15 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/** /**
* 返回语言类型 * 返回语言类型
*/ */
public int getLanguage() { public Locale getLanguage() {
return this.language; return language;
}
/**
* 返回语言类型
*/
public Locale getLocale() {
// 性能
if (language <= 1) {
return Locale.CHINA;
}
Locale[] locales = supportLocale();
if (language <= locales.length) {
return locales[language - 1];
}
return Locale.CHINA;
}
// 当前系统支持的语言
protected Locale[] supportLocale() {
Inter.getInstance();
Map<Locale, String> languageMap = InterProviderFactory.getProvider().getSupportLocaleMap();
return languageMap.keySet().toArray(new Locale[languageMap.size()]);
} }
/** /**
* 设置语言参数 * 设置语言参数
*/ */
public void setLanguage(int i) { public void setLanguage(Locale locale) {
this.language = i; this.language = locale;
} }
/** /**
@ -1310,7 +1286,34 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void readLanguage(XMLableReader reader) { private void readLanguage(XMLableReader reader) {
String tmpVal; String tmpVal;
if ((tmpVal = reader.getElementValue()) != null) { if ((tmpVal = reader.getElementValue()) != null) {
this.setLanguage(Integer.parseInt(tmpVal)); if (!CommonUtils.isNumber(tmpVal)) {
setLanguage(CommonUtils.stringToLocale(tmpVal));
} else {
// 用于兼容10.0之前的版本
int value = Integer.parseInt(tmpVal);
switch (value) {
case 0:
setLanguage(Locale.SIMPLIFIED_CHINESE);
break;
case 1:
setLanguage(Locale.US);
break;
case 2:
setLanguage(Locale.JAPAN);
break;
case 3:
setLanguage(Locale.TRADITIONAL_CHINESE);
break;
case 4:
setLanguage(Locale.KOREA);
break;
case 5:
setLanguage(new Locale("pt", "PT"));
break;
default:
setLanguage(Locale.SIMPLIFIED_CHINESE);
}
}
} }
} }
@ -1368,6 +1371,34 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
reader.readXMLObject(this.configManager); reader.readXMLObject(this.configManager);
} }
public String getUUID() {
return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid;
}
public int getActiveKeyStatus() {
return activeKeyStatus;
}
public void setActiveKeyStatus(int activeKeyStatus) {
this.activeKeyStatus = activeKeyStatus;
}
public AlphaFineConfigManager getAlphaFineConfigManager() {
return alphaFineConfigManager;
}
public void setAlphaFineConfigManager(AlphaFineConfigManager alphaFineConfigManager) {
this.alphaFineConfigManager = alphaFineConfigManager;
}
public boolean isImageCompress() {
return imageCompress;
}
public void setImageCompress(boolean imageCompress) {
this.imageCompress = imageCompress;
}
/** /**
* Read XML.<br> * Read XML.<br>
* The method will be invoked when read data from XML file.<br> * The method will be invoked when read data from XML file.<br>
@ -1640,17 +1671,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
} }
public String getUUID() {
return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid;
}
public int getActiveKeyStatus() {
return activeKeyStatus;
}
public void setActiveKeyStatus(int activeKeyStatus) {
this.activeKeyStatus = activeKeyStatus;
}
//写入uuid //写入uuid
private void writeUUID(XMLPrintWriter writer) { private void writeUUID(XMLPrintWriter writer) {
@ -1814,7 +1834,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writer.textNode("" + this.lastOpenFilePath); writer.textNode("" + this.lastOpenFilePath);
writer.end(); writer.end();
writer.startTAG("Language").textNode(String.valueOf(this.language)).end() writer.startTAG("Language").textNode(CommonUtils.localeToString(language)).end()
.startTAG("JettyServerPort").textNode(String.valueOf(this.jettyServerPort)).end(); .startTAG("JettyServerPort").textNode(String.valueOf(this.jettyServerPort)).end();
} }
@ -1867,20 +1887,4 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
.end(); .end();
} }
public AlphaFineConfigManager getAlphaFineConfigManager() {
return alphaFineConfigManager;
}
public void setAlphaFineConfigManager(AlphaFineConfigManager alphaFineConfigManager) {
this.alphaFineConfigManager = alphaFineConfigManager;
}
public boolean isImageCompress() {
return imageCompress;
}
public void setImageCompress(boolean imageCompress) {
this.imageCompress = imageCompress;
}
} }

4
designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java

@ -4,8 +4,8 @@ import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -33,7 +33,7 @@ public class VideoAction extends UpdateAction
public void actionPerformed(ActionEvent arg0) public void actionPerformed(ActionEvent arg0)
{ {
String url; String url;
if (FRContext.getLocale().equals(Locale.US)) { if (GeneralContext.getLocale().equals(Locale.US)) {
url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en");
} else { } else {
url = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); url = CloudCenter.getInstance().acquireUrlByKind("bbs.video");

84
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -12,6 +12,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIDictionaryComboBox;
import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
@ -23,7 +24,6 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.log.Log4jConfig; import com.fr.general.log.Log4jConfig;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
@ -32,14 +32,11 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -87,9 +84,7 @@ public class PreferencePane extends BasicPane {
private static final String DISPLAY_MINUS = "-"; private static final String DISPLAY_MINUS = "-";
private static final Level[] LOG = {Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG}; private static final Level[] LOG = {Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG};
private static java.util.List<String> LANGUAGE = new ArrayList<>();
private static int designerEnvLanguageIndex; // 打开设置对话框时,设计器使用的语言
private boolean languageChanged; // 是否修改了设计器语言设置 private boolean languageChanged; // 是否修改了设计器语言设置
//设置是否支持undo //设置是否支持undo
private UICheckBox supportUndoCheckBox; private UICheckBox supportUndoCheckBox;
@ -114,7 +109,8 @@ public class PreferencePane extends BasicPane {
private UITextField logExportDirectoryField; private UITextField logExportDirectoryField;
private UIComboBox logLevelComboBox, languageComboBox, pageLengthComboBox, reportLengthComboBox; private UIComboBox logLevelComboBox, pageLengthComboBox, reportLengthComboBox;
private UIDictionaryComboBox<Locale> languageComboBox;
private IntegerEditor portEditor; private IntegerEditor portEditor;
private UITextField jdkHomeTextField; private UITextField jdkHomeTextField;
private UICheckBox oracleSpace; private UICheckBox oracleSpace;
@ -123,18 +119,8 @@ public class PreferencePane extends BasicPane {
public PreferencePane() { public PreferencePane() {
this.initComponents(); this.initComponents();
this.initLanguageItems();
} }
// 语言选项
private void initLanguageItems() {
LANGUAGE.clear();
Map<Locale, String> map = InterProviderFactory.getProvider().getSupportLocaleMap();
LANGUAGE.add(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Language_Default"));
for (Locale locale : map.keySet()) {
LANGUAGE.add(getLocaledLanguage(map.get(locale), locale));
}
}
protected void initComponents() { protected void initComponents() {
JPanel contentPane = this; JPanel contentPane = this;
@ -182,13 +168,6 @@ public class PreferencePane extends BasicPane {
advancePane.add(spaceUpPane); advancePane.add(spaceUpPane);
} }
private static String getLocaledLanguage(String key, Locale locale) {
StringBuilder sb = new StringBuilder();
sb.append(com.fr.design.i18n.Toolkit.i18nText(key)).append("(");
sb.append(com.fr.design.i18n.Toolkit.i18nText(key)).append(")");
return sb.toString();
}
private void createFunctionPane(JPanel generalPane) { private void createFunctionPane(JPanel generalPane) {
JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference-Function")); JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference-Function"));
generalPane.add(functionPane); generalPane.add(functionPane);
@ -379,8 +358,9 @@ public class PreferencePane extends BasicPane {
JPanel LanguagePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Choose_Language")); JPanel LanguagePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Choose_Language"));
generalPane.add(languageAndDashBoard_pane); generalPane.add(languageAndDashBoard_pane);
languageAndDashBoard_pane.add(LanguagePane); languageAndDashBoard_pane.add(LanguagePane);
languageComboBox = new UIComboBox(LANGUAGE.toArray());
languageComboBox.setFont(FRFont.getInstance("Dialog", Font.PLAIN, 12));//为了在中文系统中显示韩文 languageComboBox = createLanguageComboBox();
ActionLabel languageLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Designer_Language")); ActionLabel languageLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Designer_Language"));
languageLabel.addActionListener(new ActionListener() { languageLabel.addActionListener(new ActionListener() {
@Override @Override
@ -402,16 +382,26 @@ public class PreferencePane extends BasicPane {
Component[][] components = { Component[][] components = {
{languageLabel, languageComboBox, noticeLabel}, {languageLabel, languageComboBox, noticeLabel},
}; };
languageComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
//Inter.fr = ResourceBundle.getBundle("com/fr/general/locale/fr", Locale.US);
}
});
JPanel choosePane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); JPanel choosePane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
LanguagePane.add(choosePane); LanguagePane.add(choosePane);
} }
private UIDictionaryComboBox<Locale> createLanguageComboBox() {
Map<Locale, String> map = InterProviderFactory.getProvider().getSupportLocaleMap();
int size = map.size();
Locale[] keys = new Locale[size];
String[] values = new String[size];
int i = 0;
for (Map.Entry<Locale, String> entry : map.entrySet()) {
keys[i] = entry.getKey();
values[i] = com.fr.design.i18n.Toolkit.i18nText(entry.getValue());
i++;
}
UIDictionaryComboBox<Locale> languageComboBox = new UIDictionaryComboBox<>(keys, values);
languageComboBox.setFont(FRFont.getInstance("Dialog", Font.PLAIN, 12));//为了在中文系统中显示韩文
return languageComboBox;
}
private String getDisplayShortCut(String shotrCut) { private String getDisplayShortCut(String shotrCut) {
return shotrCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH) return shotrCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH)
.replace(CONTROL, DISPLAY_CONTROL).replace(OPEN_BRACKET, DISPLAY_OPEN_BRACKET).replace(CLOSE_BRACKET, DISPLAY_CLOSE_BRACKET) .replace(CONTROL, DISPLAY_CONTROL).replace(OPEN_BRACKET, DISPLAY_OPEN_BRACKET).replace(CLOSE_BRACKET, DISPLAY_CLOSE_BRACKET)
@ -506,7 +496,7 @@ public class PreferencePane extends BasicPane {
JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference_CachingTemplate")); JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference_CachingTemplate"));
UILabel memoryLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference_MaxCachingTemplate")); UILabel memoryLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference_MaxCachingTemplate"));
UILabel memoryTipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference_CachingTemplateTip")); UILabel memoryTipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference_CachingTemplateTip"));
memoryTipLabel.setBorder(BorderFactory.createEmptyBorder( 0, CACHING_GAP, 0, 0)); memoryTipLabel.setBorder(BorderFactory.createEmptyBorder(0, CACHING_GAP, 0, 0));
cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT); cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT);
JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
memorySpace.add(memoryLabel); memorySpace.add(memoryLabel);
@ -564,8 +554,8 @@ public class PreferencePane extends BasicPane {
this.logLevelComboBox.setSelectedItem(Log4jConfig.getInstance().getRootLevel()); this.logLevelComboBox.setSelectedItem(Log4jConfig.getInstance().getRootLevel());
this.languageComboBox.setSelectedItem(LANGUAGE.get(designerEnvManager.getLanguage())); this.languageComboBox.setSelectedItem(designerEnvManager.getLanguage());
designerEnvLanguageIndex = designerEnvManager.getLanguage();
this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit()); this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit());
this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit()); this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit());
@ -625,7 +615,7 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setPaginationLineColor(paginationLineColorTBButton.getColor()); designerEnvManager.setPaginationLineColor(paginationLineColorTBButton.getColor());
designerEnvManager.setLanguage(getLanguageInt()); designerEnvManager.setLanguage(languageComboBox.getSelectedItem());
designerEnvManager.setPageLengthUnit((short) pageLengthComboBox.getSelectedIndex()); designerEnvManager.setPageLengthUnit((short) pageLengthComboBox.getSelectedIndex());
designerEnvManager.setReportLengthUnit((short) reportLengthComboBox.getSelectedIndex()); designerEnvManager.setReportLengthUnit((short) reportLengthComboBox.getSelectedIndex());
@ -637,7 +627,6 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected()); designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue()); designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected()); designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected());
// designerEnvManager.setAutoBackUp(this.autoBackUp.isSelected());
designerEnvManager.setUndoLimit(maxUndoLimit.getSelectedIndex() * SELECTED_INDEX_5); designerEnvManager.setUndoLimit(maxUndoLimit.getSelectedIndex() * SELECTED_INDEX_5);
if (maxUndoLimit.getSelectedIndex() == SELECTED_INDEX_5) { if (maxUndoLimit.getSelectedIndex() == SELECTED_INDEX_5) {
@ -648,21 +637,6 @@ public class PreferencePane extends BasicPane {
} }
/*
* 得到所选语言的int值
*/
private int getLanguageInt() {
int l = 0;
String lang = (String) this.languageComboBox.getSelectedItem();
for (int i = 0; i < LANGUAGE.size(); i++) {
if (ComparatorUtils.equals(lang, LANGUAGE.get(i))) {
l = i;
break;
}
}
return l;
}
// 如果语言设置改变了,则显示重启对话框 // 如果语言设置改变了,则显示重启对话框
public void showRestartDialog() { public void showRestartDialog() {
@ -689,11 +663,7 @@ public class PreferencePane extends BasicPane {
return showWindow(window, new DialogActionAdapter() { return showWindow(window, new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
if (languageComboBox.getSelectedIndex() != designerEnvLanguageIndex) { languageChanged = !ComparatorUtils.equals(languageComboBox.getSelectedItem(), DesignerEnvManager.getEnvManager(false).getLanguage());
languageChanged = true;
} else {
languageChanged = false;
}
} }
}); });
} }

15
designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java

@ -9,14 +9,10 @@ import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.SeparatorDef;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.general.GeneralContext;
import com.fr.stable.EnvChangedListener;
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;
@ -36,17 +32,6 @@ public class SwitchExistEnv extends MenuDef {
this.setName(getMenuKeySet().getMenuName()); this.setName(getMenuKeySet().getMenuName());
this.setHasScrollSubMenu(true); this.setHasScrollSubMenu(true);
initMenuDef(); initMenuDef();
JTemplate<?, ?> t = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (t != null) {
GeneralContext.addEnvWillChangedListener(
t.getPath(),
new EnvChangedListener() {
public void envChanged() {
SwitchExistEnv.this.clearShortCuts();
initMenuDef();
}
});
}
} }
private void initMenuDef() { private void initMenuDef() {

28
designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java

@ -10,8 +10,8 @@ import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
@ -72,16 +72,16 @@ public class AboutPane extends JPanel {
addPhoneAndQQPane(contentPane); addPhoneAndQQPane(contentPane);
// 官网 // 官网
JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Official_Website"), CloudCenter.getInstance().acquireUrlByKind("website." + FRContext.getLocale(), ProductConstants.WEBSITE_URL)); JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Official_Website"), CloudCenter.getInstance().acquireUrlByKind("website." + GeneralContext.getLocale(), ProductConstants.WEBSITE_URL));
// 支持邮箱 // 支持邮箱
String defaultEmail = CloudCenter.getInstance().acquireUrlByKind("support.email", ProductConstants.SUPPORT_EMAIL); String defaultEmail = CloudCenter.getInstance().acquireUrlByKind("support.email", ProductConstants.SUPPORT_EMAIL);
JPanel emailPane = getEmailActionPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Support_Email"), CloudCenter.getInstance().acquireUrlByKind("support.email." + FRContext.getLocale(), defaultEmail)); JPanel emailPane = getEmailActionPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Support_Email"), CloudCenter.getInstance().acquireUrlByKind("support.email." + GeneralContext.getLocale(), defaultEmail));
contentPane.add(urlActionPane); contentPane.add(urlActionPane);
contentPane.add(emailPane); contentPane.add(emailPane);
if (FRContext.getLocale().equals(Locale.CHINA) || FRContext.getLocale().equals(Locale.TAIWAN)){ if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)) {
contentPane.add(getRemarkPane()); contentPane.add(getRemarkPane());
} }
@ -93,13 +93,13 @@ public class AboutPane extends JPanel {
private void addPhoneAndQQPane(JPanel contentPane) { private void addPhoneAndQQPane(JPanel contentPane) {
BoxCenterAligmentPane boxCenterAlignmentPane; BoxCenterAligmentPane boxCenterAlignmentPane;
// 英文版不显示服务电话和QQ // 英文版不显示服务电话和QQ
if (FRContext.getLocale().equals(Locale.US)) { if (GeneralContext.getLocale().equals(Locale.US)) {
return; return;
} }
boxCenterAlignmentPane = new BoxCenterAligmentPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Service_Phone") + CloudCenter.getInstance().acquireUrlByKind("service.phone." + FRContext.getLocale(), COMPANY_TELEPHONE)); boxCenterAlignmentPane = new BoxCenterAligmentPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Service_Phone") + CloudCenter.getInstance().acquireUrlByKind("service.phone." + FRContext.getLocale(), COMPANY_TELEPHONE));
contentPane.add(boxCenterAlignmentPane); contentPane.add(boxCenterAlignmentPane);
// 繁体版不显示QQ // 繁体版不显示QQ
if (FRContext.getLocale().equals(Locale.TAIWAN)) { if (GeneralContext.getLocale().equals(Locale.TAIWAN)) {
return; return;
} }
boxCenterAlignmentPane = new BoxCenterAligmentPane("QQ: " + CloudCenter.getInstance().acquireUrlByKind("help.qq")); boxCenterAlignmentPane = new BoxCenterAligmentPane("QQ: " + CloudCenter.getInstance().acquireUrlByKind("help.qq"));
@ -110,17 +110,17 @@ public class AboutPane extends JPanel {
private boolean shouldShowThanks() { private boolean shouldShowThanks() {
Locale[] hideLocales = {Locale.US, Locale.KOREA, Locale.JAPAN}; Locale[] hideLocales = {Locale.US, Locale.KOREA, Locale.JAPAN};
for (Locale loc : hideLocales) { for (Locale loc : hideLocales) {
if (FRContext.getLocale().equals(loc)) { if (GeneralContext.getLocale().equals(loc)) {
return false; return false;
} }
} }
return true; return true;
} }
private JPanel getRemarkPane(){ private JPanel getRemarkPane() {
String remark = com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_About_Remark_Info",PRESIDENT_PHONE); String remark = com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_About_Remark_Info", PRESIDENT_PHONE);
UILabel label = new UILabel(); UILabel label = new UILabel();
label.setSize(new Dimension(580,30)); label.setSize(new Dimension(580, 30));
//用THML标签进行拼接,以实现自动换行 //用THML标签进行拼接,以实现自动换行
StringBuilder builder = new StringBuilder("<html>"); StringBuilder builder = new StringBuilder("<html>");
@ -139,12 +139,12 @@ public class AboutPane extends JPanel {
break; break;
} }
} }
builder.append(chars, start, len-1).append("<br/>"); builder.append(chars, start, len - 1).append("<br/>");
start = start + len - 1; start = start + len - 1;
len = 0; len = 0;
} }
//拼接剩余部分 //拼接剩余部分
builder.append(chars, start, remark.length()-start); builder.append(chars, start, remark.length() - start);
builder.append("</html>"); builder.append("</html>");
JPanel jPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel jPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
@ -184,7 +184,7 @@ public class AboutPane extends JPanel {
StringUtils.BLANK, ProductConstants.RELEASE_VERSION, BUILD_PREFIX); StringUtils.BLANK, ProductConstants.RELEASE_VERSION, BUILD_PREFIX);
} }
private JPanel getEmailActionPane(final String desc, final String mailTo){ private JPanel getEmailActionPane(final String desc, final String mailTo) {
ActionLabel emailLabel = new ActionLabel(mailTo); ActionLabel emailLabel = new ActionLabel(mailTo);
emailLabel.addActionListener(new ActionListener() { emailLabel.addActionListener(new ActionListener() {
@ -204,7 +204,7 @@ public class AboutPane extends JPanel {
return panel; return panel;
} }
private JPanel getURLActionPane(final String desc, final String url){ private JPanel getURLActionPane(final String desc, final String url) {
ActionLabel actionLabel = new ActionLabel(url); ActionLabel actionLabel = new ActionLabel(url);
actionLabel.addActionListener(new ActionListener() { actionLabel.addActionListener(new ActionListener() {
@Override @Override

3
designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java

@ -6,6 +6,7 @@ import com.fr.base.Utils;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.http.HttpToolbox; import com.fr.general.http.HttpToolbox;
import com.fr.stable.CommonUtils; import com.fr.stable.CommonUtils;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
@ -78,7 +79,7 @@ public class TutorialAction extends UpdateAction {
// 生成帮助文档 sitecenter key, help.zh_CN.10 // 生成帮助文档 sitecenter key, help.zh_CN.10
protected String createDocKey() { protected String createDocKey() {
String locale = FRContext.getLocale().toString(); String locale = GeneralContext.getLocale().toString();
return CommonUtils.join(new String[]{ "help", locale, ProductConstants.MAIN_VERSION }, "."); return CommonUtils.join(new String[]{ "help", locale, ProductConstants.MAIN_VERSION }, ".");
} }

8
designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java

@ -6,9 +6,9 @@ package com.fr.design.editor.editor;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.gui.date.UIDatePicker; import com.fr.design.gui.date.UIDatePicker;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.GeneralContext;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
@ -60,9 +60,9 @@ public class DateEditor extends Editor<Date> {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
uiDatePicker = new UIDatePicker(); uiDatePicker = new UIDatePicker();
if (format) { if (format) {
int dateStyle = (FRContext.getLocale() == Locale.ENGLISH int dateStyle = (GeneralContext.getLocale() == Locale.ENGLISH
|| FRContext.getLocale() == Locale.US || GeneralContext.getLocale() == Locale.US
|| FRContext.getLocale() == Locale.UK) ? uiDatePicker.STYLE_EN_DATE : uiDatePicker.STYLE_CN_DATE; || GeneralContext.getLocale() == Locale.UK) ? uiDatePicker.STYLE_EN_DATE : uiDatePicker.STYLE_CN_DATE;
uiDatePicker.setStyle(dateStyle); uiDatePicker.setStyle(dateStyle);
uiDatePicker.setEditable(false); uiDatePicker.setEditable(false);
} }

2
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java

@ -114,7 +114,6 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
public void closeSelectedReport(JTemplate<?, ?> selected) { public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane(); DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected); DesignTableDataManager.closeTemplate(selected);
GeneralContext.removeEnvWillChangedListener(selected.getPath());
if (contains(selected) == -1) { if (contains(selected) == -1) {
return; return;
} }
@ -139,7 +138,6 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
public void closeVirtualSelectedReport(JTemplate<?, ?> selected) { public void closeVirtualSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane(); DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected); DesignTableDataManager.closeTemplate(selected);
GeneralContext.removeEnvWillChangedListener(selected.getPath());
if (contains(selected) == -1) { if (contains(selected) == -1) {
return; return;
} }

3
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -20,6 +20,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.parser.FRLexer; import com.fr.parser.FRLexer;
import com.fr.parser.FRParser; import com.fr.parser.FRParser;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
@ -774,7 +775,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
desBuf = getText((TextUserObject) selectedValue, path); desBuf = getText((TextUserObject) selectedValue, path);
} }
} catch (IOException exp) { } catch (IOException exp) {
FRContext.getLogger().error(exp.getMessage(), exp); FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
} }
descriptionTextArea.setText(desBuf.toString()); descriptionTextArea.setText(desBuf.toString());
descriptionTextArea.moveCaretPosition(0); descriptionTextArea.moveCaretPosition(0);

4
designer-base/src/main/java/com/fr/design/formula/FunctionNAD.java

@ -1,6 +1,6 @@
package com.fr.design.formula; package com.fr.design.formula;
import com.fr.base.FRContext; import com.fr.general.GeneralContext;
import com.fr.script.CalculatorEmbeddedFunction; import com.fr.script.CalculatorEmbeddedFunction;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.script.Function; import com.fr.stable.script.Function;
@ -24,7 +24,7 @@ public class FunctionNAD extends AbstractNameAndDescription {
if (fn == null) { if (fn == null) {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
Locale locale = FRContext.getLocale(); Locale locale = GeneralContext.getLocale();
String describtion = fn.getDescription(locale); String describtion = fn.getDescription(locale);
if (describtion.startsWith(CalculatorEmbeddedFunction.LOCALE_PREFIX)) { if (describtion.startsWith(CalculatorEmbeddedFunction.LOCALE_PREFIX)) {
// 老的自定义函数兼容, 没有重写getDescription // 老的自定义函数兼容, 没有重写getDescription

7
designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -179,6 +179,7 @@ public class TemplateFileTree extends EnvFileTree {
@Override @Override
protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) { protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) {
FileNode[] fnArray = listFileNodes(treeNode); FileNode[] fnArray = listFileNodes(treeNode);
return fileNodeArray2TreeNodeArray(fnArray); return fileNodeArray2TreeNodeArray(fnArray);
@ -189,13 +190,14 @@ public class TemplateFileTree extends EnvFileTree {
*/ */
private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) { private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) {
boolean isLocal = WorkContext.getCurrent().isLocal(); boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length]; ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length];
for (int i = 0; i < res.length; i++) { for (int i = 0; i < res.length; i++) {
FileNode fn = fileNodes[i]; FileNode fn = fileNodes[i];
res[i] = new ExpandMutableTreeNode(fn); res[i] = new ExpandMutableTreeNode(fn);
if (fn.isDirectory()) { if (fn.isDirectory()) {
res[i].add(new ExpandMutableTreeNode()); res[i].add(new ExpandMutableTreeNode());
if (isLocal || WorkContext.getCurrent().isRoot()) { if (isLocal || isRoot) {
res[i].setFullAuthority(true); res[i].setFullAuthority(true);
} else { } else {
boolean hasFullAuthority = isContained(fn); boolean hasFullAuthority = isContained(fn);
@ -203,7 +205,6 @@ public class TemplateFileTree extends EnvFileTree {
} }
} }
} }
return res; return res;
} }
@ -269,6 +270,7 @@ public class TemplateFileTree extends EnvFileTree {
* 求当前TreeNode下所有的FileNode. * 求当前TreeNode下所有的FileNode.
*/ */
private FileNode[] listFileNodes(ExpandMutableTreeNode currentTreeNode) { private FileNode[] listFileNodes(ExpandMutableTreeNode currentTreeNode) {
if (currentTreeNode == null) { if (currentTreeNode == null) {
return new FileNode[0]; return new FileNode[0];
} }
@ -276,6 +278,7 @@ public class TemplateFileTree extends EnvFileTree {
Object object = currentTreeNode.getUserObject(); Object object = currentTreeNode.getUserObject();
if (object instanceof FileNode) { if (object instanceof FileNode) {
return this.listFileNodes(((FileNode) object).getEnvPath()); return this.listFileNodes(((FileNode) object).getEnvPath());
} }

20
designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java

@ -13,17 +13,30 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.env.EnvListPane; import com.fr.env.EnvListPane;
import com.fr.event.EventDispatcher;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
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;
import com.fr.workspace.WorkspaceEvent;
import com.fr.workspace.connect.AuthException; import com.fr.workspace.connect.AuthException;
import javax.swing.*; import javax.swing.BorderFactory;
import java.awt.*; import javax.swing.Icon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -132,7 +145,6 @@ public class TemplatePane extends JPanel implements MouseListener {
final String selectedName = envListPane.updateEnvManager(); final String selectedName = envListPane.updateEnvManager();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName);
GeneralContext.fireEnvWillChangeListener();
try { try {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
if (workspace == null) { if (workspace == null) {

7
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -50,7 +50,6 @@ import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction;
import com.fr.design.utils.ThemeUtils; import com.fr.design.utils.ThemeUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime; import com.fr.plugin.context.PluginRuntime;
import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.manage.PluginFilter;
@ -224,7 +223,7 @@ public abstract class ToolBarMenuDock {
// 添加帮助菜单 // 添加帮助菜单
menuList.add(createHelpMenuDef()); menuList.add(createHelpMenuDef());
if (FRContext.getLocale() == Locale.CHINA || FRContext.getLocale() == Locale.TAIWAN) { if (GeneralContext.getLocale() == Locale.CHINA || GeneralContext.getLocale() == Locale.TAIWAN) {
// 添加社区菜单 // 添加社区菜单
addCommunityMenuDef(menuList); addCommunityMenuDef(menuList);
} }
@ -272,7 +271,7 @@ public abstract class ToolBarMenuDock {
} }
public void addCommunityMenuDef(java.util.List<MenuDef> menuList) { public void addCommunityMenuDef(java.util.List<MenuDef> menuList) {
Locale locale = FRContext.getLocale(); Locale locale = GeneralContext.getLocale();
Locale[] locales = supportCommunityLocales(); Locale[] locales = supportCommunityLocales();
for (int i = 0; i < locales.length; i++) { for (int i = 0; i < locales.length; i++) {
if (locale.equals(locales[i])) { if (locale.equals(locales[i])) {
@ -451,7 +450,7 @@ public abstract class ToolBarMenuDock {
java.util.List<ShortCut> shortCuts = new ArrayList<ShortCut>(); java.util.List<ShortCut> shortCuts = new ArrayList<ShortCut>();
shortCuts.add(new WebDemoAction()); shortCuts.add(new WebDemoAction());
// 英文,把 video 和帮助文档放到 Help 下面 // 英文,把 video 和帮助文档放到 Help 下面
if (FRContext.getLocale().equals(Locale.US)) { if (GeneralContext.getLocale().equals(Locale.US)) {
shortCuts.add(new VideoAction()); shortCuts.add(new VideoAction());
shortCuts.add(new TutorialAction()); shortCuts.add(new TutorialAction());
} }

2
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -226,7 +226,7 @@ public class DesignUtils {
} }
//先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整. //先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整.
Locale designerLocale = FRContext.getLocale(); Locale designerLocale = GeneralContext.getLocale();
String file = com.fr.design.i18n.Toolkit.i18nText("FR-Designer_File"); String file = com.fr.design.i18n.Toolkit.i18nText("FR-Designer_File");
char displayChar = file.charAt(0); char displayChar = file.charAt(0);
if (!guiFRFont.canDisplay(displayChar)) { if (!guiFRFont.canDisplay(displayChar)) {

23
designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java

@ -1,33 +1,20 @@
package com.fr.design; package com.fr.design;
import com.fr.locale.InterProviderFactory;
import junit.framework.TestCase; import junit.framework.TestCase;
import java.util.HashSet;
import java.util.Locale; import java.util.Locale;
public class DesignerEnvManagerTest extends TestCase{ public class DesignerEnvManagerTest extends TestCase{
public void testGetLocale() { public void testGetLocale() {
DesignerEnvManager envManager = new DesignerEnvManager(); DesignerEnvManager envManager = new DesignerEnvManager();
assertEquals("默认值", envManager.getLocale(), Locale.CHINA); assertEquals("默认值", envManager.getLanguage(), Locale.SIMPLIFIED_CHINESE);
HashSet<Locale> result = new HashSet<>(); envManager.setLanguage(Locale.US);
Locale[] locales = envManager.supportLocale(); assertEquals("上边界", envManager.getLanguage(), Locale.US);
int len = locales.length;
assertEquals(len, InterProviderFactory.getProvider().getSupportLocaleMap().size());
for (int i = 0; i < len; i++) {
envManager.setLanguage(i + 1);
Locale locale = envManager.getLocale();
result.add(locale);
}
assertEquals("每个int都有对应的locale", result.size(), len);
envManager.setLanguage(998);
assertEquals("上边界", envManager.getLocale(), Locale.CHINA);
envManager.setLanguage(-998); envManager.setLanguage(Locale.SIMPLIFIED_CHINESE);
assertEquals("下边界", envManager.getLocale(), Locale.CHINA); assertEquals("下边界", envManager.getLanguage(), Locale.SIMPLIFIED_CHINESE);
} }
} }

11
designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java

@ -13,20 +13,17 @@ public class TutorialActionTest extends TestCase{
TutorialAction action = new TutorialAction(); TutorialAction action = new TutorialAction();
GeneralContext.setLocale(Locale.US); GeneralContext.setLocale(Locale.US);
String enKey = action.createDocKey(); String enKey = action.createDocKey();
assertTrue(enKey.indexOf(Locale.US.toString()) != -1); assertTrue(enKey.contains(Locale.US.toString()));
assertTrue(enKey.indexOf(ProductConstants.MAIN_VERSION) != -1); assertTrue(enKey.contains(ProductConstants.MAIN_VERSION));
GeneralContext.setLocale(Locale.CHINA); GeneralContext.setLocale(Locale.CHINA);
String zhKey = action.createDocKey(); String zhKey = action.createDocKey();
assertTrue(zhKey.indexOf(Locale.CHINA.toString()) != -1); assertTrue(zhKey.contains(Locale.CHINA.toString()));
Locale pt = new Locale("pt", "PT"); Locale pt = new Locale("pt", "PT");
GeneralContext.setLocale(pt); GeneralContext.setLocale(pt);
String ptKey = action.createDocKey(); String ptKey = action.createDocKey();
assertTrue(ptKey.indexOf(pt.toString()) != -1); assertTrue(ptKey.contains(pt.toString()));
GeneralContext.setLanguage(998);
assertTrue(action.createDocKey().indexOf(Locale.CHINA.toString()) != -1);
} }
public void testServerOnline() { public void testServerOnline() {

2
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -115,7 +115,7 @@ public class FormDesignerUI extends ComponentUI {
private void paintWatermark(Graphics2D g) { private void paintWatermark(Graphics2D g) {
WatermarkAttr watermark = ReportUtils.getWatermarkFromAttrMarkFile(designer.getTarget()); WatermarkAttr watermark = ReportUtils.getWatermarkFromAttrMarkFile(designer.getTarget());
WatermarkPainter painter = WatermarkPainter.createPainter(watermark, designer.getResolution()); WatermarkPainter painter = WatermarkPainter.createPainter(watermark, designer.getResolution());
painter.paint(g, 0, designer.getParaHeight(), designer.getArea().getBounds()); painter.paint(g, 0, 0, designer.getArea().getBounds());
} }
private int[] getActualLine(int i) { private int[] getActualLine(int i) {

15
designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java

@ -1,6 +1,5 @@
package com.fr.start; package com.fr.start;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -14,18 +13,12 @@ import com.fr.design.mainframe.ActiveKeyGenerator;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
@ -147,7 +140,7 @@ public class CollectUserInformationDialog extends UIDialog {
private void getKeyAction() { private void getKeyAction() {
Locale locale = FRContext.getLocale(); Locale locale = GeneralContext.getLocale();
String url = EN_LOGIN_HTML; String url = EN_LOGIN_HTML;
if (ComparatorUtils.equals(locale, Locale.TAIWAN)) { if (ComparatorUtils.equals(locale, Locale.TAIWAN)) {
url = TW_LOGIN_HTML; url = TW_LOGIN_HTML;

5
designer-realize/src/main/java/com/fr/start/Designer.java

@ -150,11 +150,6 @@ public class Designer extends BaseDesigner {
private static SplashStrategy createSplash() { private static SplashStrategy createSplash() {
// 这里可以开接口加载自定义启动画面 // 这里可以开接口加载自定义启动画面
if (OperatingSystem.isWindows()) {
return new SplashFx();
} else if (OperatingSystem.isMacOS()) {
return new SplashMac();
}
return new SplashFx(); return new SplashFx();
} }

5
designer-realize/src/main/java/com/fr/start/SplashContext.java

@ -1,11 +1,10 @@
package com.fr.start; package com.fr.start;
import com.fr.base.FRContext;
import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.design.mainframe.bbs.BBSConstants;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.general.GeneralContext;
import com.fr.module.ModuleEvent; import com.fr.module.ModuleEvent;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -135,7 +134,7 @@ public class SplashContext {
private boolean shouldShowThanks() { private boolean shouldShowThanks() {
Locale[] hideLocales = {Locale.CHINA, Locale.TAIWAN}; Locale[] hideLocales = {Locale.CHINA, Locale.TAIWAN};
for (Locale loc : hideLocales) { for (Locale loc : hideLocales) {
if (FRContext.getLocale().equals(loc)) { if (GeneralContext.getLocale().equals(loc)) {
return true; return true;
} }
} }

2
designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

@ -64,7 +64,7 @@ public class PreStartActivator extends Activator {
private void initLanguage() { private void initLanguage() {
//这两句的位置不能随便调换,因为会影响语言切换的问题 //这两句的位置不能随便调换,因为会影响语言切换的问题
GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLocale()); GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLanguage());
} }
@Override @Override

Loading…
Cancel
Save