diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 034e4968b2..40c3a12eb4 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -19,8 +19,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.Constants; import com.fr.stable.EnvChangedListener; @@ -55,6 +56,7 @@ import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.logging.FileHandler; @@ -700,6 +702,28 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { 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 languageMap = InterProviderFactory.getProvider().getSupportLocaleMap(); + return languageMap.keySet().toArray(new Locale[languageMap.size()]); + } + /** * 设置语言参数 */ diff --git a/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java b/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java index d67af54844..1d98477c2b 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java @@ -81,7 +81,9 @@ public class AboutPane extends JPanel { contentPane.add(urlActionPane); contentPane.add(emailPane); - contentPane.add(getRemarkPane()); + if (FRContext.getLocale().equals(Locale.CHINA) || FRContext.getLocale().equals(Locale.TAIWAN)){ + contentPane.add(getRemarkPane()); + } if (shouldShowThanks()) { addThankPane(contentPane); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java index 32efb23dd8..4e3ea83202 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java @@ -1,24 +1,28 @@ package com.fr.design.actions.help; -import java.awt.Desktop; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.io.File; -import java.io.IOException; -import java.net.URI; - -import javax.swing.KeyStroke; - import com.fr.base.BaseUtils; import com.fr.base.FRContext; 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.http.HttpClient; -import com.fr.stable.OperatingSystem; +import com.fr.general.http.HttpToolbox; +import com.fr.stable.CommonUtils; +import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.os.OperatingSystem; +import com.fr.third.org.apache.http.HttpStatus; +import com.fr.third.org.apache.http.StatusLine; +import com.fr.third.org.apache.http.client.methods.HttpGet; + +import javax.swing.KeyStroke; +import java.awt.Desktop; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.io.File; +import java.io.IOException; +import java.net.URI; public class TutorialAction extends UpdateAction { @@ -56,28 +60,44 @@ public class TutorialAction extends UpdateAction { * @param evt 事件 */ public void actionPerformed(ActionEvent evt) { - String helpURL = CloudCenter.getInstance().acquireUrlByKind("help." + FRContext.getLocale()); - - if (helpURL != null) { - HttpClient client = new HttpClient(helpURL); - if(client.getResponseCode() != -1) { - try { - Desktop.getDesktop().browse(new URI(helpURL)); - return; - } catch (Exception e) { - //出了异常的话, 依然打开本地教程 - } + String helpURL = CloudCenter.getInstance().acquireUrlByKind(createDocKey()); + if (isServerOnline(helpURL)) { + try { + Desktop.getDesktop().browse(new URI(helpURL)); + return; + } catch (Exception e) { } } - if (OperatingSystem.isMacOS()) { + if (OperatingSystem.isUnix()) { nativeExcuteMacInstallHomePrograms("helptutorial.app"); - } - else { + } else { Utils.nativeExcuteInstallHomePrograms("helptutorial.exe"); } } + // 生成帮助文档 sitecenter key, help.zh_CN.10 + protected String createDocKey() { + String locale = FRContext.getLocale().toString(); + return CommonUtils.join(new String[]{ "help", locale, ProductConstants.MAIN_VERSION }, "."); + } + + // 判断是否可以访问在线文档 + protected boolean isServerOnline(String url) { + if (StringUtils.isEmpty(url)) { + return false; + } + + HttpGet getHelp = new HttpGet(url); + try { + StatusLine statusLine = HttpToolbox.getHttpClient(url).execute(getHelp).getStatusLine(); + return statusLine.getStatusCode() == HttpStatus.SC_OK; + } catch (Exception ignore) { + // 网络异常 + return false; + } + } + public static final MenuKeySet HELP_TUTORIAL = new MenuKeySet() { @Override public char getMnemonic() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index eb1e44c058..9f03ddcf66 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -535,7 +535,7 @@ public abstract class JTemplate> FineLoggerFactory.getLogger().error(e.getMessage(), e); } if (!access) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("FR-Designer_No-Privilege") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Permission_Denied") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE); return false; } collectInfo(); @@ -585,7 +585,7 @@ public abstract class JTemplate> FineLoggerFactory.getLogger().error(e.getMessage(), e); } if (!access) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("FR-Designer_No-Privilege") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Permission_Denied") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE); return false; } editingFILE = fileChooser.getSelectedFILE(); diff --git a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java new file mode 100644 index 0000000000..65a3e78df8 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java @@ -0,0 +1,33 @@ +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); + + HashSet 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(998); + assertEquals("上边界", envManager.getLocale(), Locale.CHINA); + + envManager.setLanguage(-998); + assertEquals("下边界", envManager.getLocale(), Locale.CHINA); + + } +} diff --git a/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java b/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java new file mode 100644 index 0000000000..e538a637e3 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java @@ -0,0 +1,40 @@ +package com.fr.design.actions.help; + +import com.fr.general.GeneralContext; +import com.fr.stable.ProductConstants; +import junit.framework.TestCase; + +import java.util.Locale; +import java.util.UUID; + +public class TutorialActionTest extends TestCase{ + + public void testCreateKey() { + 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); + + GeneralContext.setLocale(Locale.CHINA); + String zhKey = action.createDocKey(); + assertTrue(zhKey.indexOf(Locale.CHINA.toString()) != -1); + + 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); + } + + public void testServerOnline() { + TutorialAction action = new TutorialAction(); + assertFalse(action.isServerOnline(null)); + assertFalse(action.isServerOnline("中文")); + assertTrue("百度暂时不会挂", action.isServerOnline("http://www.baidu.com")); + assertTrue("https测试", action.isServerOnline("https://www.baidu.com")); + assertFalse("连上是正常的", action.isServerOnline("https://www.fine-" + UUID.randomUUID() + ".com")); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chart/axis/ChartAlertLinePane.java b/designer-chart/src/main/java/com/fr/design/chart/axis/ChartAlertLinePane.java deleted file mode 100644 index e07379c693..0000000000 --- a/designer-chart/src/main/java/com/fr/design/chart/axis/ChartAlertLinePane.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.fr.design.chart.axis; - - -import com.fr.general.NameObject; -import com.fr.stable.Nameable; -import com.fr.chart.chartattr.ChartAlertValue; -import com.fr.design.gui.controlpane.JListControlPane; -import com.fr.design.gui.controlpane.NameObjectCreator; -import com.fr.design.gui.controlpane.NameableCreator; - -import java.util.ArrayList; -import java.util.List; - -public class ChartAlertLinePane extends JListControlPane { - - public NameableCreator[] createNameableCreators() { - return new NameableCreator[]{ - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("ChartF-Alert-Line"), - ChartAlertValue.class, ChartAlertValuePane.class) - }; - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Edit", "ChartF-Alert-Line"}); - } - - public void populate(ChartAlertValue[] alertList) { - if (alertList == null) { - alertList = new ChartAlertValue[0]; - } - List nameObjectList = new ArrayList(); - - for (int i = 0; i < alertList.length; i++) { - ChartAlertValue value = alertList[i]; - nameObjectList.add(new NameObject(value.getAlertPaneSelectName(), value)); - } - - if (!nameObjectList.isEmpty()) { - populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); - } - } - - public ChartAlertValue[] updateAlertValues() { - Nameable[] res = update(); - - NameObject[] res_array = new NameObject[res.length]; - java.util.Arrays.asList(res).toArray(res_array); - - if (res_array.length < 1) { - return new ChartAlertValue[0]; - } - - List alertValueList = new ArrayList(); - for (int i = 0; i < res_array.length; i++) { - NameObject nameObject = res_array[i]; - ChartAlertValue chartAlertValue = (ChartAlertValue) nameObject.getObject(); - chartAlertValue.setAlertPaneSelectName(nameObject.getName()); - alertValueList.add(chartAlertValue); - } - return (ChartAlertValue[]) alertValueList.toArray(new ChartAlertValue[alertValueList.size()]); - } -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chart/axis/ChartAlertValuePane.java b/designer-chart/src/main/java/com/fr/design/chart/axis/ChartAlertValuePane.java index d599c19e65..6608c55aaf 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/axis/ChartAlertValuePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/axis/ChartAlertValuePane.java @@ -61,12 +61,12 @@ public class ChartAlertValuePane extends BasicBeanPane { JPanel alertLinePane =FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); pane.add(alertLinePane); - alertLinePane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"ChartF-Alert-Line", "Set"}))); + alertLinePane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Line_Setting"))); JPanel valuePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); alertLinePane.add(valuePane); - valuePane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"ChartF_Alert", "Value"}) + ":")); + valuePane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Value") + ":")); textField = new UITextField(); textField.setColumns(4); @@ -88,14 +88,14 @@ public class ChartAlertValuePane extends BasicBeanPane { JPanel lineStylePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); alertLinePane.add(lineStylePane); - lineStylePane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Line-Style") + ":")); + lineStylePane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Line_Style") + ":")); lineCombo = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); lineStylePane.add(lineCombo); JPanel lineColorPane =FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); alertLinePane.add(lineColorPane); - lineColorPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"ChartF-Alert-Line", "Color"}) + ":")); + lineColorPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Line_Color") + ":")); colorBox = new ColorSelectBox(80); lineColorPane.add(colorBox); @@ -105,7 +105,7 @@ public class ChartAlertValuePane extends BasicBeanPane { JPanel tipPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); pane.add(tipPane); - tipPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Chart_Alert_Tip") + ":", null)); + tipPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Tip") + ":", null)); JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); tipPane.add(centerPane); @@ -130,10 +130,10 @@ public class ChartAlertValuePane extends BasicBeanPane { double[] rowSize = {t, t, t, t, t}; double[] columnSize = {0.1, 0.2, 0.5, 0.2}; Component[][] components= { - {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Content") + ":"), contentField = new UITextField(3)}, - {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("FRFont") + ":"), fontNameBox}, - {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("FRFont-Size") + ":"), fontSizeBox}, - {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Layout") + ": "), leftButton = new UIRadioButton(getLeftName())}, + {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Content") + ":"), contentField = new UITextField(3)}, + {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Font") + ":"), fontNameBox}, + {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Font_Size") + ":"), fontSizeBox}, + {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Layout") + ": "), leftButton = new UIRadioButton(getLeftName())}, {null, null, rightButton = new UIRadioButton(getRightName())}, }; @@ -148,16 +148,16 @@ public class ChartAlertValuePane extends BasicBeanPane { } protected String getLeftName() {// 居左 居右 - return com.fr.design.i18n.Toolkit.i18nText("Chart_Alert_Left"); + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_At_The_Left"); } protected String getRightName() { - return com.fr.design.i18n.Toolkit.i18nText("Chart_Alert_Right"); + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_At_The_Right"); } @Override protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("ChartF-Alert-Line"); + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Line"); } private void showFormulaPane() { diff --git a/designer-chart/src/main/java/com/fr/design/chart/axis/ChartStyleAxisPane.java b/designer-chart/src/main/java/com/fr/design/chart/axis/ChartStyleAxisPane.java index 71366d543d..8b17587a4e 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/axis/ChartStyleAxisPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/axis/ChartStyleAxisPane.java @@ -27,7 +27,7 @@ import com.fr.design.dialog.BasicPane; public abstract class ChartStyleAxisPane extends BasicPane implements ListSelectionListener { protected static final String CATE_AXIS = com.fr.design.i18n.Toolkit.i18nText("ChartF-Category_Axis"); protected static final String VALUE_AXIS = com.fr.design.i18n.Toolkit.i18nText("Chart_F_Radar_Axis"); - protected static final String SECOND_AXIS = com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Second", "Chart_F_Radar_Axis"}); + protected static final String SECOND_AXIS = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Second_Value_Axis"); private JList mainList; private CardLayout cardLayout; private JPanel cardDisplayPane = null; diff --git a/designer-chart/src/main/java/com/fr/design/chart/axis/MinMaxValuePane.java b/designer-chart/src/main/java/com/fr/design/chart/axis/MinMaxValuePane.java index d5645fa750..02eb1a2e11 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/axis/MinMaxValuePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/axis/MinMaxValuePane.java @@ -31,13 +31,13 @@ public class MinMaxValuePane extends JPanel { protected UITextField secUnitField; public MinMaxValuePane() { - minCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Custom", "Min_Value"})); + minCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Custom_Min_Value")); minValueField = new UITextField(6); - maxCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Custom", "Max_Value"})); + maxCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Custom_Max_Value")); maxValueField = new UITextField(6); - isCustomMainUnitBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Custom", "FR-Chart_MainGraduationUnit"})); + isCustomMainUnitBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Main_Graduation_Unit")); mainUnitField = new UITextField(6); - isCustomSecUnitBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Custom", "FR-Chart_SecondGraduationUnit"})); + isCustomSecUnitBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Second_Graduation_Unit")); secUnitField = new UITextField(6); double p = TableLayout.PREFERRED; diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java index f8d56b04d4..23c44e530d 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java @@ -11,7 +11,7 @@ public class SetAnalysisLineStyleAction extends ChartComponentAction{ public SetAnalysisLineStyleAction(ChartComponent chartComponent) { super(chartComponent); - this.setName(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Set", "AnalysisLine"})); + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Analysis_Line")); } @Override diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java index e3abec9b45..a4920e883b 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java @@ -18,7 +18,7 @@ import com.fr.stable.StringUtils; public class SetAxisStyleAction extends ChartComponentAction { public SetAxisStyleAction(ChartComponent chartComponent) { super(chartComponent); - this.setName(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Set", "ChartF-Axis", "Format"})); + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Axis_Format")); } public void actionPerformed(ActionEvent e) { diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java index a961a58197..eda97f42f4 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java @@ -18,7 +18,7 @@ public class SetChartStyleAciton extends ChartComponentAction { public SetChartStyleAciton(ChartComponent chartComponent) { super(chartComponent); - this.setName(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"DashBoard-ChartFloat", "Style"})); + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style")); } public void actionPerformed(ActionEvent e) { diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java index f6b5532493..262016bfac 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java @@ -11,7 +11,7 @@ public class SetDataLabelStyleAction extends ChartComponentAction{ public SetDataLabelStyleAction(ChartComponent chartComponent) { super(chartComponent); - this.setName(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Set", "Data-Label"})); + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Data_Label")); } @Override diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java index 1d6fd311dd..92b7530f1e 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java @@ -19,7 +19,7 @@ public class SetPlotStyleAction extends ChartComponentAction { public SetPlotStyleAction(ChartComponent chartComponent) { super(chartComponent); - this.setName(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Set", "ChartF-Plot"})); + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Plot")); } public void actionPerformed(ActionEvent e) { diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java index 68b4e16b03..b336475d4d 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java @@ -19,7 +19,7 @@ public class SetTitleStyleAction extends ChartComponentAction { public SetTitleStyleAction(ChartComponent chartComponent) { super(chartComponent); - this.setName(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Set", "Title", "Style"})); + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Title_Style")); } public void actionPerformed(ActionEvent e) { diff --git a/designer-chart/src/main/java/com/fr/design/chart/report/GisMapReportDataContentPane.java b/designer-chart/src/main/java/com/fr/design/chart/report/GisMapReportDataContentPane.java index b6e90e843f..55063796a4 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/report/GisMapReportDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/report/GisMapReportDataContentPane.java @@ -84,7 +84,7 @@ public class GisMapReportDataContentPane extends FurtherBasicBeanPane { * 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"SingleLayer", "Chart-Map"}); + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Single_Layer_Map"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/chart/report/MapTableCubeDataPane.java b/designer-chart/src/main/java/com/fr/design/chart/report/MapTableCubeDataPane.java index e64b6fcff2..c600c13255 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/report/MapTableCubeDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/report/MapTableCubeDataPane.java @@ -33,7 +33,7 @@ public class MapTableCubeDataPane extends FurtherBasicBeanPane tableEditorPane; private final String[] columnNames = new String[] { - com.fr.design.i18n.Toolkit.i18nTextArray(new String[] {"Verify-Verify_Formula", "Verify-ToolTips"}, new String[] {"(", ")"}), - com.fr.design.i18n.Toolkit.i18nText("Verify-Error_Information") }; + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Formula_Verify"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Formula_Verify_Warn_Text") }; public ValueVerifierEditPane() { // ben:UITableEditorPane; diff --git a/designer-realize/src/main/java/com/fr/design/webattr/ReportWebWidgetConstants.java b/designer-realize/src/main/java/com/fr/design/webattr/ReportWebWidgetConstants.java index ab46373052..b95123ea43 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/ReportWebWidgetConstants.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/ReportWebWidgetConstants.java @@ -4,10 +4,8 @@ import com.fr.base.BaseUtils; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOptionFactory; import com.fr.form.ui.CustomToolBarButton; -import com.fr.form.ui.Widget; import com.fr.report.web.button.AppletPrint; -import com.fr.report.web.button.Edit; import com.fr.report.web.button.Email; import com.fr.report.web.button.ExcelO; import com.fr.report.web.button.ExcelP; @@ -16,13 +14,11 @@ import com.fr.report.web.button.Export; import com.fr.report.web.button.FlashPrint; import com.fr.report.web.button.NewPrint; import com.fr.report.web.button.PDF; -import com.fr.report.web.button.PDF2; import com.fr.report.web.button.PDFPrint; import com.fr.report.web.button.PageSetup; import com.fr.report.web.button.Print; import com.fr.report.web.button.PrintPreview; import com.fr.report.web.button.Scale; -import com.fr.report.web.button.ServerPrint; import com.fr.report.web.button.Word; import com.fr.report.web.button.page.First; import com.fr.report.web.button.page.Last; @@ -45,8 +41,6 @@ import com.fr.report.web.button.write.Submit; import com.fr.report.web.button.write.SubmitForcibly; import com.fr.report.web.button.write.Verify; import com.fr.report.web.button.write.WriteOfflineHTML; -import com.fr.stable.bridge.BridgeMark; -import com.fr.stable.bridge.StableFactory; public class ReportWebWidgetConstants { private ReportWebWidgetConstants() { @@ -61,25 +55,12 @@ public class ReportWebWidgetConstants { return new WidgetOption[]{PAGESETUP, EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, NEW_PRINT, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, SETPRINTEROFFSET, PRINTPREVIEW, CUSTOM_BUTTON}; } - public static WidgetOption[] getPreviewToolBarInstance() { - return new WidgetOption[]{FIRST, PREVIOUS, PAGENAVI, NEXT, LAST, SCALE, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, NEW_PRINT, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, - SETPRINTEROFFSET, CUSTOM_BUTTON}; - } - public static WidgetOption[] getWriteToolBarInstance() { return new WidgetOption[]{SUBMIT, VERIFY, EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, NEW_PRINT, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, IMPORTEXCELDATA, SHOWCELLVALUE, APPENDCOLUMNROW, DELETECOLUMNROW, SETPRINTEROFFSET, WRITEOFFLINEHTML, CUSTOM_BUTTON, WRITESTASH, WRITESTASHCLEAR, IMPORTEXCELDATA_CUSTOMIZED, IMPORTEXCEL, IMPORTEXCEL_COVER, IMPORTEXCEL_CLEAN, IMPORTEXCEL_APPEND}; } - public static WidgetOption[] getFormToolBarInstance() { - return new WidgetOption[]{EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, NEW_PRINT, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, SETPRINTEROFFSET, CUSTOM_BUTTON}; - } - - // 查询 - public static final WidgetOption SEARCH = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Query", "Form-Button"}), - BaseUtils.readIcon("/com/fr/web/images/form/resources/preview_16.png"), StableFactory.getMarkedClass(BridgeMark.SUBMIT_BUTTON, Widget.class)); - // 提交按钮 public static final WidgetOption SUBMIT = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("FR-Engine_Utils-Submit"), BaseUtils.readIcon("/com/fr/web/images/save.png"), Submit.class); @@ -96,36 +77,29 @@ public class ReportWebWidgetConstants { public static final WidgetOption PDF = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("FR-Engine_ReportServerP-PDF"), BaseUtils.readIcon("/com/fr/web/images/pdf.png"), PDF.class); - // PDF导出,解决linux下无中文字体的导出字体混乱 - public static final WidgetOption PDF2 = WidgetOptionFactory.createByWidgetClass( - com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"ReportServerP-PDF", "ReportServerP-PDF2-INFO"}, new String[]{"(", ")"}), BaseUtils.readIcon("/com/fr/web/images/pdf.png"), PDF2.class); - // 客户端PDF打印 public static final WidgetOption PDFPRINT = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("FR-Engine_Utils-Print[Client]"), BaseUtils.readIcon("/com/fr/web/images/pdfPrint.png"), PDFPrint.class); - // 服务器端打印 - public static final WidgetOption SERVERPRINT = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("FR-Engine_ReportServerP-Print[Server]"), - BaseUtils.readIcon("/com/fr/web/images/serverPrint.png"), ServerPrint.class); + // 邮件发送 public static final WidgetOption EMAIL = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("FR-Engine_Email"), BaseUtils.readIcon("/com/fr/web/images/email.png"), Email.class); public static final WidgetOption PRINTPREVIEW = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("PrintP-Print_Preview"), BaseUtils.readIcon("/com/fr/web/images/preview.png"), PrintPreview.class); - public static final WidgetOption EDIT = WidgetOptionFactory.createByWidgetClass("Edit", Edit.class); // 导出成Excel 分页导出 - public static final WidgetOption EXCELP = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Excel", "FR-Designer_Export_Excel_Page"}, new String[]{"(", ")"}), + public static final WidgetOption EXCELP = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Export_Excel_Page"), BaseUtils.readIcon("/com/fr/web/images/excel.png"), ExcelP.class); // 导出成Excel 原样导出 - public static final WidgetOption EXCELO = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Excel", "FR-Designer_Export_Excel_Simple"}, new String[]{"(", ")"}), + public static final WidgetOption EXCELO = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Export_Excel_Simple"), BaseUtils.readIcon("/com/fr/web/images/excel.png"), ExcelO.class); // 导出成Excel 分页分Sheet导出 - public static final WidgetOption EXCELS = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Excel", "FR-Designer_Export_Excel_PageToSheet"}, new String[]{"(", ")"}), + public static final WidgetOption EXCELS = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Export_Excel_Page_To_Sheet"), BaseUtils.readIcon("/com/fr/web/images/excel.png"), ExcelS.class); // 导出成Word - public static final WidgetOption WORD = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("FR-Engine_Word"), BaseUtils.readIcon("/com/fr/web/images/word.png"), Word.class); + public static final WidgetOption WORD = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Export_Word"), BaseUtils.readIcon("/com/fr/web/images/word.png"), Word.class); // 页面设置 public static final WidgetOption PAGESETUP = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("PageSetup-Page_Setup"), BaseUtils.readIcon("/com/fr/web/images/pageSetup.png"), PageSetup.class); // 导出 @@ -133,7 +107,7 @@ public class ReportWebWidgetConstants { .createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("FR-Engine_Export"), BaseUtils.readIcon("/com/fr/web/images/export.png"), Export.class); // 当前页/总页数 - public static final WidgetOption PAGENAVI = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"HJS-Current_Page", "HF-Number_of_Page"}, new String[]{"/", ""}), + public static final WidgetOption PAGENAVI = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Widget_Page_Navi_Text"), BaseUtils.readIcon("/com/fr/web/images/pageNumber.png"), PageNavi.class); // 首页 public static final WidgetOption FIRST = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("FR-Engine_ReportServerP-First"), BaseUtils.readIcon("/com/fr/web/images/first.png"), diff --git a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java index c7fb372ecf..45e1d7ece7 100644 --- a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java +++ b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java @@ -1,21 +1,5 @@ package com.fr.design.write.submit; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dialog; -import java.awt.event.ActionEvent; - -import javax.swing.BorderFactory; -import javax.swing.JDialog; -import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; - import com.fr.cache.list.IntList; import com.fr.data.ClassSubmitJob; import com.fr.design.actions.UpdateAction; @@ -30,13 +14,16 @@ import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UIBasicSpinner; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.*; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.JWorkBook; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; - import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; @@ -45,411 +32,423 @@ import com.fr.stable.ColumnRowGroup; import com.fr.stable.StringUtils; import com.fr.write.DMLConfigJob; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableColumn; +import java.awt.*; +import java.awt.event.ActionEvent; + public class SmartInsertDBManipulationPane extends DBManipulationPane { - private static final Selection NO_SELECTION = new CellSelection(-1, -1, -1, -1); - private ElementCasePane ePane; - private static int CELL_GROUP_LIMIT = 6; + private static final Selection NO_SELECTION = new CellSelection(-1, -1, -1, -1); + private ElementCasePane ePane; + private static int CELL_GROUP_LIMIT = 6; private static int TOP_PADDING = 30; private static int LEFT_COLUMN_MAX_WIDTH = 40; - public SmartInsertDBManipulationPane(ElementCasePane ePane) { - super(ValueEditorPaneFactory.extendedCellGroupEditors()); - this.ePane = ePane; - } + public SmartInsertDBManipulationPane(ElementCasePane ePane) { + super(ValueEditorPaneFactory.extendedCellGroupEditors()); + this.ePane = ePane; + } public SmartInsertDBManipulationPane() { super(ValueEditorPaneFactory.extendedCellGroupEditors()); - init(); + init(); + } + + private void init() { + JTemplate jTemplate = DesignerContext.getDesignerFrame().getSelectedJTemplate(); + this.ePane = ((JWorkBook) jTemplate).getEditingElementCasePane(); + } + + @Override + protected SubmitJobListPane createSubmitJobListPane() { + return new SmartInsertSubmitJobListPane(); + } + + class SmartInsertSubmitJobListPane extends SubmitJobListPane { + + public SmartInsertSubmitJobListPane() { + super(ePane); + } + + public void hideParentDialog() { + hideDialog4AddCellAction(); + } + + public void showParentDialog() { + showDialogAfterAddCellAction(); + } + + @Override + public NameableCreator[] createNameableCreators() { + return new NameableCreator[]{ + new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Submit", "Event"}), + "/com/fr/web/images/reportlet.png", + DMLConfigJob.class, + SmartInsertDMLJobPane.class), + new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Custom", "Event"}), + "/com/fr/web/images/reportlet.png", + ClassSubmitJob.class, + CustomSubmitJobPane.class)}; + } + } + + @Override + protected UpdateAction[] getActions() { + return new UpdateAction[]{ + new SmartAddFieldsAction(), + new AddFieldAction(), + new SmartAddCellAction(), + new SmartAddCellGroupAction(), + new BatchModCellAction(), + new RemoveFieldAction() + }; + } + + public class BatchModCellAction extends UpdateAction { + public BatchModCellAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("RWA-Batch_Modify_Cells")); + } + + /** + * 执行事件 + * + * @param evt 事件对象 + */ + public void actionPerformed(ActionEvent evt) { + BasicPane bPane = new BasicPane() { + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("RWA-Batch_Modify_Cells"); + } + }; + bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); + bPane.setBorder(BorderFactory.createEmptyBorder(TOP_PADDING, 0, 0, 0)); + final UIBasicSpinner columnSpinner = new UIBasicSpinner(); + final UIBasicSpinner rowSpinner = new UIBasicSpinner(); + Component[][] coms = new Component[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("RWA-Row_Offset")), rowSpinner}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("RWA-Column_Offset")), columnSpinner}}; + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + bPane.add(TableLayoutHelper.createTableLayoutPane(coms, new double[]{p, p}, new double[]{p, f}), BorderLayout.NORTH); + BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(SmartInsertDBManipulationPane.this), new DialogActionAdapter() { + public void doOk() { + int row_offset = ((Number) rowSpinner.getValue()).intValue(); + int column_offset = ((Number) columnSpinner.getValue()).intValue(); + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); + int[] selectedRows = keyColumnValuesTable.getSelectedRows(); + // 如果一行都没选中,取所有的行 + if (selectedRows.length == 0) { + selectedRows = IntList.range(model.getRowCount()); + } + for (int i = 0; i < selectedRows.length; i++) { + int row = selectedRows[i]; + KeyColumnNameValue kcnv = model.getKeyColumnNameValue(row); + if (kcnv.cv.obj instanceof ColumnRow) { + ColumnRow or = (ColumnRow) kcnv.cv.obj; + int n_column = or.getColumn() + column_offset; + if (n_column < 0) { + n_column = 0; + } + int n_row = or.getRow() + row_offset; + if (n_row < 0) { + n_row = 0; + } + kcnv.cv.obj = ColumnRow.valueOf(n_column, n_row); + } + } + model.fireTableDataChanged(); + keyColumnValuesTable.validate(); + for (int i = 0; i < selectedRows.length; i++) { + keyColumnValuesTable.addRowSelectionInterval(selectedRows[i], selectedRows[i]); + } + } + }); + dlg.setVisible(true); + } + } + + public class SmartAddCellAction extends UpdateAction { + public SmartAddCellAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("RWA-Smart_Add_Cells")); + } + + /** + * 执行事件 + * + * @param evt 事件s + */ + public void actionPerformed(ActionEvent evt) { + showCellWindow(false); + } } - private void init() { - JTemplate jTemplate = DesignerContext.getDesignerFrame().getSelectedJTemplate(); - this.ePane = ((JWorkBook) jTemplate).getEditingElementCasePane(); - } - - @Override - protected SubmitJobListPane createSubmitJobListPane() { - return new SmartInsertSubmitJobListPane(); - } - - class SmartInsertSubmitJobListPane extends SubmitJobListPane { - - public SmartInsertSubmitJobListPane() { - super(ePane); - } - - public void hideParentDialog() { - hideDialog4AddCellAction(); - } - - public void showParentDialog() { - showDialogAfterAddCellAction(); - } - - @Override - public NameableCreator[] createNameableCreators() { - return new NameableCreator[] { - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Submit", "Event"}), - "/com/fr/web/images/reportlet.png", - DMLConfigJob.class, - SmartInsertDMLJobPane.class), - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Custom", "Event"}), - "/com/fr/web/images/reportlet.png", - ClassSubmitJob.class, - CustomSubmitJobPane.class) }; - } - } - - @Override - protected UpdateAction[] getActions() { - return new UpdateAction[] { - new SmartAddFieldsAction(), - new AddFieldAction(), - new SmartAddCellAction(), - new SmartAddCellGroupAction(), - new BatchModCellAction(), - new RemoveFieldAction() - }; - } - - public class BatchModCellAction extends UpdateAction { - public BatchModCellAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("RWA-Batch_Modify_Cells")); - } - - /** - * 执行事件 - * @param evt 事件对象 - */ - public void actionPerformed(ActionEvent evt) { - BasicPane bPane = new BasicPane() { - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("RWA-Batch_Modify_Cells"); - } - }; - bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - bPane.setBorder(BorderFactory.createEmptyBorder(TOP_PADDING, 0, 0, 0)); - final UIBasicSpinner columnSpinner = new UIBasicSpinner(); - final UIBasicSpinner rowSpinner = new UIBasicSpinner(); - Component[][] coms = new Component[][] { { new UILabel(com.fr.design.i18n.Toolkit.i18nText("RWA-Row_Offset")), rowSpinner },{ new UILabel(com.fr.design.i18n.Toolkit.i18nText("RWA-Column_Offset")), columnSpinner } }; - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - bPane.add(TableLayoutHelper.createTableLayoutPane(coms, new double[]{p, p}, new double[]{p, f}), BorderLayout.NORTH); - BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(SmartInsertDBManipulationPane.this), new DialogActionAdapter() { - public void doOk() { - int row_offset = ((Number)rowSpinner.getValue()).intValue(); - int column_offset = ((Number)columnSpinner.getValue()).intValue(); - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); - int[] selectedRows = keyColumnValuesTable.getSelectedRows(); - // 如果一行都没选中,取所有的行 - if (selectedRows.length == 0) { - selectedRows = IntList.range(model.getRowCount()); - } - for (int i = 0; i < selectedRows.length; i++) { - int row = selectedRows[i]; - KeyColumnNameValue kcnv = model.getKeyColumnNameValue(row); - if (kcnv.cv.obj instanceof ColumnRow) { - ColumnRow or = (ColumnRow)kcnv.cv.obj; - int n_column = or.getColumn() + column_offset; - if (n_column < 0) { - n_column = 0; - } - int n_row = or.getRow() + row_offset; - if (n_row < 0) { - n_row = 0; - } - kcnv.cv.obj = ColumnRow.valueOf(n_column, n_row); - } - } - model.fireTableDataChanged(); - keyColumnValuesTable.validate(); - for (int i = 0; i < selectedRows.length; i++) { - keyColumnValuesTable.addRowSelectionInterval(selectedRows[i], selectedRows[i]); - } - } - }); - dlg.setVisible(true); - } - } - - public class SmartAddCellAction extends UpdateAction { - public SmartAddCellAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("RWA-Smart_Add_Cells")); - } - - /** - * 执行事件 - * @param evt 事件s - */ - public void actionPerformed(ActionEvent evt) { - showCellWindow(false); - } - } - - public class SmartAddCellGroupAction extends UpdateAction { - public SmartAddCellGroupAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("RWA-Smart_Add_Cell_Group")); - } - - /** - * 智能添加单元格组 - * @param e 事件s - */ - public void actionPerformed(ActionEvent e) { - showCellWindow(true); - } - } - - /** - * 切换到单元格窗口,设置属性面板不可编辑 - * @param isCellGroup 判断是否单元格组 - */ - - private void showCellWindow(boolean isCellGroup){ - if (ePane == null) { - return; - } - - BasicPane bPane = new SmartJTablePane4DB(keyColumnValuesTable.getTableModel4SmartAddCell(), ePane, isCellGroup); - - // ReportWriteAttrDialog.this.setVisible(false); - hideDialog4AddCellAction(); - /* - * 当前的ReportPane不可编辑,不可切换Sheet,加GridSelectionChangeListener - */ - //必须先设置面板不可编辑才能释放单元格选中 - ePane.setEditable(false); - ePane.setSelection(NO_SELECTION); - ePane.getGrid().setNotShowingTableSelectPane(false); - - BasicDialog dlg = bPane.showWindow(SwingUtilities.getWindowAncestor(SmartInsertDBManipulationPane.this)); - - dlg.setModal(false); - dlg.setVisible(true); - } - - private void showDialogAfterAddCellAction() { - Container dialog = this; - if (parentPane != null && parentPane.getContentDBManiPane() instanceof SmartInsertDBManipulationPane && parentPane.getContentDBManiPane() != this) { - ((SmartInsertDBManipulationPane)parentPane.getContentDBManiPane()).showDialogAfterAddCellAction(); - } - while (dialog.getParent() != null) { - dialog = dialog.getParent(); - if (dialog instanceof Dialog) { - //这边需要另起一个线程设置可见,防止阻塞 - final Container finalDialog = dialog; - SwingWorker worker = new SwingWorker() { - @Override - protected Object doInBackground() throws Exception { - finalDialog.setVisible(true); - return null; - } - }; - worker.execute(); - } - } - } - - private void hideDialog4AddCellAction() { - Container dialog = this; - if (parentPane != null && parentPane.getContentDBManiPane() instanceof SmartInsertDBManipulationPane && parentPane.getContentDBManiPane() != this) { - ((SmartInsertDBManipulationPane)parentPane.getContentDBManiPane()).hideDialog4AddCellAction(); - } - while (dialog.getParent() != null) { - dialog = dialog.getParent(); - if (dialog instanceof Dialog) { - // 条件属性中添加的控件的话有两层dialog,需要都隐藏 - dialog.setVisible(false); - } - } - } - - - /** - * 检测是否合法 - * @throws Exception - */ - public void checkValid() throws Exception { - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); - int cnt = model.getRowCount(); - int groupLength = -1; - for (int i=0; i= model.getRowCount()) { - return; - } - KeyColumnNameValue kcv = model.getKeyColumnNameValue(editingRowIndex); - ElementCasePane currentReportPane = (ElementCasePane)e.getSource(); - Selection selection = currentReportPane.getSelection(); - if (selection == NO_SELECTION || selection instanceof FloatSelection) { - return; - } - CellSelection cellselection = (CellSelection)selection; - kcv.cv.obj = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); - - if (editingRowIndex >= model.getRowCount() - 1) { - setEditingRowIndex(0); - } else { - setEditingRowIndex(editingRowIndex + 1); - } - - model.fireTableDataChanged(); - - } - - }; - - /** - * 单元格组的点选格子事件 - */ - private SelectionListener groupListener = new SelectionListener() { - @Override - public void selectionChanged(SelectionEvent e) { - KeyColumnTableModel model = (KeyColumnTableModel)table.getModel(); - if (editingRowIndex < 0 || editingRowIndex >= model.getRowCount()) { - return; - } - KeyColumnNameValue kcv = model.getKeyColumnNameValue(editingRowIndex); - ElementCasePane currentReportPane = (ElementCasePane)e.getSource(); - Selection selection = currentReportPane.getSelection(); - if (selection == NO_SELECTION || selection instanceof FloatSelection) { - return; - } - CellSelection cellselection = (CellSelection)selection; - Object oriValue = kcv.cv.obj; - ColumnRowGroup newValue = getColumnRowGroupValue(oriValue); - - // 要考虑多选的情况 要结合之前的看看 可能是增加 也可能需要减少 - ColumnRowGroup add = new ColumnRowGroup(); - int removeCount = 0; - if (oriCellSelection != null && isSameStartPoint(cellselection, oriCellSelection)) { + if (isCellGroup) { + column2.setCellRenderer(new ColumnRowGroupCellRenderer2()); + column2.setCellEditor(new ColumnValueEditor(ValueEditorPaneFactory.cellGroupEditor())); + } else { + column2.setCellRenderer(new SelectedColumnValueTableCellRenderer()); + } + } + + /** + * 检查是否合法 + * + * @throws Exception + */ + public void checkValid() throws Exception { + SmartInsertDBManipulationPane.this.checkValid(); + } + + private SelectionListener listener = new SelectionListener() { + + @Override + public void selectionChanged(SelectionEvent e) { + KeyColumnTableModel model = (KeyColumnTableModel) table.getModel(); + if (editingRowIndex < 0 || editingRowIndex >= model.getRowCount()) { + return; + } + KeyColumnNameValue kcv = model.getKeyColumnNameValue(editingRowIndex); + ElementCasePane currentReportPane = (ElementCasePane) e.getSource(); + Selection selection = currentReportPane.getSelection(); + if (selection == NO_SELECTION || selection instanceof FloatSelection) { + return; + } + CellSelection cellselection = (CellSelection) selection; + kcv.cv.obj = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); + + if (editingRowIndex >= model.getRowCount() - 1) { + setEditingRowIndex(0); + } else { + setEditingRowIndex(editingRowIndex + 1); + } + + model.fireTableDataChanged(); + + } + + }; + + /** + * 单元格组的点选格子事件 + */ + private SelectionListener groupListener = new SelectionListener() { + @Override + public void selectionChanged(SelectionEvent e) { + KeyColumnTableModel model = (KeyColumnTableModel) table.getModel(); + if (editingRowIndex < 0 || editingRowIndex >= model.getRowCount()) { + return; + } + KeyColumnNameValue kcv = model.getKeyColumnNameValue(editingRowIndex); + ElementCasePane currentReportPane = (ElementCasePane) e.getSource(); + Selection selection = currentReportPane.getSelection(); + if (selection == NO_SELECTION || selection instanceof FloatSelection) { + return; + } + CellSelection cellselection = (CellSelection) selection; + Object oriValue = kcv.cv.obj; + ColumnRowGroup newValue = getColumnRowGroupValue(oriValue); + + // 要考虑多选的情况 要结合之前的看看 可能是增加 也可能需要减少 + ColumnRowGroup add = new ColumnRowGroup(); + int removeCount = 0; + if (oriCellSelection != null && isSameStartPoint(cellselection, oriCellSelection)) { removeCount = dealDragSelection(add, cellselection); - } else if (cellselection.getSelectedType() == CellSelection.CHOOSE_ROW || cellselection.getSelectedType() == CellSelection.CHOOSE_COLUMN) { + } else if (cellselection.getSelectedType() == CellSelection.CHOOSE_ROW || cellselection.getSelectedType() == CellSelection.CHOOSE_COLUMN) { dealSelectColRow(add, cellselection); } else { - add.addColumnRow(ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow())); - } + add.addColumnRow(ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow())); + } - if (add.getSize() > 0) { - newValue.addAll(add); - } else if (removeCount > 0) { - newValue.splice(newValue.getSize()-removeCount, removeCount); - } + if (add.getSize() > 0) { + newValue.addAll(add); + } else if (removeCount > 0) { + newValue.splice(newValue.getSize() - removeCount, removeCount); + } - kcv.cv.obj = newValue; + kcv.cv.obj = newValue; - model.fireTableDataChanged(); + model.fireTableDataChanged(); - oriCellSelection = cellselection; - } + oriCellSelection = cellselection; + } - private ColumnRowGroup getColumnRowGroupValue(Object oriValue) { - ColumnRowGroup newValue = new ColumnRowGroup(); - if (oriValue instanceof ColumnRowGroup) { - newValue.addAll((ColumnRowGroup)oriValue); - } else if (oriValue instanceof ColumnRow) { - newValue.addColumnRow((ColumnRow) oriValue); - } - return newValue; - } + private ColumnRowGroup getColumnRowGroupValue(Object oriValue) { + ColumnRowGroup newValue = new ColumnRowGroup(); + if (oriValue instanceof ColumnRowGroup) { + newValue.addAll((ColumnRowGroup) oriValue); + } else if (oriValue instanceof ColumnRow) { + newValue.addColumnRow((ColumnRow) oriValue); + } + return newValue; + } - private boolean isSameStartPoint(CellSelection cs1, CellSelection cs2) { - return cs1.getColumn() == cs2.getColumn() && cs1.getRow() == cs2.getRow(); - } + private boolean isSameStartPoint(CellSelection cs1, CellSelection cs2) { + return cs1.getColumn() == cs2.getColumn() && cs1.getRow() == cs2.getRow(); + } private int dealDragSelection(ColumnRowGroup add, CellSelection cellselection) { int removeCount = 0; if (cellselection.getRowSpan() == oriCellSelection.getRowSpan() + 1) { - for (int i=0; i= CELL_GROUP_LIMIT) { - this.setText("[" + com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Has_Selected", "Classifier-Ge", "Cell"}, - new String[]{((ColumnRowGroup)cv).getSize()+StringUtils.EMPTY, StringUtils.EMPTY}) + "]"); - tip = cv.toString() + " " + tip; - } else if (cv != null) { - this.setText(cv.toString()); - } else { - this.setText(StringUtils.EMPTY); - } - } - - this.setToolTipText(tip); - - if (row == SmartJTablePane4DB.this.editingRowIndex) { - this.setBackground(java.awt.Color.cyan); - } else { - this.setBackground(java.awt.Color.WHITE); - } - - return this; - } - } - } + } + + @Override + public void showDialog() { + Container container = SmartJTablePane4DB.this; + while (container.getParent() != null) { + container = container.getParent(); + if (container instanceof JDialog) { + container.setVisible(false); + } + } + updateUpdateCheckBoxEnable(); + ((SmartInsertDBManipulationPane) dialog).showDialogAfterAddCellAction(); + } + }; + + /* + * ColumnValueTableCellRenderer + */ + private class SelectedColumnValueTableCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value instanceof ColumnValue) { + if (((ColumnValue) value).obj != null) { + this.setText(((ColumnValue) value).obj.toString()); + } else { + this.setText(StringUtils.EMPTY); + } + } + + if (row == SmartJTablePane4DB.this.editingRowIndex) { + this.setBackground(java.awt.Color.cyan); + } else { + this.setBackground(java.awt.Color.WHITE); + } + + return this; + } + } + + private class ColumnRowGroupCellRenderer2 extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + String tip = com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Double_Click_Edit_OR_Clear"); + + if (value instanceof ColumnValue) { + Object cv = ((ColumnValue) value).obj; + if (cv instanceof ColumnRowGroup && ((ColumnRowGroup) cv).getSize() >= CELL_GROUP_LIMIT) { + this.setText("[" + + Toolkit.i18nText("Fine-Design_Write_Select_Cell_Count", ((ColumnRowGroup) cv).getSize()) + + "]"); + tip = cv.toString() + " " + tip; + } else if (cv != null) { + this.setText(cv.toString()); + } else { + this.setText(StringUtils.EMPTY); + } + } + + this.setToolTipText(tip); + + if (row == SmartJTablePane4DB.this.editingRowIndex) { + this.setBackground(java.awt.Color.cyan); + } else { + this.setBackground(java.awt.Color.WHITE); + } + + return this; + } + } + } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java index 38f8c1c202..7797479900 100644 --- a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java @@ -1,11 +1,11 @@ package com.fr.start.module; -import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; import com.fr.design.utils.DesignUtils; import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralContext; import com.fr.module.Activator; import com.fr.stable.ProductConstants; @@ -64,7 +64,7 @@ public class PreStartActivator extends Activator { private void initLanguage() { //这两句的位置不能随便调换,因为会影响语言切换的问题 - FRContext.setLanguage(DesignerEnvManager.getEnvManager(false).getLanguage()); + GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLocale()); } @Override