From 717ce1109002578f33b11c4ed163001e2e882301 Mon Sep 17 00:00:00 2001 From: neil Date: Tue, 13 Dec 2016 15:50:08 +0800 Subject: [PATCH] pmd --- .../widget/ui/TextFieldEditorDefinePane.java | 6 +- .../fr/design/actions/file/LocalePane.java | 90 ++++++++----------- 2 files changed, 40 insertions(+), 56 deletions(-) diff --git a/designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java b/designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java index c9128627cc..1c11aad2e4 100644 --- a/designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java +++ b/designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java @@ -61,7 +61,11 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane regPane.getRegComboBox().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RegExp regExp = (RegExp) regPane.getRegComboBox().getSelectedItem(); - getRegErrorMsgTextField().setEnabled(regExp.errorMessageEditable()); + if (!StringUtils.isNotEmpty(regExp.toRegText())) { + getRegErrorMsgTextField().setEnabled(false); + } else { + getRegErrorMsgTextField().setEnabled(true); + } } }); diff --git a/designer_base/src/com/fr/design/actions/file/LocalePane.java b/designer_base/src/com/fr/design/actions/file/LocalePane.java index 4dd25c5048..c215ab6181 100644 --- a/designer_base/src/com/fr/design/actions/file/LocalePane.java +++ b/designer_base/src/com/fr/design/actions/file/LocalePane.java @@ -4,33 +4,29 @@ package com.fr.design.actions.file; -import java.awt.BorderLayout; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.*; - -import javax.swing.JTable; -import javax.swing.RowFilter; -import javax.swing.SwingWorker; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableRowSorter; - import com.fr.base.Env; import com.fr.base.FRContext; +import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.dialog.BasicPane; import com.fr.file.filetree.FileNode; import com.fr.general.*; import com.fr.stable.ArrayUtils; -import com.fr.stable.StringUtils; -import com.fr.stable.bridge.StableFactory; import com.fr.stable.project.ProjectConstants; +import javax.swing.*; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; +import java.awt.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.*; +import java.util.List; + /** * @author : richie * @since : 8.0 @@ -53,8 +49,8 @@ public class LocalePane extends BasicPane { add(tabbedPane, BorderLayout.CENTER); predefineTableModel = new DefaultTableModel() { - public boolean isCellEditable(int row, int column) { - return column == 0; + public boolean isCellEditable(int col, int row) { + return false; } }; @@ -111,39 +107,23 @@ public class LocalePane extends BasicPane { } private void initPredefinedProperties() { - - Map supportLocaleMap = Inter.getSupportLocaleMap(); - - String[] localeFiles = StableFactory.getLocaleFiles(); - - + Map map = Inter.getPredefinedPackageMap(); + LocalePackage chinese = map.get(Locale.SIMPLIFIED_CHINESE); List sortKeys = new ArrayList(); - for (String path : localeFiles) { - ResourceBundle chineseBundle = loadResourceBundle(path, Locale.SIMPLIFIED_CHINESE); - sortKeys.addAll(chineseBundle.keySet()); + Set bundles = chinese.getKindsOfResourceBundle(); + for (ResourceBundle bundle : bundles) { + sortKeys.addAll(bundle.keySet()); } Collections.sort(sortKeys); - Map> localeResourceBundleMap = new HashMap>(); - for (Map.Entry entry : supportLocaleMap.entrySet()) { - Locale locale = entry.getKey(); - List list = new ArrayList<>(); - for (String path : localeFiles) { - ResourceBundle chineseBundle = loadResourceBundle(path, locale); - list.add(chineseBundle); - } - localeResourceBundleMap.put(locale, list); - } - Map> data = new HashMap>(); - for (Map.Entry> entry : localeResourceBundleMap.entrySet()) { + for (Map.Entry entry : map.entrySet()) { Vector column = new Vector(); - List rbs = entry.getValue(); for (String key : sortKeys) { - column.add(readText(rbs, key)); + column.add(entry.getValue().getLocText(key)); } data.put(entry.getKey(), column); } @@ -158,19 +138,6 @@ public class LocalePane extends BasicPane { } } - private String readText(List rbs, String key) { - for (ResourceBundle rb : rbs) { - if (rb.containsKey(key)) { - return rb.getString(key); - } - } - return null; - } - - private ResourceBundle loadResourceBundle(String dir, Locale locale) { - return ResourceBundle.getBundle(dir, locale, Inter.class.getClassLoader()); - } - private void initCustomProperties() throws Exception { Env env = FRContext.getCurrentEnv(); if (env == null) { @@ -207,9 +174,22 @@ public class LocalePane extends BasicPane { } } + private Properties loadLocaleProperties(String name) { + Properties properties = new Properties(); + InputStream inputStream = IOUtils.readResource("/com/fr/general/locale/" + name); + try { + properties.load(inputStream); + } catch (IOException e) { + FRLogger.getLogger().error(e.getMessage()); + } + return properties; + } + /** * 保存当前编辑的国际化 * + * + * @date 2014-9-30-下午3:10:30 */ public void save() { Env env = FRContext.getCurrentEnv();