Browse Source

CORE-116 继续改国际化规范

research/10.0
richie 6 years ago
parent
commit
9ab8e82ada
  1. 130
      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. 5
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  5. 30
      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. 3
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  9. 48
      designer-base/src/main/java/com/fr/design/formula/FunctionNAD.java
  10. 2
      designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java
  11. 7
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  12. 2
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  13. 23
      designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java
  14. 11
      designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java
  15. 15
      designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java
  16. 5
      designer-realize/src/main/java/com/fr/start/SplashContext.java
  17. 2
      designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

130
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.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
import com.fr.stable.Constants;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.ListMap;
@ -43,10 +42,9 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.connect.AuthException;
import javax.swing.SwingWorker;
import javax.swing.*;
import javax.swing.SwingWorker.StateValue;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
@ -111,7 +109,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private Color paginationLineColor = Color.black; // line color of paper
private boolean supportCellEditorDef = false;
private boolean isDragPermited = false;
private int language;
private Locale language = Locale.SIMPLIFIED_CHINESE;
//2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容
private boolean useOracleSystemSpace = true;
private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT;
@ -502,7 +500,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* 返回默认环境
*/
public DesignerWorkspaceInfo getDefaultConfig() {
String installHome = StableUtils.getInstallHome();
String installHome = StableUtils.getInstallHome();
String defaultenvPath = getDefaultenvPath(installHome);
defaultenvPath = new File(defaultenvPath).getPath();
Iterator<Entry<String, DesignerWorkspaceInfo>> entryIt = nameEnvMap.entrySet().iterator();
@ -554,7 +552,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
try {
final String envName = getDefaultEnvName();
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(getDefaultConfig()),new WorkContextCallback() {
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(getDefaultConfig()), new WorkContextCallback() {
@Override
public void done() {
@ -713,37 +711,15 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/**
* 返回语言类型
*/
public int getLanguage() {
return this.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 Locale getLanguage() {
return language;
}
/**
* 设置语言参数
*/
public void setLanguage(int i) {
this.language = i;
public void setLanguage(Locale locale) {
this.language = locale;
}
/**
@ -1310,7 +1286,34 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void readLanguage(XMLableReader reader) {
String tmpVal;
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);
}
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>
* 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
private void writeUUID(XMLPrintWriter writer) {
@ -1814,7 +1834,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writer.textNode("" + this.lastOpenFilePath);
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();
}
@ -1867,20 +1887,4 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
.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.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
@ -33,7 +33,7 @@ public class VideoAction extends UpdateAction
public void actionPerformed(ActionEvent arg0)
{
String url;
if (FRContext.getLocale().equals(Locale.US)) {
if (GeneralContext.getLocale().equals(Locale.US)) {
url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en");
} else {
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.icheckbox.UICheckBox;
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.UILabel;
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.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.log.Log4jConfig;
import com.fr.locale.InterProviderFactory;
import com.fr.third.apache.log4j.Level;
@ -32,14 +32,11 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Map;
@ -87,9 +84,7 @@ public class PreferencePane extends BasicPane {
private static final String DISPLAY_MINUS = "-";
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; // 是否修改了设计器语言设置
//设置是否支持undo
private UICheckBox supportUndoCheckBox;
@ -114,7 +109,8 @@ public class PreferencePane extends BasicPane {
private UITextField logExportDirectoryField;
private UIComboBox logLevelComboBox, languageComboBox, pageLengthComboBox, reportLengthComboBox;
private UIComboBox logLevelComboBox, pageLengthComboBox, reportLengthComboBox;
private UIDictionaryComboBox<Locale> languageComboBox;
private IntegerEditor portEditor;
private UITextField jdkHomeTextField;
private UICheckBox oracleSpace;
@ -123,18 +119,8 @@ public class PreferencePane extends BasicPane {
public PreferencePane() {
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() {
JPanel contentPane = this;
@ -182,13 +168,6 @@ public class PreferencePane extends BasicPane {
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) {
JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference-Function"));
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"));
generalPane.add(languageAndDashBoard_pane);
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"));
languageLabel.addActionListener(new ActionListener() {
@Override
@ -402,16 +382,26 @@ public class PreferencePane extends BasicPane {
Component[][] components = {
{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);
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) {
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)
@ -506,7 +496,7 @@ public class PreferencePane extends BasicPane {
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 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);
JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
memorySpace.add(memoryLabel);
@ -564,8 +554,8 @@ public class PreferencePane extends BasicPane {
this.logLevelComboBox.setSelectedItem(Log4jConfig.getInstance().getRootLevel());
this.languageComboBox.setSelectedItem(LANGUAGE.get(designerEnvManager.getLanguage()));
designerEnvLanguageIndex = designerEnvManager.getLanguage();
this.languageComboBox.setSelectedItem(designerEnvManager.getLanguage());
this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit());
this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit());
@ -625,7 +615,7 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setPaginationLineColor(paginationLineColorTBButton.getColor());
designerEnvManager.setLanguage(getLanguageInt());
designerEnvManager.setLanguage(languageComboBox.getSelectedItem());
designerEnvManager.setPageLengthUnit((short) pageLengthComboBox.getSelectedIndex());
designerEnvManager.setReportLengthUnit((short) reportLengthComboBox.getSelectedIndex());
@ -637,7 +627,6 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected());
// designerEnvManager.setAutoBackUp(this.autoBackUp.isSelected());
designerEnvManager.setUndoLimit(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() {
@ -689,11 +663,7 @@ public class PreferencePane extends BasicPane {
return showWindow(window, new DialogActionAdapter() {
@Override
public void doOk() {
if (languageComboBox.getSelectedIndex() != designerEnvLanguageIndex) {
languageChanged = true;
} else {
languageChanged = false;
}
languageChanged = !ComparatorUtils.equals(languageComboBox.getSelectedItem(), DesignerEnvManager.getEnvManager(false).getLanguage());
}
});
}

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

@ -14,16 +14,15 @@ import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.utils.DesignUtils;
import com.fr.event.EventDispatcher;
import com.fr.general.GeneralContext;
import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Iterator;

30
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.layout.FRGUIPaneFactory;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.GeneralUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
@ -72,18 +72,18 @@ public class AboutPane extends JPanel {
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);
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(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());
}
}
if (shouldShowThanks()) {
addThankPane(contentPane);
@ -93,13 +93,13 @@ public class AboutPane extends JPanel {
private void addPhoneAndQQPane(JPanel contentPane) {
BoxCenterAligmentPane boxCenterAlignmentPane;
// 英文版不显示服务电话和QQ
if (FRContext.getLocale().equals(Locale.US)) {
if (GeneralContext.getLocale().equals(Locale.US)) {
return;
}
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);
// 繁体版不显示QQ
if (FRContext.getLocale().equals(Locale.TAIWAN)) {
if (GeneralContext.getLocale().equals(Locale.TAIWAN)) {
return;
}
boxCenterAlignmentPane = new BoxCenterAligmentPane("QQ: " + CloudCenter.getInstance().acquireUrlByKind("help.qq"));
@ -110,17 +110,17 @@ public class AboutPane extends JPanel {
private boolean shouldShowThanks() {
Locale[] hideLocales = {Locale.US, Locale.KOREA, Locale.JAPAN};
for (Locale loc : hideLocales) {
if (FRContext.getLocale().equals(loc)) {
if (GeneralContext.getLocale().equals(loc)) {
return false;
}
}
return true;
}
private JPanel getRemarkPane(){
String remark = com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_About_Remark_Info",PRESIDENT_PHONE);
private JPanel getRemarkPane() {
String remark = com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_About_Remark_Info", PRESIDENT_PHONE);
UILabel label = new UILabel();
label.setSize(new Dimension(580,30));
label.setSize(new Dimension(580, 30));
//用THML标签进行拼接,以实现自动换行
StringBuilder builder = new StringBuilder("<html>");
@ -139,12 +139,12 @@ public class AboutPane extends JPanel {
break;
}
}
builder.append(chars, start, len-1).append("<br/>");
builder.append(chars, start, len - 1).append("<br/>");
start = start + len - 1;
len = 0;
}
//拼接剩余部分
builder.append(chars, start, remark.length()-start);
builder.append(chars, start, remark.length() - start);
builder.append("</html>");
JPanel jPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
@ -184,7 +184,7 @@ public class AboutPane extends JPanel {
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);
emailLabel.addActionListener(new ActionListener() {
@ -204,7 +204,7 @@ public class AboutPane extends JPanel {
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.addActionListener(new ActionListener() {
@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.menu.MenuKeySet;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.http.HttpToolbox;
import com.fr.stable.CommonUtils;
import com.fr.stable.ProductConstants;
@ -78,7 +79,7 @@ public class TutorialAction extends UpdateAction {
// 生成帮助文档 sitecenter key, help.zh_CN.10
protected String createDocKey() {
String locale = FRContext.getLocale().toString();
String locale = GeneralContext.getLocale().toString();
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.design.gui.date.UIDatePicker;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.GeneralContext;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
@ -60,9 +60,9 @@ public class DateEditor extends Editor<Date> {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
uiDatePicker = new UIDatePicker();
if (format) {
int dateStyle = (FRContext.getLocale() == Locale.ENGLISH
|| FRContext.getLocale() == Locale.US
|| FRContext.getLocale() == Locale.UK) ? uiDatePicker.STYLE_EN_DATE : uiDatePicker.STYLE_CN_DATE;
int dateStyle = (GeneralContext.getLocale() == Locale.ENGLISH
|| GeneralContext.getLocale() == Locale.US
|| GeneralContext.getLocale() == Locale.UK) ? uiDatePicker.STYLE_EN_DATE : uiDatePicker.STYLE_CN_DATE;
uiDatePicker.setStyle(dateStyle);
uiDatePicker.setEditable(false);
}

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

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

@ -1,6 +1,6 @@
package com.fr.design.formula;
import com.fr.base.FRContext;
import com.fr.general.GeneralContext;
import com.fr.script.CalculatorEmbeddedFunction;
import com.fr.stable.StringUtils;
import com.fr.stable.script.Function;
@ -10,29 +10,29 @@ import java.util.Locale;
public class FunctionNAD extends AbstractNameAndDescription {
private Function fn;
FunctionNAD(Function fn) {
this.fn = fn;
}
public String getName() {
return fn == null ? StringUtils.EMPTY : fn.getClass().getSimpleName();
}
public String getDesc() {
if (fn == null) {
return StringUtils.EMPTY;
}
Locale locale = FRContext.getLocale();
String describtion = fn.getDescription(locale);
if (describtion.startsWith(CalculatorEmbeddedFunction.LOCALE_PREFIX)) {
// 老的自定义函数兼容, 没有重写getDescription
return Locale.CHINA.equals(locale) ? fn.getCN() : fn.getEN();
}
return describtion;
}
private Function fn;
FunctionNAD(Function fn) {
this.fn = fn;
}
public String getName() {
return fn == null ? StringUtils.EMPTY : fn.getClass().getSimpleName();
}
public String getDesc() {
if (fn == null) {
return StringUtils.EMPTY;
}
Locale locale = GeneralContext.getLocale();
String describtion = fn.getDescription(locale);
if (describtion.startsWith(CalculatorEmbeddedFunction.LOCALE_PREFIX)) {
// 老的自定义函数兼容, 没有重写getDescription
return Locale.CHINA.equals(locale) ? fn.getCN() : fn.getEN();
}
return describtion;
}
@Override
public String searchResult(String keyWord, boolean findDescription) {

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

@ -13,6 +13,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.DesignUtils;
import com.fr.env.EnvListPane;
import com.fr.event.EventDispatcher;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
@ -20,6 +21,7 @@ import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import com.fr.workspace.connect.AuthException;
import javax.swing.*;

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.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime;
import com.fr.plugin.manage.PluginFilter;
@ -224,7 +223,7 @@ public abstract class ToolBarMenuDock {
// 添加帮助菜单
menuList.add(createHelpMenuDef());
if (FRContext.getLocale() == Locale.CHINA || FRContext.getLocale() == Locale.TAIWAN) {
if (GeneralContext.getLocale() == Locale.CHINA || GeneralContext.getLocale() == Locale.TAIWAN) {
// 添加社区菜单
addCommunityMenuDef(menuList);
}
@ -272,7 +271,7 @@ public abstract class ToolBarMenuDock {
}
public void addCommunityMenuDef(java.util.List<MenuDef> menuList) {
Locale locale = FRContext.getLocale();
Locale locale = GeneralContext.getLocale();
Locale[] locales = supportCommunityLocales();
for (int i = 0; i < locales.length; i++) {
if (locale.equals(locales[i])) {
@ -451,7 +450,7 @@ public abstract class ToolBarMenuDock {
java.util.List<ShortCut> shortCuts = new ArrayList<ShortCut>();
shortCuts.add(new WebDemoAction());
// 英文,把 video 和帮助文档放到 Help 下面
if (FRContext.getLocale().equals(Locale.US)) {
if (GeneralContext.getLocale().equals(Locale.US)) {
shortCuts.add(new VideoAction());
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 designerLocale = FRContext.getLocale();
Locale designerLocale = GeneralContext.getLocale();
String file = com.fr.design.i18n.Toolkit.i18nText("FR-Designer_File");
char displayChar = file.charAt(0);
if (!guiFRFont.canDisplay(displayChar)) {

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

@ -1,33 +1,20 @@
package com.fr.design;
import com.fr.locale.InterProviderFactory;
import junit.framework.TestCase;
import java.util.HashSet;
import java.util.Locale;
public class DesignerEnvManagerTest extends TestCase{
public void testGetLocale() {
DesignerEnvManager envManager = new DesignerEnvManager();
assertEquals("默认值", envManager.getLocale(), Locale.CHINA);
assertEquals("默认值", envManager.getLanguage(), Locale.SIMPLIFIED_CHINESE);
HashSet<Locale> result = new HashSet<>();
Locale[] locales = envManager.supportLocale();
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(Locale.US);
assertEquals("上边界", envManager.getLanguage(), Locale.US);
envManager.setLanguage(998);
assertEquals("上边界", envManager.getLocale(), Locale.CHINA);
envManager.setLanguage(-998);
assertEquals("下边界", envManager.getLocale(), Locale.CHINA);
envManager.setLanguage(Locale.SIMPLIFIED_CHINESE);
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();
GeneralContext.setLocale(Locale.US);
String enKey = action.createDocKey();
assertTrue(enKey.indexOf(Locale.US.toString()) != -1);
assertTrue(enKey.indexOf(ProductConstants.MAIN_VERSION) != -1);
assertTrue(enKey.contains(Locale.US.toString()));
assertTrue(enKey.contains(ProductConstants.MAIN_VERSION));
GeneralContext.setLocale(Locale.CHINA);
String zhKey = action.createDocKey();
assertTrue(zhKey.indexOf(Locale.CHINA.toString()) != -1);
assertTrue(zhKey.contains(Locale.CHINA.toString()));
Locale pt = new Locale("pt", "PT");
GeneralContext.setLocale(pt);
String ptKey = action.createDocKey();
assertTrue(ptKey.indexOf(pt.toString()) != -1);
GeneralContext.setLanguage(998);
assertTrue(action.createDocKey().indexOf(Locale.CHINA.toString()) != -1);
assertTrue(ptKey.contains(pt.toString()));
}
public void testServerOnline() {

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

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

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

@ -1,11 +1,10 @@
package com.fr.start;
import com.fr.base.FRContext;
import com.fr.design.mainframe.bbs.BBSConstants;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.GeneralContext;
import com.fr.module.ModuleEvent;
import com.fr.stable.StringUtils;
@ -135,7 +134,7 @@ public class SplashContext {
private boolean shouldShowThanks() {
Locale[] hideLocales = {Locale.CHINA, Locale.TAIWAN};
for (Locale loc : hideLocales) {
if (FRContext.getLocale().equals(loc)) {
if (GeneralContext.getLocale().equals(loc)) {
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() {
//这两句的位置不能随便调换,因为会影响语言切换的问题
GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLocale());
GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLanguage());
}
@Override

Loading…
Cancel
Save