diff --git a/designer-base/pom.xml b/designer-base/pom.xml index 942dcd302d..522da84ff9 100644 --- a/designer-base/pom.xml +++ b/designer-base/pom.xml @@ -8,6 +8,9 @@ design 10.0 + com.fr.report + designer-base + 10.0 io.socket @@ -15,7 +18,4 @@ 0.7.0 - com.fr.report - designer-base - 10.0 \ No newline at end of file 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 eefafb84ef..d054ab959f 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -26,6 +26,7 @@ import com.fr.general.xml.GeneralXMLTools; import com.fr.log.FineLoggerFactory; import com.fr.stable.CommonUtils; import com.fr.stable.Constants; +import com.fr.stable.CoreConstants; import com.fr.stable.EnvChangedListener; import com.fr.stable.ListMap; import com.fr.stable.ProductConstants; @@ -38,12 +39,14 @@ import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; +import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; -import javax.swing.*; +import javax.swing.SwingWorker; import javax.swing.SwingWorker.StateValue; -import java.awt.*; +import java.awt.Color; +import java.awt.Rectangle; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; @@ -57,6 +60,7 @@ import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.ListIterator; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; @@ -482,7 +486,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public void setLastEastRegionContainerWidth(int eastRegionContainerWidth) { this.eastRegionContainerWidth = eastRegionContainerWidth; } - + /** * 返回默认环境 */ @@ -544,7 +548,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { DesignerEnvManager.getEnvManager().setCurEnvName(envName); DesignUtils.refreshDesignerFrame(); - if(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate() != null) { + if (HistoryTemplateListPane.getInstance().getCurrentEditingTemplate() != null) { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); } DesignTableDataManager.fireDSChanged(new HashMap()); @@ -622,7 +626,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { fout.flush(); fout.close(); } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } @@ -848,10 +852,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * @param filePath 文件路径 */ public void addRecentOpenedFilePath(String filePath) { + filePath = FilenameUtils.standard(filePath); // 先删除. - if (getRecentOpenedFilePathList().contains(filePath)) { - getRecentOpenedFilePathList().remove(filePath); - } + getRecentOpenedFilePathList().remove(filePath); getRecentOpenedFilePathList().add(0, filePath); checkRecentOpenedFileNum(); @@ -860,18 +863,38 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { /** * 替换近期打开的文件路径 * - * @param oldPath 旧的路径 - * @param newPath 新的路径 + * @param oldPath path 使用 unix 分隔符 + * @param newPath path 使用 unix 分隔符 */ public void replaceRecentOpenedFilePath(String oldPath, String newPath) { List list = getRecentOpenedFilePathList(); if (list.contains(oldPath)) { - int index = getRecentOpenedFilePathList().indexOf(oldPath); + int index = list.indexOf(oldPath); list.remove(oldPath); list.add(index, newPath); } } + /** + * 替换近期打开的文件路径 + * + * @param type 文件类型,文件夹true,文件false + * @param oldPath path 使用 unix 分隔符 + * @param newPath path 使用 unix 分隔符 + */ + public void replaceRecentOpenedFilePath(boolean type, String oldPath, String newPath) { + List list = getRecentOpenedFilePathList(); + ListIterator iterator = list.listIterator(); + + while (iterator.hasNext()) { + String s = FilenameUtils.standard(iterator.next()); + if (type ? s.contains(oldPath + CoreConstants.SEPARATOR) : s.equals(oldPath)) { + s = s.replace(oldPath, newPath); + iterator.set(s); + } + } + } + private void checkRecentOpenedFileNum() { List list = getRecentOpenedFilePathList(); if (list == null) { @@ -888,9 +911,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * @param filePath 文件路径 */ public void removeRecentOpenedFilePath(String filePath) { - if (getRecentOpenedFilePathList().contains(filePath)) { - getRecentOpenedFilePathList().remove(filePath); - } + filePath = FilenameUtils.standard(filePath); + getRecentOpenedFilePathList().remove(filePath); } @@ -1609,7 +1631,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (reader.isChildNode()) { String n = reader.getTagName(); if ("Path".equals(n)) { - String path = reader.getElementValue(); + String path = FilenameUtils.standard(reader.getElementValue()); if (StringUtils.isNotEmpty(path)) { recentOpenedFileList.add(path); } diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java new file mode 100644 index 0000000000..9ad3b4ab11 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -0,0 +1,173 @@ +package com.fr.design; + +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.env.DesignerWorkspaceGenerator; +import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.TemplateTreePane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.utils.DesignUtils; +import com.fr.env.EnvListPane; +import com.fr.general.GeneralContext; +import com.fr.license.exception.RegistEditionException; +import com.fr.log.FineLoggerFactory; +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.SwingUtilities; +import javax.swing.UIManager; +import java.util.HashMap; + +import static javax.swing.JOptionPane.ERROR_MESSAGE; + +public class EnvChangeEntrance { + + private String currentEnvName = ""; + + public static EnvChangeEntrance getInstance() { + return HOLDER.singleton; + } + + private static class HOLDER { + private static EnvChangeEntrance singleton = new EnvChangeEntrance(); + } + + + private EnvChangeEntrance() { + currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); + GeneralContext.addEnvChangedListener(new EnvChangedListener() { + @Override + public void envChanged() { + currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); + } + }); + } + + private boolean envListOkAction(EnvListPane envListPane) { + final String selectedName = envListPane.updateEnvManager(); + return switch2Env(selectedName); + } + + + /** + * 切换到新环境 + * + * @param envName 新工作环境名称 + * @return 是否成功 + */ + public boolean switch2Env(final String envName) { + DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); + + try { + Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); + boolean checkValid = workspace != null && selectedEnv.checkValid(); + if (!checkValid) { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + return false; + } + WorkContext.switchTo(workspace, new WorkContextCallback() { + @Override + public void done() { + DesignerEnvManager.getEnvManager().setCurEnvName(envName); + DesignUtils.refreshDesignerFrame(); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + template.refreshToolArea(); + } + DesignTableDataManager.fireDSChanged(new HashMap()); + } + }); + + } catch (AuthException | RegistEditionException e) { + // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); + // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + return false; + } catch (Exception exception) { + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + return false; + } + TemplateTreePane.getInstance().refreshDockingView(); + DesignModelAdapter model = DesignModelAdapter.getCurrentModelAdapter(); + if (model != null) { + model.envChanged(); + } + return true; + } + + /** + * 编辑items + * + * @see EnvChangeEntrance#chooseEnv() + * @deprecated use {@link EnvChangeEntrance#chooseEnv()} + */ + @Deprecated + public void editItems() { + chooseEnv(); + } + + /** + * 出现对话框,选择使用的工作环境 + */ + public void chooseEnv() { + final EnvListPane envListPane = new EnvListPane(); + final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); + + envListPane.populateEnvManager(currentEnvName); + envListDialog.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doOk() { + envListDialog.dispose(); + envListOkAction(envListPane); + } + + @Override + public void doCancel() { + + envListDialog.dispose(); + } + }); + envListDialog.setVisible(true); + } + + /** + * 处理异常 + */ + public void dealEvnExceptionWhenStartDesigner() { + final EnvListPane envListPane = new EnvListPane(); + envListPane.populateEnvManager(currentEnvName); + BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); + envListDialog.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doOk() { + + if (!envListOkAction(envListPane)) { + System.exit(0); + } + + } + + @Override + public void doCancel() { + System.exit(0); + } + }); + envListDialog.setVisible(true); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/RestartHelper.java b/designer-base/src/main/java/com/fr/design/RestartHelper.java index 2900e09f51..6f1b77acb2 100644 --- a/designer-base/src/main/java/com/fr/design/RestartHelper.java +++ b/designer-base/src/main/java/com/fr/design/RestartHelper.java @@ -166,7 +166,7 @@ public class RestartHelper { FineLoggerFactory.getLogger().error("restart lock null!"); } }catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } if (OperatingSystem.isMacOS()) { restartInMacOS(installHome, filesToBeDelete); @@ -174,7 +174,7 @@ public class RestartHelper { restartInWindows(installHome, filesToBeDelete); } } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } finally { DesignerContext.getDesignerFrame().exit(); } diff --git a/designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java b/designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java index f8b185a09d..a4b7c88034 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java @@ -1,12 +1,11 @@ package com.fr.design.actions.file; +import com.fr.design.EnvChangeEntrance; import com.fr.design.actions.UpdateAction; -import com.fr.design.mainframe.TemplatePane; import java.awt.event.ActionEvent; - public class EditEnvAction extends UpdateAction { @@ -16,7 +15,6 @@ public class EditEnvAction extends UpdateAction { @Override public void actionPerformed(ActionEvent e) { - TemplatePane.getInstance().editItems(); - + EnvChangeEntrance.getInstance().chooseEnv(); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 325df90e09..c6aebd2a28 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -155,8 +155,6 @@ public class PreferencePane extends BasicPane { createServerPane(advancePane); - createJdkHomePane(advancePane); - JPanel oraclePane = FRGUIPaneFactory.createTitledBorderPane("Oracle" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Oracle_All_Tables")); oracleSpace = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Show_All_Oracle_Tables")); oraclePane.add(oracleSpace); @@ -470,42 +468,6 @@ public class PreferencePane extends BasicPane { serverPortPane.add(choosePortPane, BorderLayout.CENTER); } - private void createJdkHomePane(JPanel advancePane) { - double p = TableLayout.PREFERRED; - double rowSize[] = {p}; - double columnSize[] = {p, p, p}; - - JPanel serverPortPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_JDK_Home")); - advancePane.add(serverPortPane); - jdkHomeTextField = new UITextField(); - UIButton chooseBtn = new UIButton("..."); - chooseBtn.setPreferredSize(new Dimension(20, 20)); - JPanel panel = GUICoreUtils.createBorderLayoutPane( - jdkHomeTextField, BorderLayout.CENTER, - chooseBtn, BorderLayout.EAST - ); - chooseBtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int returnValue = fileChooser.showOpenDialog(PreferencePane.this); - if (returnValue == JFileChooser.APPROVE_OPTION) { - File file = fileChooser.getSelectedFile(); - jdkHomeTextField.setText(file.getAbsolutePath()); - } - } - }); - panel.setPreferredSize(new Dimension(300, 20)); - UILabel notiJlabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Work_After_Restart_Designer")); - UILabel serverPortLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_JDK_Home") + ":"); - Component[][] portComponents = { - {serverPortLabel, panel, notiJlabel}, - }; - JPanel choosePortPane = TableLayoutHelper.createTableLayoutPane(portComponents, rowSize, columnSize); - serverPortPane.add(choosePortPane, BorderLayout.CENTER); - } - private JPanel createMemoryPane() { JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Caching_Template")); UILabel memoryLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Max_Caching_Template")); @@ -575,8 +537,6 @@ public class PreferencePane extends BasicPane { this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort())); - this.jdkHomeTextField.setText(designerEnvManager.getJdkHome()); - this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace()); this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit()); this.joinProductImprove.setSelected(designerEnvManager.isJoinProductImprove()); @@ -636,8 +596,6 @@ public class PreferencePane extends BasicPane { designerEnvManager.setJettyServerPort(portEditor.getValue().intValue()); - designerEnvManager.setJdkHome(jdkHomeTextField.getText()); - designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected()); designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue()); designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected()); diff --git a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java index d79df8d2c3..2b55da4793 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java @@ -2,30 +2,15 @@ package com.fr.design.actions.file; import com.fr.base.BaseUtils; import com.fr.design.DesignerEnvManager; +import com.fr.design.EnvChangeEntrance; import com.fr.design.actions.UpdateAction; -import com.fr.design.data.DesignTableDataManager; -import com.fr.design.data.tabledata.ResponseDataSourceChange; -import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.mainframe.DesignerContext; 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.license.exception.RegistEditionException; -import com.fr.log.FineLoggerFactory; -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 java.awt.event.ActionEvent; -import java.util.HashMap; import java.util.Iterator; -import java.util.Map; public class SwitchExistEnv extends MenuDef { @@ -37,7 +22,6 @@ public class SwitchExistEnv extends MenuDef { } private void initMenuDef() { - // ButtonGroup group = new ButtonGroup(); Iterator nameIt = DesignerEnvManager.getEnvManager().getEnvNameIterator(); while (nameIt.hasNext()) { String name = nameIt.next(); @@ -48,7 +32,8 @@ public class SwitchExistEnv extends MenuDef { this.addShortCut(new EditEnvAction()); } - public static class GetExistEnvAction extends UpdateAction implements ResponseDataSourceChange { + public static class GetExistEnvAction extends UpdateAction { + public GetExistEnvAction() { } @@ -67,60 +52,14 @@ public class SwitchExistEnv extends MenuDef { } } - /** - * 响应数据集改变 - */ - public void fireDSChanged() { - fireDSChanged(new HashMap()); - } - - /** - * 响应数据集改变 - * - * @param map 数据集 - */ - public void fireDSChanged(Map map) { - DesignTableDataManager.fireDSChanged(map); - } - /** * 动作 * * @param e 事件 */ public void actionPerformed(ActionEvent e) { - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); final String envName = getName(); - DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); - Workspace workspace; - try { - workspace = DesignerWorkspaceGenerator.generate(selectedEnv); - boolean checkValid = workspace == null ? false : selectedEnv.checkValid(); - if (!checkValid) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - null, 0, UIManager.getIcon("OptionPane.errorIcon")); - return; - } - WorkContext.switchTo(workspace, new WorkContextCallback() { - - @Override - public void done() { - - DesignerEnvManager.getEnvManager().setCurEnvName(envName); - DesignUtils.refreshDesignerFrame(); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); - fireDSChanged(); - } - }); - } catch (AuthException exception) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"), - null, 0, UIManager.getIcon("OptionPane.errorIcon")); - } catch (RegistEditionException exception) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"), - null, 0, UIManager.getIcon("OptionPane.errorIcon")); - } catch (Exception exception) { - FineLoggerFactory.getLogger().error(exception.getMessage(), exception); - } + EnvChangeEntrance.getInstance().switch2Env(envName); } } } diff --git a/designer-base/src/main/java/com/fr/design/actions/help/FeedBackPane.java b/designer-base/src/main/java/com/fr/design/actions/help/FeedBackPane.java index 3047f64703..1aa8ea7d4d 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/FeedBackPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/FeedBackPane.java @@ -279,7 +279,7 @@ public class FeedBackPane extends BasicPane { try { return DesignUtils.sendFeedBack(feedBackInfo); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; } } diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index b1c03c09bc..c853db1698 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -18,11 +18,11 @@ public class AlphaFineConfigManager implements XMLable { /** * 是否开启alphafine */ - private boolean isEnabled = true; + private boolean enabled = true; /** * 是否联网搜索 */ - private boolean isSearchOnLine = true; + private boolean searchOnLine = true; /** * 搜索范围 @@ -34,27 +34,35 @@ public class AlphaFineConfigManager implements XMLable { /** * 猜您需要 */ - private boolean isContainRecommend = true; + private boolean containRecommend = true; /** * 设置 */ - private boolean isContainAction = true; + private boolean containAction = true; /** * 帮助文档 */ - private boolean isContainDocument = true; + private boolean containDocument = true; /** * 模板 */ - private boolean isContainTemplate = true; + private boolean containTemplate = true; /** * 模板内容 */ - private boolean isContainFileContent; + private boolean containFileContent; /** * 应用中心 */ - private boolean isContainPlugin = true; + private boolean containPlugin = true; + /** + * 分词搜索 + */ + private boolean needSegmentationCheckbox = true; + /** + * 智能客服 + */ + private boolean needIntelligentCustomerService = true; /** * 快捷键 */ @@ -62,7 +70,7 @@ public class AlphaFineConfigManager implements XMLable { /** * 是否提醒 */ - private boolean isNeedRemind = true; + private boolean needRemind = true; /** * 直接操作菜单次数 */ @@ -94,6 +102,8 @@ public class AlphaFineConfigManager implements XMLable { this.setContainAction(reader.getAttrAsBoolean("isContainAction", true)); this.setContainTemplate(reader.getAttrAsBoolean("isContainTemplate", true)); this.setContainFileContent(reader.getAttrAsBoolean("isContainFileContent", false)); + this.setNeedSegmentationCheckbox(reader.getAttrAsBoolean("needSegmentationCheckbox", true)); + this.setNeedIntelligentCustomerService(reader.getAttrAsBoolean("needIntelligentCustomerService", true)); this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts())); this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true)); this.setOperateCount(reader.getAttrAsInt("operateCount", 0)); @@ -115,16 +125,18 @@ public class AlphaFineConfigManager implements XMLable { .attr("isContainPlugin", this.isContainPlugin()) .attr("isContainFileContent", this.isContainFileContent()) .attr("isNeedRemind", this.isNeedRemind()) - .attr("operateCount", this.getOperateCount()); + .attr("operateCount", this.getOperateCount()) + .attr("needSegmentationCheckbox", this.isNeedSegmentationCheckbox()) + .attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService()); writer.end(); } public boolean isSearchOnLine() { - return isSearchOnLine; + return searchOnLine; } public void setSearchOnLine(boolean searchOnLine) { - isSearchOnLine = searchOnLine; + this.searchOnLine = searchOnLine; } public String getShortcuts() { @@ -149,51 +161,51 @@ public class AlphaFineConfigManager implements XMLable { } public boolean isContainAction() { - return isContainAction; + return containAction; } public void setContainAction(boolean containAction) { - this.isContainAction = containAction; + this.containAction = containAction; } public boolean isContainDocument() { - return isContainDocument; + return containDocument; } public void setContainDocument(boolean containDocument) { - this.isContainDocument = containDocument; + this.containDocument = containDocument; } public boolean isContainTemplate() { - return isContainTemplate; + return containTemplate; } public void setContainTemplate(boolean containTemplate) { - this.isContainTemplate = containTemplate; + this.containTemplate = containTemplate; } public boolean isContainPlugin() { - return isContainPlugin; + return containPlugin; } public void setContainPlugin(boolean containPlugin) { - this.isContainPlugin = containPlugin; + this.containPlugin = containPlugin; } public boolean isContainRecommend() { - return isContainRecommend; + return containRecommend; } public void setContainRecommend(boolean containConclude) { - isContainRecommend = containConclude; + this.containRecommend = containConclude; } public boolean isEnabled() { - return isEnabled; + return enabled; } - public void setEnabled(boolean isEnabled) { - this.isEnabled = isEnabled; + public void setEnabled(boolean enabled) { + this.enabled = enabled; } public KeyStroke getShortCutKeyStore() { @@ -212,19 +224,35 @@ public class AlphaFineConfigManager implements XMLable { } public boolean isContainFileContent() { - return isContainFileContent; + return containFileContent; } public void setContainFileContent(boolean containFileContent) { - isContainFileContent = containFileContent; + this.containFileContent = containFileContent; } public boolean isNeedRemind() { - return isNeedRemind; + return needRemind; } public void setNeedRemind(boolean needRemind) { - isNeedRemind = needRemind; + this.needRemind = needRemind; + } + + public boolean isNeedSegmentationCheckbox() { + return needSegmentationCheckbox; + } + + public void setNeedSegmentationCheckbox(boolean needSegmentationCheckbox) { + this.needSegmentationCheckbox = needSegmentationCheckbox; + } + + public boolean isNeedIntelligentCustomerService() { + return needIntelligentCustomerService; + } + + public void setNeedIntelligentCustomerService(boolean needIntelligentCustomerService) { + this.needIntelligentCustomerService = needIntelligentCustomerService; } public int getOperateCount() { diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java index ddb8e425c8..c886e3c93a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java @@ -8,7 +8,6 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; - import com.fr.log.FineLoggerFactory; import javax.swing.*; @@ -56,7 +55,7 @@ public class AlphaFineConfigPane extends BasicPane { private static final double COLUMN_GAP = 180; private static final double ROW_GAP = 25; private KeyStroke shortCutKeyStore = null; - private UICheckBox isEnabledCheckbox, isSearchOnlineCheckbox, isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox, isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox; + private UICheckBox enabledCheckbox, searchOnlineCheckbox, needSegmentationCheckbox, needIntelligentCustomerService, containRecommendCheckbox, containActionCheckbox, containDocumentCheckbox, containTemplateCheckbox, containPluginCheckbox, containFileContentCheckbox; private UITextField shortcutsField; public AlphaFineConfigPane() { @@ -76,24 +75,33 @@ public class AlphaFineConfigPane extends BasicPane { private Component[][] initSearchRangeComponents() { Component[][] components = new Component[][]{ - new Component[]{isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox}, - new Component[]{isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox} + new Component[]{containRecommendCheckbox, containActionCheckbox, containDocumentCheckbox}, + new Component[]{containTemplateCheckbox, containPluginCheckbox, containFileContentCheckbox}, + new Component[]{needIntelligentCustomerService, null, null} + }; + return components; + } + + private Component[][] initOnlineComponents() { + Component[][] components = new Component[][]{ + new Component[]{searchOnlineCheckbox, needSegmentationCheckbox, null} }; return components; } private void createSearchConfigPane(JPanel contentPane) { - double[] rowSize = {ROW_GAP, ROW_GAP}; + double[] rowSize = {ROW_GAP, ROW_GAP, ROW_GAP}; double[] columnSize = {COLUMN_GAP, COLUMN_GAP, COLUMN_GAP}; JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Range")); - isContainRecommendCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Recommend")); - isContainActionCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set")); - isContainPluginCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon")); - isContainDocumentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help")); - isContainTemplateCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates")); - isContainFileContentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + containRecommendCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Recommend")); + containActionCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set")); + containPluginCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon")); + containDocumentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help")); + containTemplateCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates")); + containFileContentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + needIntelligentCustomerService = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Intelligent_Customer_Service")); JPanel searchConfigPane = TableLayoutHelper.createTableLayoutPane(initSearchRangeComponents(), rowSize, columnSize); northPane.add(searchConfigPane); contentPane.add(northPane); @@ -138,33 +146,40 @@ public class AlphaFineConfigPane extends BasicPane { } private void createOnlinePane(JPanel contentPane) { - JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Internet")); - isSearchOnlineCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Internet_Search")); - isSearchOnlineCheckbox.addActionListener(new ActionListener() { + JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Type")); + searchOnlineCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Internet_Search")); + needSegmentationCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Segmentation")); + searchOnlineCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if (!isSearchOnlineCheckbox.isSelected()) { - isContainRecommendCheckbox.setEnabled(false); - isContainPluginCheckbox.setEnabled(false); - isContainDocumentCheckbox.setEnabled(false); - isContainRecommendCheckbox.setSelected(false); - isContainPluginCheckbox.setSelected(false); - isContainDocumentCheckbox.setSelected(false); + if (!searchOnlineCheckbox.isSelected()) { + containRecommendCheckbox.setEnabled(false); + containPluginCheckbox.setEnabled(false); + containDocumentCheckbox.setEnabled(false); + needIntelligentCustomerService.setEnabled(false); + containRecommendCheckbox.setSelected(false); + containPluginCheckbox.setSelected(false); + containDocumentCheckbox.setSelected(false); + needIntelligentCustomerService.setSelected(false); } else { - isContainRecommendCheckbox.setEnabled(true); - isContainPluginCheckbox.setEnabled(true); - isContainDocumentCheckbox.setEnabled(true); + containRecommendCheckbox.setEnabled(true); + containPluginCheckbox.setEnabled(true); + containDocumentCheckbox.setEnabled(true); + needIntelligentCustomerService.setEnabled(true); } } }); - northPane.add(isSearchOnlineCheckbox); + double[] rowSize = {ROW_GAP}; + double[] columnSize = {COLUMN_GAP, COLUMN_GAP, COLUMN_GAP}; + JPanel onlinePane = TableLayoutHelper.createTableLayoutPane(initOnlineComponents(), rowSize, columnSize); + northPane.add(onlinePane); contentPane.add(northPane); } private void createOpenPane(JPanel contentPane) { JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable")); - isEnabledCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_AlphaFine")); - northPane.add(isEnabledCheckbox); + enabledCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_AlphaFine")); + northPane.add(enabledCheckbox); contentPane.add(northPane); } @@ -174,40 +189,46 @@ public class AlphaFineConfigPane extends BasicPane { } public void populate(AlphaFineConfigManager alphaFineConfigManager) { - this.isEnabledCheckbox.setSelected(alphaFineConfigManager.isEnabled()); - this.isSearchOnlineCheckbox.setEnabled(FRContext.isChineseEnv()); - this.isSearchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine()); - this.isContainActionCheckbox.setSelected(alphaFineConfigManager.isContainAction()); - this.isContainTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate()); - this.isContainFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent()); - this.isContainDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine()); - this.isContainDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); - this.isContainPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine()); - this.isContainPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); - this.isContainRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine()); - this.isContainRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.enabledCheckbox.setSelected(alphaFineConfigManager.isEnabled()); + this.searchOnlineCheckbox.setEnabled(FRContext.isChineseEnv()); + this.searchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine()); + this.containActionCheckbox.setSelected(alphaFineConfigManager.isContainAction()); + this.containTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate()); + this.containFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent()); + this.containDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine()); + this.containDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine()); + this.containPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine()); + this.containRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts())); + + this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox()); + this.needIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && alphaFineConfigManager.isSearchOnLine()); + this.needIntelligentCustomerService.setEnabled(alphaFineConfigManager.isSearchOnLine()); shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts()); } public void update() { DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); AlphaFineConfigManager alphaFineConfigManager = designerEnvManager.getAlphaFineConfigManager(); - alphaFineConfigManager.setContainPlugin(this.isContainPluginCheckbox.isSelected()); - alphaFineConfigManager.setContainAction(this.isContainActionCheckbox.isSelected()); - alphaFineConfigManager.setContainDocument(this.isContainDocumentCheckbox.isSelected()); - alphaFineConfigManager.setContainRecommend(this.isContainRecommendCheckbox.isSelected()); - alphaFineConfigManager.setEnabled(this.isEnabledCheckbox.isSelected()); - alphaFineConfigManager.setSearchOnLine(this.isSearchOnlineCheckbox.isSelected()); - alphaFineConfigManager.setContainTemplate(this.isContainTemplateCheckbox.isSelected()); - alphaFineConfigManager.setContainFileContent(this.isContainFileContentCheckbox.isSelected()); + alphaFineConfigManager.setContainPlugin(this.containPluginCheckbox.isSelected()); + alphaFineConfigManager.setContainAction(this.containActionCheckbox.isSelected()); + alphaFineConfigManager.setContainDocument(this.containDocumentCheckbox.isSelected()); + alphaFineConfigManager.setContainRecommend(this.containRecommendCheckbox.isSelected()); + alphaFineConfigManager.setEnabled(this.enabledCheckbox.isSelected()); + alphaFineConfigManager.setSearchOnLine(this.searchOnlineCheckbox.isSelected()); + alphaFineConfigManager.setContainTemplate(this.containTemplateCheckbox.isSelected()); + alphaFineConfigManager.setContainFileContent(this.containFileContentCheckbox.isSelected()); + alphaFineConfigManager.setNeedSegmentationCheckbox(this.needSegmentationCheckbox.isSelected()); + alphaFineConfigManager.setNeedIntelligentCustomerService(this.needIntelligentCustomerService.isSelected()); alphaFineConfigManager.setShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText()); designerEnvManager.setAlphaFineConfigManager(alphaFineConfigManager); try { DesignerEnvManager.loadLogSetting(); DesignerEnvManager.getEnvManager().saveXMLFile(); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -234,10 +255,10 @@ public class AlphaFineConfigPane extends BasicPane { } public UICheckBox getIsContainFileContentCheckbox() { - return isContainFileContentCheckbox; + return containFileContentCheckbox; } public void setIsContainFileContentCheckbox(UICheckBox isContainFileContentCheckbox) { - this.isContainFileContentCheckbox = isContainFileContentCheckbox; + this.containFileContentCheckbox = isContainFileContentCheckbox; } } diff --git a/designer-base/src/main/java/com/fr/design/bbs/BBSLoginUtils.java b/designer-base/src/main/java/com/fr/design/bbs/BBSLoginUtils.java index 5b46b7c68e..ea24c49da0 100644 --- a/designer-base/src/main/java/com/fr/design/bbs/BBSLoginUtils.java +++ b/designer-base/src/main/java/com/fr/design/bbs/BBSLoginUtils.java @@ -32,7 +32,7 @@ public class BBSLoginUtils { }); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -58,7 +58,7 @@ public class BBSLoginUtils { }); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -71,7 +71,7 @@ public class BBSLoginUtils { try { MarketConfig.getInstance().setBBsAttr(bbsAttr); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } } diff --git a/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java b/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java index 9a6cd609e6..36fa874ccf 100644 --- a/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java +++ b/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java @@ -966,7 +966,7 @@ public abstract class LiteConditionPane extends BasicBeanPa try{ newCondition = (Condition)joinCondition.getCondition().clone(); }catch (CloneNotSupportedException e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return newCondition; } diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index 9e45309ff4..ec1f69d98b 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -488,7 +488,7 @@ public abstract class DesignTableDataManager { } rs.release(); } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index dc891c1c63..d004ba6af9 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -278,7 +278,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha schemaBox.setSelectedIndex(index); } } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } schemaBox.setRefreshingModel(false); schemaBox.removePopupMenuListener(listener); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java index 0bc32dcf0a..263d2de53a 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java @@ -113,7 +113,7 @@ public class ChoosePaneSupportFormula extends ChoosePane { selectedDSName = Utils.objectToString(ca.eval(BaseFormula.createFormulaBuilder().build(item))); // selectedDSName = ParameterHelper.analyzeCurrentContextTableData4Templatee(item, parameters); } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } else { selectedDSName = item; @@ -156,7 +156,7 @@ public class ChoosePaneSupportFormula extends ChoosePane { dsName = dsItem.startsWith("=") ? Utils.objectToString(ca.eval(BaseFormula.createFormulaBuilder().build(dsItem))) : dsItem; tableName = tableItem.startsWith("=") ? Utils.objectToString(ca.eval(BaseFormula.createFormulaBuilder().build(tableItem))) : tableItem; } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } ori_ds_name = dsName; ori_table_name = tableName; diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/ResponseDataSourceChange.java b/designer-base/src/main/java/com/fr/design/data/tabledata/ResponseDataSourceChange.java index e995d9cceb..58daf1cc95 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/ResponseDataSourceChange.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/ResponseDataSourceChange.java @@ -14,12 +14,12 @@ public interface ResponseDataSourceChange { /** * 响应数据集改变 */ - public void fireDSChanged(); + void fireDSChanged(); /** * 响应数据集改变 */ - public void fireDSChanged(Map map); + void fireDSChanged(Map map); } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java index 40a62ec0a3..ae8fb5cf88 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java @@ -146,7 +146,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { } return true; } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } return false; } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java index 9e52524c19..d620caef2f 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java @@ -77,7 +77,7 @@ public final class StoreProcedureNameWrapper implements TableDataWrapper { try { procedureDataModel = DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar)[0]; } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } diff --git a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java index bfba65b942..7380bb58f1 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java @@ -166,7 +166,7 @@ public abstract class UIDialog extends JDialog { l.doOk(); } catch (RuntimeException e) { isDoOKSucceed = false; - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } if (isDoOKSucceed) { diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java index 09cfff5cf8..2e5cc9f8c0 100644 --- a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java @@ -1,7 +1,7 @@ package com.fr.design.env; import com.fr.stable.xml.XMLable; -import com.fr.workspace.connect.WorkspaceConnection; +import com.fr.workspace.connect.WorkspaceConnectionInfo; public interface DesignerWorkspaceInfo extends XMLable { DesignerWorkspaceType getType(); @@ -10,7 +10,7 @@ public interface DesignerWorkspaceInfo extends XMLable { String getPath(); - WorkspaceConnection getConnection(); + WorkspaceConnectionInfo getConnection(); boolean checkValid(); } diff --git a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java index 7da0d9fe0f..efba8a2dfa 100644 --- a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -1,13 +1,10 @@ package com.fr.design.env; -import com.fr.base.EnvException; import com.fr.general.ComparatorUtils; -import com.fr.general.NameObject; -import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; -import com.fr.workspace.connect.WorkspaceConnection; +import com.fr.workspace.connect.WorkspaceConnectionInfo; import java.io.File; @@ -47,7 +44,7 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { } @Override - public WorkspaceConnection getConnection() { + public WorkspaceConnectionInfo getConnection() { return null; } diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index fd8aa77dcf..ffc80cb089 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -5,15 +5,15 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; -import com.fr.workspace.connect.WorkspaceConnection; +import com.fr.workspace.connect.WorkspaceConnectionInfo; public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { private String name; - private WorkspaceConnection connection; + private WorkspaceConnectionInfo connection; - public static RemoteDesignerWorkspaceInfo create(WorkspaceConnection connection) { + public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); info.connection = connection; return info; @@ -38,7 +38,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { } @Override - public WorkspaceConnection getConnection() { + public WorkspaceConnectionInfo getConnection() { return connection; } @@ -58,7 +58,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n")); String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY); String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); - this.connection = new WorkspaceConnection(url, username, password, certPath, certSecretKey); + this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey); } } } @@ -83,7 +83,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo) super.clone(); - object.connection = (WorkspaceConnection) StableUtils.cloneObject(this.connection); + object.connection = (WorkspaceConnectionInfo) StableUtils.cloneObject(this.connection); return object; } diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java index 35bc5d82f2..36d8e7f7a5 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java @@ -6,6 +6,7 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceClient; import com.fr.workspace.connect.WorkspaceConnection; +import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.server.authority.decision.DecisionOperator; /** @@ -18,9 +19,11 @@ public class RemoteWorkspace implements Workspace { private final String address; - private final WorkspaceConnection connection; + private final WorkspaceConnectionInfo connection; - RemoteWorkspace(WorkspaceClient client, WorkspaceConnection connection) { + private volatile Boolean isRoot = null; + + RemoteWorkspace(WorkspaceClient client, WorkspaceConnectionInfo connection) { this.client = client; this.address = connection.getUrl(); @@ -53,19 +56,35 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isRoot() { - try { - return WorkContext.getCurrent().get(DecisionOperator.class).isRoot(WorkContext.getConnector().currentUser()); - } catch (Exception e) { - return false; + + if (isRoot == null) { + synchronized (this) { + if (isRoot == null) { + isRoot = WorkContext.getCurrent().get(DecisionOperator.class).isRoot(getConnection().getUserName()); + } + } } + return isRoot; } - + + @Override + public WorkspaceConnection getConnection() { + + return client.getConnection(); + } + @Override public T get(Class type) { return client.getPool().get(type); } + @Override + public void close() { + + client.close(); + } + @Override public int hashCode() { @@ -75,6 +94,6 @@ public class RemoteWorkspace implements Workspace { @Override public boolean equals(Object obj) { - return obj != null && obj instanceof RemoteWorkspace && AssistUtils.equals(((RemoteWorkspace) obj).connection, this.connection); + return obj instanceof RemoteWorkspace && AssistUtils.equals(((RemoteWorkspace) obj).connection, this.connection); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java b/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java index b22c5905a4..a89a4df031 100644 --- a/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java +++ b/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java @@ -150,7 +150,7 @@ public class LoginWebBridge { try { Thread.sleep(millis); } catch (InterruptedException e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } @@ -306,7 +306,7 @@ public class LoginWebBridge { } } } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index b0b1f54324..17658d94e4 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -116,7 +116,7 @@ public class PluginOperateUtils { JSONArray jsonArray = new JSONArray(result); resultArray = PluginUtils.filterPluginsFromVersion(jsonArray); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return resultArray.toString(); } diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java index e2e41a941c..ff4b44c216 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java @@ -59,7 +59,7 @@ public class PluginUtils { httpClient.asGet(); result = httpClient.getResponseText(); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } else { result = PluginConstants.CONNECTION_404; diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java b/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java index 3ab17b92ea..33d5276453 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java @@ -350,7 +350,7 @@ public class PluginWebBridge { Task task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(new JSONObject(info))); threadPoolExecutor.submit(task); } catch (JSONException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -486,10 +486,10 @@ public class PluginWebBridge { } } catch (NullPointerException e) { //此为uri为空时抛出异常 - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } catch (IOException e) { //此为无法获取系统默认浏览器 - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java b/designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java index f3d37cab70..a621d4ecf4 100644 --- a/designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java @@ -149,7 +149,7 @@ public class QQLoginWebPane extends JFXPanel { } }); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java index 11bfc334ab..3e4099bc62 100644 --- a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java @@ -123,7 +123,7 @@ public class WebViewDlgHelper { try { CommonIOUtils.copy(new File(mainJsPath), new File(installHome)); } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java b/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java index 884b115da0..4a1168734e 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java @@ -72,7 +72,7 @@ public class GetPluginFromStoreExecutor implements Executor { JSONArray resultJSONArray = PluginUtils.filterPluginsFromVersion(resultArr); result = resultJSONArray.toString(); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } else { result = PluginConstants.CONNECTION_404; diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java b/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java index 501cc1dff3..739b84666d 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java @@ -42,7 +42,7 @@ public class ReadUpdateOnlineExecutor implements Executor { } result = jsonArray.toString(); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java b/designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java index a35d10588e..fdbd8562f4 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java @@ -50,7 +50,7 @@ public class SearchOnlineExecutor implements Executor { JSONArray resultJSONArray = PluginUtils.filterPluginsFromVersion(jsonArray); result = resultJSONArray.toString(); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } } diff --git a/designer-base/src/main/java/com/fr/design/file/FileOperations.java b/designer-base/src/main/java/com/fr/design/file/FileOperations.java index 34b86cbc68..6509142a44 100644 --- a/designer-base/src/main/java/com/fr/design/file/FileOperations.java +++ b/designer-base/src/main/java/com/fr/design/file/FileOperations.java @@ -1,45 +1,88 @@ package com.fr.design.file; +import com.fr.file.FILE; +import com.fr.file.filetree.FileNode; + public interface FileOperations { + + /** + * 新建文件夹 + * + * @param name 文件夹名称 + * @return 是否成功 + */ + boolean mkdir(String name); + + /** + * 打开报表文件 + */ + void openFile(); + + /** + * 打开文件夹 + */ + void showInExplorer(); + + /** + * 刷新 + */ + void refresh(); + /** - *打开选中的报表文件 + * 删除文件 */ - public void openSelectedReport(); + void deleteFile(); /** - *打开文件夹 + * 加上文件锁 */ - public void openContainerFolder(); + void lockFile(); /** - *刷新 + * 文件解锁 */ - public void refresh(); + void unlockFile(); + + /** + * 选中的模板路径 + * + * @return 选中的模板路径 + */ + String getFilePath(); + /** - *删除文件 + * 选中的文件节点 + * + * @return 文件节点 */ - public void deleteFile(); + FileNode getFileNode(); /** - *加上文件锁 + * 是否有完整权限 + * + * @return 是否有完整权限 */ - public void lockFile(); + boolean access(); /** - *文件解锁 + * 重命名 + * + * @param tplFile 旧文件 + * @param to 新文件名 + * @param from 旧文件名 + * @return 是否成功 */ - public void unLockFile(); + boolean rename(FILE tplFile, String from, String to); - public String getSelectedTemplatePath(); /** - *文件名是否存在 + * 文件名是否存在 + * * @param newName 原名 - * @param oldName 新的文件名 - * @param suffix 后缀名 + * @param suffix 后缀名 * @return 是否存在 */ - public boolean isNameAlreadyExist(String newName, String oldName, String suffix); + boolean duplicated(String newName, String suffix); } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java new file mode 100644 index 0000000000..b73805ee66 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -0,0 +1,295 @@ +package com.fr.design.file; + +import com.fr.base.chart.chartdata.CallbackEvent; +import com.fr.design.DesignerEnvManager; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.JVirtualTemplate; +import com.fr.design.module.DesignModuleFactory; +import com.fr.file.FILE; +import com.fr.file.FileNodeFILE; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.CoreConstants; +import com.fr.stable.StringUtils; +import com.fr.third.org.apache.commons.io.FilenameUtils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.ListIterator; + +/** + * 历史模板缓存 + * + * @see HistoryTemplateListPane + */ +public class HistoryTemplateListCache implements CallbackEvent { + + //最大保存内存中面板数,为0时关闭优化内存 + private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit(); + private List> historyList; + private JTemplate editingTemplate; + + private static volatile HistoryTemplateListCache THIS; + + public static HistoryTemplateListCache getInstance() { + if (THIS == null) { + synchronized (HistoryTemplateListCache.class) { + if (THIS == null) { + THIS = new HistoryTemplateListCache(); + } + } + } + return THIS; + } + + private HistoryTemplateListCache() { + historyList = new ArrayList<>(); + } + + /** + * 关闭选择的文件 + * + * @param selected 选择的 + */ + public void closeSelectedReport(JTemplate selected) { + DesignModuleFactory.clearChartPropertyPane(); + DesignTableDataManager.closeTemplate(selected); + if (contains(selected) == -1) { + return; + } + selected.fireJTemplateClosed(); + selected.stopEditing(); + try { + historyList.remove(contains(selected)); + selected.getEditingFILE().closeTemplate(); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName())); + MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + + } + + /** + * 临时关闭选择的文件 + * + * @param selected 选择的 + */ + public void closeVirtualSelectedReport(JTemplate selected) { + DesignModuleFactory.clearChartPropertyPane(); + DesignTableDataManager.closeTemplate(selected); + if (contains(selected) == -1) { + return; + } + selected.fireJTemplateClosed(); + selected.stopEditing(); + try { + selected.getEditingFILE().closeTemplate(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + + public JTemplate getCurrentEditingTemplate() { + return this.editingTemplate; + } + + public void setCurrentEditingTemplate(JTemplate jt) { + this.editingTemplate = jt; + //如果当前历史面板中没有 + + if (contains(jt) == -1) { + addHistory(); + } + MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); + //设置tab栏为当前选中的那一栏 + if (editingTemplate != null) { + MutilTempalteTabPane.getInstance().setSelectedIndex(contains(jt)); + } + + } + + /** + * 添加历史记录 + */ + public void addHistory() { + if (editingTemplate == null) { + return; + } + DesignerEnvManager.getEnvManager().addRecentOpenedFilePath(editingTemplate.getPath()); + historyList.add(editingTemplate); + closeOverLineTemplate(); + } + + + public List> getHistoryList() { + return historyList; + } + + + /** + * 清空历史记录 + */ + public void removeAllHistory() { + historyList.clear(); + this.editingTemplate = null; + } + + public int getHistoryCount() { + return historyList.size(); + } + + + public JTemplate get(int index) { + if (index > historyList.size() - 1 || index < 0) { + return null; + } + Collections.reverse(historyList); + JTemplate select = historyList.get(index); + Collections.reverse(historyList); + return select; + } + + + public JTemplate getTemplate(int index) { + return historyList.get(index); + } + + /** + * 获取模板的index + * + * @param jt 模板 + * @return 位置 + */ + public int contains(JTemplate jt) { + for (int i = 0; i < historyList.size(); i++) { + if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), jt.getEditingFILE())) { + return i; + } + } + return -1; + } + + + /** + * 判断是否打开过该模板 + * + * @param filename 文件名 + * @return 文件位置 + */ + public int contains(String filename) { + for (int i = 0; i < historyList.size(); i++) { + String historyPath = historyList.get(i).getPath(); + //文件路径和历史路径都是 reportlets/xxx/xxx/xxx/xx.suffix + if (filename.equals(historyPath)) { + return i; + } + } + return -1; + } + + /** + * 是否是当前编辑的文件 + * + * @param filename 文件名 + * @return 是则返回TRUE + */ + public boolean isCurrentEditingFile(String filename) { + String editingFileName = editingTemplate.getPath(); + return ComparatorUtils.equals(filename, editingFileName); + } + + @Override + public void callback() { + getCurrentEditingTemplate().repaint(); + } + + /** + * 打开new模板的同时关闭old模板,优先关已保存的、先打开的 + */ + public void closeOverLineTemplate() { + int size = historyList.size(); + int vCount = size - DEAD_LINE; + if (DEAD_LINE == 0 || vCount <= 0) { + return; + } + for (int i = 0; i < vCount; i++) { + JTemplate overTemplate = historyList.get(i); + + if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) { + closeVirtualSelectedReport(overTemplate); + historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE())); + } + } + MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); + } + + + public void deleteFile(FileNodeFILE file) { + boolean isDir = file.isDirectory(); + + String suffix = isDir ? CoreConstants.SEPARATOR : StringUtils.EMPTY; + + // path like reportlets/xx/xxx/xxx + String path = file.getPath() + suffix; + + ListIterator> iterator = historyList.listIterator(); + + while (iterator.hasNext()) { + JTemplate template = iterator.next(); + String tPath = template.getPath(); + if (isDir ? tPath.startsWith(path) : tPath.equals(path)) { + iterator.remove(); + int index = iterator.nextIndex(); + int size = getHistoryCount(); + if (size == index + 1 && index > 0) { + //如果删除的是后一个Tab,则定位到前一个 + MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1); + JTemplate selectedFile = MutilTempalteTabPane.getInstance().getSelectedFile(); + if (!isCurrentEditingFile(selectedFile.getPath())) { + //如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样 + DesignerContext.getDesignerFrame().activateJTemplate(selectedFile); + } + } + } + } + //如果打开过,则删除,实时刷新多tab面板 + int openFileCount = getHistoryCount(); + if (openFileCount == 0) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + } + MutilTempalteTabPane.getInstance().repaint(); + } + + + public boolean rename(FILE tplFile, String from, String to) { + boolean isDir = tplFile.isDirectory(); + + JTemplate template; + + template = this.getCurrentEditingTemplate(); + if (template != null) { + String editingPath = FilenameUtils.standard(template.getEditingFILE().getPath()); + if (isDir ? editingPath.contains(from + CoreConstants.SEPARATOR) : editingPath.equals(from)) { + FILE renameFile = template.getEditingFILE(); + renameFile.setPath(editingPath.replace(from, to)); + } + } + + for (int i = 0; i < this.getHistoryCount(); i++) { + template = this.get(i); + String editingPath = FilenameUtils.standard(template.getEditingFILE().getPath()); + if (isDir ? editingPath.contains(from + CoreConstants.SEPARATOR) : editingPath.equals(from)) { + FILE renameFile = template.getEditingFILE(); + renameFile.setPath(editingPath.replace(from, to)); + } + + } + return true; + } +} diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java index eff4291e44..073c4fd1d5 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java @@ -1,443 +1,16 @@ package com.fr.design.file; -import com.fr.base.FRContext; -import com.fr.base.chart.chartdata.CallbackEvent; -import com.fr.design.DesignModelAdapter; -import com.fr.design.DesignerEnvManager; -import com.fr.design.constants.UIConstants; -import com.fr.design.data.DesignTableDataManager; -import com.fr.design.data.datapane.TableDataTreePane; -import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ilist.UIList; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.module.DesignModuleFactory; -import com.fr.design.utils.gui.GUIPaintUtils; -import com.fr.file.filetree.FileNode; -import com.fr.general.ComparatorUtils; -import com.fr.general.IOUtils; - -import com.fr.log.FineLoggerFactory; -import com.fr.stable.Constants; -import com.fr.stable.StableUtils; -import com.fr.stable.project.ProjectConstants; -import com.fr.workspace.WorkContext; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent { - //最大保存内存中面板数,为0时关闭优化内存 - private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit();; - private static final int LIST_BORDER = 4; - private List> historyList; - private JTemplate editingTemplate; - private FileToolbarStateChangeListener toobarStateChangeListener; - - private static volatile HistoryTemplateListPane THIS; - - private UIList list; - - public static final HistoryTemplateListPane getInstance() { - if (THIS == null) { - synchronized (HistoryTemplateListPane.class) { - if (THIS == null) { - THIS = new HistoryTemplateListPane(); - } - } - } - return THIS; - } - - private HistoryTemplateListPane() { - setLayout(new BorderLayout()); - historyList = new ArrayList>(); - list = new UIList(new HistoryListDataMode()) { - public int locationToIndex(Point location) { - int rowCount = getModel().getSize(); - int height = getPreferredSize().height - 2 * LIST_BORDER; - int rowHeight = height / rowCount; - int index = (location.y - LIST_BORDER) / rowHeight; - if (location.y < LIST_BORDER || index > rowCount - 1) { - return -1; - } else { - return index; - } - } - }; - ToolTipManager.sharedInstance().registerComponent(list); - list.setBackground(UIConstants.NORMAL_BACKGROUND); - list.setCellRenderer(new HistoryListCellRender()); - list.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() < 2) { - return; - } - openSelectedReport(); - } - }); - - - list.addListSelectionListener(new ListSelectionListener() { - - @Override - public void valueChanged(ListSelectionEvent e) { - if (toobarStateChangeListener != null) { - toobarStateChangeListener.stateChange(); - } - - } - }); - list.setBorder(BorderFactory.createEmptyBorder(LIST_BORDER, LIST_BORDER, LIST_BORDER, LIST_BORDER)); - UIScrollPane scrollPane = new UIScrollPane(list); - scrollPane.setBorder(null); - - this.add(scrollPane, BorderLayout.CENTER); - - } - - /** - * 关闭选择的文件 - * - * @param selected 选择的 - */ - public void closeSelectedReport(JTemplate selected) { - DesignModuleFactory.clearChartPropertyPane(); - DesignTableDataManager.closeTemplate(selected); - if (contains(selected) == -1) { - return; - } - selected.fireJTemplateClosed(); - selected.stopEditing(); - try { - historyList.remove(contains(selected)); - selected.getEditingFILE().closeTemplate(); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName())); - MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - - } - - /** - * 临时关闭选择的文件 - * - * @param selected 选择的 - */ - public void closeVirtualSelectedReport(JTemplate selected) { - DesignModuleFactory.clearChartPropertyPane(); - DesignTableDataManager.closeTemplate(selected); - if (contains(selected) == -1) { - return; - } - selected.fireJTemplateClosed(); - selected.stopEditing(); - try { - selected.getEditingFILE().closeTemplate(); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - } - - /** - * 关闭选择的文件 - */ - public void selectedReportToVirtual(int i) { - closeOverLineTemplate(); - } - - public JTemplate getCurrentEditingTemplate() { - return this.editingTemplate; - } - - public void setCurrentEditingTemplate(JTemplate jt) { - this.editingTemplate = jt; - //如果当前历史面板中没有 - - if (contains(jt) == -1) { - addHistory(); - } - MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); - //设置tab栏为当前选中的那一栏 - if (editingTemplate != null) { - MutilTempalteTabPane.getInstance().setSelectedIndex(contains(jt)); - } - - } - - /** - * 添加历史记录 - */ - public void addHistory() { - if (editingTemplate == null) { - return; - } - DesignerEnvManager.getEnvManager().addRecentOpenedFilePath(editingTemplate.getPath()); - ((HistoryListDataMode) list.getModel()).add(editingTemplate); - } - - - public List> getHistoryList() { - return historyList; - } - - - /** - * 清空历史记录 - */ - public void removeAllHistory() { - historyList.clear(); - this.editingTemplate = null; - } - - public int getHistoryCount() { - return list.getModel().getSize(); - } - - - public UIList getList() { - return list; - } - - - public JTemplate get(int index) { - return (JTemplate) list.getModel().getElementAt(index); - } - - - public JTemplate getTemplate(int index) { - return historyList.get(index); - } - - /** - * 获取模板的index - * - * @param jt 模板 - * @return 位置 - */ - public int contains(JTemplate jt) { - for (int i = 0; i < historyList.size(); i++) { - if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), jt.getEditingFILE())) { - return i; - } - } - return -1; - } - - - /** - * 判断是否打开过该模板 - * - * @param filename 文件名 - * @return 文件位置 - */ - public int contains(String filename) { - for (int i = 0; i < historyList.size(); i++) { - String historyPath = historyList.get(i).getPath().replaceAll("/", "\\\\"); - //文件路径是全路径,历史路径是reportlets/模板名 - if (filename.endsWith(historyPath)) { - return i; - } - } - return -1; - } - - /** - * 是否是当前编辑的文件 - * - * @param filename 文件名 - * @return 是则返回TRUE - */ - public boolean isCurrentEditingFile(String filename) { - String editingFileName = editingTemplate.getPath(); - return ComparatorUtils.equals(filename, editingFileName); - } - - @Override - public void callback() { - getCurrentEditingTemplate().repaint(); - } - - private class HistoryListCellRender extends DefaultListCellRenderer { - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - JTemplate jt = (JTemplate) value; - UILabel nameLabel = new UILabel(jt.getEditingFILE().getName()); - final int nameWidth = nameLabel.getPreferredSize().width; - UILabel uiLabel = new UILabel() { - public void paint(Graphics g) { - GUIPaintUtils.fillPaint((Graphics2D) g, 18, 0, nameWidth + 2, getHeight(), true, Constants.NULL, isSelected ? UIConstants.FLESH_BLUE : UIConstants.NORMAL_BACKGROUND, UIConstants.ARC); - super.paint(g); - } - - }; - uiLabel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); - uiLabel.setIcon(jt.getIcon()); - uiLabel.setText(jt.getEditingFILE().getName()); - return uiLabel; - } - - } - - - private class HistoryListDataMode extends AbstractListModel { - - @Override - public int getSize() { - return historyList.size(); - } - - @Override - public JTemplate getElementAt(int index) { - if (index > getSize() - 1 || index < 0) { - return null; - } - Collections.reverse(historyList); - JTemplate select = historyList.get(index); - Collections.reverse(historyList); - return select; - } - - public void remove(int index) { - boolean outofindex = index >= historyList.size() || index < 0; - if (historyList.isEmpty() || outofindex) { - return; - } - historyList.remove(index); - } - - public void add(JTemplate jt) { - historyList.add(jt); - closeOverLineTemplate(); - refresh(); - } - } - - /** - * 打开new模板的同时关闭old模板,优先关已保存的、先打开的 - */ - public void closeOverLineTemplate() { - int size = historyList.size(); - int vCount = size - DEAD_LINE; - if (DEAD_LINE == 0 || vCount <= 0) { - return; - } - for (int i = 0; i < vCount; i++) { - JTemplate overTemplate = historyList.get(i); - - if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) { - historyList.get(i).closeOverLineTemplate(i); - } - } - MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); - } - - /** - * 刷新 - */ - public void refresh() { - list.removeAll(); - list.setModel(new HistoryListDataMode()); - list.setSelectedIndex(list.getSelectedIndex()); - } - - /** - * 打开选择的文件 - */ - public void openSelectedReport() { - DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate) list.getSelectedValue()); - TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); - refresh(); - } - - /** - * 打开文件所在文件夹 - */ - public void openContainerFolder() { - FileNode fileNode = new FileNode(((JTemplate) list.getSelectedValue()).getEditingFILE().getPath(), false); - if (WorkContext.getCurrent().isLocal()) { - IOUtils.openWindowsFolder(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fileNode.getEnvPath())); - } - } - - /** - * 删除文件 - */ - public void deleteFile() { -// TODO Auto-generated method stub - - } - - /*** - * 琐文件 - */ - public void lockFile() { -// TODO Auto-generated method stub - - } - - /** - * 解锁 - */ - public void unLockFile() { -// TODO Auto-generated method stub - - } - - /** - * 路径 - * - * @return 路径 - */ - public String getSelectedTemplatePath() { - if (list.getSelectedIndex() < 0 || list.getSelectedIndex() > list.getModel().getSize() - 1) { - return null; - } - ; - String path = ((HistoryListDataMode) list.getModel()).getElementAt(list.getSelectedIndex()).getEditingFILE().getPath(); - if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) { - return path.substring(ProjectConstants.REPORTLETS_NAME.length()); - } - return path; - } - - public void setToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) { - this.toobarStateChangeListener = toobarStateChangeListener; - } - - /** - * 文件是否存在 - * - * @param newName 文件名 - * @param oldName 原名 - * @param suffix 后缀名 - * @return 文件是否存在 - */ - public boolean isNameAlreadyExist(String newName, String oldName, String suffix) { - boolean isNameAreadyExist = false; - for (int i = 0; i < getHistoryCount(); i++) { - JTemplate jt = ((HistoryListDataMode) list.getModel()).getElementAt(i); - if (ComparatorUtils.equals(jt.getEditingFILE().getName(), newName + suffix)) { - isNameAreadyExist = true; - break; - } - } - if (ComparatorUtils.equals(newName, oldName)) { - isNameAreadyExist = false; - } - - return isNameAreadyExist; +/** + * 历史模板缓存 + * + * 为可能存在的插件做兼容处理 + * + * @see HistoryTemplateListCache + * @deprecated use HistoryTemplateListCache instead + */ +@Deprecated +public class HistoryTemplateListPane { + public static HistoryTemplateListCache getInstance() { + return HistoryTemplateListCache.getInstance(); } } diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index b1cb56ede1..b6f18a1882 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -7,23 +7,41 @@ import com.fr.base.vcs.DesignerMode; import com.fr.design.constants.UIConstants; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIScrollPopUpMenu; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.file.FILE; -import com.fr.file.FileNodeFILE; import com.fr.general.ComparatorUtils; - import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; -import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; -import com.fr.stable.project.ProjectConstants; - -import javax.swing.*; +import com.fr.third.javax.annotation.Nonnull; +import com.fr.third.org.apache.commons.io.FilenameUtils; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.lock.TplOperator; + +import javax.swing.BorderFactory; +import javax.swing.ButtonModel; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSeparator; import javax.swing.plaf.basic.BasicMenuItemUI; -import java.awt.*; +import java.awt.AWTEvent; +import java.awt.AlphaComposite; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; import java.awt.event.AWTEventListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -35,14 +53,15 @@ import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; -import java.io.File; +import java.util.List; /** * Author : daisy * Date: 13-8-5 * Time: 下午6:12 */ -public class MutilTempalteTabPane extends JComponent implements MouseListener, MouseMotionListener, Action { +public class MutilTempalteTabPane extends JComponent { + private static Icon LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_normal.png"); private static Icon MOUSE_OVER_LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_pressed.png"); private static Icon MOUSE_PRESS_LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_pressed.png"); @@ -50,13 +69,11 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M private static Icon MOUSE_OVER_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/mouseoverclose icon.png"); private static Icon MOUSE_PRESS_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/pressclose icon.png"); private static final String ELLIPSIS = "..."; - private static final int GAP_BEFORE_CLOSE = 10; private static final int GAP = 5; private static final int SMALLGAP = 3; private static final int LIST_BUTTON_WIDTH = 34; private static final int HEIGHT = 26; private static final int LIST_DOWN_HEIGHT = 25; - private static final double FOR_CAL_BYTES = 0.5; private static final double CORNOR_RADIUS = 0.0; //选了30度和60度的特殊角度的x,y作为经过的两个点的坐标 private static final double SPECIAL_LOCATION_1 = 2.5; @@ -86,19 +103,11 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M private int minPaintIndex = 0; private int maxPaintIndex = 0; - /** - * 鼠标按下时的坐标数组、鼠标放开时的坐标数组 - */ - private int[] xyPressedCoordinate = {0, 0}; - - //每个关闭图标的起始位置 private int[] startX; private boolean[] isNeedToolTips; - private Graphics2D g2d; - //记录关闭按钮的状态 private int closeIconIndex = -1; private boolean isCloseCurrent = false; @@ -112,26 +121,41 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M private JTemplate temTemplate = null; - private AWTEventListener awt = new AWTEventListener() { - public void eventDispatched(AWTEvent event) { - if (event instanceof MouseEvent) { - MouseEvent mv = (MouseEvent) event; - if (mv.getClickCount() > 0 && !ComparatorUtils.equals(mv.getSource(), MutilTempalteTabPane.this)) { - isShowList = false; - } - } - } - - }; - - - public static final MutilTempalteTabPane getInstance() { + public static MutilTempalteTabPane getInstance() { if (THIS == null) { THIS = new MutilTempalteTabPane(); } return THIS; } + + /** + * 多工作簿面板 + */ + public MutilTempalteTabPane() { + this.setLayout(new BorderLayout(0, 0)); + this.addMouseListener(new MultiTemplateTabMouseListener()); + this.addMouseMotionListener(new MultiTemplateTabMouseMotionListener()); + this.setBorder(null); + this.setForeground(new Color(58, 56, 58)); + this.setFont(new Font(Toolkit.i18nText("Fine-Design_Basic_Song_TypeFace"), 0, 12)); + openedTemplate = HistoryTemplateListCache.getInstance().getHistoryList(); + selectedIndex = openedTemplate.size() - 1; + AWTEventListener awt = new AWTEventListener() { + @Override + public void eventDispatched(AWTEvent event) { + if (event instanceof MouseEvent) { + MouseEvent mv = (MouseEvent) event; + if (mv.getClickCount() > 0 && !ComparatorUtils.equals(mv.getSource(), MutilTempalteTabPane.this)) { + isShowList = false; + } + } + } + + }; + java.awt.Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); + } + public JTemplate getSelectedFile() { return openedTemplate.get(selectedIndex); } @@ -152,31 +176,18 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M } + @Override public Dimension getPreferredSize() { Dimension dimension = super.getPreferredSize(); dimension.height = HEIGHT; return dimension; } - /** - * 多工作簿面板 - */ - public MutilTempalteTabPane() { - this.setLayout(new BorderLayout(0, 0)); - this.addMouseListener(this); - this.addMouseMotionListener(this); - this.setBorder(null); - this.setForeground(new Color(58, 56, 58)); - this.setFont(new Font(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Song_TypeFace"), 0, 12)); - openedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); - selectedIndex = openedTemplate.size() - 1; - Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); - } - private UIMenuItem initCloseOther() { - UIMenuItem closeOther = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FS_Close_Other_Templates")); + UIMenuItem closeOther = new UIMenuItem(Toolkit.i18nText("Fine-Design_Basic_FS_Close_Other_Templates")); setListDownItemPreferredSize(closeOther); closeOther.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (openedTemplate.size() == 1) { return; @@ -190,20 +201,21 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M } for (int i = 0; i < panes.length; i++) { if (i != selectedIndex) { + JTemplate jTemplate = panes[i]; //判断关闭的模板是不是格式刷的被参照的模板 - openedTemplate.remove(panes[i]); - closeFormat(panes[i]); - HistoryTemplateListPane.getInstance().closeSelectedReport(panes[i]); + openedTemplate.remove(jTemplate); + closeFormat(jTemplate); + HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); + // release lock + WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(jTemplate.getPath()); } } - JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - HistoryTemplateListPane.getInstance().removeAllHistory(); + JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + HistoryTemplateListCache.getInstance().removeAllHistory(); DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); THIS.repaint(); } //如果取消保存了,则不关闭其他模板 - - } }); if (openedTemplate.size() == 1) { @@ -227,6 +239,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M templates[i].setBackground(UIConstants.SHADOW_CENTER); } templates[i].addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { selectedIndex = index; tem.activeNewJTemplate(); @@ -256,7 +269,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M * * @param history 模板 */ - public void refreshOpenedTemplate(java.util.List> history) { + public void refreshOpenedTemplate(List> history) { openedTemplate = history; } @@ -271,6 +284,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); menu.add(initCloseOther()); JSeparator separator = new JSeparator() { + @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 1; @@ -278,6 +292,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M } }; menu.add(new JPanel() { + @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 1; @@ -287,6 +302,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M separator.setForeground(UIConstants.LINE_COLOR); menu.add(separator); menu.add(new JPanel() { + @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 1; @@ -306,14 +322,16 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M } + @Override public void paintComponent(Graphics g) { super.paintComponent(g); double maxWidth = getWidth() - LIST_BUTTON_WIDTH; //最大宽度 - g2d = (Graphics2D) g; + Graphics2D g2d = (Graphics2D) g; paintBackgroundAndLine(g2d, maxWidth); } + @Override public void paint(Graphics g) { //不可见时,按钮.4f透明 AlphaComposite composite = DesignerMode.isVcsMode() @@ -354,7 +372,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M isNeedToolTips[i - minPaintIndex] = false; } - Icon selectedIcon = null; + Icon selectedIcon; if (i == closeIconIndex) { selectedIcon = clodeMode; } else { @@ -370,7 +388,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M } if (!DesignerMode.isVcsMode()) { - paintListDown(g2d, maxWidth); + paintListDown(g2d, maxWidth); } paintUnderLine(templateStartX, maxWidth, g2d); } @@ -551,7 +569,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M int closePosition = (int) templateStartX + realWidth - CLOSE.getIconWidth() - SMALLGAP; int closeY = (getHeight() - closeIcon.getIconHeight()) / 2; if (!DesignerMode.isVcsMode()) { - closeIcon.paintIcon(this, g2d, closePosition, closeY); + closeIcon.paintIcon(this, g2d, closePosition, closeY); } return closePosition; @@ -609,7 +627,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M int closeY = (getHeight() - closeIcon.getIconHeight()) / 2; int closePosition = (int) templateStartX + realWidth - CLOSE.getIconWidth() - SMALLGAP; if (!DesignerMode.isVcsMode()) { - closeIcon.paintIcon(this, g2d, closePosition, closeY); + closeIcon.paintIcon(this, g2d, closePosition, closeY); } return closePosition; } @@ -642,72 +660,6 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M generalPath.closePath(); } - /** - * 点击 - * - * @param e 鼠标事件 - */ - public void mouseClicked(MouseEvent e) { - } - - /** - * 按下 - * - * @param e 鼠标事件 - */ - public void mousePressed(MouseEvent e) { - //如果在版本管理情况下,不允许切换tab - if (DesignerMode.isVcsMode()) { - return; - } - - int evtX = e.getX(); - int evtY = e.getY(); - this.setPressedXY(evtX, evtY); - - //是否点击关闭按钮 如果点击了关闭按钮,则将点击的模板关闭,不需要切换,如果没有点击关闭按钮,则切换到点击的模板处 - boolean isOverCloseIcon = isOverCloseIcon(evtX); - if (isOverListDown(evtX)) { - listDownMode = isOverListDown(evtX) ? MOUSE_PRESS_LIST_DOWN : LIST_DOWN; - if (!isShowList) { - showListDown(); - } - isShowList = !isShowList; - - } else if (isOverCloseIcon) { - //关闭按钮的图标变化 - closeIconIndex = getTemplateIndex(evtX); - clodeMode = MOUSE_PRESS_CLOSE; - //关闭close图标所在的模板{ - closeFormat(openedTemplate.get(closeIconIndex)); - closeSpecifiedTemplate(openedTemplate.get(closeIconIndex)); - DesignerContext.getDesignerFrame().getContentFrame().repaint(); - isShowList = false; - } else { - //没有点击关闭和ListDown按钮,则切换到点击的模板处 - closeIconIndex = -1; - clodeMode = CLOSE; - int tempSelectedIndex = selectedIndex; - if (selectedIndex != getTemplateIndex(evtX) && getTemplateIndex(evtX) != -1) { - openedTemplate.get(selectedIndex).stopEditing(); - selectedIndex = getTemplateIndex(evtX); - //如果在权限编辑情况下,不允许切换到表单类型的工作簿 - if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); - JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") - + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); - this.repaint(); - return; - } - JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX)); - evtXTemplate.activeNewJTemplate(); - } - isShowList = false; - } - this.repaint(); - - - } public void setIsCloseCurrent(boolean isCloseCurrent) { this.isCloseCurrent = isCloseCurrent; @@ -725,24 +677,30 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M } //当前激活的模板 - String filename = openedTemplate.get(selectedIndex).getEditingFILE().getPath(); - if (filename.startsWith(ProjectConstants.REPORTLETS_NAME)) { - filename = ((FileNodeFILE) openedTemplate.get(selectedIndex).getEditingFILE()).getEnvPath() + File.separator + filename; - } - - filename = OperatingSystem.isWindows() ? filename.replaceAll("/", "\\\\") : filename.replaceAll("\\\\", "/"); - + String filename = openedTemplate.get(selectedIndex).getPath(); + filename = FilenameUtils.standard(filename); if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { specifiedTemplate.stopEditing(); - int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", + int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); - if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { + if (returnVal == JOptionPane.YES_OPTION) { specifiedTemplate.saveTemplate(); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + closeTpl(specifiedTemplate, filename); + } else if (returnVal == JOptionPane.NO_OPTION) { + closeTpl(specifiedTemplate, filename); } + } else { + closeTpl(specifiedTemplate, filename); } - HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); - activeTemplate(filename); + + } + + private void closeTpl(@Nonnull JTemplate specifiedTemplate, @Nonnull String fileName) { + HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); + // release lock + WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(specifiedTemplate.getPath()); + activeTemplate(fileName); } /** @@ -767,15 +725,15 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M /** * 关闭掉一个模板之后该激活的Tab * - * @param fileName + * @param fileName 关闭掉一个模板之后该激活的Tab的文件名,绝对路径 */ private void activeTemplate(String fileName) { if (openedTemplate.isEmpty()) { //新建并激活模板 DesignerContext.getDesignerFrame().addAndActivateJTemplate(); selectedIndex = 0; - //此时刚自动新建的模板在HistoryTemplateListPane的editingTemplate - temTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + //此时刚自动新建的模板在HistoryTemplateListCache的editingTemplate + temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); } else { //如果关闭的模板是当前选中的模板,则重新激活 @@ -794,30 +752,13 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M } } else { //如果关闭的模板不是当前选中的模板,则激活的模板不变 - selectedIndex = HistoryTemplateListPane.getInstance().contains(fileName); + selectedIndex = HistoryTemplateListCache.getInstance().contains(fileName); } //如果是已后台关闭的模板,则重新打开文件 openedTemplate.get(selectedIndex).activeOldJTemplate(); } } - /** - * 鼠标释放 - * - * @param e 鼠标事件 - */ - public void mouseReleased(MouseEvent e) { - } - - /** - * 鼠标进入 - * - * @param e 鼠标事件 - */ - public void mouseEntered(MouseEvent e) { - - } - private boolean isOverCloseIcon(int evtX) { boolean isOverCloseIcon = false; @@ -849,76 +790,6 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M return -1; } - /** - * 鼠标离开 - * - * @param e 鼠标事件 - */ - public void mouseExited(MouseEvent e) { - listDownMode = LIST_DOWN; - closeIconIndex = -1; - mouseOveredIndex = -1; - this.repaint(); - } - - /** - * 鼠标拖拽 - * - * @param e 鼠标事件 - */ - public void mouseDragged(MouseEvent e) { - } - - /** - * 鼠标移动 - * - * @param e 鼠标事件 - */ - public void mouseMoved(MouseEvent e) { - int evtX = e.getX(); - mouseOveredIndex = getTemplateIndex(evtX); - - //看是否需要显示toolTip - if (mouseOveredIndex != -1 && isNeedToolTips[mouseOveredIndex - minPaintIndex]) { - setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName()); - } else { - setToolTipText(null); - } - - listDownMode = isOverListDown(evtX) ? MOUSE_OVER_LIST_DOWN : LIST_DOWN; - - boolean isOverCloseIcon = isOverCloseIcon(evtX); - clodeMode = isOverCloseIcon ? MOUSE_OVER_CLOSE : CLOSE; - closeIconIndex = isOverCloseIcon ? mouseOveredIndex : -1; - this.repaint(); - } - - - private void setPressedXY(int x, int y) { - this.xyPressedCoordinate[0] = x; - this.xyPressedCoordinate[1] = y; - } - - public Object getValue(String key) { - return null; - } - - /** - * 加入值 - * - * @param key 键 - * @param value 值 - */ - public void putValue(String key, Object value) { - } - - /** - * 动作 - * - * @param e 事件 - */ - public void actionPerformed(ActionEvent e) { - } /** * 处理自动新建的模板 在切换时的处理 @@ -926,7 +797,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M public void doWithtemTemplate() { //temtemplate保存的一定是手动新建的没有编辑或是编辑了没有保存的模板 //没有保存,说明有编辑;已经保存在磁盘里的文件,说明有过处理,并且已经保存,此时切换都不将其自动关闭 - if (temTemplate == null || temTemplate == HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()) { + if (temTemplate == null || temTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) { return; } @@ -936,9 +807,9 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M //自动新建的模板B若没有进行任何编辑(新建模板没有进行任何编辑时saved都是true):还没有存盘 if (temTemplate != null && temTemplate.getEditingFILE().isMemFile() && temTemplate.isSaved()) { - HistoryTemplateListPane.getInstance().closeSelectedReport(temTemplate); + HistoryTemplateListCache.getInstance().closeSelectedReport(temTemplate); temTemplate = null; - setSelectedIndex(HistoryTemplateListPane.getInstance().contains(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate())); + setSelectedIndex(HistoryTemplateListCache.getInstance().contains(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())); } } @@ -970,5 +841,146 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M } } + private class MultiTemplateTabMouseListener implements MouseListener { + + + /** + * 鼠标进入 + * + * @param e 鼠标事件 + */ + @Override + public void mouseEntered(MouseEvent e) { + + } + + /** + * 鼠标离开 + * + * @param e 鼠标事件 + */ + @Override + public void mouseExited(MouseEvent e) { + listDownMode = LIST_DOWN; + closeIconIndex = -1; + mouseOveredIndex = -1; + MutilTempalteTabPane.this.repaint(); + } + + /** + * 鼠标释放 + * + * @param e 鼠标事件 + */ + @Override + public void mouseReleased(MouseEvent e) { + } + + /** + * 点击 + * + * @param e 鼠标事件 + */ + @Override + public void mouseClicked(MouseEvent e) { + } + + /** + * 按下 + * + * @param e 鼠标事件 + */ + @Override + public void mousePressed(MouseEvent e) { + //如果在版本管理情况下,不允许切换tab + if (DesignerMode.isVcsMode()) { + return; + } + + int evtX = e.getX(); + + //是否点击关闭按钮 如果点击了关闭按钮,则将点击的模板关闭,不需要切换,如果没有点击关闭按钮,则切换到点击的模板处 + boolean isOverCloseIcon = isOverCloseIcon(evtX); + if (isOverListDown(evtX)) { + listDownMode = isOverListDown(evtX) ? MOUSE_PRESS_LIST_DOWN : LIST_DOWN; + if (!isShowList) { + showListDown(); + } + isShowList = !isShowList; + + } else if (isOverCloseIcon) { + //关闭按钮的图标变化 + closeIconIndex = getTemplateIndex(evtX); + clodeMode = MOUSE_PRESS_CLOSE; + //关闭close图标所在的模板{ + closeFormat(openedTemplate.get(closeIconIndex)); + closeSpecifiedTemplate(openedTemplate.get(closeIconIndex)); + DesignerContext.getDesignerFrame().getContentFrame().repaint(); + isShowList = false; + } else { + //没有点击关闭和ListDown按钮,则切换到点击的模板处 + closeIconIndex = -1; + clodeMode = CLOSE; + int tempSelectedIndex = selectedIndex; + if (selectedIndex != getTemplateIndex(evtX) && getTemplateIndex(evtX) != -1) { + openedTemplate.get(selectedIndex).stopEditing(); + selectedIndex = getTemplateIndex(evtX); + //如果在权限编辑情况下,不允许切换到表单类型的工作簿 + if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); + JOptionPane.showMessageDialog(MutilTempalteTabPane.this, Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); + MutilTempalteTabPane.this.repaint(); + return; + } + JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX)); + evtXTemplate.activeNewJTemplate(); + } + isShowList = false; + } + MutilTempalteTabPane.this.repaint(); + + + } + + + } + + private class MultiTemplateTabMouseMotionListener implements MouseMotionListener { + /** + * 鼠标拖拽 + * + * @param e 鼠标事件 + */ + @Override + public void mouseDragged(MouseEvent e) { + } + + /** + * 鼠标移动 + * + * @param e 鼠标事件 + */ + @Override + public void mouseMoved(MouseEvent e) { + int evtX = e.getX(); + mouseOveredIndex = getTemplateIndex(evtX); + + //看是否需要显示toolTip + if (mouseOveredIndex != -1 && isNeedToolTips[mouseOveredIndex - minPaintIndex]) { + setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName()); + } else { + setToolTipText(null); + } + + listDownMode = isOverListDown(evtX) ? MOUSE_OVER_LIST_DOWN : LIST_DOWN; + + boolean isOverCloseIcon = isOverCloseIcon(evtX); + clodeMode = isOverCloseIcon ? MOUSE_OVER_CLOSE : CLOSE; + closeIconIndex = isOverCloseIcon ? mouseOveredIndex : -1; + MutilTempalteTabPane.this.repaint(); + } + } + } diff --git a/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java b/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java new file mode 100644 index 0000000000..01c4615af3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java @@ -0,0 +1,225 @@ +package com.fr.design.file; + +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.file.FILE; +import com.fr.file.FileNodeFILE; +import com.fr.file.filetree.FileNode; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.report.DesignAuthority; +import com.fr.stable.CoreConstants; +import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.authority.AuthorityOperator; + +import java.util.ArrayList; + +public class NodeAuthProcessor { + + public static NodeAuthProcessor getInstance() { + return NodeAuthProcessor.HOLDER.singleton; + } + + private static class HOLDER { + private static NodeAuthProcessor singleton = new NodeAuthProcessor(); + } + + /** + * 远程设计拥有全部权限的文件夹路径 + */ + private ArrayList authPaths = new ArrayList<>(); + + + private NodeAuthProcessor() { + + } + + public void refresh() { + + authPaths.clear(); + if (!WorkContext.getCurrent().isLocal()) { + try { + String username = WorkContext.getCurrent().getConnection().getUserName(); + // 远程设计获取全部设计成员的权限列表 + DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities(); + DesignAuthority authority = null; + + if (authorities != null) { + for (DesignAuthority designAuthority : authorities) { + if (ComparatorUtils.equals(designAuthority.getUsername(), username)) { + authority = designAuthority; + } + } + } + if (authority != null) { + for (DesignAuthority.Item item : authority.getItems()) { + if (item.getType()) { + authPaths.add(item.getPath()); + } + } + } + } catch (Exception exception) { + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + } + } + } + + public void clear() { + authPaths.clear(); + } + + + /** + * 生成带权限信息的文件节点,供另存对话框使用 + * + * @param fileNodes file nodes + * @return 带权限信息的文件节点 + */ + public FILE[] parser2FILEArray(FileNode[] fileNodes, String envPath) { + + boolean isLocal = WorkContext.getCurrent().isLocal(); + boolean isRoot = WorkContext.getCurrent().isRoot(); + FILE[] res = new FILE[fileNodes.length]; + for (int i = 0; i < res.length; i++) { + FileNode fn = fileNodes[i]; + + if (fn.isDirectory()) { + if (isLocal || isRoot) { + res[i] = new FileNodeFILE(fileNodes[i], envPath); + } else { + boolean hasFullAuthority = isContained(fn); + res[i] = new FileNodeFILE(fileNodes[i], envPath, hasFullAuthority); + } + } else { + res[i] = new FileNodeFILE(fileNodes[i], envPath); + } + } + return res; + } + + /** + * 生成带权限信息的文件节点,供另存对话框使用 + * + * @param fileNode file nodes + * @return 带权限信息的文件节点 + */ + public FILE fixFILENodeAuth(FileNode fileNode) { + + boolean isLocal = WorkContext.getCurrent().isLocal(); + boolean isRoot = WorkContext.getCurrent().isRoot(); + + if (fileNode.isDirectory()) { + if (isLocal || isRoot) { + return new FileNodeFILE(fileNode); + } else { + boolean hasFullAuthority = isContained(fileNode); + return new FileNodeFILE(fileNode, hasFullAuthority); + } + } else { + return new FileNodeFILE(fileNode); + } + } + + /** + * 生成带权限信息的文件节点,供另存对话框使用 + * + * @param fileNode file nodes + * @return 带权限信息的文件节点 + */ + public boolean fixFileNodeAuth(FileNode fileNode) { + + boolean isLocal = WorkContext.getCurrent().isLocal(); + boolean isRoot = WorkContext.getCurrent().isRoot(); + + if (fileNode.isDirectory()) { + if (isLocal || isRoot) { + return true; + } else { + return isContained(fileNode); + } + } else { + return true; + } + } + + /** + * 生成带权限信息的目录树节点, + * 提供给目录树使用 + * + * @param fileNodes file nodes + * @return 带权限信息的目录树节点 + */ + public ExpandMutableTreeNode[] parser2TreeNodeArray(FileNode[] fileNodes) { + boolean isLocal = WorkContext.getCurrent().isLocal(); + boolean isRoot = WorkContext.getCurrent().isRoot(); + ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length]; + for (int i = 0; i < res.length; i++) { + FileNode fn = fileNodes[i]; + res[i] = new ExpandMutableTreeNode(fn); + if (fn.isDirectory()) { + res[i].add(new ExpandMutableTreeNode()); + if (isLocal || isRoot) { + res[i].setFullAuthority(true); + } else { + boolean hasFullAuthority = isContained(fn); + res[i].setFullAuthority(hasFullAuthority); + } + } + } + return res; + } + + public void fixTreeNodeAuth(ExpandMutableTreeNode treeNode) { + if (treeNode == null) { + return; + } + + Object object = treeNode.getUserObject(); + if (object instanceof FileNode) { + boolean isLocal = WorkContext.getCurrent().isLocal(); + boolean isRoot = WorkContext.getCurrent().isRoot(); + if (((FileNode) object).isDirectory()) { + if (isLocal || isRoot) { + treeNode.setFullAuthority(true); + } else { + boolean hasFullAuthority = isContained((FileNode) object); + treeNode.setFullAuthority(hasFullAuthority); + } + } + } + + + } + + private boolean isContained(FileNode fileNode) { + + for (String auPath : authPaths) { + if (isContained(auPath, fileNode)) { + return true; + } + } + return false; + } + + private boolean isContained(String auPath, FileNode fileNode) { + auPath = ProjectConstants.REPORTLETS_NAME + CoreConstants.SEPARATOR + auPath; + String fileName = fileNode.getEnvPath(); + String[] auPaths = auPath.split(CoreConstants.SEPARATOR); + String[] nodePaths = fileName.split(CoreConstants.SEPARATOR); + // 待判断目录是有权限目录或者有权限目录的子目录,全部权限 + if (auPaths.length <= nodePaths.length) { + for (int i = 0; i < auPaths.length; i++) { + if (!auPaths[i].equals(nodePaths[i])) { + return false; + } + } + return fileNode.isDirectory(); + } + // 其他情况半权限 + else { + return false; + } + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index e3d12da1ac..61d071e00a 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -4,29 +4,32 @@ package com.fr.design.file; import com.fr.base.FRContext; -import com.fr.base.io.FileAssistUtilsOperator; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itree.filetree.TemplateFileTree; +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; import com.fr.file.filetree.IOFileNodeFilter; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; - import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; -import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; +import com.fr.workspace.server.lock.TplOperator; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.ToolTipManager; +import javax.swing.UIManager; import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; import java.awt.BorderLayout; import java.awt.Desktop; import java.awt.Dimension; @@ -37,6 +40,12 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Enumeration; + +import static javax.swing.JOptionPane.WARNING_MESSAGE; +import static javax.swing.JOptionPane.YES_NO_OPTION; public class TemplateTreePane extends JPanel implements FileOperations { @@ -49,7 +58,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { } private TemplateFileTree reportletsTree; - private FileToolbarStateChangeListener toobarStateChangeListener; + private FileToolbarStateChangeListener toolBarStateChangeListener; private TemplateTreePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -71,14 +80,14 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public void mousePressed(MouseEvent evt) { if (evt.getClickCount() == 2) { - openSelectedReport(); + openFile(); } } @Override public void mouseReleased(MouseEvent e) { - if (toobarStateChangeListener != null) { - toobarStateChangeListener.stateChange(); + if (toolBarStateChangeListener != null) { + toolBarStateChangeListener.stateChange(); } } }; @@ -89,24 +98,24 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { - openSelectedReport(); + openFile(); } } @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { - openSelectedReport(); + openFile(); } - if (toobarStateChangeListener != null) { - toobarStateChangeListener.stateChange(); + if (toolBarStateChangeListener != null) { + toolBarStateChangeListener.stateChange(); } } @Override public void keyTyped(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { - openSelectedReport(); + openFile(); } } }); @@ -116,6 +125,49 @@ public class TemplateTreePane extends JPanel implements FileOperations { return this.reportletsTree; } + + /** + * 选中的路径数 + * + * @return 选中的路径数 + */ + public int countSelectedPath() { + TreePath[] treePaths = reportletsTree.getSelectionPaths(); + if (treePaths == null) { + return 0; + } + return treePaths.length; + } + + /** + * 选中的文件夹个数 + * + * @return 选中的文件夹个数 + */ + + public int countSelectedFolder() { + + if (reportletsTree.getSelectedFolderPaths() == null) { + return 0; + } + + return reportletsTree.getSelectedFolderPaths().length; + } + + /** + * 选中的文件个数 + * + * @return 选中的文件 + */ + public int countSelectedFile() { + + if (reportletsTree.getSelectionPaths() == null) { + return 0; + } + + return reportletsTree.getSelectedTemplatePaths().length; + } + /** * 刷新 */ @@ -125,11 +177,27 @@ public class TemplateTreePane extends JPanel implements FileOperations { } + @Override + public boolean mkdir(String path) { + return WorkContext.getWorkResource().createDirectory(path); + } + /** * 打开选中的报表文件 */ @Override - public void openSelectedReport() { + public void openFile() { + // 判断是否是远程设计的锁定文件 + if (!WorkContext.getCurrent().isLocal()) { + FileNode node = reportletsTree.getSelectedFileNode(); + if (node == null) { + return; + } + String lock = node.getLock(); + if (lock != null && !lock.equals(node.getUserID())) { + return; + } + } String reportPath = reportletsTree.getSelectedTemplatePath(); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); @@ -139,7 +207,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { * 打开文件夹 */ @Override - public void openContainerFolder() { + public void showInExplorer() { FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode(); String filePath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fn.getEnvPath()); filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR)); @@ -156,134 +224,243 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public void refresh() { reportletsTree.refresh(); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!"); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!"); } /** * 删除文件 + * 文件夹和文件均可删除 + *

+ * 当文件被锁时不能删除 + * 当文件夹中包含被锁文件时不能删除 */ @Override public void deleteFile() { - String[] reportPaths = reportletsTree.getSelectedTemplatePaths(); - if (reportPaths.length == 0) { - return; + + + ExpandMutableTreeNode[] treeNodes = reportletsTree.getSelectedTreeNodes(); + // 筛选可以删除的文件 + ArrayList deletableNodes = new ArrayList<>(); + ArrayList lockedNodes = new ArrayList<>(); + for (ExpandMutableTreeNode treeNode : treeNodes) { + checkFreeOrLock(treeNode, deletableNodes, lockedNodes); } - if (JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File")) != JOptionPane.OK_OPTION) { - return; + if (lockedNodes.isEmpty()) { + + String tipContent = + countSelectedFolder() > 0 + ? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Folder") + : Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File"); + + if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + tipContent, + UIManager.getString("OptionPane.messageDialogTitle"), + YES_NO_OPTION) + == JOptionPane.YES_OPTION) { + // 删除所有选中的即可 + if (!deleteNodes(Arrays.asList(treeNodes))) { + JOptionPane.showConfirmDialog(null, + Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"), + UIManager.getString("OptionPane.messageDialogTitle"), + JOptionPane.DEFAULT_OPTION, + JOptionPane.ERROR_MESSAGE); + } + } + } else { + + String tipContent = + countSelectedFolder() > 0 + ? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File_And_Folder") + : Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File"); + + if (deletableNodes.isEmpty()) { + // 提醒被锁定模板无法删除 + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Unable_Delete_Locked_File"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + WARNING_MESSAGE); + return; + } + + + if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + tipContent, + UIManager.getString("OptionPane.messageDialogTitle"), + YES_NO_OPTION) + == JOptionPane.YES_OPTION) { + // 删除其他 + if (!deleteNodes(deletableNodes)) { + JOptionPane.showConfirmDialog(null, + Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"), + UIManager.getString("OptionPane.messageDialogTitle"), + JOptionPane.DEFAULT_OPTION, + JOptionPane.ERROR_MESSAGE); + } + } } - for (String reportPath : reportPaths) { - FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false)); + reportletsTree.refresh(); + } - if (nodeFile.isLocked()) { - if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FileLocked_Undeleted"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.YES_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.YES_OPTION) { - refreshDockingView(); + private boolean deleteNodes(Collection nodes) { + + boolean isLocal = WorkContext.getCurrent().isLocal(); + + boolean success = true; + for (ExpandMutableTreeNode treeNode : nodes) { + Object node = treeNode.getUserObject(); + if (node instanceof FileNode) { + FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node); + if (nodeFILE.exists()) { + if (WorkContext.getCurrent().get(TplOperator.class).delete(nodeFILE.getPath())) { + HistoryTemplateListCache.getInstance().deleteFile(nodeFILE); + } else { + success = false; + } } - break; } - if (nodeFile.exists()) { - String path = StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()); - FileAssistUtilsOperator fileAssistUtils = WorkContext.getCurrent().get(FileAssistUtilsOperator.class); - fileAssistUtils.moveToTrash(nodeFile.getPath()); - deleteHistory(path.replaceAll("/", "\\\\")); + } + return success; + } + + private boolean checkFreeOrLock(ExpandMutableTreeNode node, ArrayList dNodes, ArrayList lNodes) { + // 自己没锁 + boolean selfEmptyLock = false; + Object userObj = node.getUserObject(); + if (userObj instanceof FileNode) { + String lock = ((FileNode) userObj).getLock(); + selfEmptyLock = lock == null || ((FileNode) userObj).getUserID().equals(lock); + } + + if (node.isLeaf()) { + if (selfEmptyLock) { + dNodes.add(node); } else { - JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), ProductConstants.PRODUCT_NAME, - JOptionPane.INFORMATION_MESSAGE); + lNodes.add(node); } + return selfEmptyLock; } - reportletsTree.refresh(); + + ExpandMutableTreeNode[] children = reportletsTree.loadChildTreeNodes(node); + + boolean childrenEmptyLock = true; + + for (ExpandMutableTreeNode child : children) { + childrenEmptyLock = checkFreeOrLock(child, dNodes, lNodes) && childrenEmptyLock; + } + + boolean emptyLock = childrenEmptyLock && selfEmptyLock; + if (emptyLock) { + dNodes.add(node); + } else { + lNodes.add(node); + } + return emptyLock; } + @Override public void lockFile() { throw new UnsupportedOperationException("unsupport now"); } @Override - public void unLockFile() { + public void unlockFile() { throw new UnsupportedOperationException("unsupport now"); } - private void deleteHistory(String fileName) { - int index = HistoryTemplateListPane.getInstance().contains(fileName); - int size = HistoryTemplateListPane.getInstance().getHistoryCount(); - if (index == -1) { - return; + + @Override + public String getFilePath() { + return reportletsTree.getSelectedTemplatePath(); + } + + @Override + public boolean access() { + + TreePath[] selectedTreePaths = reportletsTree.getSelectionPaths(); + + if (selectedTreePaths == null || selectedTreePaths.length != 1) { + return false; } - //如果打开过,则删除,实时刷新多tab面板 - HistoryTemplateListPane.getInstance().getHistoryList().remove(index); - int openfileCount = HistoryTemplateListPane.getInstance().getHistoryCount(); - if (openfileCount == 0) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + // 选中的是文件夹 + TreePath treePath = selectedTreePaths[0]; + ExpandMutableTreeNode currentTreeNode = (ExpandMutableTreeNode) treePath.getLastPathComponent(); + + ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) currentTreeNode.getParent(); + + return parentTreeNode != null && parentTreeNode.hasFullAuthority(); + } + + @Override + public boolean rename(FILE tplFile, String from, String to) { + + // 多人协作时判断是否有锁定的文件 + ExpandMutableTreeNode[] treeNodes = reportletsTree.getSelectedTreeNodes(); + // 筛选可以重命名的文件 + ArrayList unlockedNodes = new ArrayList<>(); + ArrayList lockedNodes = new ArrayList<>(); + for (ExpandMutableTreeNode treeNode : treeNodes) { + checkFreeOrLock(treeNode, unlockedNodes, lockedNodes); } - MutilTempalteTabPane.getInstance().repaint(); - if (size == index + 1 && index != 0) { - //如果删除的是最后一个Tab,则定位到前一个 - MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1); + + if (!lockedNodes.isEmpty()) { + JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Warn_Rename_Lock_File"), + UIManager.getString("OptionPane.messageDialogTitle"), + JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE); + return true; } - JTemplate selectedfile = MutilTempalteTabPane.getInstance().getSelectedFile(); - if (!HistoryTemplateListPane.getInstance().isCurrentEditingFile(selectedfile.getPath())) { - //如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样 - DesignerContext.getDesignerFrame().activateJTemplate(selectedfile); + + try { + // 接收的是WEB-INF下的路径 + return WorkContext.getCurrent().get(TplOperator.class).rename(from, to); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return false; } - MutilTempalteTabPane.getInstance().repaint(); } - @Override - public String getSelectedTemplatePath() { - return reportletsTree.getSelectedTemplatePath(); + public FileNode getFileNode() { + return reportletsTree.getSelectedFileNode(); } - public void setToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) { - this.toobarStateChangeListener = toobarStateChangeListener; + public void setToolbarStateChangeListener(FileToolbarStateChangeListener listener) { + this.toolBarStateChangeListener = listener; } + /** - * 文件名是否存在 + * 仅支持在拥有完整权限的文件夹下进行新建和重命名操作,那么是可以看到改文件夹下所有文件的。 * * @param newName 原名 - * @param oldName 新的文件名 * @param suffix 后缀名 - * @return 是否存在 + * @return 是否有重名的 */ @Override - public boolean isNameAlreadyExist(String newName, String oldName, String suffix) { - boolean isNameAlreadyExist = false; - - TemplateFileTree tt = reportletsTree; - DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot(); - ArrayList al = new ArrayList(); - - findFiles(gen, al); - - for (int i = 0; i < al.size(); i++) { - if (ComparatorUtils.equals(al.get(i), newName + suffix)) { - isNameAlreadyExist = true; - break; - } - } + public boolean duplicated(String newName, String suffix) { - if (ComparatorUtils.equals(newName, oldName)) { - isNameAlreadyExist = false; + // 选中的节点 + TreePath treePath = reportletsTree.getSelectionPath(); + if (treePath == null) { + return false; } + DefaultMutableTreeNode currentTreeNode = (DefaultMutableTreeNode) treePath.getLastPathComponent(); + TreeNode parentTreeNode = currentTreeNode.getParent(); - return isNameAlreadyExist; - } - + Enumeration children = parentTreeNode.children(); - private void findFiles(DefaultMutableTreeNode node, ArrayList al) { - String[] str = new String[node.getChildCount()]; - for (int j = 0; j < node.getChildCount(); j++) { - DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) node.getChildAt(j); - if (childNode.getChildCount() > 0) { - findFiles(childNode, al); - } else { - str[j] = node.getChildAt(j).toString(); - if (str[j].contains(".")) { - al.add(str[j]); + while (children.hasMoreElements()) { + DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) children.nextElement(); + Object object = childNode.getUserObject(); + if (object instanceof FileNode) { + if (ComparatorUtils.equals(((FileNode) object).getName(), newName + suffix)) { + return true; } + } else { + return false; } } + return false; } } diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java index 2247fe453a..049b868c43 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java @@ -77,4 +77,7 @@ public class ProgressDialog extends UIDialog { centerDialog.dispose(); super.dispose(); } + public void updateLoadingText(String text) { + this.text.setText(text); + } } diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java index 862aff3796..0a13dd1bdb 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -2,17 +2,13 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.FRContext; import com.fr.base.extension.FileExtension; +import com.fr.design.file.NodeAuthProcessor; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.file.filetree.FileNode; -import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; -import com.fr.report.DesignAuthority; import com.fr.stable.ArrayUtils; -import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.authority.AuthorityOperator; import javax.swing.text.Position; import javax.swing.tree.DefaultTreeModel; @@ -26,12 +22,6 @@ import java.util.List; */ public class TemplateFileTree extends EnvFileTree { - - /** - * 远程设计拥有全部权限的文件夹路径 - */ - private ArrayList paths = new ArrayList<>(); - public TemplateFileTree() { super(ProjectConstants.REPORTLETS_NAME, null, null); } @@ -79,10 +69,32 @@ public class TemplateFileTree extends EnvFileTree { } } + return selectedPathList.toArray(new String[0]); + } + public String[] getSelectedFolderPaths() { + TreePath[] selectedTreePaths = this.getSelectionPaths(); + if (ArrayUtils.isEmpty(selectedTreePaths)) { + return ArrayUtils.EMPTY_STRING_ARRAY; + } + List selectedPathList = new ArrayList(); + for (TreePath treepath : selectedTreePaths) { + ExpandMutableTreeNode currentTreeNode = (ExpandMutableTreeNode) treepath.getLastPathComponent(); + Object userObject = currentTreeNode.getUserObject(); + if (userObject instanceof FileNode) { + FileNode fn = (FileNode) userObject; + if (fn.isDirectory()) { + String envPath = fn.getEnvPath(); + if (envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { + selectedPathList.add(envPath.substring(ProjectConstants.REPORTLETS_NAME.length())); + } + } + } + } return selectedPathList.toArray(new String[0]); } + @Override public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias) { @@ -122,37 +134,11 @@ public class TemplateFileTree extends EnvFileTree { */ @Override public void refreshEnv() { - paths.clear(); - - if (!WorkContext.getCurrent().isLocal()) { - try { - String username = WorkContext.getConnector().currentUser(); - // 远程设计获取全部设计成员的权限列表 - DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities(); - DesignAuthority authority = null; - - if (authorities != null) { - for (DesignAuthority designAuthority : authorities) { - if (ComparatorUtils.equals(designAuthority.getUsername(), username)) { - authority = designAuthority; - } - } - } - if (authority != null) { - for (DesignAuthority.Item item : authority.getItems()) { - if (item.getType()) { - paths.add(item.getPath()); - } - } - } - } catch (Exception exception) { - FineLoggerFactory.getLogger().error(exception.getMessage(), exception); - } - } - + NodeAuthProcessor.getInstance().refresh(); DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel(); ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); + NodeAuthProcessor.getInstance().fixTreeNodeAuth(rootTreeNode); rootTreeNode.removeAllChildren(); FileNode[] fns; @@ -178,64 +164,34 @@ public class TemplateFileTree extends EnvFileTree { } @Override - protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) { - + public ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) { + FileNode[] fnArray = listFileNodes(treeNode); - + return fileNodeArray2TreeNodeArray(fnArray); } - /* - * 把FileNode[]转成ExpandMutableTreeNode[] - */ - private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) { - boolean isLocal = WorkContext.getCurrent().isLocal(); - boolean isRoot = WorkContext.getCurrent().isRoot(); - ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length]; - for (int i = 0; i < res.length; i++) { - FileNode fn = fileNodes[i]; - res[i] = new ExpandMutableTreeNode(fn); - if (fn.isDirectory()) { - res[i].add(new ExpandMutableTreeNode()); - if (isLocal || isRoot) { - res[i].setFullAuthority(true); - } else { - boolean hasFullAuthority = isContained(fn); - res[i].setFullAuthority(hasFullAuthority); - } - } + + public ExpandMutableTreeNode[] getSelectedTreeNodes() { + TreePath[] paths = this.getSelectionPaths(); + + if (paths == null) { + return new ExpandMutableTreeNode[0]; } - return res; - } - private boolean isContained(FileNode fileNode) { + ArrayList res = new ArrayList<>(); - for (String auPath : paths) { - if (isContained(auPath, fileNode)) { - return true; - } + for (TreePath path : paths) { + res.add((ExpandMutableTreeNode) path.getLastPathComponent()); } - return false; + return res.toArray(new ExpandMutableTreeNode[res.size()]); } - private boolean isContained(String auPath, FileNode fileNode) { - auPath = ProjectConstants.REPORTLETS_NAME + CoreConstants.SEPARATOR + auPath; - String fileName = fileNode.getEnvPath(); - String[] auPaths = auPath.split(CoreConstants.SEPARATOR); - String[] nodePaths = fileName.split(CoreConstants.SEPARATOR); - // 待判断目录是有权限目录或者有权限目录的子目录,全部权限 - if (auPaths.length <= nodePaths.length) { - for (int i = 0; i < auPaths.length; i++) { - if (!auPaths[i].equals(nodePaths[i])) { - return false; - } - } - return fileNode.isDirectory(); - } - // 其他情况半权限 - else { - return false; - } + /* + * 把FileNode[]转成ExpandMutableTreeNode[] + */ + private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) { + return NodeAuthProcessor.getInstance().parser2TreeNodeArray(fileNodes); } @@ -270,7 +226,7 @@ public class TemplateFileTree extends EnvFileTree { * 求当前TreeNode下所有的FileNode. */ private FileNode[] listFileNodes(ExpandMutableTreeNode currentTreeNode) { - + if (currentTreeNode == null) { return new FileNode[0]; } @@ -278,12 +234,10 @@ public class TemplateFileTree extends EnvFileTree { Object object = currentTreeNode.getUserObject(); if (object instanceof FileNode) { - + return this.listFileNodes(((FileNode) object).getEnvPath()); } return new FileNode[0]; } - - } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/WebHyperlinkPane.java b/designer-base/src/main/java/com/fr/design/hyperlink/WebHyperlinkPane.java index 89663ba7a5..2975e7c343 100644 --- a/designer-base/src/main/java/com/fr/design/hyperlink/WebHyperlinkPane.java +++ b/designer-base/src/main/java/com/fr/design/hyperlink/WebHyperlinkPane.java @@ -4,14 +4,16 @@ import com.fr.base.Parameter; import com.fr.design.gui.frpane.ReportletParameterViewPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.itableeditorpane.ParameterTableModel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; - import com.fr.js.WebHyperlink; import com.fr.stable.ParameterProvider; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; import java.util.HashMap; import java.util.List; @@ -19,8 +21,6 @@ public class WebHyperlinkPane extends AbstractHyperLinkPane { private static final int BORDER_WIDTH = 4; private WebHyperNorthPane northPane; - private UICheckBox useCJKCheckBox; - private UICheckBox extendParametersCheckBox; public WebHyperlinkPane() { @@ -42,16 +42,15 @@ public class WebHyperlinkPane extends AbstractHyperLinkPane { parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); this.add(parameterViewPane, BorderLayout.CENTER); - parameterViewPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters"), null)); + parameterViewPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Parameters"), null)); - useCJKCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Use_CJK_To_Encode_Parameter")); - extendParametersCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters")); - this.add(GUICoreUtils.createFlowPane(new Component[]{useCJKCheckBox, extendParametersCheckBox}, FlowLayout.LEFT), BorderLayout.SOUTH); + extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters")); + this.add(GUICoreUtils.createFlowPane(new Component[]{extendParametersCheckBox}, FlowLayout.LEFT), BorderLayout.SOUTH); } @Override public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Web_Link"); + return Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Web_Link"); } @Override @@ -63,7 +62,6 @@ public class WebHyperlinkPane extends AbstractHyperLinkPane { ParameterProvider[] parameters = ob.getParameters(); parameterViewPane.populate(parameters); - useCJKCheckBox.setSelected(ob.isUseCJK()); extendParametersCheckBox.setSelected(ob.isExtendParameters()); } @@ -88,7 +86,6 @@ public class WebHyperlinkPane extends AbstractHyperLinkPane { } else { webHyperlink.setParameters(null); } - webHyperlink.setUseCJK(this.useCJKCheckBox.isSelected()); webHyperlink.setExtendParameters(this.extendParametersCheckBox.isSelected()); } @@ -110,14 +107,6 @@ public class WebHyperlinkPane extends AbstractHyperLinkPane { this.northPane = northPane; } - public UICheckBox getUseCJKCheckBox() { - return useCJKCheckBox; - } - - public void setUseCJKCheckBox(UICheckBox useCJKCheckBox) { - this.useCJKCheckBox = useCJKCheckBox; - } - public UICheckBox getExtendParametersCheckBox() { return extendParametersCheckBox; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 78f546f4d8..be2695815c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -42,7 +42,6 @@ import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; - import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.injectable.PluginModule; @@ -57,7 +56,7 @@ import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; -import com.fr.workspace.connect.WorkspaceConnection; +import com.fr.workspace.connect.WorkspaceConnectionInfo; import javax.swing.Icon; import javax.swing.JComponent; @@ -747,7 +746,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta String username = null; if (info != null) { - WorkspaceConnection connection = info.getConnection(); + WorkspaceConnectionInfo connection = info.getConnection(); username = connection == null ? StringUtils.EMPTY : connection.getUserName(); } defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]"); @@ -758,7 +757,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) { path = workspace.getPath() + File.separator + path; } - defaultTitleSB.append(" " + path); + defaultTitleSB.append(" ").append(path); } setTitle(defaultTitleSB.toString()); @@ -1070,8 +1069,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta EastRegionContainerPane.getInstance().getContainerWidth()); DesignerEnvManager.getEnvManager().saveXMLFile(); - - WorkContext.switchTo(null); + //关闭当前环境 + WorkContext.getCurrent().close(); this.setVisible(false); this.dispose(); @@ -1153,4 +1152,36 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta return progressDialog; } + + public void showProgressDialog() { + + progressDialog.setVisible(true); + + } + + /** + * 隐藏进度框 + */ + public void hideProgressDialog() { + + progressDialog.setVisible(false); + } + + /** + * 更新进度框进度 + * + * @param progress + */ + public void updateProgress(int progress) { + + progressDialog.setProgressValue(progress); + } + + /** + * 释放进度框 + */ + public void disposeProgressDialog() { + + progressDialog.dispose(); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index ec27d1f732..d0800c087d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.base.FRContext; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; @@ -13,74 +12,77 @@ import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.file.FileOperations; import com.fr.design.file.FileToolbarStateChangeListener; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; +import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.file.TemplateTreePane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuHighLight; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itoolbar.UIToolbar; -import com.fr.design.gui.itree.filetree.TemplateFileTree; +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.menu.KeySetUtils; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; -import com.fr.io.utils.ResourceIOUtils; +import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; -import com.fr.stable.StableUtils; -import com.fr.stable.project.ProjectConstants; +import com.fr.stable.StringUtils; +import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.workspace.WorkContext; import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.BoxLayout; import javax.swing.JDialog; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingConstants; +import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Dimension; -import java.awt.GridLayout; +import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; +import static javax.swing.JOptionPane.WARNING_MESSAGE; + public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { private static final String FILE = "file"; private static volatile DesignerFrameFileDealerPane THIS; - private CardLayout card; - - private JPanel cardPane; - - private java.util.List otherToobarStateChangeListeners = new ArrayList<>(); + private List otherToolbarStateChangeListeners = new ArrayList<>(); private FileOperations selectedOperation; private UIToolbar toolBar; - private OpenReportAction openReportAction = new OpenReportAction(); + private NewFolderAction newFolderAction = new NewFolderAction(); private RefreshTreeAction refreshTreeAction = new RefreshTreeAction(); - private OpenFolderAction openFolderAction = new OpenFolderAction(); + private ShowInExplorerAction showInExplorerAction = new ShowInExplorerAction(); private RenameAction renameAction = new RenameAction(); @@ -91,11 +93,10 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt * 刷新 */ public void refresh() { - selectedOperation.refresh(); } - public static final DesignerFrameFileDealerPane getInstance() { + public static DesignerFrameFileDealerPane getInstance() { if (THIS == null) { synchronized (DesignerFrameFileDealerPane.class) { @@ -121,13 +122,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt tooBarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); add(tooBarPane, BorderLayout.NORTH); - cardPane = new JPanel(card = new CardLayout()); + CardLayout card; + JPanel cardPane = new JPanel(card = new CardLayout()); cardPane.add(TemplateTreePane.getInstance(), FILE); selectedOperation = TemplateTreePane.getInstance(); card.show(cardPane, FILE); - TemplateTreePane.getInstance().setToobarStateChangeListener(this); + TemplateTreePane.getInstance().setToolbarStateChangeListener(this); add(cardPane, BorderLayout.CENTER); stateChange(); @@ -136,7 +138,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt public final void setCurrentEditingTemplate(JTemplate jt) { - DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel()); + DesignModelAdapter.setCurrentModelAdapter(jt.getModel()); fireDSChanged(); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt); @@ -152,7 +154,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt jt.requestFocus(); jt.revert(); - FRContext.getLogger().info("\"" + jt.getEditingFILE().getName() + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_LOG_Has_Been_Openned") + "!"); + FineLoggerFactory.getLogger().info( + "\"" + jt.getEditingFILE().getName() + "\"" + + Toolkit.i18nText("Fine-Design_Basic_LOG_Has_Been_Openned") + "!"); } /** @@ -161,27 +165,26 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt public void refreshDockingView() { ToolBarDef toolbarDef = new ToolBarDef(); - toolbarDef.addShortCut(openReportAction, refreshTreeAction); + toolbarDef.addShortCut(newFolderAction, refreshTreeAction); if (WorkContext.getCurrent().isLocal()) { - toolbarDef.addShortCut(openFolderAction, renameAction); + toolbarDef.addShortCut(showInExplorerAction); } - toolbarDef.addShortCut(delFileAction); + toolbarDef.addShortCut(renameAction, delFileAction); Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); for (ShortCut shortCut : extraShortCuts) { toolbarDef.addShortCut(shortCut); } - toolbarDef.updateToolBar(toolBar); - refreshActions(); + resetActionStatus(); refresh(); } - private void refreshActions() { + private void resetActionStatus() { - openReportAction.setEnabled(false); + newFolderAction.setEnabled(false); refreshTreeAction.setEnabled(true); - openFolderAction.setEnabled(false); + showInExplorerAction.setEnabled(false); renameAction.setEnabled(false); delFileAction.setEnabled(false); this.repaint(); @@ -206,28 +209,53 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } + public void addToolbarStateChangeListener(FileToolbarStateChangeListener listener) { + this.otherToolbarStateChangeListeners.add(listener); + } + + public void removeToolbarStateChangeListener(FileToolbarStateChangeListener listener) { + this.otherToolbarStateChangeListeners.remove(listener); + } + + private void otherStateChange() { + for (FileToolbarStateChangeListener listener : otherToolbarStateChangeListeners) { + listener.stateChange(); + } + } + /* - * Open Report Action + * 新建文件夹 */ - private class OpenReportAction extends UpdateAction { + private class NewFolderAction extends UpdateAction { - public OpenReportAction() { + public NewFolderAction() { - this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png")); + this.setName(KeySetUtils.NEW_FOLDER.getMenuKeySetName()); + this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/icon_NewFolderIcon_normal.png")); } @Override public void actionPerformed(ActionEvent evt) { - selectedOperation.openSelectedReport(); + if (!selectedOperation.access()) { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + WARNING_MESSAGE); + return; + } + + new MkdirDialog(); } } - private class OpenFolderAction extends UpdateAction { + /** + * 在系统资源管理器中打开 + */ + private class ShowInExplorerAction extends UpdateAction { - public OpenFolderAction() { + public ShowInExplorerAction() { this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Show_In_Containing_Folder")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png")); @@ -236,7 +264,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt @Override public void actionPerformed(ActionEvent evt) { - selectedOperation.openContainerFolder(); + selectedOperation.showInExplorer(); } } @@ -247,7 +275,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt public RefreshTreeAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh")); + this.setName(Toolkit.i18nText("Fine-Design_Basic_Refresh")); this.setSmallIcon(UIConstants.REFRESH_ICON); } @@ -260,20 +288,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } } - public void addToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) { - this.otherToobarStateChangeListeners.add(toobarStateChangeListener); - } - - public void removeToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) { - this.otherToobarStateChangeListeners.remove(toobarStateChangeListener); - } - - private void otherStateChange() { - for (FileToolbarStateChangeListener toobarStateChangeListener : otherToobarStateChangeListeners) { - toobarStateChangeListener.stateChange(); - } - } - /* * 重命名文件 */ @@ -281,14 +295,32 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt public RenameAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Rename")); + this.setName(Toolkit.i18nText("Fine-Design_Basic_Rename")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png")); } @Override public void actionPerformed(ActionEvent evt) { + if (!selectedOperation.access()) { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + WARNING_MESSAGE); + return; + } - new RenameDialog(); + FileNode node = selectedOperation.getFileNode(); + String lock = node.getLock(); + if (lock != null && !lock.equals(node.getUserID())) { + // 提醒被锁定模板无法重命名 + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Unable_Rename_Locked_File"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + WARNING_MESSAGE); + return; + } + + new FileRenameDialog(node); MutilTempalteTabPane.getInstance().repaint(); } @@ -301,13 +333,21 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt public DelFileAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove")); + this.setName(Toolkit.i18nText("Fine-Design_Basic_Remove")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png")); } @Override public void actionPerformed(ActionEvent evt) { + if (!selectedOperation.access()) { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + WARNING_MESSAGE); + return; + } + selectedOperation.deleteFile(); } } @@ -318,295 +358,431 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt @Override public void stateChange() { - if (selectedOperation.getSelectedTemplatePath() != null) { - openReportAction.setEnabled(true); - renameAction.setEnabled(true); - delFileAction.setEnabled(true); - } else { - openReportAction.setEnabled(false); - renameAction.setEnabled(false); - delFileAction.setEnabled(false); - } - openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0); + int selectedPathNum = TemplateTreePane.getInstance().countSelectedPath(); + + // 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用 + boolean singleSelected = selectedPathNum == 1; + newFolderAction.setEnabled(singleSelected); + renameAction.setEnabled(singleSelected); + showInExplorerAction.setEnabled(singleSelected); + + // 删除操作在至少选中一个时可用 + boolean selected = selectedPathNum > 0; + delFileAction.setEnabled(selected); + // 刷新操作始终可用 refreshTreeAction.setEnabled(true); - if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) { - refreshActions(); - } else if (containsFolderNums() == 0 && seletedTemplateNums() > 1) { - openReportAction.setEnabled(false); - refreshTreeAction.setEnabled(true); - openFolderAction.setEnabled(false); - renameAction.setEnabled(false); - delFileAction.setEnabled(true); - } + // 其他状态 otherStateChange(); } - /** - * 是否包含文件夹 - * - * @return - */ - - private int containsFolderNums() { - - TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); - if (fileTree.getSelectionPaths() == null) { - return 0; - } - - //选择的包含文件和文件夹的数目 - if (fileTree.getSelectionPaths().length == 0) { - return 0; - } - //所有的num减去模板的num,得到文件夹的num - return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length; + public FileOperations getSelectedOperation() { + return selectedOperation; } /** - * 是否选择了多个模板 - * - * @return + * 重命名对话框 + * 支持快捷键Enter,ESC */ - private int seletedTemplateNums() { + private class FileRenameDialog extends JDialog { - TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); - if (fileTree.getSelectionPaths() == null) { - return 0; - } + private UITextField nameField; - return fileTree.getSelectedTemplatePaths().length; - } + private UILabel warnLabel; + private UIButton confirmButton; - // js: 重命名对话框,模仿Eclipse的重命名,支持快捷键F2,Enter,ESC - private class RenameDialog { + /** + * 操作的节点 + */ + private FileNodeFILE fnf; - private UITextField jt; - private String userInput; + private FileRenameDialog(FileNode node) { + if (node == null) { + return; + } + fnf = new FileNodeFILE(node); - private String oldName; + String oldName = fnf.getName(); + String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); + oldName = oldName.replaceAll(suffix, StringUtils.EMPTY); - private UILabel hintsLabel; + this.setLayout(new BorderLayout()); + this.setModal(true); - private UIButton confirmButton; + // 输入框前提示 + UILabel newNameLabel = new UILabel(Toolkit.i18nText( + fnf.isDirectory() ? + "Fine-Design_Basic_Enter_New_Folder_Name" : "Fine-Design_Basic_Enter_New_File_Name") + ); + newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT); + newNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); + newNameLabel.setPreferredSize(new Dimension(118, 15)); - private JDialog jd; + // 重命名输入框 + nameField = new UITextField(oldName); + nameField.getDocument().addDocumentListener(new DocumentListener() { - private String suffix; + public void changedUpdate(DocumentEvent e) { + validInput(); + } - public RenameDialog() { + public void insertUpdate(DocumentEvent e) { + validInput(); + } - final String reportPath = selectedOperation.getSelectedTemplatePath(); - if (reportPath == null) { - return; - } + public void removeUpdate(DocumentEvent e) { + validInput(); + } + }); + nameField.selectAll(); + nameField.setPreferredSize(new Dimension(180, 20)); - final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false)); - final String path = nodeFile.getPath(); - oldName = nodeFile.getName(); - suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); - oldName = oldName.replaceAll(suffix, ""); - - jd = new JDialog(); - jd.setLayout(new GridLayout(2, 2)); - jd.setModal(true); - UILabel newNameLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Enter_New_File_Name")); - newNameLabel.setMinimumSize(new Dimension(150, 27)); - newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT); - jt = new UITextField(oldName); - jt.getDocument().addDocumentListener(getdoDocumentListener()); - jt.selectAll(); - jt.setPreferredSize(new Dimension(150, 20)); - - JPanel newNamePanel = new JPanel(); - newNamePanel.setLayout(new BoxLayout(newNamePanel, BoxLayout.X_AXIS)); - newNamePanel.add(Box.createHorizontalGlue()); - newNamePanel.add(newNameLabel); - newNamePanel.add(Box.createHorizontalStrut(5)); - jd.add(newNamePanel); - - JPanel jtPanel = new JPanel(); - jtPanel.setLayout(new BoxLayout(jtPanel, BoxLayout.Y_AXIS)); - JPanel containJt = new JPanel(new BorderLayout()); - containJt.add(jt, BorderLayout.WEST); - containJt.setMaximumSize(new Dimension(200, 20)); - jtPanel.add(Box.createVerticalGlue()); - jtPanel.add(containJt); - jtPanel.add(Box.createVerticalGlue()); - jd.add(jtPanel); - - addUITextFieldListener(nodeFile, path); - - hintsLabel = new UILabel(); - hintsLabel.setBounds(20, 50, 250, 30); - hintsLabel.setMaximumSize(new Dimension(200, 30)); - hintsLabel.setHorizontalAlignment(SwingConstants.RIGHT); - hintsLabel.setForeground(Color.RED); - hintsLabel.setVisible(false); - - confirmButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm")); - confirmButton.setPreferredSize(new Dimension(80, 25)); - confirmButton.setMinimumSize(new Dimension(80, 25)); - confirmButton.setMaximumSize(new Dimension(80, 25)); - confirmButton.addActionListener(new ActionListener() { + JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5)); + topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15)); + topPanel.add(newNameLabel); + topPanel.add(nameField); + // 增加enter以及esc快捷键的支持 + nameField.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + dispose(); + } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { + if (confirmButton.isEnabled()) { + confirmClose(); + } + } + } + }); + // 重名提示 + warnLabel = new UILabel(); + warnLabel.setPreferredSize(new Dimension(300, 30)); + warnLabel.setHorizontalAlignment(SwingConstants.LEFT); + warnLabel.setForeground(Color.RED); + warnLabel.setVisible(false); + + JPanel midPanel = new JPanel(new BorderLayout()); + midPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); + midPanel.add(warnLabel, BorderLayout.WEST); + + // 确认按钮 + confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm")); + confirmButton.setPreferredSize(new Dimension(60, 25)); + confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - - confirmClose(nodeFile, path); + confirmClose(); } }); - UIButton cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); - cancelButton.setPreferredSize(new Dimension(80, 25)); - cancelButton.setMinimumSize(new Dimension(80, 25)); - cancelButton.setMaximumSize(new Dimension(80, 25)); + // 取消按钮 + UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); + cancelButton.setPreferredSize(new Dimension(60, 25)); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - - jd.dispose(); + dispose(); } }); - JPanel hintsPanel = new JPanel(); - hintsPanel.setLayout(new BorderLayout()); - hintsPanel.add(hintsLabel, BorderLayout.EAST); - jd.add(hintsLabel); - - JPanel btPanel = new JPanel(new BorderLayout()); - btPanel.setLayout(new BoxLayout(btPanel, BoxLayout.X_AXIS)); - btPanel.add(Box.createHorizontalGlue()); - btPanel.add(confirmButton); - btPanel.add(Box.createHorizontalStrut(5)); - btPanel.add(cancelButton); - btPanel.add(Box.createHorizontalStrut(20)); - jd.add(btPanel); - - jd.setSize(380, 200); - jd.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Rename")); - jd.setResizable(false); - jd.setAlwaysOnTop(true); - jd.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); - jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - GUICoreUtils.centerWindow(jd); - jd.setVisible(true); + JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); + bottomPanel.add(confirmButton); + bottomPanel.add(cancelButton); + + this.add( + TableLayoutHelper.createTableLayoutPane( + new Component[][]{ + new Component[]{topPanel}, + new Component[]{midPanel}, + new Component[]{bottomPanel} + }, + new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL}, + new double[]{TableLayout.FILL} + ), + BorderLayout.CENTER); + + + this.setSize(340, 180); + this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Rename")); + this.setResizable(false); + this.setAlwaysOnTop(true); + this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + GUICoreUtils.centerWindow(this); + this.setVisible(true); } - public void confirmClose(FileNodeFILE nodeFile, String path) { + private void confirmClose() { + + String userInput = nameField.getText().trim(); + // 处理不合法的文件夹名称 + userInput = userInput.replaceAll("[\\\\/:*?\"<>|]", StringUtils.EMPTY); + + String path = FilenameUtils.standard(fnf.getPath()); + + String oldName = fnf.getName(); + String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); + oldName = oldName.replaceAll(suffix, StringUtils.EMPTY); + + // 输入为空或者没有修改 + if (ComparatorUtils.equals(userInput, oldName)) { + this.dispose(); + return; + } + + String parentPath = FilenameUtils.standard(fnf.getParent().getPath()); - userInput = userInput == null ? oldName : userInput; - String oldPath = path.replaceAll("/", "\\\\"); - String newPath = path.replace(nodeFile.getName(), userInput + suffix); - renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix); - DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\")); + // 简单执行old new 替换是不可行的,例如 /abc/abc/abc/abc/ + String newPath = parentPath + CoreConstants.SEPARATOR + userInput + suffix; + this.dispose(); //模版重命名 - ResourceIOUtils.renameTo(path, newPath); - selectedOperation.refresh(); - DesignerContext.getDesignerFrame().setTitle(); - jd.dispose(); + boolean success = false; + + // 提醒保存文件 + SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); + // 只有一个文件未保存时 + if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) { + int choose = saveSomeTempaltePane.saveLastOneTemplate(); + if (choose != JOptionPane.CANCEL_OPTION) { + success = selectedOperation.rename(fnf, path, newPath); + } + } else { + if (saveSomeTempaltePane.showSavePane()) { + success = selectedOperation.rename(fnf, path, newPath); + } + } + + if (success) { + HistoryTemplateListCache.getInstance().rename(fnf, path, newPath); + DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(fnf.isDirectory(), path, newPath); + selectedOperation.refresh(); + DesignerContext.getDesignerFrame().setTitle(); + } else { + JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Rename_Failure"), + UIManager.getString("OptionPane.messageDialogTitle"), + JOptionPane.DEFAULT_OPTION, + JOptionPane.ERROR_MESSAGE); + } } - private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) { - JTemplate dPane = getSpecialTemplateByFILE(tplFile); - if (dPane == null) { + private void validInput() { + + String userInput = nameField.getText().trim(); + + String oldName = fnf.getName(); + String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); + oldName = oldName.replaceAll(suffix, StringUtils.EMPTY); + + if (StringUtils.isEmpty(userInput)) { + confirmButton.setEnabled(false); + return; + } + + if (ComparatorUtils.equals(userInput, oldName)) { + warnLabel.setVisible(false); + confirmButton.setEnabled(true); return; } - FILE renameFile = dPane.getEditingFILE(); - renameFile.setPath(renameFile.getPath().replace(oldName, newName)); + + if (selectedOperation.duplicated(userInput, suffix)) { + nameField.selectAll(); + // 如果文件名已存在,则灰掉确认按钮 + warnLabel.setText( + Toolkit.i18nText(fnf.isDirectory() ? + "Fine-Design_Basic_Folder_Name_Duplicate" : + "Fine-Design_Basic_Template_File_Name_Duplicate", + userInput)); + warnLabel.setVisible(true); + confirmButton.setEnabled(false); + } else { + warnLabel.setVisible(false); + confirmButton.setEnabled(true); + } } + } - // 增加enter以及esc快捷键的支持 - public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) { - jt.addKeyListener(new KeyAdapter() { + /** + * 新建文件夹对话框 + * 支持快捷键Enter,ESC + */ + private class MkdirDialog extends JDialog { - public void keyPressed(KeyEvent e) { + private UITextField nameField; - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - jd.dispose(); - } + private UILabel warnLabel; + + private UIButton confirmButton; + + + private MkdirDialog() { + + this.setLayout(new BorderLayout()); + this.setModal(true); + + // 输入框前提示 + UILabel newNameLabel = new UILabel(Toolkit.i18nText( + "Fine-Design_Basic_Enter_New_Folder_Name") + ); + newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT); + newNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); + newNameLabel.setPreferredSize(new Dimension(118, 15)); + + // 文件名输入框 + nameField = new UITextField(); + nameField.getDocument().addDocumentListener(new DocumentListener() { + + public void changedUpdate(DocumentEvent e) { + validInput(); + } + + public void insertUpdate(DocumentEvent e) { + validInput(); + } + + public void removeUpdate(DocumentEvent e) { + validInput(); } }); + nameField.selectAll(); + nameField.setPreferredSize(new Dimension(180, 20)); - jt.addKeyListener(new KeyAdapter() { + JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5)); + topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15)); + topPanel.add(newNameLabel); + topPanel.add(nameField); + // 增加enter以及esc快捷键的支持 + nameField.addKeyListener(new KeyAdapter() { + @Override public void keyPressed(KeyEvent e) { - - if (e.getKeyCode() == KeyEvent.VK_ENTER) { + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + dispose(); + } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (confirmButton.isEnabled()) { - confirmClose(nodeFile, path); + confirmClose(); } } } }); + // 重名提示 + warnLabel = new UILabel(); + warnLabel.setPreferredSize(new Dimension(300, 30)); + warnLabel.setHorizontalAlignment(SwingConstants.LEFT); + warnLabel.setForeground(Color.RED); + warnLabel.setVisible(false); + + JPanel midPanel = new JPanel(new BorderLayout()); + midPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); + midPanel.add(warnLabel, BorderLayout.WEST); + + // 确认按钮 + confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm")); + confirmButton.setPreferredSize(new Dimension(60, 25)); + confirmButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + confirmClose(); + } + }); + confirmButton.setEnabled(false); - } - - // UITextField的输入监听 - public DocumentListener getdoDocumentListener() { - - DocumentListener dl = new DocumentListener() { + // 取消按钮 + UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); + cancelButton.setPreferredSize(new Dimension(60, 25)); - public void changedUpdate(DocumentEvent e) { + cancelButton.addActionListener(new ActionListener() { - isNameAlreadyExist(); + public void actionPerformed(ActionEvent e) { + dispose(); } + }); - public void insertUpdate(DocumentEvent e) { + JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); + bottomPanel.add(confirmButton); + bottomPanel.add(cancelButton); + + this.add( + TableLayoutHelper.createTableLayoutPane( + new Component[][]{ + new Component[]{topPanel}, + new Component[]{midPanel}, + new Component[]{bottomPanel} + }, + new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL}, + new double[]{TableLayout.FILL} + ), + BorderLayout.CENTER); + + + this.setSize(340, 180); + this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Mkdir")); + this.setResizable(false); + this.setAlwaysOnTop(true); + this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + GUICoreUtils.setWindowCenter(DesignerContext.getDesignerFrame(), this); + this.setVisible(true); + } - isNameAlreadyExist(); - } + private void confirmClose() { + String userInput = nameField.getText().trim(); - public void removeUpdate(DocumentEvent e) { + // 处理不合法的文件夹名称 + userInput = userInput.replaceAll("[\\\\/:*?\"<>|]", StringUtils.EMPTY); - isNameAlreadyExist(); - } - }; + if (StringUtils.isEmpty(userInput)) { + return; + } - return dl; + //新建文件夹 + boolean success = selectedOperation.mkdir( + FilenameUtils.standard(selectedOperation.getFileNode().getParent() + CoreConstants.SEPARATOR + userInput) + ); + selectedOperation.refresh(); + this.dispose(); + if (!success) { + JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Make_Failure"), + UIManager.getString("OptionPane.messageDialogTitle"), + JOptionPane.DEFAULT_OPTION, + JOptionPane.ERROR_MESSAGE); + } } - private void isNameAlreadyExist() { - userInput = jt.getText().trim(); - if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) { - jt.selectAll(); + private void validInput() { + String userInput = nameField.getText().trim(); + + + if (StringUtils.isEmpty(userInput)) { + confirmButton.setEnabled(false); + return; + } + + if (selectedOperation.duplicated(userInput, StringUtils.EMPTY)) { + nameField.selectAll(); // 如果文件名已存在,则灰掉确认按钮 - hintsLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_File_Name_Duplicate", userInput)); - hintsLabel.setVisible(true); + warnLabel.setText( + Toolkit.i18nText( + "Fine-Design_Basic_Folder_Name_Duplicate", + userInput)); + warnLabel.setVisible(true); confirmButton.setEnabled(false); } else { - hintsLabel.setVisible(false); + warnLabel.setVisible(false); confirmButton.setEnabled(true); } } } - /** - * @param tplFile - * @return 内存中的template重命名一下 - */ - private JTemplate getSpecialTemplateByFILE(FILE tplFile) { - - HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance(); - if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) { - return historyHandle.getCurrentEditingTemplate(); - } - for (int i = 0; i < historyHandle.getHistoryCount(); i++) { - if (ComparatorUtils.equals(historyHandle.get(i).getEditingFILE(), tplFile)) { - return historyHandle.get(i); - } - } - return null; - } - public FileOperations getSelectedOperation() { - return selectedOperation; - } } 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 b2519271b0..0098a2a4de 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 @@ -17,7 +17,6 @@ import com.fr.design.actions.edit.UndoAction; import com.fr.design.actions.file.SaveAsTemplateAction; import com.fr.design.actions.file.SaveTemplateAction; import com.fr.design.actions.file.WebPreviewUtils; -import com.fr.design.constants.UIConstants; import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListPane; @@ -47,7 +46,6 @@ import com.fr.file.MemFILE; import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; - import com.fr.log.FineLoggerFactory; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; @@ -56,10 +54,13 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.core.UUID; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JOptionPane; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.undo.UndoManager; -import java.awt.*; +import java.awt.BorderLayout; import java.util.ArrayList; import java.util.Arrays; import java.util.Set; @@ -180,7 +181,6 @@ public abstract class JTemplate> * 有条件取消格式刷 */ public void doConditionCancelFormat() { - return; } @Override @@ -193,7 +193,6 @@ public abstract class JTemplate> */ @Override public void cancelFormat() { - return; } //因为报表的tab从0开始,所以表单默认为-1吧 @@ -462,8 +461,6 @@ public abstract class JTemplate> // 子类实现 } - ; - /** * 是否保存 * @@ -522,7 +519,7 @@ public abstract class JTemplate> // return false; // } // } catch (Exception e) { -// FineLoggerFactory.getLogger().error(e.getMessage()); +// FineLoggerFactory.getLogger().error(e.getMessage(), e); // } @@ -565,8 +562,9 @@ public abstract class JTemplate> /** * 保存 + * * @param isShowLoc 是否显示“报表运行环境”外的路径(C盘D盘等) - * @param fileName 保存文件名 + * @param fileName 保存文件名 * @return */ public boolean saveAsTemplate(boolean isShowLoc, String fileName) { @@ -592,7 +590,6 @@ public abstract class JTemplate> return false; } editingFILE = fileChooser.getSelectedFILE(); - mkNewFile(editingFILE); } return saveNewFile(editingFILE, oldName); @@ -727,7 +724,7 @@ public abstract class JTemplate> tplMenu.addShortCut(shortcut4TemplateMenu()); } if (!DesignerMode.isVcsMode()) { - tplMenu.addShortCut(shortCuts4Authority()); + tplMenu.addShortCut(shortCuts4Authority()); } return new MenuDef[]{tplMenu}; @@ -942,17 +939,6 @@ public abstract class JTemplate> DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); } - /** - * 后台关闭template - */ - public void closeOverLineTemplate(int index) { - JTemplate overTemplate = HistoryTemplateListPane.getInstance().getHistoryList().get(index); - HistoryTemplateListPane.getInstance().closeVirtualSelectedReport(overTemplate); - HistoryTemplateListPane.getInstance().getHistoryList().set(index, new JVirtualTemplate(overTemplate.getEditingFILE())); - } - - ; - /** * 返回当前支持的超链界面pane diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java index d472cc062f..cea1088920 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java @@ -11,15 +11,11 @@ import com.fr.design.mainframe.templateinfo.TemplateProcessInfo; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.file.FILE; -import com.fr.file.FileNodeFILE; -import com.fr.stable.OperatingSystem; import com.fr.stable.StringUtils; -import com.fr.stable.project.ProjectConstants; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JPanel; -import java.io.File; import java.util.List; /** @@ -30,20 +26,10 @@ import java.util.List; */ public class JVirtualTemplate extends JTemplate { - private FILE editingFILE = null; + private FILE editingFILE; public JVirtualTemplate(FILE editingFILE) { - setEditingFILE(editingFILE); - } - - @Override - public String getPath() { - String editingFileName = getEditingFILE().getPath(); - if (editingFileName.startsWith(ProjectConstants.REPORTLETS_NAME)) { - editingFileName = ((FileNodeFILE) getEditingFILE()).getEnvPath() + File.separator + editingFileName; - } - editingFileName = OperatingSystem.isWindows() ? editingFileName.replaceAll("/", "\\\\") : editingFileName.replaceAll("\\\\", "/"); - return editingFileName; + this.editingFILE = editingFILE; } /** @@ -237,10 +223,6 @@ public class JVirtualTemplate extends JTemplate { DesignerContext.getDesignerFrame().openTemplate(this.getEditingFILE()); } - @Override - public void closeOverLineTemplate(int index) { - } - @Override public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { return null; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java b/designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java index 452c876ff9..bb5b3dab84 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java @@ -1,344 +1,19 @@ package com.fr.design.mainframe; -import com.fr.base.BaseUtils; -import com.fr.design.DesignModelAdapter; -import com.fr.design.DesignerEnvManager; -import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.env.DesignerWorkspaceGenerator; -import com.fr.design.env.DesignerWorkspaceInfo; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.TemplateTreePane; -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.general.GeneralContext; -import com.fr.general.IOUtils; -import com.fr.license.exception.RegistEditionException; -import com.fr.log.FineLoggerFactory; -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 com.fr.design.EnvChangeEntrance; -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; +/** + * @see EnvChangeEntrance + * @deprecated use {@link EnvChangeEntrance} + */ +@Deprecated +public class TemplatePane { -//TODO: august TemplatePane和TemplateTreePane最好合并成一个类 -public class TemplatePane extends JPanel implements MouseListener { - - private static final long NUM = 1L; - - private static int NUM200 = 200; - - public static TemplatePane getInstance() { - - return HOLDER.singleton; + public static EnvChangeEntrance getInstance() { + return EnvChangeEntrance.getInstance(); } - private static class HOLDER { - - private static TemplatePane singleton = new TemplatePane(); - } - - private static final long serialVersionUID = 2108412478281713143L; - - public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量 - - private static javax.swing.Icon leftIcon = BaseUtils.readIcon("/com/fr/design/images/docking/left.png"); - - private static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png"); - - private boolean isExpanded = false; - - private UIButton editButton; - - private UILabel envLabel; - private TemplatePane() { - - super(); - this.initComponents(); - this.setFocusable(true); - this.addMouseListener(this); - isExpanded = DesignerEnvManager.getEnvManager().isTemplateTreePaneExpanded(); - TemplateTreePane.getInstance().setVisible(isExpanded); - TemplateTreePane.getInstance().setVisible(true); } - - private void initComponents() { - - GeneralContext.addEnvChangedListener(new EnvChangedListener() { - - public void envChanged() { - - setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); - } - }); - this.setLayout(new BorderLayout(25, 0)); - editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) { - - private static final long serialVersionUID = NUM; - - @Override - public Point getToolTipLocation(MouseEvent event) { - - return new Point(25, 2); - } - }; - editButton.setOpaque(false); - editButton.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 10)); - editButton.setMargin(null); - editButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); - editButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Env_Configure_Workspace")); - this.add(new UILabel(" "), BorderLayout.WEST); - this.add(editButton, BorderLayout.EAST); - editButton.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - - editItems(); - } - }); - envLabel = new UILabel(); - envLabel.setForeground(new Color(102, 102, 102)); - setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); - this.add(envLabel, BorderLayout.CENTER); - } - - /** - * 是否可扩展 - * - * @return 同上 - */ - public boolean IsExpanded() { - - return this.isExpanded; - } - - public void setExpand(boolean b) { - - this.isExpanded = b; - this.repaint(); - } - - private boolean envListOkAction(EnvListPane envListPane) { - - final String selectedName = envListPane.updateEnvManager(); - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName); - try { - Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); - boolean checkValid = workspace == null ? false : selectedEnv.checkValid(); - if (!checkValid) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - null, 0, UIManager.getIcon("OptionPane.errorIcon")); - return false; - } - WorkContext.switchTo(workspace, new WorkContextCallback() { - @Override - public void done() { - DesignerEnvManager.getEnvManager().setCurEnvName(selectedName); - DesignUtils.refreshDesignerFrame(); - } - }); - JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (template != null) { - template.refreshToolArea(); - } - setJLabel(selectedName); - } catch (AuthException e) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"), - null, 0, UIManager.getIcon("OptionPane.errorIcon")); - return false; - } catch (RegistEditionException e) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"), - null, 0, UIManager.getIcon("OptionPane.errorIcon")); - } catch (Exception exception) { - FineLoggerFactory.getLogger().error(exception.getMessage(), exception); - } - TemplateTreePane.getInstance().refreshDockingView(); - DesignModelAdapter model = DesignModelAdapter.getCurrentModelAdapter(); - if (model != null) { - model.envChanged(); - } - return true; - } - - /** - * 编辑items - */ - public void editItems() { - - final EnvListPane envListPane = new EnvListPane(); - final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); - - envListPane.populateEnvManager(envLabel.getText()); - envListDialog.addDialogActionListener(new DialogActionAdapter() { - - public void doOk() { - - envListOkAction(envListPane); - } - - public void doCancel() { - - envListDialog.setVisible(false); - } - }); - envListDialog.setVisible(true); - } - - private void setJLabel(String name) { - - DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name); - if (config != null) { - switch (config.getType()) { - case Remote: { - envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); - break; - } - case Local: { - envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); - break; - } - } - } - - envLabel.setText(name); - envLabel.repaint(); - } - - @Override - public Dimension getPreferredSize() { - - return new Dimension(250, HEIGHT); - } - - @Override - public void paintComponent(Graphics g) { - - super.paintComponent(g); - paintBackgroundIcon(g); - } - - private void paintBackgroundIcon(Graphics g) { - - int w = this.getWidth(); - int h = this.getHeight(); - Graphics2D g2d = (Graphics2D) g; - Color lightColor = new Color(226, 230, 234); - Color darkColor = new Color(183, 188, 195); - GradientPaint gp = new GradientPaint(1, 1, lightColor, 1, h - 1, darkColor); - g2d.setPaint(gp); - g2d.fillRect(1, 1, w - 2, h - 1); - g2d.setColor(lightColor); - g2d.drawLine(0, 2, 0, h - 1); - g2d.setColor(darkColor); - g2d.drawLine(w - 1, 2, w - 1, h - 1); - Icon icon = !isExpanded ? leftIcon : rightIcon; - icon.paintIcon(this, g2d, 4, 4); - - } - - /** - * 鼠标点击 - * - * @param e 事件 - */ - @Override - public void mouseClicked(MouseEvent e) { - - } - - /** - * 鼠标按下 - * - * @param e 事件 - */ - @Override - public void mousePressed(MouseEvent e) { - - if (e.getX() < NUM200) { - isExpanded = !isExpanded; - TemplateTreePane.getInstance().setVisible(isExpanded); - this.setExpand(isExpanded); - DesignerEnvManager.getEnvManager().setTemplateTreePaneExpanded(isExpanded); - } - } - - /** - * 鼠标放开 - * - * @param e 事件 - */ - @Override - public void mouseReleased(MouseEvent e) { - - } - - /** - * 鼠标进入 - * - * @param e 事件 - */ - @Override - public void mouseEntered(MouseEvent e) { - - } - - /** - * 鼠标离开 - * - * @param e 事件 - */ - @Override - public void mouseExited(MouseEvent e) { - - } - - /** - * 处理异常 - */ - public void dealEvnExceptionWhenStartDesigner() { - - final EnvListPane envListPane = new EnvListPane(); - envListPane.populateEnvManager(envLabel.getText()); - BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); - envListDialog.addDialogActionListener(new DialogActionAdapter() { - - public void doOk() { - - if (!envListOkAction(envListPane)) { - System.exit(0); - } - - } - - public void doCancel() { - - System.exit(0); - } - }); - envListDialog.setVisible(true); - } - } + diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 877a322cb8..35abeb82cc 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -5,20 +5,29 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.ComparatorUtils; - import com.fr.general.log.Log4jConfig; import com.fr.log.FineLoggerFactory; import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.ThrowableInformation; -import javax.swing.*; +import javax.swing.AbstractAction; +import javax.swing.ActionMap; +import javax.swing.InputMap; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTextPane; +import javax.swing.KeyStroke; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultEditorKit; import javax.swing.text.Document; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -32,57 +41,74 @@ import java.util.Date; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; public class DesignerLogHandler { - + private static final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - protected static final int INFO_INT = Level.INFO.toInt(); - protected static final int ERROR_INT = Level.ERROR.toInt(); - protected static final int WARN_INT = Level.WARN.toInt(); - protected static final int DEBUG_INT = Level.DEBUG.toInt(); + + private static final int INFO_INT = Level.INFO.toInt(); + + private static final int ERROR_INT = Level.ERROR.toInt(); + + private static final int WARN_INT = Level.WARN.toInt(); + + private static final int DEBUG_INT = Level.DEBUG.toInt(); + private static final int GAP_X = -150; + private static final int INFO_GAP_Y = -60; + private static final int ERRO_GAP_Y = -40; + private static final int SERVER_GAP_Y = -20; - + public static DesignerLogHandler getInstance() { + return HOLDER.singleton; } - + private static class HOLDER { + private static DesignerLogHandler singleton = new DesignerLogHandler(); } - + // 所有的面板 private LogHandlerBar caption; + private JCheckBoxMenuItem showInfo; + private JCheckBoxMenuItem showError; + private JCheckBoxMenuItem showServer; + private LogHandlerArea logHandlerArea; - + public DesignerLogHandler() { + logHandlerArea = new LogHandlerArea(); caption = new LogHandlerBar(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Log")); - + caption.addClearListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { + logHandlerArea.jTextArea.setText(""); caption.clearMessage(); } }); caption.addSelectedListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { + logHandlerArea.jTextArea.requestFocus(); logHandlerArea.jTextArea.selectAll(); } }); ItemListener itemlistener = new ItemListener() { - + @Override public void itemStateChanged(ItemEvent e) { + logHandlerArea.jTextArea.setText(""); caption.clearMessage(); } @@ -94,11 +120,12 @@ public class DesignerLogHandler { showServer = new JCheckBoxMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Log_Level_Error"), true); showServer.addItemListener(itemlistener); caption.addSetListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { + JPopupMenu jPopupMenu = new JPopupMenu(); - + int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt(); if (logLevelInt <= INFO_INT) { jPopupMenu.add(showInfo); @@ -116,61 +143,72 @@ public class DesignerLogHandler { } }); } - + public JComponent getLogHandlerArea() { + return logHandlerArea; } - + public JComponent getCaption() { + return caption; } - + public void printRemoteLog(String message, Level level, Date date) { + logHandlerArea.printStackTrace(message, level, date); } - + private class LogHandlerArea extends JPanel { - + private static final long serialVersionUID = 8215630927304621660L; + private JTextPane jTextArea; + private JPopupMenu popup; + private UIMenuItem selectAll; + private UIMenuItem copy; + private UIMenuItem clear; - + private LogHandlerArea() { + jTextArea = initLogJTextArea(); this.setLayout(FRGUIPaneFactory.createBorderLayout()); UIScrollPane js = new UIScrollPane(jTextArea); this.add(js, BorderLayout.CENTER); this.setPreferredSize(new Dimension(super.getPreferredSize().width, 150)); - + jTextArea.setEditable(false); jTextArea.setBackground(Color.WHITE); - + popup = new JPopupMenu(); selectAll = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_All")); selectAll.addActionListener(popupListener); selectAll.setIcon(BaseUtils.readIcon("/com/fr/design/images/log/selectedall.png")); popup.add(selectAll); - + copy = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy")); copy.addActionListener(popupListener); copy.setIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); popup.add(copy); - + clear = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_All")); clear.addActionListener(popupListener); clear.setIcon(BaseUtils.readIcon("/com/fr/design/images/log/clear.png")); popup.add(clear); - + selectAll.setAccelerator(KeyStroke.getKeyStroke('A', DEFAULT_MODIFIER)); copy.setAccelerator(KeyStroke.getKeyStroke('C', DEFAULT_MODIFIER)); clear.setAccelerator(KeyStroke.getKeyStroke('L', DEFAULT_MODIFIER)); - + jTextArea.addMouseListener(new MouseAdapter() { + // check for right click public void mousePressed(MouseEvent event) { + if (event.getButton() == MouseEvent.BUTTON3) { popup.show(jTextArea, event.getX(), event.getY()); checkEnabled(); @@ -178,8 +216,9 @@ public class DesignerLogHandler { } }); } - + private JTextPane initLogJTextArea() { + final JTextPane resultPane = new JTextPane(); InputMap inputMap = resultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction); @@ -187,15 +226,18 @@ public class DesignerLogHandler { inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MODIFIER), "clear"); ActionMap actionMap = resultPane.getActionMap(); actionMap.put("clear", new AbstractAction() { + public void actionPerformed(ActionEvent evt) { + resultPane.setText(""); caption.clearMessage(); } }); return resultPane; } - + public void printStackTrace(LoggingEvent event) { + int intLevel = event.getLevel().toInt(); Date date = new Date(event.getTimeStamp()); ThrowableInformation information = event.getThrowableInformation(); @@ -207,27 +249,27 @@ public class DesignerLogHandler { printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); } } - + public void printStackTrace(String message, Level level, Date date) { + int intLevel = level.toInt(); - int logLevel = Log4jConfig.getInstance().getRootLevel().toInt(); if (intLevel == INFO_INT && showInfo.isSelected()) { printMessage(message, intLevel, date); } else if (intLevel == ERROR_INT && showError.isSelected()) { printMessage(message, intLevel, date); } else if (intLevel == WARN_INT && showServer.isSelected()) { printMessage(message, intLevel, date); - } else if (intLevel == DEBUG_INT && logLevel == DEBUG_INT){ - printMessage(message, intLevel, date); } - + } - + private void printMessage(String message, int intLevel, Date date) { + printMessage(message, intLevel, date, null); } - + private void printMessage(String msg, int intLevel, Date date, Throwable e) { + this.log(LOG_SIMPLE_DATE_FORMAT.format(date) + "\n", 0); String message = appendLocaleMark(msg, intLevel); this.log(message, intLevel); @@ -235,14 +277,15 @@ public class DesignerLogHandler { if (e == null) { return; } - + StackTraceElement[] traceElements = e.getStackTrace(); for (int i = 0; i < traceElements.length; i++) { this.log("\t" + "at " + traceElements[i].toString() + "\n", 0); } } - + private void log(String str, int style) { + SimpleAttributeSet attrSet = new SimpleAttributeSet(); if (style == ERROR_INT) { StyleConstants.setForeground(attrSet, new Color(247, 148, 29)); @@ -261,11 +304,12 @@ public class DesignerLogHandler { try { doc.insertString(doc.getLength(), str, attrSet); } catch (BadLocationException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } - + private String appendLocaleMark(String str, int style) { + if (style == ERROR_INT) { str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":" + str + "\n"; } else if (style == WARN_INT) { @@ -275,8 +319,9 @@ public class DesignerLogHandler { } return str; } - + private void setMessage(String message, int level) { + LogMessageBar.getInstance().setMessage(message); if (level == DesignerLogHandler.INFO_INT && showInfo.isSelected()) { caption.infoAdd(); @@ -286,28 +331,31 @@ public class DesignerLogHandler { caption.serverAdd(); } } - + private void checkEnabled() { + this.selectAll.setEnabled(true); this.copy.setEnabled(true); this.clear.setEnabled(true); - + if (ComparatorUtils.equals(this.jTextArea.getText(), "")) { this.selectAll.setEnabled(false); this.clear.setEnabled(false); } - + if (ComparatorUtils.equals(this.jTextArea.getSelectionStart(), this.jTextArea.getSelectionEnd())) { this.copy.setEnabled(false); } - + if (this.jTextArea.getSelectionStart() == 0 && ComparatorUtils.equals(this.jTextArea.getSelectionEnd(), this.jTextArea.getText().length())) { this.selectAll.setEnabled(false); } } - + ActionListener popupListener = new ActionListener() { + public void actionPerformed(ActionEvent evt) { + if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.selectAll.getText())) { LogHandlerArea.this.jTextArea.selectAll(); } else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.copy.getText())) { @@ -318,10 +366,11 @@ public class DesignerLogHandler { } } }; - + } - + public void printLoggingEvent(LoggingEvent event) { + logHandlerArea.printStackTrace(event); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index 7eb5e7bfd3..c1ca5d6bb1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java @@ -132,11 +132,11 @@ public class TemplateInfoCollector implements Serializable, } xmlInputStream.close(); } catch (FileNotFoundException e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } catch (IOException e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } catch (XMLStreamException e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 4f7920d1e9..8f20583abd 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -16,7 +16,6 @@ import com.fr.design.actions.community.NeedAction; import com.fr.design.actions.community.QuestionAction; import com.fr.design.actions.community.SignAction; import com.fr.design.actions.community.TechSolutionAction; -import com.fr.design.actions.community.UpAction; import com.fr.design.actions.community.VideoAction; import com.fr.design.actions.file.CloseCurrentTemplateAction; import com.fr.design.actions.file.ExitDesignerAction; @@ -51,7 +50,7 @@ import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.onlineupdate.actions.SoftwareUpdateAction; -import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction; +import com.fr.design.remote.action.RemoteDesignAuthManagerAction; import com.fr.design.utils.ThemeUtils; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; @@ -426,8 +425,8 @@ public abstract class ToolBarMenuDock { new PlatformManagerAction() ); - if (shouldShowRemotePermission()) { - menuDef.addShortCut(new RemoteDesignAuthorityManagerAction()); + if (shouldShowRemoteAuth()) { + menuDef.addShortCut(new RemoteDesignAuthManagerAction()); } if (!DesignerMode.isAuthorityEditing()) { @@ -451,7 +450,13 @@ public abstract class ToolBarMenuDock { return processor == null ? new GlobalTableDataAction() : processor.createServerTDAction(); } - private boolean shouldShowRemotePermission() { + /** + * 判断是否应该展示远程设计权限管理 + * 如果当前环境是远程环境,并且登录用户为管理员,那么应该展示;否则不予展示 + * + * @return boolean + */ + private boolean shouldShowRemoteAuth() { return WorkContext.getCurrent() != null && !WorkContext.getCurrent().isLocal() && WorkContext.getCurrent().isRoot(); } @@ -474,9 +479,10 @@ public abstract class ToolBarMenuDock { shortCuts.add(new TutorialAction()); } //远程不使用更新升级 -// if(WorkContext.getCurrent().isLocal()) { -// shortCuts.add(new SoftwareUpdateAction()); -// } + if (WorkContext.getCurrent().isLocal()) { + shortCuts.add(new SoftwareUpdateAction()); + } + if (AlphaFineConfigManager.isALPHALicAvailable()) { shortCuts.add(new AlphaFineAction()); } diff --git a/designer-base/src/main/java/com/fr/design/menu/KeySetUtils.java b/designer-base/src/main/java/com/fr/design/menu/KeySetUtils.java index f220b46a0b..3ecda64c49 100644 --- a/designer-base/src/main/java/com/fr/design/menu/KeySetUtils.java +++ b/designer-base/src/main/java/com/fr/design/menu/KeySetUtils.java @@ -5,7 +5,7 @@ package com.fr.design.menu; -import javax.swing.*; +import javax.swing.KeyStroke; import java.awt.event.KeyEvent; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; @@ -20,6 +20,23 @@ import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_M public class KeySetUtils { + public static final MenuKeySet NEW_FOLDER = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'I'; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_New_Folder"); + } + + @Override + public KeyStroke getKeyStroke() { + return KeyStroke.getKeyStroke(KeyEvent.VK_I, DEFAULT_MODIFIER); + } + }; + public static final MenuKeySet OPEN_TEMPLATE = new MenuKeySet() { @Override @@ -547,7 +564,9 @@ public class KeySetUtils { public static final MenuKeySet REPORT_WATERMARK = new MenuKeySet() { @Override - public char getMnemonic() { return 'M'; } + public char getMnemonic() { + return 'M'; + } @Override public String getMenuName() { @@ -974,14 +993,6 @@ public class KeySetUtils { }; - - - - - - - - public static final MenuKeySet INSERT_FLOAT = new MenuKeySet() { @Override public char getMnemonic() { @@ -1000,41 +1011,4 @@ public class KeySetUtils { }; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } diff --git a/designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/EncodingDetect.java b/designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/EncodingDetect.java new file mode 100644 index 0000000000..ecd63fa162 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/EncodingDetect.java @@ -0,0 +1,4555 @@ +package com.fr.design.onlineupdate.ui.dialog; + + +import java.io.File; +import java.io.FileInputStream; + +/** + * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * EncodingDetect.java
+ * 自动获取文件的编码 + * @author Mata + * @since Create on 2018-08-23 + * @version 1.0 + */ +public class EncodingDetect { + /** + * 得到文件的编码 + * @param file 文件路径 + * @return 文件的编码 + */ + public static String getJavaEncode(File file){ + BytesEncodingDetect s = new BytesEncodingDetect(); + String fileCode = BytesEncodingDetect.javaname[s.detectEncoding(file)]; + return fileCode; + } + + +} + +class BytesEncodingDetect extends Encoding { + // Frequency tables to hold the GB, Big5, and EUC-TW character + // frequencies + int GBFreq[][]; + + int GBKFreq[][]; + + int Big5Freq[][]; + + int Big5PFreq[][]; + + int EUC_TWFreq[][]; + + int KRFreq[][]; + + int JPFreq[][]; + + // int UnicodeFreq[94][128]; + // public static String[] nicename; + // public static String[] codings; + public boolean debug; + + public BytesEncodingDetect() { + super(); + debug = false; + GBFreq = new int[94][94]; + GBKFreq = new int[126][191]; + Big5Freq = new int[94][158]; + Big5PFreq = new int[126][191]; + EUC_TWFreq = new int[94][94]; + KRFreq = new int[94][94]; + JPFreq = new int[94][94]; + // Initialize the Frequency Table for GB, GBK, Big5, EUC-TW, KR, JP + initialize_frequencies(); + } + + /** + * Function : detectEncoding Aruguments: File Returns : One of the encodings from the Encoding enumeration (GB2312, HZ, BIG5, + * EUC_TW, ASCII, or OTHER) Description: This function looks at the file and assigns it a probability score for each encoding + * type. The encoding type with the highest probability is returned. + */ + public int detectEncoding(File testfile) { + FileInputStream chinesefile; + byte[] rawtext; + rawtext = new byte[(int) testfile.length()]; + try { + chinesefile = new FileInputStream(testfile); + chinesefile.read(rawtext); + chinesefile.close(); + } catch (Exception e) { + System.err.println("Error: " + e); + } + return detectEncoding(rawtext); + } + + /** + * Function : detectEncoding Aruguments: byte array Returns : One of the encodings from the Encoding enumeration (GB2312, HZ, + * BIG5, EUC_TW, ASCII, or OTHER) Description: This function looks at the byte array and assigns it a probability score for + * each encoding type. The encoding type with the highest probability is returned. + */ + public int detectEncoding(byte[] rawtext) { + int[] scores; + int index, maxscore = 0; + int encoding_guess = OTHER; + scores = new int[TOTALTYPES]; + // Assign Scores + scores[GB2312] = gb2312_probability(rawtext); + scores[GBK] = gbk_probability(rawtext); + scores[GB18030] = gb18030_probability(rawtext); + scores[HZ] = hz_probability(rawtext); + scores[BIG5] = big5_probability(rawtext); + scores[CNS11643] = euc_tw_probability(rawtext); + scores[ISO2022CN] = iso_2022_cn_probability(rawtext); + scores[UTF8] = utf8_probability(rawtext); + scores[UNICODE] = utf16_probability(rawtext); + scores[EUC_KR] = euc_kr_probability(rawtext); + scores[CP949] = cp949_probability(rawtext); + scores[JOHAB] = 0; + scores[ISO2022KR] = iso_2022_kr_probability(rawtext); + scores[ASCII] = ascii_probability(rawtext); + scores[SJIS] = sjis_probability(rawtext); + scores[EUC_JP] = euc_jp_probability(rawtext); + scores[ISO2022JP] = iso_2022_jp_probability(rawtext); + scores[UNICODET] = 0; + scores[UNICODES] = 0; + scores[ISO2022CN_GB] = 0; + scores[ISO2022CN_CNS] = 0; + scores[OTHER] = 0; + // Tabulate Scores + for (index = 0; index < TOTALTYPES; index++) { + if (debug) + System.err.println("Encoding " + nicename[index] + " score " + scores[index]); + if (scores[index] > maxscore) { + encoding_guess = index; + maxscore = scores[index]; + } + } + // Return OTHER if nothing scored above 50 + if (maxscore <= 50) { + encoding_guess = OTHER; + } + return encoding_guess; + } + + /* + * Function: gb2312_probability Argument: pointer to byte array Returns : number from 0 to 100 representing probability text + * in array uses GB-2312 encoding + */ + int gb2312_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, gbchars = 1; + long gbfreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int row, column; + // Stage 1: Check to see if characters fit into acceptable ranges + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + // System.err.println(rawtext[i]); + if (rawtext[i] >= 0) { + // asciichars++; + } else { + dbchars++; + if ((byte) 0xA1 <= rawtext[i] && rawtext[i] <= (byte) 0xF7 && (byte) 0xA1 <= rawtext[i + 1] + && rawtext[i + 1] <= (byte) 0xFE) { + gbchars++; + totalfreq += 500; + row = rawtext[i] + 256 - 0xA1; + column = rawtext[i + 1] + 256 - 0xA1; + if (GBFreq[row][column] != 0) { + gbfreq += GBFreq[row][column]; + } else if (15 <= row && row < 55) { + // In GB high-freq character range + gbfreq += 200; + } + } + i++; + } + } + rangeval = 50 * ((float) gbchars / (float) dbchars); + freqval = 50 * ((float) gbfreq / (float) totalfreq); + return (int) (rangeval + freqval); + } + + /* + * Function: gbk_probability Argument: pointer to byte array Returns : number from 0 to 100 representing probability text in + * array uses GBK encoding + */ + int gbk_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, gbchars = 1; + long gbfreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int row, column; + // Stage 1: Check to see if characters fit into acceptable ranges + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + // System.err.println(rawtext[i]); + if (rawtext[i] >= 0) { + // asciichars++; + } else { + dbchars++; + if ((byte) 0xA1 <= rawtext[i] && rawtext[i] <= (byte) 0xF7 && // Original GB range + (byte) 0xA1 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0xFE) { + gbchars++; + totalfreq += 500; + row = rawtext[i] + 256 - 0xA1; + column = rawtext[i + 1] + 256 - 0xA1; + // System.out.println("original row " + row + " column " + column); + if (GBFreq[row][column] != 0) { + gbfreq += GBFreq[row][column]; + } else if (15 <= row && row < 55) { + gbfreq += 200; + } + } else if ((byte) 0x81 <= rawtext[i] + && rawtext[i] <= (byte) 0xFE + && // Extended GB range + (((byte) 0x80 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0xFE) || ((byte) 0x40 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0x7E))) { + gbchars++; + totalfreq += 500; + row = rawtext[i] + 256 - 0x81; + if (0x40 <= rawtext[i + 1] && rawtext[i + 1] <= 0x7E) { + column = rawtext[i + 1] - 0x40; + } else { + column = rawtext[i + 1] + 256 - 0x40; + } + // System.out.println("extended row " + row + " column " + column + " rawtext[i] " + rawtext[i]); + if (GBKFreq[row][column] != 0) { + gbfreq += GBKFreq[row][column]; + } + } + i++; + } + } + rangeval = 50 * ((float) gbchars / (float) dbchars); + freqval = 50 * ((float) gbfreq / (float) totalfreq); + // For regular GB files, this would give the same score, so I handicap it slightly + return (int) (rangeval + freqval) - 1; + } + + /* + * Function: gb18030_probability Argument: pointer to byte array Returns : number from 0 to 100 representing probability text + * in array uses GBK encoding + */ + int gb18030_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, gbchars = 1; + long gbfreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int row, column; + // Stage 1: Check to see if characters fit into acceptable ranges + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + // System.err.println(rawtext[i]); + if (rawtext[i] >= 0) { + // asciichars++; + } else { + dbchars++; + if ((byte) 0xA1 <= rawtext[i] && rawtext[i] <= (byte) 0xF7 && // Original GB range + i + 1 < rawtextlen && (byte) 0xA1 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0xFE) { + gbchars++; + totalfreq += 500; + row = rawtext[i] + 256 - 0xA1; + column = rawtext[i + 1] + 256 - 0xA1; + // System.out.println("original row " + row + " column " + column); + if (GBFreq[row][column] != 0) { + gbfreq += GBFreq[row][column]; + } else if (15 <= row && row < 55) { + gbfreq += 200; + } + } else if ((byte) 0x81 <= rawtext[i] && rawtext[i] <= (byte) 0xFE + && // Extended GB range + i + 1 < rawtextlen + && (((byte) 0x80 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0xFE) || ((byte) 0x40 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0x7E))) { + gbchars++; + totalfreq += 500; + row = rawtext[i] + 256 - 0x81; + if (0x40 <= rawtext[i + 1] && rawtext[i + 1] <= 0x7E) { + column = rawtext[i + 1] - 0x40; + } else { + column = rawtext[i + 1] + 256 - 0x40; + } + // System.out.println("extended row " + row + " column " + column + " rawtext[i] " + rawtext[i]); + if (GBKFreq[row][column] != 0) { + gbfreq += GBKFreq[row][column]; + } + } else if ((byte) 0x81 <= rawtext[i] + && rawtext[i] <= (byte) 0xFE + && // Extended GB range + i + 3 < rawtextlen && (byte) 0x30 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0x39 + && (byte) 0x81 <= rawtext[i + 2] && rawtext[i + 2] <= (byte) 0xFE && (byte) 0x30 <= rawtext[i + 3] + && rawtext[i + 3] <= (byte) 0x39) { + gbchars++; + /* + * totalfreq += 500; row = rawtext[i] + 256 - 0x81; if (0x40 <= rawtext[i+1] && rawtext[i+1] <= 0x7E) { column = + * rawtext[i+1] - 0x40; } else { column = rawtext[i+1] + 256 - 0x40; } //System.out.println("extended row " + row + " + * column " + column + " rawtext[i] " + rawtext[i]); if (GBKFreq[row][column] != 0) { gbfreq += GBKFreq[row][column]; } + */ + } + i++; + } + } + rangeval = 50 * ((float) gbchars / (float) dbchars); + freqval = 50 * ((float) gbfreq / (float) totalfreq); + // For regular GB files, this would give the same score, so I handicap it slightly + return (int) (rangeval + freqval) - 1; + } + + /* + * Function: hz_probability Argument: byte array Returns : number from 0 to 100 representing probability text in array uses HZ + * encoding + */ + int hz_probability(byte[] rawtext) { + int i, rawtextlen; + int hzchars = 0, dbchars = 1; + long hzfreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int hzstart = 0, hzend = 0; + int row, column; + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen; i++) { + if (rawtext[i] == '~') { + if (rawtext[i + 1] == '{') { + hzstart++; + i += 2; + while (i < rawtextlen - 1) { + if (rawtext[i] == 0x0A || rawtext[i] == 0x0D) { + break; + } else if (rawtext[i] == '~' && rawtext[i + 1] == '}') { + hzend++; + i++; + break; + } else if ((0x21 <= rawtext[i] && rawtext[i] <= 0x77) && (0x21 <= rawtext[i + 1] && rawtext[i + 1] <= 0x77)) { + hzchars += 2; + row = rawtext[i] - 0x21; + column = rawtext[i + 1] - 0x21; + totalfreq += 500; + if (GBFreq[row][column] != 0) { + hzfreq += GBFreq[row][column]; + } else if (15 <= row && row < 55) { + hzfreq += 200; + } + } else if ((0xA1 <= rawtext[i] && rawtext[i] <= 0xF7) && (0xA1 <= rawtext[i + 1] && rawtext[i + 1] <= 0xF7)) { + hzchars += 2; + row = rawtext[i] + 256 - 0xA1; + column = rawtext[i + 1] + 256 - 0xA1; + totalfreq += 500; + if (GBFreq[row][column] != 0) { + hzfreq += GBFreq[row][column]; + } else if (15 <= row && row < 55) { + hzfreq += 200; + } + } + dbchars += 2; + i += 2; + } + } else if (rawtext[i + 1] == '}') { + hzend++; + i++; + } else if (rawtext[i + 1] == '~') { + i++; + } + } + } + if (hzstart > 4) { + rangeval = 50; + } else if (hzstart > 1) { + rangeval = 41; + } else if (hzstart > 0) { // Only 39 in case the sequence happened to occur + rangeval = 39; // in otherwise non-Hz text + } else { + rangeval = 0; + } + freqval = 50 * ((float) hzfreq / (float) totalfreq); + return (int) (rangeval + freqval); + } + + /** + * Function: big5_probability Argument: byte array Returns : number from 0 to 100 representing probability text in array uses + * Big5 encoding + */ + int big5_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, bfchars = 1; + float rangeval = 0, freqval = 0; + long bffreq = 0, totalfreq = 1; + int row, column; + // Check to see if characters fit into acceptable ranges + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + if (rawtext[i] >= 0) { + // asciichars++; + } else { + dbchars++; + if ((byte) 0xA1 <= rawtext[i] + && rawtext[i] <= (byte) 0xF9 + && (((byte) 0x40 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0x7E) || ((byte) 0xA1 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0xFE))) { + bfchars++; + totalfreq += 500; + row = rawtext[i] + 256 - 0xA1; + if (0x40 <= rawtext[i + 1] && rawtext[i + 1] <= 0x7E) { + column = rawtext[i + 1] - 0x40; + } else { + column = rawtext[i + 1] + 256 - 0x61; + } + if (Big5Freq[row][column] != 0) { + bffreq += Big5Freq[row][column]; + } else if (3 <= row && row <= 37) { + bffreq += 200; + } + } + i++; + } + } + rangeval = 50 * ((float) bfchars / (float) dbchars); + freqval = 50 * ((float) bffreq / (float) totalfreq); + return (int) (rangeval + freqval); + } + + /* + * Function: big5plus_probability Argument: pointer to unsigned char array Returns : number from 0 to 100 representing + * probability text in array uses Big5+ encoding + */ + int big5plus_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, bfchars = 1; + long bffreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int row, column; + // Stage 1: Check to see if characters fit into acceptable ranges + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + // System.err.println(rawtext[i]); + if (rawtext[i] >= 128) { + // asciichars++; + } else { + dbchars++; + if (0xA1 <= rawtext[i] && rawtext[i] <= 0xF9 && // Original Big5 range + ((0x40 <= rawtext[i + 1] && rawtext[i + 1] <= 0x7E) || (0xA1 <= rawtext[i + 1] && rawtext[i + 1] <= 0xFE))) { + bfchars++; + totalfreq += 500; + row = rawtext[i] - 0xA1; + if (0x40 <= rawtext[i + 1] && rawtext[i + 1] <= 0x7E) { + column = rawtext[i + 1] - 0x40; + } else { + column = rawtext[i + 1] - 0x61; + } + // System.out.println("original row " + row + " column " + column); + if (Big5Freq[row][column] != 0) { + bffreq += Big5Freq[row][column]; + } else if (3 <= row && row < 37) { + bffreq += 200; + } + } else if (0x81 <= rawtext[i] && rawtext[i] <= 0xFE && // Extended Big5 range + ((0x40 <= rawtext[i + 1] && rawtext[i + 1] <= 0x7E) || (0x80 <= rawtext[i + 1] && rawtext[i + 1] <= 0xFE))) { + bfchars++; + totalfreq += 500; + row = rawtext[i] - 0x81; + if (0x40 <= rawtext[i + 1] && rawtext[i + 1] <= 0x7E) { + column = rawtext[i + 1] - 0x40; + } else { + column = rawtext[i + 1] - 0x40; + } + // System.out.println("extended row " + row + " column " + column + " rawtext[i] " + rawtext[i]); + if (Big5PFreq[row][column] != 0) { + bffreq += Big5PFreq[row][column]; + } + } + i++; + } + } + rangeval = 50 * ((float) bfchars / (float) dbchars); + freqval = 50 * ((float) bffreq / (float) totalfreq); + // For regular Big5 files, this would give the same score, so I handicap it slightly + return (int) (rangeval + freqval) - 1; + } + + /* + * Function: euc_tw_probability Argument: byte array Returns : number from 0 to 100 representing probability text in array + * uses EUC-TW (CNS 11643) encoding + */ + int euc_tw_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, cnschars = 1; + long cnsfreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int row, column; + // Check to see if characters fit into acceptable ranges + // and have expected frequency of use + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + if (rawtext[i] >= 0) { // in ASCII range + // asciichars++; + } else { // high bit set + dbchars++; + if (i + 3 < rawtextlen && (byte) 0x8E == rawtext[i] && (byte) 0xA1 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0xB0 + && (byte) 0xA1 <= rawtext[i + 2] && rawtext[i + 2] <= (byte) 0xFE && (byte) 0xA1 <= rawtext[i + 3] + && rawtext[i + 3] <= (byte) 0xFE) { // Planes 1 - 16 + cnschars++; + // System.out.println("plane 2 or above CNS char"); + // These are all less frequent chars so just ignore freq + i += 3; + } else if ((byte) 0xA1 <= rawtext[i] && rawtext[i] <= (byte) 0xFE && // Plane 1 + (byte) 0xA1 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0xFE) { + cnschars++; + totalfreq += 500; + row = rawtext[i] + 256 - 0xA1; + column = rawtext[i + 1] + 256 - 0xA1; + if (EUC_TWFreq[row][column] != 0) { + cnsfreq += EUC_TWFreq[row][column]; + } else if (35 <= row && row <= 92) { + cnsfreq += 150; + } + i++; + } + } + } + rangeval = 50 * ((float) cnschars / (float) dbchars); + freqval = 50 * ((float) cnsfreq / (float) totalfreq); + return (int) (rangeval + freqval); + } + + /* + * Function: iso_2022_cn_probability Argument: byte array Returns : number from 0 to 100 representing probability text in + * array uses ISO 2022-CN encoding WORKS FOR BASIC CASES, BUT STILL NEEDS MORE WORK + */ + int iso_2022_cn_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, isochars = 1; + long isofreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int row, column; + // Check to see if characters fit into acceptable ranges + // and have expected frequency of use + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + if (rawtext[i] == (byte) 0x1B && i + 3 < rawtextlen) { // Escape char ESC + if (rawtext[i + 1] == (byte) 0x24 && rawtext[i + 2] == 0x29 && rawtext[i + 3] == (byte) 0x41) { // GB Escape $ ) A + i += 4; + while (rawtext[i] != (byte) 0x1B) { + dbchars++; + if ((0x21 <= rawtext[i] && rawtext[i] <= 0x77) && (0x21 <= rawtext[i + 1] && rawtext[i + 1] <= 0x77)) { + isochars++; + row = rawtext[i] - 0x21; + column = rawtext[i + 1] - 0x21; + totalfreq += 500; + if (GBFreq[row][column] != 0) { + isofreq += GBFreq[row][column]; + } else if (15 <= row && row < 55) { + isofreq += 200; + } + i++; + } + i++; + } + } else if (i + 3 < rawtextlen && rawtext[i + 1] == (byte) 0x24 && rawtext[i + 2] == (byte) 0x29 + && rawtext[i + 3] == (byte) 0x47) { + // CNS Escape $ ) G + i += 4; + while (rawtext[i] != (byte) 0x1B) { + dbchars++; + if ((byte) 0x21 <= rawtext[i] && rawtext[i] <= (byte) 0x7E && (byte) 0x21 <= rawtext[i + 1] + && rawtext[i + 1] <= (byte) 0x7E) { + isochars++; + totalfreq += 500; + row = rawtext[i] - 0x21; + column = rawtext[i + 1] - 0x21; + if (EUC_TWFreq[row][column] != 0) { + isofreq += EUC_TWFreq[row][column]; + } else if (35 <= row && row <= 92) { + isofreq += 150; + } + i++; + } + i++; + } + } + if (rawtext[i] == (byte) 0x1B && i + 2 < rawtextlen && rawtext[i + 1] == (byte) 0x28 && rawtext[i + 2] == (byte) 0x42) { // ASCII: + // ESC + // ( B + i += 2; + } + } + } + rangeval = 50 * ((float) isochars / (float) dbchars); + freqval = 50 * ((float) isofreq / (float) totalfreq); + // System.out.println("isochars dbchars isofreq totalfreq " + isochars + " " + dbchars + " " + isofreq + " " + totalfreq + " + // " + rangeval + " " + freqval); + return (int) (rangeval + freqval); + // return 0; + } + + /* + * Function: utf8_probability Argument: byte array Returns : number from 0 to 100 representing probability text in array uses + * UTF-8 encoding of Unicode + */ + int utf8_probability(byte[] rawtext) { + int score = 0; + int i, rawtextlen = 0; + int goodbytes = 0, asciibytes = 0; + // Maybe also use UTF8 Byte Order Mark: EF BB BF + // Check to see if characters fit into acceptable ranges + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen; i++) { + if ((rawtext[i] & (byte) 0x7F) == rawtext[i]) { // One byte + asciibytes++; + // Ignore ASCII, can throw off count + } else if (-64 <= rawtext[i] && rawtext[i] <= -33 && // Two bytes + i + 1 < rawtextlen && -128 <= rawtext[i + 1] && rawtext[i + 1] <= -65) { + goodbytes += 2; + i++; + } else if (-32 <= rawtext[i] && rawtext[i] <= -17 + && // Three bytes + i + 2 < rawtextlen && -128 <= rawtext[i + 1] && rawtext[i + 1] <= -65 && -128 <= rawtext[i + 2] + && rawtext[i + 2] <= -65) { + goodbytes += 3; + i += 2; + } + } + if (asciibytes == rawtextlen) { + return 0; + } + score = (int) (100 * ((float) goodbytes / (float) (rawtextlen - asciibytes))); + // System.out.println("rawtextlen " + rawtextlen + " goodbytes " + goodbytes + " asciibytes " + asciibytes + " score " + + // score); + // If not above 98, reduce to zero to prevent coincidental matches + // Allows for some (few) bad formed sequences + if (score > 98) { + return score; + } else if (score > 95 && goodbytes > 30) { + return score; + } else { + return 0; + } + } + + /* + * Function: utf16_probability Argument: byte array Returns : number from 0 to 100 representing probability text in array uses + * UTF-16 encoding of Unicode, guess based on BOM // NOT VERY GENERAL, NEEDS MUCH MORE WORK + */ + int utf16_probability(byte[] rawtext) { + // int score = 0; + // int i, rawtextlen = 0; + // int goodbytes = 0, asciibytes = 0; + if (rawtext.length > 1 && ((byte) 0xFE == rawtext[0] && (byte) 0xFF == rawtext[1]) || // Big-endian + ((byte) 0xFF == rawtext[0] && (byte) 0xFE == rawtext[1])) { // Little-endian + return 100; + } + return 0; + /* + * // Check to see if characters fit into acceptable ranges rawtextlen = rawtext.length; for (i = 0; i < rawtextlen; i++) { + * if ((rawtext[i] & (byte)0x7F) == rawtext[i]) { // One byte goodbytes += 1; asciibytes++; } else if ((rawtext[i] & + * (byte)0xDF) == rawtext[i]) { // Two bytes if (i+1 < rawtextlen && (rawtext[i+1] & (byte)0xBF) == rawtext[i+1]) { + * goodbytes += 2; i++; } } else if ((rawtext[i] & (byte)0xEF) == rawtext[i]) { // Three bytes if (i+2 < rawtextlen && + * (rawtext[i+1] & (byte)0xBF) == rawtext[i+1] && (rawtext[i+2] & (byte)0xBF) == rawtext[i+2]) { goodbytes += 3; i+=2; } } } + * + * score = (int)(100 * ((float)goodbytes/(float)rawtext.length)); // An all ASCII file is also a good UTF8 file, but I'd + * rather it // get identified as ASCII. Can delete following 3 lines otherwise if (goodbytes == asciibytes) { score = 0; } // + * If not above 90, reduce to zero to prevent coincidental matches if (score > 90) { return score; } else { return 0; } + */ + } + + /* + * Function: ascii_probability Argument: byte array Returns : number from 0 to 100 representing probability text in array uses + * all ASCII Description: Sees if array has any characters not in ASCII range, if so, score is reduced + */ + int ascii_probability(byte[] rawtext) { + int score = 75; + int i, rawtextlen; + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen; i++) { + if (rawtext[i] < 0) { + score = score - 5; + } else if (rawtext[i] == (byte) 0x1B) { // ESC (used by ISO 2022) + score = score - 5; + } + if (score <= 0) { + return 0; + } + } + return score; + } + + /* + * Function: euc_kr__probability Argument: pointer to byte array Returns : number from 0 to 100 representing probability text + * in array uses EUC-KR encoding + */ + int euc_kr_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, krchars = 1; + long krfreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int row, column; + // Stage 1: Check to see if characters fit into acceptable ranges + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + // System.err.println(rawtext[i]); + if (rawtext[i] >= 0) { + // asciichars++; + } else { + dbchars++; + if ((byte) 0xA1 <= rawtext[i] && rawtext[i] <= (byte) 0xFE && (byte) 0xA1 <= rawtext[i + 1] + && rawtext[i + 1] <= (byte) 0xFE) { + krchars++; + totalfreq += 500; + row = rawtext[i] + 256 - 0xA1; + column = rawtext[i + 1] + 256 - 0xA1; + if (KRFreq[row][column] != 0) { + krfreq += KRFreq[row][column]; + } else if (15 <= row && row < 55) { + krfreq += 0; + } + } + i++; + } + } + rangeval = 50 * ((float) krchars / (float) dbchars); + freqval = 50 * ((float) krfreq / (float) totalfreq); + return (int) (rangeval + freqval); + } + + /* + * Function: cp949__probability Argument: pointer to byte array Returns : number from 0 to 100 representing probability text + * in array uses Cp949 encoding + */ + int cp949_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, krchars = 1; + long krfreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int row, column; + // Stage 1: Check to see if characters fit into acceptable ranges + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + // System.err.println(rawtext[i]); + if (rawtext[i] >= 0) { + // asciichars++; + } else { + dbchars++; + if ((byte) 0x81 <= rawtext[i] + && rawtext[i] <= (byte) 0xFE + && ((byte) 0x41 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0x5A || (byte) 0x61 <= rawtext[i + 1] + && rawtext[i + 1] <= (byte) 0x7A || (byte) 0x81 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0xFE)) { + krchars++; + totalfreq += 500; + if ((byte) 0xA1 <= rawtext[i] && rawtext[i] <= (byte) 0xFE && (byte) 0xA1 <= rawtext[i + 1] + && rawtext[i + 1] <= (byte) 0xFE) { + row = rawtext[i] + 256 - 0xA1; + column = rawtext[i + 1] + 256 - 0xA1; + if (KRFreq[row][column] != 0) { + krfreq += KRFreq[row][column]; + } + } + } + i++; + } + } + rangeval = 50 * ((float) krchars / (float) dbchars); + freqval = 50 * ((float) krfreq / (float) totalfreq); + return (int) (rangeval + freqval); + } + + int iso_2022_kr_probability(byte[] rawtext) { + int i; + for (i = 0; i < rawtext.length; i++) { + if (i + 3 < rawtext.length && rawtext[i] == 0x1b && (char) rawtext[i + 1] == '$' && (char) rawtext[i + 2] == ')' + && (char) rawtext[i + 3] == 'C') { + return 100; + } + } + return 0; + } + + /* + * Function: euc_jp_probability Argument: pointer to byte array Returns : number from 0 to 100 representing probability text + * in array uses EUC-JP encoding + */ + int euc_jp_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, jpchars = 1; + long jpfreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int row, column; + // Stage 1: Check to see if characters fit into acceptable ranges + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + // System.err.println(rawtext[i]); + if (rawtext[i] >= 0) { + // asciichars++; + } else { + dbchars++; + if ((byte) 0xA1 <= rawtext[i] && rawtext[i] <= (byte) 0xFE && (byte) 0xA1 <= rawtext[i + 1] + && rawtext[i + 1] <= (byte) 0xFE) { + jpchars++; + totalfreq += 500; + row = rawtext[i] + 256 - 0xA1; + column = rawtext[i + 1] + 256 - 0xA1; + if (JPFreq[row][column] != 0) { + jpfreq += JPFreq[row][column]; + } else if (15 <= row && row < 55) { + jpfreq += 0; + } + } + i++; + } + } + rangeval = 50 * ((float) jpchars / (float) dbchars); + freqval = 50 * ((float) jpfreq / (float) totalfreq); + return (int) (rangeval + freqval); + } + + int iso_2022_jp_probability(byte[] rawtext) { + int i; + for (i = 0; i < rawtext.length; i++) { + if (i + 2 < rawtext.length && rawtext[i] == 0x1b && (char) rawtext[i + 1] == '$' && (char) rawtext[i + 2] == 'B') { + return 100; + } + } + return 0; + } + + /* + * Function: sjis_probability Argument: pointer to byte array Returns : number from 0 to 100 representing probability text in + * array uses Shift-JIS encoding + */ + int sjis_probability(byte[] rawtext) { + int i, rawtextlen = 0; + int dbchars = 1, jpchars = 1; + long jpfreq = 0, totalfreq = 1; + float rangeval = 0, freqval = 0; + int row, column, adjust; + // Stage 1: Check to see if characters fit into acceptable ranges + rawtextlen = rawtext.length; + for (i = 0; i < rawtextlen - 1; i++) { + // System.err.println(rawtext[i]); + if (rawtext[i] >= 0) { + // asciichars++; + } else { + dbchars++; + if (i + 1 < rawtext.length + && (((byte) 0x81 <= rawtext[i] && rawtext[i] <= (byte) 0x9F) || ((byte) 0xE0 <= rawtext[i] && rawtext[i] <= (byte) 0xEF)) + && (((byte) 0x40 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0x7E) || ((byte) 0x80 <= rawtext[i + 1] && rawtext[i + 1] <= (byte) 0xFC))) { + jpchars++; + totalfreq += 500; + row = rawtext[i] + 256; + column = rawtext[i + 1] + 256; + if (column < 0x9f) { + adjust = 1; + if (column > 0x7f) { + column -= 0x20; + } else { + column -= 0x19; + } + } else { + adjust = 0; + column -= 0x7e; + } + if (row < 0xa0) { + row = ((row - 0x70) << 1) - adjust; + } else { + row = ((row - 0xb0) << 1) - adjust; + } + row -= 0x20; + column = 0x20; + // System.out.println("original row " + row + " column " + column); + if (row < JPFreq.length && column < JPFreq[row].length && JPFreq[row][column] != 0) { + jpfreq += JPFreq[row][column]; + } + i++; + } else if ((byte) 0xA1 <= rawtext[i] && rawtext[i] <= (byte) 0xDF) { + // half-width katakana, convert to full-width + } + } + } + rangeval = 50 * ((float) jpchars / (float) dbchars); + freqval = 50 * ((float) jpfreq / (float) totalfreq); + // For regular GB files, this would give the same score, so I handicap it slightly + return (int) (rangeval + freqval) - 1; + } + + void initialize_frequencies() { + int i, j; + for (i = 0; i < 94; i++) { + for (j = 0; j < 94; j++) { + GBFreq[i][j] = 0; + } + } + for (i = 0; i < 126; i++) { + for (j = 0; j < 191; j++) { + GBKFreq[i][j] = 0; + } + } + for (i = 0; i < 94; i++) { + for (j = 0; j < 158; j++) { + Big5Freq[i][j] = 0; + } + } + for (i = 0; i < 126; i++) { + for (j = 0; j < 191; j++) { + Big5PFreq[i][j] = 0; + } + } + for (i = 0; i < 94; i++) { + for (j = 0; j < 94; j++) { + EUC_TWFreq[i][j] = 0; + } + } + for (i = 0; i < 94; i++) { + for (j = 0; j < 94; j++) { + JPFreq[i][j] = 0; + } + } + GBFreq[20][35] = 599; + GBFreq[49][26] = 598; + GBFreq[41][38] = 597; + GBFreq[17][26] = 596; + GBFreq[32][42] = 595; + GBFreq[39][42] = 594; + GBFreq[45][49] = 593; + GBFreq[51][57] = 592; + GBFreq[50][47] = 591; + GBFreq[42][90] = 590; + GBFreq[52][65] = 589; + GBFreq[53][47] = 588; + GBFreq[19][82] = 587; + GBFreq[31][19] = 586; + GBFreq[40][46] = 585; + GBFreq[24][89] = 584; + GBFreq[23][85] = 583; + GBFreq[20][28] = 582; + GBFreq[42][20] = 581; + GBFreq[34][38] = 580; + GBFreq[45][9] = 579; + GBFreq[54][50] = 578; + GBFreq[25][44] = 577; + GBFreq[35][66] = 576; + GBFreq[20][55] = 575; + GBFreq[18][85] = 574; + GBFreq[20][31] = 573; + GBFreq[49][17] = 572; + GBFreq[41][16] = 571; + GBFreq[35][73] = 570; + GBFreq[20][34] = 569; + GBFreq[29][44] = 568; + GBFreq[35][38] = 567; + GBFreq[49][9] = 566; + GBFreq[46][33] = 565; + GBFreq[49][51] = 564; + GBFreq[40][89] = 563; + GBFreq[26][64] = 562; + GBFreq[54][51] = 561; + GBFreq[54][36] = 560; + GBFreq[39][4] = 559; + GBFreq[53][13] = 558; + GBFreq[24][92] = 557; + GBFreq[27][49] = 556; + GBFreq[48][6] = 555; + GBFreq[21][51] = 554; + GBFreq[30][40] = 553; + GBFreq[42][92] = 552; + GBFreq[31][78] = 551; + GBFreq[25][82] = 550; + GBFreq[47][0] = 549; + GBFreq[34][19] = 548; + GBFreq[47][35] = 547; + GBFreq[21][63] = 546; + GBFreq[43][75] = 545; + GBFreq[21][87] = 544; + GBFreq[35][59] = 543; + GBFreq[25][34] = 542; + GBFreq[21][27] = 541; + GBFreq[39][26] = 540; + GBFreq[34][26] = 539; + GBFreq[39][52] = 538; + GBFreq[50][57] = 537; + GBFreq[37][79] = 536; + GBFreq[26][24] = 535; + GBFreq[22][1] = 534; + GBFreq[18][40] = 533; + GBFreq[41][33] = 532; + GBFreq[53][26] = 531; + GBFreq[54][86] = 530; + GBFreq[20][16] = 529; + GBFreq[46][74] = 528; + GBFreq[30][19] = 527; + GBFreq[45][35] = 526; + GBFreq[45][61] = 525; + GBFreq[30][9] = 524; + GBFreq[41][53] = 523; + GBFreq[41][13] = 522; + GBFreq[50][34] = 521; + GBFreq[53][86] = 520; + GBFreq[47][47] = 519; + GBFreq[22][28] = 518; + GBFreq[50][53] = 517; + GBFreq[39][70] = 516; + GBFreq[38][15] = 515; + GBFreq[42][88] = 514; + GBFreq[16][29] = 513; + GBFreq[27][90] = 512; + GBFreq[29][12] = 511; + GBFreq[44][22] = 510; + GBFreq[34][69] = 509; + GBFreq[24][10] = 508; + GBFreq[44][11] = 507; + GBFreq[39][92] = 506; + GBFreq[49][48] = 505; + GBFreq[31][46] = 504; + GBFreq[19][50] = 503; + GBFreq[21][14] = 502; + GBFreq[32][28] = 501; + GBFreq[18][3] = 500; + GBFreq[53][9] = 499; + GBFreq[34][80] = 498; + GBFreq[48][88] = 497; + GBFreq[46][53] = 496; + GBFreq[22][53] = 495; + GBFreq[28][10] = 494; + GBFreq[44][65] = 493; + GBFreq[20][10] = 492; + GBFreq[40][76] = 491; + GBFreq[47][8] = 490; + GBFreq[50][74] = 489; + GBFreq[23][62] = 488; + GBFreq[49][65] = 487; + GBFreq[28][87] = 486; + GBFreq[15][48] = 485; + GBFreq[22][7] = 484; + GBFreq[19][42] = 483; + GBFreq[41][20] = 482; + GBFreq[26][55] = 481; + GBFreq[21][93] = 480; + GBFreq[31][76] = 479; + GBFreq[34][31] = 478; + GBFreq[20][66] = 477; + GBFreq[51][33] = 476; + GBFreq[34][86] = 475; + GBFreq[37][67] = 474; + GBFreq[53][53] = 473; + GBFreq[40][88] = 472; + GBFreq[39][10] = 471; + GBFreq[24][3] = 470; + GBFreq[27][25] = 469; + GBFreq[26][15] = 468; + GBFreq[21][88] = 467; + GBFreq[52][62] = 466; + GBFreq[46][81] = 465; + GBFreq[38][72] = 464; + GBFreq[17][30] = 463; + GBFreq[52][92] = 462; + GBFreq[34][90] = 461; + GBFreq[21][7] = 460; + GBFreq[36][13] = 459; + GBFreq[45][41] = 458; + GBFreq[32][5] = 457; + GBFreq[26][89] = 456; + GBFreq[23][87] = 455; + GBFreq[20][39] = 454; + GBFreq[27][23] = 453; + GBFreq[25][59] = 452; + GBFreq[49][20] = 451; + GBFreq[54][77] = 450; + GBFreq[27][67] = 449; + GBFreq[47][33] = 448; + GBFreq[41][17] = 447; + GBFreq[19][81] = 446; + GBFreq[16][66] = 445; + GBFreq[45][26] = 444; + GBFreq[49][81] = 443; + GBFreq[53][55] = 442; + GBFreq[16][26] = 441; + GBFreq[54][62] = 440; + GBFreq[20][70] = 439; + GBFreq[42][35] = 438; + GBFreq[20][57] = 437; + GBFreq[34][36] = 436; + GBFreq[46][63] = 435; + GBFreq[19][45] = 434; + GBFreq[21][10] = 433; + GBFreq[52][93] = 432; + GBFreq[25][2] = 431; + GBFreq[30][57] = 430; + GBFreq[41][24] = 429; + GBFreq[28][43] = 428; + GBFreq[45][86] = 427; + GBFreq[51][56] = 426; + GBFreq[37][28] = 425; + GBFreq[52][69] = 424; + GBFreq[43][92] = 423; + GBFreq[41][31] = 422; + GBFreq[37][87] = 421; + GBFreq[47][36] = 420; + GBFreq[16][16] = 419; + GBFreq[40][56] = 418; + GBFreq[24][55] = 417; + GBFreq[17][1] = 416; + GBFreq[35][57] = 415; + GBFreq[27][50] = 414; + GBFreq[26][14] = 413; + GBFreq[50][40] = 412; + GBFreq[39][19] = 411; + GBFreq[19][89] = 410; + GBFreq[29][91] = 409; + GBFreq[17][89] = 408; + GBFreq[39][74] = 407; + GBFreq[46][39] = 406; + GBFreq[40][28] = 405; + GBFreq[45][68] = 404; + GBFreq[43][10] = 403; + GBFreq[42][13] = 402; + GBFreq[44][81] = 401; + GBFreq[41][47] = 400; + GBFreq[48][58] = 399; + GBFreq[43][68] = 398; + GBFreq[16][79] = 397; + GBFreq[19][5] = 396; + GBFreq[54][59] = 395; + GBFreq[17][36] = 394; + GBFreq[18][0] = 393; + GBFreq[41][5] = 392; + GBFreq[41][72] = 391; + GBFreq[16][39] = 390; + GBFreq[54][0] = 389; + GBFreq[51][16] = 388; + GBFreq[29][36] = 387; + GBFreq[47][5] = 386; + GBFreq[47][51] = 385; + GBFreq[44][7] = 384; + GBFreq[35][30] = 383; + GBFreq[26][9] = 382; + GBFreq[16][7] = 381; + GBFreq[32][1] = 380; + GBFreq[33][76] = 379; + GBFreq[34][91] = 378; + GBFreq[52][36] = 377; + GBFreq[26][77] = 376; + GBFreq[35][48] = 375; + GBFreq[40][80] = 374; + GBFreq[41][92] = 373; + GBFreq[27][93] = 372; + GBFreq[15][17] = 371; + GBFreq[16][76] = 370; + GBFreq[51][12] = 369; + GBFreq[18][20] = 368; + GBFreq[15][54] = 367; + GBFreq[50][5] = 366; + GBFreq[33][22] = 365; + GBFreq[37][57] = 364; + GBFreq[28][47] = 363; + GBFreq[42][31] = 362; + GBFreq[18][2] = 361; + GBFreq[43][64] = 360; + GBFreq[23][47] = 359; + GBFreq[28][79] = 358; + GBFreq[25][45] = 357; + GBFreq[23][91] = 356; + GBFreq[22][19] = 355; + GBFreq[25][46] = 354; + GBFreq[22][36] = 353; + GBFreq[54][85] = 352; + GBFreq[46][20] = 351; + GBFreq[27][37] = 350; + GBFreq[26][81] = 349; + GBFreq[42][29] = 348; + GBFreq[31][90] = 347; + GBFreq[41][59] = 346; + GBFreq[24][65] = 345; + GBFreq[44][84] = 344; + GBFreq[24][90] = 343; + GBFreq[38][54] = 342; + GBFreq[28][70] = 341; + GBFreq[27][15] = 340; + GBFreq[28][80] = 339; + GBFreq[29][8] = 338; + GBFreq[45][80] = 337; + GBFreq[53][37] = 336; + GBFreq[28][65] = 335; + GBFreq[23][86] = 334; + GBFreq[39][45] = 333; + GBFreq[53][32] = 332; + GBFreq[38][68] = 331; + GBFreq[45][78] = 330; + GBFreq[43][7] = 329; + GBFreq[46][82] = 328; + GBFreq[27][38] = 327; + GBFreq[16][62] = 326; + GBFreq[24][17] = 325; + GBFreq[22][70] = 324; + GBFreq[52][28] = 323; + GBFreq[23][40] = 322; + GBFreq[28][50] = 321; + GBFreq[42][91] = 320; + GBFreq[47][76] = 319; + GBFreq[15][42] = 318; + GBFreq[43][55] = 317; + GBFreq[29][84] = 316; + GBFreq[44][90] = 315; + GBFreq[53][16] = 314; + GBFreq[22][93] = 313; + GBFreq[34][10] = 312; + GBFreq[32][53] = 311; + GBFreq[43][65] = 310; + GBFreq[28][7] = 309; + GBFreq[35][46] = 308; + GBFreq[21][39] = 307; + GBFreq[44][18] = 306; + GBFreq[40][10] = 305; + GBFreq[54][53] = 304; + GBFreq[38][74] = 303; + GBFreq[28][26] = 302; + GBFreq[15][13] = 301; + GBFreq[39][34] = 300; + GBFreq[39][46] = 299; + GBFreq[42][66] = 298; + GBFreq[33][58] = 297; + GBFreq[15][56] = 296; + GBFreq[18][51] = 295; + GBFreq[49][68] = 294; + GBFreq[30][37] = 293; + GBFreq[51][84] = 292; + GBFreq[51][9] = 291; + GBFreq[40][70] = 290; + GBFreq[41][84] = 289; + GBFreq[28][64] = 288; + GBFreq[32][88] = 287; + GBFreq[24][5] = 286; + GBFreq[53][23] = 285; + GBFreq[42][27] = 284; + GBFreq[22][38] = 283; + GBFreq[32][86] = 282; + GBFreq[34][30] = 281; + GBFreq[38][63] = 280; + GBFreq[24][59] = 279; + GBFreq[22][81] = 278; + GBFreq[32][11] = 277; + GBFreq[51][21] = 276; + GBFreq[54][41] = 275; + GBFreq[21][50] = 274; + GBFreq[23][89] = 273; + GBFreq[19][87] = 272; + GBFreq[26][7] = 271; + GBFreq[30][75] = 270; + GBFreq[43][84] = 269; + GBFreq[51][25] = 268; + GBFreq[16][67] = 267; + GBFreq[32][9] = 266; + GBFreq[48][51] = 265; + GBFreq[39][7] = 264; + GBFreq[44][88] = 263; + GBFreq[52][24] = 262; + GBFreq[23][34] = 261; + GBFreq[32][75] = 260; + GBFreq[19][10] = 259; + GBFreq[28][91] = 258; + GBFreq[32][83] = 257; + GBFreq[25][75] = 256; + GBFreq[53][45] = 255; + GBFreq[29][85] = 254; + GBFreq[53][59] = 253; + GBFreq[16][2] = 252; + GBFreq[19][78] = 251; + GBFreq[15][75] = 250; + GBFreq[51][42] = 249; + GBFreq[45][67] = 248; + GBFreq[15][74] = 247; + GBFreq[25][81] = 246; + GBFreq[37][62] = 245; + GBFreq[16][55] = 244; + GBFreq[18][38] = 243; + GBFreq[23][23] = 242; + GBFreq[38][30] = 241; + GBFreq[17][28] = 240; + GBFreq[44][73] = 239; + GBFreq[23][78] = 238; + GBFreq[40][77] = 237; + GBFreq[38][87] = 236; + GBFreq[27][19] = 235; + GBFreq[38][82] = 234; + GBFreq[37][22] = 233; + GBFreq[41][30] = 232; + GBFreq[54][9] = 231; + GBFreq[32][30] = 230; + GBFreq[30][52] = 229; + GBFreq[40][84] = 228; + GBFreq[53][57] = 227; + GBFreq[27][27] = 226; + GBFreq[38][64] = 225; + GBFreq[18][43] = 224; + GBFreq[23][69] = 223; + GBFreq[28][12] = 222; + GBFreq[50][78] = 221; + GBFreq[50][1] = 220; + GBFreq[26][88] = 219; + GBFreq[36][40] = 218; + GBFreq[33][89] = 217; + GBFreq[41][28] = 216; + GBFreq[31][77] = 215; + GBFreq[46][1] = 214; + GBFreq[47][19] = 213; + GBFreq[35][55] = 212; + GBFreq[41][21] = 211; + GBFreq[27][10] = 210; + GBFreq[32][77] = 209; + GBFreq[26][37] = 208; + GBFreq[20][33] = 207; + GBFreq[41][52] = 206; + GBFreq[32][18] = 205; + GBFreq[38][13] = 204; + GBFreq[20][18] = 203; + GBFreq[20][24] = 202; + GBFreq[45][19] = 201; + GBFreq[18][53] = 200; + /* + * GBFreq[39][0] = 199; GBFreq[40][71] = 198; GBFreq[41][27] = 197; GBFreq[15][69] = 196; GBFreq[42][10] = 195; + * GBFreq[31][89] = 194; GBFreq[51][28] = 193; GBFreq[41][22] = 192; GBFreq[40][43] = 191; GBFreq[38][6] = 190; + * GBFreq[37][11] = 189; GBFreq[39][60] = 188; GBFreq[48][47] = 187; GBFreq[46][80] = 186; GBFreq[52][49] = 185; + * GBFreq[50][48] = 184; GBFreq[25][1] = 183; GBFreq[52][29] = 182; GBFreq[24][66] = 181; GBFreq[23][35] = 180; + * GBFreq[49][72] = 179; GBFreq[47][45] = 178; GBFreq[45][14] = 177; GBFreq[51][70] = 176; GBFreq[22][30] = 175; + * GBFreq[49][83] = 174; GBFreq[26][79] = 173; GBFreq[27][41] = 172; GBFreq[51][81] = 171; GBFreq[41][54] = 170; + * GBFreq[20][4] = 169; GBFreq[29][60] = 168; GBFreq[20][27] = 167; GBFreq[50][15] = 166; GBFreq[41][6] = 165; + * GBFreq[35][34] = 164; GBFreq[44][87] = 163; GBFreq[46][66] = 162; GBFreq[42][37] = 161; GBFreq[42][24] = 160; + * GBFreq[54][7] = 159; GBFreq[41][14] = 158; GBFreq[39][83] = 157; GBFreq[16][87] = 156; GBFreq[20][59] = 155; + * GBFreq[42][12] = 154; GBFreq[47][2] = 153; GBFreq[21][32] = 152; GBFreq[53][29] = 151; GBFreq[22][40] = 150; + * GBFreq[24][58] = 149; GBFreq[52][88] = 148; GBFreq[29][30] = 147; GBFreq[15][91] = 146; GBFreq[54][72] = 145; + * GBFreq[51][75] = 144; GBFreq[33][67] = 143; GBFreq[41][50] = 142; GBFreq[27][34] = 141; GBFreq[46][17] = 140; + * GBFreq[31][74] = 139; GBFreq[42][67] = 138; GBFreq[54][87] = 137; GBFreq[27][14] = 136; GBFreq[16][63] = 135; + * GBFreq[16][5] = 134; GBFreq[43][23] = 133; GBFreq[23][13] = 132; GBFreq[31][12] = 131; GBFreq[25][57] = 130; + * GBFreq[38][49] = 129; GBFreq[42][69] = 128; GBFreq[23][80] = 127; GBFreq[29][0] = 126; GBFreq[28][2] = 125; + * GBFreq[28][17] = 124; GBFreq[17][27] = 123; GBFreq[40][16] = 122; GBFreq[45][1] = 121; GBFreq[36][33] = 120; + * GBFreq[35][23] = 119; GBFreq[20][86] = 118; GBFreq[29][53] = 117; GBFreq[23][88] = 116; GBFreq[51][87] = 115; + * GBFreq[54][27] = 114; GBFreq[44][36] = 113; GBFreq[21][45] = 112; GBFreq[53][52] = 111; GBFreq[31][53] = 110; + * GBFreq[38][47] = 109; GBFreq[27][21] = 108; GBFreq[30][42] = 107; GBFreq[29][10] = 106; GBFreq[35][35] = 105; + * GBFreq[24][56] = 104; GBFreq[41][29] = 103; GBFreq[18][68] = 102; GBFreq[29][24] = 101; GBFreq[25][84] = 100; + * GBFreq[35][47] = 99; GBFreq[29][56] = 98; GBFreq[30][44] = 97; GBFreq[53][3] = 96; GBFreq[30][63] = 95; GBFreq[52][52] = + * 94; GBFreq[54][1] = 93; GBFreq[22][48] = 92; GBFreq[54][66] = 91; GBFreq[21][90] = 90; GBFreq[52][47] = 89; + * GBFreq[39][25] = 88; GBFreq[39][39] = 87; GBFreq[44][37] = 86; GBFreq[44][76] = 85; GBFreq[46][75] = 84; GBFreq[18][37] = + * 83; GBFreq[47][42] = 82; GBFreq[19][92] = 81; GBFreq[51][27] = 80; GBFreq[48][83] = 79; GBFreq[23][70] = 78; + * GBFreq[29][9] = 77; GBFreq[33][79] = 76; GBFreq[52][90] = 75; GBFreq[53][6] = 74; GBFreq[24][36] = 73; GBFreq[25][25] = + * 72; GBFreq[44][26] = 71; GBFreq[25][36] = 70; GBFreq[29][87] = 69; GBFreq[48][0] = 68; GBFreq[15][40] = 67; + * GBFreq[17][45] = 66; GBFreq[30][14] = 65; GBFreq[48][38] = 64; GBFreq[23][19] = 63; GBFreq[40][42] = 62; GBFreq[31][63] = + * 61; GBFreq[16][23] = 60; GBFreq[26][21] = 59; GBFreq[32][76] = 58; GBFreq[23][58] = 57; GBFreq[41][37] = 56; + * GBFreq[30][43] = 55; GBFreq[47][38] = 54; GBFreq[21][46] = 53; GBFreq[18][33] = 52; GBFreq[52][37] = 51; GBFreq[36][8] = + * 50; GBFreq[49][24] = 49; GBFreq[15][66] = 48; GBFreq[35][77] = 47; GBFreq[27][58] = 46; GBFreq[35][51] = 45; + * GBFreq[24][69] = 44; GBFreq[20][54] = 43; GBFreq[24][41] = 42; GBFreq[41][0] = 41; GBFreq[33][71] = 40; GBFreq[23][52] = + * 39; GBFreq[29][67] = 38; GBFreq[46][51] = 37; GBFreq[46][90] = 36; GBFreq[49][33] = 35; GBFreq[33][28] = 34; + * GBFreq[37][86] = 33; GBFreq[39][22] = 32; GBFreq[37][37] = 31; GBFreq[29][62] = 30; GBFreq[29][50] = 29; GBFreq[36][89] = + * 28; GBFreq[42][44] = 27; GBFreq[51][82] = 26; GBFreq[28][83] = 25; GBFreq[15][78] = 24; GBFreq[46][62] = 23; + * GBFreq[19][69] = 22; GBFreq[51][23] = 21; GBFreq[37][69] = 20; GBFreq[25][5] = 19; GBFreq[51][85] = 18; GBFreq[48][77] = + * 17; GBFreq[32][46] = 16; GBFreq[53][60] = 15; GBFreq[28][57] = 14; GBFreq[54][82] = 13; GBFreq[54][15] = 12; + * GBFreq[49][54] = 11; GBFreq[53][87] = 10; GBFreq[27][16] = 9; GBFreq[29][34] = 8; GBFreq[20][44] = 7; GBFreq[42][73] = 6; + * GBFreq[47][71] = 5; GBFreq[29][37] = 4; GBFreq[25][50] = 3; GBFreq[18][84] = 2; GBFreq[50][45] = 1; GBFreq[48][46] = 0; + */ + // GBFreq[43][89] = -1; GBFreq[54][68] = -2; + Big5Freq[9][89] = 600; + Big5Freq[11][15] = 599; + Big5Freq[3][66] = 598; + Big5Freq[6][121] = 597; + Big5Freq[3][0] = 596; + Big5Freq[5][82] = 595; + Big5Freq[3][42] = 594; + Big5Freq[5][34] = 593; + Big5Freq[3][8] = 592; + Big5Freq[3][6] = 591; + Big5Freq[3][67] = 590; + Big5Freq[7][139] = 589; + Big5Freq[23][137] = 588; + Big5Freq[12][46] = 587; + Big5Freq[4][8] = 586; + Big5Freq[4][41] = 585; + Big5Freq[18][47] = 584; + Big5Freq[12][114] = 583; + Big5Freq[6][1] = 582; + Big5Freq[22][60] = 581; + Big5Freq[5][46] = 580; + Big5Freq[11][79] = 579; + Big5Freq[3][23] = 578; + Big5Freq[7][114] = 577; + Big5Freq[29][102] = 576; + Big5Freq[19][14] = 575; + Big5Freq[4][133] = 574; + Big5Freq[3][29] = 573; + Big5Freq[4][109] = 572; + Big5Freq[14][127] = 571; + Big5Freq[5][48] = 570; + Big5Freq[13][104] = 569; + Big5Freq[3][132] = 568; + Big5Freq[26][64] = 567; + Big5Freq[7][19] = 566; + Big5Freq[4][12] = 565; + Big5Freq[11][124] = 564; + Big5Freq[7][89] = 563; + Big5Freq[15][124] = 562; + Big5Freq[4][108] = 561; + Big5Freq[19][66] = 560; + Big5Freq[3][21] = 559; + Big5Freq[24][12] = 558; + Big5Freq[28][111] = 557; + Big5Freq[12][107] = 556; + Big5Freq[3][112] = 555; + Big5Freq[8][113] = 554; + Big5Freq[5][40] = 553; + Big5Freq[26][145] = 552; + Big5Freq[3][48] = 551; + Big5Freq[3][70] = 550; + Big5Freq[22][17] = 549; + Big5Freq[16][47] = 548; + Big5Freq[3][53] = 547; + Big5Freq[4][24] = 546; + Big5Freq[32][120] = 545; + Big5Freq[24][49] = 544; + Big5Freq[24][142] = 543; + Big5Freq[18][66] = 542; + Big5Freq[29][150] = 541; + Big5Freq[5][122] = 540; + Big5Freq[5][114] = 539; + Big5Freq[3][44] = 538; + Big5Freq[10][128] = 537; + Big5Freq[15][20] = 536; + Big5Freq[13][33] = 535; + Big5Freq[14][87] = 534; + Big5Freq[3][126] = 533; + Big5Freq[4][53] = 532; + Big5Freq[4][40] = 531; + Big5Freq[9][93] = 530; + Big5Freq[15][137] = 529; + Big5Freq[10][123] = 528; + Big5Freq[4][56] = 527; + Big5Freq[5][71] = 526; + Big5Freq[10][8] = 525; + Big5Freq[5][16] = 524; + Big5Freq[5][146] = 523; + Big5Freq[18][88] = 522; + Big5Freq[24][4] = 521; + Big5Freq[20][47] = 520; + Big5Freq[5][33] = 519; + Big5Freq[9][43] = 518; + Big5Freq[20][12] = 517; + Big5Freq[20][13] = 516; + Big5Freq[5][156] = 515; + Big5Freq[22][140] = 514; + Big5Freq[8][146] = 513; + Big5Freq[21][123] = 512; + Big5Freq[4][90] = 511; + Big5Freq[5][62] = 510; + Big5Freq[17][59] = 509; + Big5Freq[10][37] = 508; + Big5Freq[18][107] = 507; + Big5Freq[14][53] = 506; + Big5Freq[22][51] = 505; + Big5Freq[8][13] = 504; + Big5Freq[5][29] = 503; + Big5Freq[9][7] = 502; + Big5Freq[22][14] = 501; + Big5Freq[8][55] = 500; + Big5Freq[33][9] = 499; + Big5Freq[16][64] = 498; + Big5Freq[7][131] = 497; + Big5Freq[34][4] = 496; + Big5Freq[7][101] = 495; + Big5Freq[11][139] = 494; + Big5Freq[3][135] = 493; + Big5Freq[7][102] = 492; + Big5Freq[17][13] = 491; + Big5Freq[3][20] = 490; + Big5Freq[27][106] = 489; + Big5Freq[5][88] = 488; + Big5Freq[6][33] = 487; + Big5Freq[5][139] = 486; + Big5Freq[6][0] = 485; + Big5Freq[17][58] = 484; + Big5Freq[5][133] = 483; + Big5Freq[9][107] = 482; + Big5Freq[23][39] = 481; + Big5Freq[5][23] = 480; + Big5Freq[3][79] = 479; + Big5Freq[32][97] = 478; + Big5Freq[3][136] = 477; + Big5Freq[4][94] = 476; + Big5Freq[21][61] = 475; + Big5Freq[23][123] = 474; + Big5Freq[26][16] = 473; + Big5Freq[24][137] = 472; + Big5Freq[22][18] = 471; + Big5Freq[5][1] = 470; + Big5Freq[20][119] = 469; + Big5Freq[3][7] = 468; + Big5Freq[10][79] = 467; + Big5Freq[15][105] = 466; + Big5Freq[3][144] = 465; + Big5Freq[12][80] = 464; + Big5Freq[15][73] = 463; + Big5Freq[3][19] = 462; + Big5Freq[8][109] = 461; + Big5Freq[3][15] = 460; + Big5Freq[31][82] = 459; + Big5Freq[3][43] = 458; + Big5Freq[25][119] = 457; + Big5Freq[16][111] = 456; + Big5Freq[7][77] = 455; + Big5Freq[3][95] = 454; + Big5Freq[24][82] = 453; + Big5Freq[7][52] = 452; + Big5Freq[9][151] = 451; + Big5Freq[3][129] = 450; + Big5Freq[5][87] = 449; + Big5Freq[3][55] = 448; + Big5Freq[8][153] = 447; + Big5Freq[4][83] = 446; + Big5Freq[3][114] = 445; + Big5Freq[23][147] = 444; + Big5Freq[15][31] = 443; + Big5Freq[3][54] = 442; + Big5Freq[11][122] = 441; + Big5Freq[4][4] = 440; + Big5Freq[34][149] = 439; + Big5Freq[3][17] = 438; + Big5Freq[21][64] = 437; + Big5Freq[26][144] = 436; + Big5Freq[4][62] = 435; + Big5Freq[8][15] = 434; + Big5Freq[35][80] = 433; + Big5Freq[7][110] = 432; + Big5Freq[23][114] = 431; + Big5Freq[3][108] = 430; + Big5Freq[3][62] = 429; + Big5Freq[21][41] = 428; + Big5Freq[15][99] = 427; + Big5Freq[5][47] = 426; + Big5Freq[4][96] = 425; + Big5Freq[20][122] = 424; + Big5Freq[5][21] = 423; + Big5Freq[4][157] = 422; + Big5Freq[16][14] = 421; + Big5Freq[3][117] = 420; + Big5Freq[7][129] = 419; + Big5Freq[4][27] = 418; + Big5Freq[5][30] = 417; + Big5Freq[22][16] = 416; + Big5Freq[5][64] = 415; + Big5Freq[17][99] = 414; + Big5Freq[17][57] = 413; + Big5Freq[8][105] = 412; + Big5Freq[5][112] = 411; + Big5Freq[20][59] = 410; + Big5Freq[6][129] = 409; + Big5Freq[18][17] = 408; + Big5Freq[3][92] = 407; + Big5Freq[28][118] = 406; + Big5Freq[3][109] = 405; + Big5Freq[31][51] = 404; + Big5Freq[13][116] = 403; + Big5Freq[6][15] = 402; + Big5Freq[36][136] = 401; + Big5Freq[12][74] = 400; + Big5Freq[20][88] = 399; + Big5Freq[36][68] = 398; + Big5Freq[3][147] = 397; + Big5Freq[15][84] = 396; + Big5Freq[16][32] = 395; + Big5Freq[16][58] = 394; + Big5Freq[7][66] = 393; + Big5Freq[23][107] = 392; + Big5Freq[9][6] = 391; + Big5Freq[12][86] = 390; + Big5Freq[23][112] = 389; + Big5Freq[37][23] = 388; + Big5Freq[3][138] = 387; + Big5Freq[20][68] = 386; + Big5Freq[15][116] = 385; + Big5Freq[18][64] = 384; + Big5Freq[12][139] = 383; + Big5Freq[11][155] = 382; + Big5Freq[4][156] = 381; + Big5Freq[12][84] = 380; + Big5Freq[18][49] = 379; + Big5Freq[25][125] = 378; + Big5Freq[25][147] = 377; + Big5Freq[15][110] = 376; + Big5Freq[19][96] = 375; + Big5Freq[30][152] = 374; + Big5Freq[6][31] = 373; + Big5Freq[27][117] = 372; + Big5Freq[3][10] = 371; + Big5Freq[6][131] = 370; + Big5Freq[13][112] = 369; + Big5Freq[36][156] = 368; + Big5Freq[4][60] = 367; + Big5Freq[15][121] = 366; + Big5Freq[4][112] = 365; + Big5Freq[30][142] = 364; + Big5Freq[23][154] = 363; + Big5Freq[27][101] = 362; + Big5Freq[9][140] = 361; + Big5Freq[3][89] = 360; + Big5Freq[18][148] = 359; + Big5Freq[4][69] = 358; + Big5Freq[16][49] = 357; + Big5Freq[6][117] = 356; + Big5Freq[36][55] = 355; + Big5Freq[5][123] = 354; + Big5Freq[4][126] = 353; + Big5Freq[4][119] = 352; + Big5Freq[9][95] = 351; + Big5Freq[5][24] = 350; + Big5Freq[16][133] = 349; + Big5Freq[10][134] = 348; + Big5Freq[26][59] = 347; + Big5Freq[6][41] = 346; + Big5Freq[6][146] = 345; + Big5Freq[19][24] = 344; + Big5Freq[5][113] = 343; + Big5Freq[10][118] = 342; + Big5Freq[34][151] = 341; + Big5Freq[9][72] = 340; + Big5Freq[31][25] = 339; + Big5Freq[18][126] = 338; + Big5Freq[18][28] = 337; + Big5Freq[4][153] = 336; + Big5Freq[3][84] = 335; + Big5Freq[21][18] = 334; + Big5Freq[25][129] = 333; + Big5Freq[6][107] = 332; + Big5Freq[12][25] = 331; + Big5Freq[17][109] = 330; + Big5Freq[7][76] = 329; + Big5Freq[15][15] = 328; + Big5Freq[4][14] = 327; + Big5Freq[23][88] = 326; + Big5Freq[18][2] = 325; + Big5Freq[6][88] = 324; + Big5Freq[16][84] = 323; + Big5Freq[12][48] = 322; + Big5Freq[7][68] = 321; + Big5Freq[5][50] = 320; + Big5Freq[13][54] = 319; + Big5Freq[7][98] = 318; + Big5Freq[11][6] = 317; + Big5Freq[9][80] = 316; + Big5Freq[16][41] = 315; + Big5Freq[7][43] = 314; + Big5Freq[28][117] = 313; + Big5Freq[3][51] = 312; + Big5Freq[7][3] = 311; + Big5Freq[20][81] = 310; + Big5Freq[4][2] = 309; + Big5Freq[11][16] = 308; + Big5Freq[10][4] = 307; + Big5Freq[10][119] = 306; + Big5Freq[6][142] = 305; + Big5Freq[18][51] = 304; + Big5Freq[8][144] = 303; + Big5Freq[10][65] = 302; + Big5Freq[11][64] = 301; + Big5Freq[11][130] = 300; + Big5Freq[9][92] = 299; + Big5Freq[18][29] = 298; + Big5Freq[18][78] = 297; + Big5Freq[18][151] = 296; + Big5Freq[33][127] = 295; + Big5Freq[35][113] = 294; + Big5Freq[10][155] = 293; + Big5Freq[3][76] = 292; + Big5Freq[36][123] = 291; + Big5Freq[13][143] = 290; + Big5Freq[5][135] = 289; + Big5Freq[23][116] = 288; + Big5Freq[6][101] = 287; + Big5Freq[14][74] = 286; + Big5Freq[7][153] = 285; + Big5Freq[3][101] = 284; + Big5Freq[9][74] = 283; + Big5Freq[3][156] = 282; + Big5Freq[4][147] = 281; + Big5Freq[9][12] = 280; + Big5Freq[18][133] = 279; + Big5Freq[4][0] = 278; + Big5Freq[7][155] = 277; + Big5Freq[9][144] = 276; + Big5Freq[23][49] = 275; + Big5Freq[5][89] = 274; + Big5Freq[10][11] = 273; + Big5Freq[3][110] = 272; + Big5Freq[3][40] = 271; + Big5Freq[29][115] = 270; + Big5Freq[9][100] = 269; + Big5Freq[21][67] = 268; + Big5Freq[23][145] = 267; + Big5Freq[10][47] = 266; + Big5Freq[4][31] = 265; + Big5Freq[4][81] = 264; + Big5Freq[22][62] = 263; + Big5Freq[4][28] = 262; + Big5Freq[27][39] = 261; + Big5Freq[27][54] = 260; + Big5Freq[32][46] = 259; + Big5Freq[4][76] = 258; + Big5Freq[26][15] = 257; + Big5Freq[12][154] = 256; + Big5Freq[9][150] = 255; + Big5Freq[15][17] = 254; + Big5Freq[5][129] = 253; + Big5Freq[10][40] = 252; + Big5Freq[13][37] = 251; + Big5Freq[31][104] = 250; + Big5Freq[3][152] = 249; + Big5Freq[5][22] = 248; + Big5Freq[8][48] = 247; + Big5Freq[4][74] = 246; + Big5Freq[6][17] = 245; + Big5Freq[30][82] = 244; + Big5Freq[4][116] = 243; + Big5Freq[16][42] = 242; + Big5Freq[5][55] = 241; + Big5Freq[4][64] = 240; + Big5Freq[14][19] = 239; + Big5Freq[35][82] = 238; + Big5Freq[30][139] = 237; + Big5Freq[26][152] = 236; + Big5Freq[32][32] = 235; + Big5Freq[21][102] = 234; + Big5Freq[10][131] = 233; + Big5Freq[9][128] = 232; + Big5Freq[3][87] = 231; + Big5Freq[4][51] = 230; + Big5Freq[10][15] = 229; + Big5Freq[4][150] = 228; + Big5Freq[7][4] = 227; + Big5Freq[7][51] = 226; + Big5Freq[7][157] = 225; + Big5Freq[4][146] = 224; + Big5Freq[4][91] = 223; + Big5Freq[7][13] = 222; + Big5Freq[17][116] = 221; + Big5Freq[23][21] = 220; + Big5Freq[5][106] = 219; + Big5Freq[14][100] = 218; + Big5Freq[10][152] = 217; + Big5Freq[14][89] = 216; + Big5Freq[6][138] = 215; + Big5Freq[12][157] = 214; + Big5Freq[10][102] = 213; + Big5Freq[19][94] = 212; + Big5Freq[7][74] = 211; + Big5Freq[18][128] = 210; + Big5Freq[27][111] = 209; + Big5Freq[11][57] = 208; + Big5Freq[3][131] = 207; + Big5Freq[30][23] = 206; + Big5Freq[30][126] = 205; + Big5Freq[4][36] = 204; + Big5Freq[26][124] = 203; + Big5Freq[4][19] = 202; + Big5Freq[9][152] = 201; + /* + * Big5Freq[5][0] = 200; Big5Freq[26][57] = 199; Big5Freq[13][155] = 198; Big5Freq[3][38] = 197; Big5Freq[9][155] = 196; + * Big5Freq[28][53] = 195; Big5Freq[15][71] = 194; Big5Freq[21][95] = 193; Big5Freq[15][112] = 192; Big5Freq[14][138] = 191; + * Big5Freq[8][18] = 190; Big5Freq[20][151] = 189; Big5Freq[37][27] = 188; Big5Freq[32][48] = 187; Big5Freq[23][66] = 186; + * Big5Freq[9][2] = 185; Big5Freq[13][133] = 184; Big5Freq[7][127] = 183; Big5Freq[3][11] = 182; Big5Freq[12][118] = 181; + * Big5Freq[13][101] = 180; Big5Freq[30][153] = 179; Big5Freq[4][65] = 178; Big5Freq[5][25] = 177; Big5Freq[5][140] = 176; + * Big5Freq[6][25] = 175; Big5Freq[4][52] = 174; Big5Freq[30][156] = 173; Big5Freq[16][13] = 172; Big5Freq[21][8] = 171; + * Big5Freq[19][74] = 170; Big5Freq[15][145] = 169; Big5Freq[9][15] = 168; Big5Freq[13][82] = 167; Big5Freq[26][86] = 166; + * Big5Freq[18][52] = 165; Big5Freq[6][109] = 164; Big5Freq[10][99] = 163; Big5Freq[18][101] = 162; Big5Freq[25][49] = 161; + * Big5Freq[31][79] = 160; Big5Freq[28][20] = 159; Big5Freq[12][115] = 158; Big5Freq[15][66] = 157; Big5Freq[11][104] = 156; + * Big5Freq[23][106] = 155; Big5Freq[34][157] = 154; Big5Freq[32][94] = 153; Big5Freq[29][88] = 152; Big5Freq[10][46] = 151; + * Big5Freq[13][118] = 150; Big5Freq[20][37] = 149; Big5Freq[12][30] = 148; Big5Freq[21][4] = 147; Big5Freq[16][33] = 146; + * Big5Freq[13][52] = 145; Big5Freq[4][7] = 144; Big5Freq[21][49] = 143; Big5Freq[3][27] = 142; Big5Freq[16][91] = 141; + * Big5Freq[5][155] = 140; Big5Freq[29][130] = 139; Big5Freq[3][125] = 138; Big5Freq[14][26] = 137; Big5Freq[15][39] = 136; + * Big5Freq[24][110] = 135; Big5Freq[7][141] = 134; Big5Freq[21][15] = 133; Big5Freq[32][104] = 132; Big5Freq[8][31] = 131; + * Big5Freq[34][112] = 130; Big5Freq[10][75] = 129; Big5Freq[21][23] = 128; Big5Freq[34][131] = 127; Big5Freq[12][3] = 126; + * Big5Freq[10][62] = 125; Big5Freq[9][120] = 124; Big5Freq[32][149] = 123; Big5Freq[8][44] = 122; Big5Freq[24][2] = 121; + * Big5Freq[6][148] = 120; Big5Freq[15][103] = 119; Big5Freq[36][54] = 118; Big5Freq[36][134] = 117; Big5Freq[11][7] = 116; + * Big5Freq[3][90] = 115; Big5Freq[36][73] = 114; Big5Freq[8][102] = 113; Big5Freq[12][87] = 112; Big5Freq[25][64] = 111; + * Big5Freq[9][1] = 110; Big5Freq[24][121] = 109; Big5Freq[5][75] = 108; Big5Freq[17][83] = 107; Big5Freq[18][57] = 106; + * Big5Freq[8][95] = 105; Big5Freq[14][36] = 104; Big5Freq[28][113] = 103; Big5Freq[12][56] = 102; Big5Freq[14][61] = 101; + * Big5Freq[25][138] = 100; Big5Freq[4][34] = 99; Big5Freq[11][152] = 98; Big5Freq[35][0] = 97; Big5Freq[4][15] = 96; + * Big5Freq[8][82] = 95; Big5Freq[20][73] = 94; Big5Freq[25][52] = 93; Big5Freq[24][6] = 92; Big5Freq[21][78] = 91; + * Big5Freq[17][32] = 90; Big5Freq[17][91] = 89; Big5Freq[5][76] = 88; Big5Freq[15][60] = 87; Big5Freq[15][150] = 86; + * Big5Freq[5][80] = 85; Big5Freq[15][81] = 84; Big5Freq[28][108] = 83; Big5Freq[18][14] = 82; Big5Freq[19][109] = 81; + * Big5Freq[28][133] = 80; Big5Freq[21][97] = 79; Big5Freq[5][105] = 78; Big5Freq[18][114] = 77; Big5Freq[16][95] = 76; + * Big5Freq[5][51] = 75; Big5Freq[3][148] = 74; Big5Freq[22][102] = 73; Big5Freq[4][123] = 72; Big5Freq[8][88] = 71; + * Big5Freq[25][111] = 70; Big5Freq[8][149] = 69; Big5Freq[9][48] = 68; Big5Freq[16][126] = 67; Big5Freq[33][150] = 66; + * Big5Freq[9][54] = 65; Big5Freq[29][104] = 64; Big5Freq[3][3] = 63; Big5Freq[11][49] = 62; Big5Freq[24][109] = 61; + * Big5Freq[28][116] = 60; Big5Freq[34][113] = 59; Big5Freq[5][3] = 58; Big5Freq[21][106] = 57; Big5Freq[4][98] = 56; + * Big5Freq[12][135] = 55; Big5Freq[16][101] = 54; Big5Freq[12][147] = 53; Big5Freq[27][55] = 52; Big5Freq[3][5] = 51; + * Big5Freq[11][101] = 50; Big5Freq[16][157] = 49; Big5Freq[22][114] = 48; Big5Freq[18][46] = 47; Big5Freq[4][29] = 46; + * Big5Freq[8][103] = 45; Big5Freq[16][151] = 44; Big5Freq[8][29] = 43; Big5Freq[15][114] = 42; Big5Freq[22][70] = 41; + * Big5Freq[13][121] = 40; Big5Freq[7][112] = 39; Big5Freq[20][83] = 38; Big5Freq[3][36] = 37; Big5Freq[10][103] = 36; + * Big5Freq[3][96] = 35; Big5Freq[21][79] = 34; Big5Freq[25][120] = 33; Big5Freq[29][121] = 32; Big5Freq[23][71] = 31; + * Big5Freq[21][22] = 30; Big5Freq[18][89] = 29; Big5Freq[25][104] = 28; Big5Freq[10][124] = 27; Big5Freq[26][4] = 26; + * Big5Freq[21][136] = 25; Big5Freq[6][112] = 24; Big5Freq[12][103] = 23; Big5Freq[17][66] = 22; Big5Freq[13][151] = 21; + * Big5Freq[33][152] = 20; Big5Freq[11][148] = 19; Big5Freq[13][57] = 18; Big5Freq[13][41] = 17; Big5Freq[7][60] = 16; + * Big5Freq[21][29] = 15; Big5Freq[9][157] = 14; Big5Freq[24][95] = 13; Big5Freq[15][148] = 12; Big5Freq[15][122] = 11; + * Big5Freq[6][125] = 10; Big5Freq[11][25] = 9; Big5Freq[20][55] = 8; Big5Freq[19][84] = 7; Big5Freq[21][82] = 6; + * Big5Freq[24][3] = 5; Big5Freq[13][70] = 4; Big5Freq[6][21] = 3; Big5Freq[21][86] = 2; Big5Freq[12][23] = 1; + * Big5Freq[3][85] = 0; EUC_TWFreq[45][90] = 600; + */ + Big5PFreq[41][122] = 600; + Big5PFreq[35][0] = 599; + Big5PFreq[43][15] = 598; + Big5PFreq[35][99] = 597; + Big5PFreq[35][6] = 596; + Big5PFreq[35][8] = 595; + Big5PFreq[38][154] = 594; + Big5PFreq[37][34] = 593; + Big5PFreq[37][115] = 592; + Big5PFreq[36][12] = 591; + Big5PFreq[18][77] = 590; + Big5PFreq[35][100] = 589; + Big5PFreq[35][42] = 588; + Big5PFreq[120][75] = 587; + Big5PFreq[35][23] = 586; + Big5PFreq[13][72] = 585; + Big5PFreq[0][67] = 584; + Big5PFreq[39][172] = 583; + Big5PFreq[22][182] = 582; + Big5PFreq[15][186] = 581; + Big5PFreq[15][165] = 580; + Big5PFreq[35][44] = 579; + Big5PFreq[40][13] = 578; + Big5PFreq[38][1] = 577; + Big5PFreq[37][33] = 576; + Big5PFreq[36][24] = 575; + Big5PFreq[56][4] = 574; + Big5PFreq[35][29] = 573; + Big5PFreq[9][96] = 572; + Big5PFreq[37][62] = 571; + Big5PFreq[48][47] = 570; + Big5PFreq[51][14] = 569; + Big5PFreq[39][122] = 568; + Big5PFreq[44][46] = 567; + Big5PFreq[35][21] = 566; + Big5PFreq[36][8] = 565; + Big5PFreq[36][141] = 564; + Big5PFreq[3][81] = 563; + Big5PFreq[37][155] = 562; + Big5PFreq[42][84] = 561; + Big5PFreq[36][40] = 560; + Big5PFreq[35][103] = 559; + Big5PFreq[11][84] = 558; + Big5PFreq[45][33] = 557; + Big5PFreq[121][79] = 556; + Big5PFreq[2][77] = 555; + Big5PFreq[36][41] = 554; + Big5PFreq[37][47] = 553; + Big5PFreq[39][125] = 552; + Big5PFreq[37][26] = 551; + Big5PFreq[35][48] = 550; + Big5PFreq[35][28] = 549; + Big5PFreq[35][159] = 548; + Big5PFreq[37][40] = 547; + Big5PFreq[35][145] = 546; + Big5PFreq[37][147] = 545; + Big5PFreq[46][160] = 544; + Big5PFreq[37][46] = 543; + Big5PFreq[50][99] = 542; + Big5PFreq[52][13] = 541; + Big5PFreq[10][82] = 540; + Big5PFreq[35][169] = 539; + Big5PFreq[35][31] = 538; + Big5PFreq[47][31] = 537; + Big5PFreq[18][79] = 536; + Big5PFreq[16][113] = 535; + Big5PFreq[37][104] = 534; + Big5PFreq[39][134] = 533; + Big5PFreq[36][53] = 532; + Big5PFreq[38][0] = 531; + Big5PFreq[4][86] = 530; + Big5PFreq[54][17] = 529; + Big5PFreq[43][157] = 528; + Big5PFreq[35][165] = 527; + Big5PFreq[69][147] = 526; + Big5PFreq[117][95] = 525; + Big5PFreq[35][162] = 524; + Big5PFreq[35][17] = 523; + Big5PFreq[36][142] = 522; + Big5PFreq[36][4] = 521; + Big5PFreq[37][166] = 520; + Big5PFreq[35][168] = 519; + Big5PFreq[35][19] = 518; + Big5PFreq[37][48] = 517; + Big5PFreq[42][37] = 516; + Big5PFreq[40][146] = 515; + Big5PFreq[36][123] = 514; + Big5PFreq[22][41] = 513; + Big5PFreq[20][119] = 512; + Big5PFreq[2][74] = 511; + Big5PFreq[44][113] = 510; + Big5PFreq[35][125] = 509; + Big5PFreq[37][16] = 508; + Big5PFreq[35][20] = 507; + Big5PFreq[35][55] = 506; + Big5PFreq[37][145] = 505; + Big5PFreq[0][88] = 504; + Big5PFreq[3][94] = 503; + Big5PFreq[6][65] = 502; + Big5PFreq[26][15] = 501; + Big5PFreq[41][126] = 500; + Big5PFreq[36][129] = 499; + Big5PFreq[31][75] = 498; + Big5PFreq[19][61] = 497; + Big5PFreq[35][128] = 496; + Big5PFreq[29][79] = 495; + Big5PFreq[36][62] = 494; + Big5PFreq[37][189] = 493; + Big5PFreq[39][109] = 492; + Big5PFreq[39][135] = 491; + Big5PFreq[72][15] = 490; + Big5PFreq[47][106] = 489; + Big5PFreq[54][14] = 488; + Big5PFreq[24][52] = 487; + Big5PFreq[38][162] = 486; + Big5PFreq[41][43] = 485; + Big5PFreq[37][121] = 484; + Big5PFreq[14][66] = 483; + Big5PFreq[37][30] = 482; + Big5PFreq[35][7] = 481; + Big5PFreq[49][58] = 480; + Big5PFreq[43][188] = 479; + Big5PFreq[24][66] = 478; + Big5PFreq[35][171] = 477; + Big5PFreq[40][186] = 476; + Big5PFreq[39][164] = 475; + Big5PFreq[78][186] = 474; + Big5PFreq[8][72] = 473; + Big5PFreq[36][190] = 472; + Big5PFreq[35][53] = 471; + Big5PFreq[35][54] = 470; + Big5PFreq[22][159] = 469; + Big5PFreq[35][9] = 468; + Big5PFreq[41][140] = 467; + Big5PFreq[37][22] = 466; + Big5PFreq[48][97] = 465; + Big5PFreq[50][97] = 464; + Big5PFreq[36][127] = 463; + Big5PFreq[37][23] = 462; + Big5PFreq[40][55] = 461; + Big5PFreq[35][43] = 460; + Big5PFreq[26][22] = 459; + Big5PFreq[35][15] = 458; + Big5PFreq[72][179] = 457; + Big5PFreq[20][129] = 456; + Big5PFreq[52][101] = 455; + Big5PFreq[35][12] = 454; + Big5PFreq[42][156] = 453; + Big5PFreq[15][157] = 452; + Big5PFreq[50][140] = 451; + Big5PFreq[26][28] = 450; + Big5PFreq[54][51] = 449; + Big5PFreq[35][112] = 448; + Big5PFreq[36][116] = 447; + Big5PFreq[42][11] = 446; + Big5PFreq[37][172] = 445; + Big5PFreq[37][29] = 444; + Big5PFreq[44][107] = 443; + Big5PFreq[50][17] = 442; + Big5PFreq[39][107] = 441; + Big5PFreq[19][109] = 440; + Big5PFreq[36][60] = 439; + Big5PFreq[49][132] = 438; + Big5PFreq[26][16] = 437; + Big5PFreq[43][155] = 436; + Big5PFreq[37][120] = 435; + Big5PFreq[15][159] = 434; + Big5PFreq[43][6] = 433; + Big5PFreq[45][188] = 432; + Big5PFreq[35][38] = 431; + Big5PFreq[39][143] = 430; + Big5PFreq[48][144] = 429; + Big5PFreq[37][168] = 428; + Big5PFreq[37][1] = 427; + Big5PFreq[36][109] = 426; + Big5PFreq[46][53] = 425; + Big5PFreq[38][54] = 424; + Big5PFreq[36][0] = 423; + Big5PFreq[72][33] = 422; + Big5PFreq[42][8] = 421; + Big5PFreq[36][31] = 420; + Big5PFreq[35][150] = 419; + Big5PFreq[118][93] = 418; + Big5PFreq[37][61] = 417; + Big5PFreq[0][85] = 416; + Big5PFreq[36][27] = 415; + Big5PFreq[35][134] = 414; + Big5PFreq[36][145] = 413; + Big5PFreq[6][96] = 412; + Big5PFreq[36][14] = 411; + Big5PFreq[16][36] = 410; + Big5PFreq[15][175] = 409; + Big5PFreq[35][10] = 408; + Big5PFreq[36][189] = 407; + Big5PFreq[35][51] = 406; + Big5PFreq[35][109] = 405; + Big5PFreq[35][147] = 404; + Big5PFreq[35][180] = 403; + Big5PFreq[72][5] = 402; + Big5PFreq[36][107] = 401; + Big5PFreq[49][116] = 400; + Big5PFreq[73][30] = 399; + Big5PFreq[6][90] = 398; + Big5PFreq[2][70] = 397; + Big5PFreq[17][141] = 396; + Big5PFreq[35][62] = 395; + Big5PFreq[16][180] = 394; + Big5PFreq[4][91] = 393; + Big5PFreq[15][171] = 392; + Big5PFreq[35][177] = 391; + Big5PFreq[37][173] = 390; + Big5PFreq[16][121] = 389; + Big5PFreq[35][5] = 388; + Big5PFreq[46][122] = 387; + Big5PFreq[40][138] = 386; + Big5PFreq[50][49] = 385; + Big5PFreq[36][152] = 384; + Big5PFreq[13][43] = 383; + Big5PFreq[9][88] = 382; + Big5PFreq[36][159] = 381; + Big5PFreq[27][62] = 380; + Big5PFreq[40][18] = 379; + Big5PFreq[17][129] = 378; + Big5PFreq[43][97] = 377; + Big5PFreq[13][131] = 376; + Big5PFreq[46][107] = 375; + Big5PFreq[60][64] = 374; + Big5PFreq[36][179] = 373; + Big5PFreq[37][55] = 372; + Big5PFreq[41][173] = 371; + Big5PFreq[44][172] = 370; + Big5PFreq[23][187] = 369; + Big5PFreq[36][149] = 368; + Big5PFreq[17][125] = 367; + Big5PFreq[55][180] = 366; + Big5PFreq[51][129] = 365; + Big5PFreq[36][51] = 364; + Big5PFreq[37][122] = 363; + Big5PFreq[48][32] = 362; + Big5PFreq[51][99] = 361; + Big5PFreq[54][16] = 360; + Big5PFreq[41][183] = 359; + Big5PFreq[37][179] = 358; + Big5PFreq[38][179] = 357; + Big5PFreq[35][143] = 356; + Big5PFreq[37][24] = 355; + Big5PFreq[40][177] = 354; + Big5PFreq[47][117] = 353; + Big5PFreq[39][52] = 352; + Big5PFreq[22][99] = 351; + Big5PFreq[40][142] = 350; + Big5PFreq[36][49] = 349; + Big5PFreq[38][17] = 348; + Big5PFreq[39][188] = 347; + Big5PFreq[36][186] = 346; + Big5PFreq[35][189] = 345; + Big5PFreq[41][7] = 344; + Big5PFreq[18][91] = 343; + Big5PFreq[43][137] = 342; + Big5PFreq[35][142] = 341; + Big5PFreq[35][117] = 340; + Big5PFreq[39][138] = 339; + Big5PFreq[16][59] = 338; + Big5PFreq[39][174] = 337; + Big5PFreq[55][145] = 336; + Big5PFreq[37][21] = 335; + Big5PFreq[36][180] = 334; + Big5PFreq[37][156] = 333; + Big5PFreq[49][13] = 332; + Big5PFreq[41][107] = 331; + Big5PFreq[36][56] = 330; + Big5PFreq[53][8] = 329; + Big5PFreq[22][114] = 328; + Big5PFreq[5][95] = 327; + Big5PFreq[37][0] = 326; + Big5PFreq[26][183] = 325; + Big5PFreq[22][66] = 324; + Big5PFreq[35][58] = 323; + Big5PFreq[48][117] = 322; + Big5PFreq[36][102] = 321; + Big5PFreq[22][122] = 320; + Big5PFreq[35][11] = 319; + Big5PFreq[46][19] = 318; + Big5PFreq[22][49] = 317; + Big5PFreq[48][166] = 316; + Big5PFreq[41][125] = 315; + Big5PFreq[41][1] = 314; + Big5PFreq[35][178] = 313; + Big5PFreq[41][12] = 312; + Big5PFreq[26][167] = 311; + Big5PFreq[42][152] = 310; + Big5PFreq[42][46] = 309; + Big5PFreq[42][151] = 308; + Big5PFreq[20][135] = 307; + Big5PFreq[37][162] = 306; + Big5PFreq[37][50] = 305; + Big5PFreq[22][185] = 304; + Big5PFreq[36][166] = 303; + Big5PFreq[19][40] = 302; + Big5PFreq[22][107] = 301; + Big5PFreq[22][102] = 300; + Big5PFreq[57][162] = 299; + Big5PFreq[22][124] = 298; + Big5PFreq[37][138] = 297; + Big5PFreq[37][25] = 296; + Big5PFreq[0][69] = 295; + Big5PFreq[43][172] = 294; + Big5PFreq[42][167] = 293; + Big5PFreq[35][120] = 292; + Big5PFreq[41][128] = 291; + Big5PFreq[2][88] = 290; + Big5PFreq[20][123] = 289; + Big5PFreq[35][123] = 288; + Big5PFreq[36][28] = 287; + Big5PFreq[42][188] = 286; + Big5PFreq[42][164] = 285; + Big5PFreq[42][4] = 284; + Big5PFreq[43][57] = 283; + Big5PFreq[39][3] = 282; + Big5PFreq[42][3] = 281; + Big5PFreq[57][158] = 280; + Big5PFreq[35][146] = 279; + Big5PFreq[24][54] = 278; + Big5PFreq[13][110] = 277; + Big5PFreq[23][132] = 276; + Big5PFreq[26][102] = 275; + Big5PFreq[55][178] = 274; + Big5PFreq[17][117] = 273; + Big5PFreq[41][161] = 272; + Big5PFreq[38][150] = 271; + Big5PFreq[10][71] = 270; + Big5PFreq[47][60] = 269; + Big5PFreq[16][114] = 268; + Big5PFreq[21][47] = 267; + Big5PFreq[39][101] = 266; + Big5PFreq[18][45] = 265; + Big5PFreq[40][121] = 264; + Big5PFreq[45][41] = 263; + Big5PFreq[22][167] = 262; + Big5PFreq[26][149] = 261; + Big5PFreq[15][189] = 260; + Big5PFreq[41][177] = 259; + Big5PFreq[46][36] = 258; + Big5PFreq[20][40] = 257; + Big5PFreq[41][54] = 256; + Big5PFreq[3][87] = 255; + Big5PFreq[40][16] = 254; + Big5PFreq[42][15] = 253; + Big5PFreq[11][83] = 252; + Big5PFreq[0][94] = 251; + Big5PFreq[122][81] = 250; + Big5PFreq[41][26] = 249; + Big5PFreq[36][34] = 248; + Big5PFreq[44][148] = 247; + Big5PFreq[35][3] = 246; + Big5PFreq[36][114] = 245; + Big5PFreq[42][112] = 244; + Big5PFreq[35][183] = 243; + Big5PFreq[49][73] = 242; + Big5PFreq[39][2] = 241; + Big5PFreq[38][121] = 240; + Big5PFreq[44][114] = 239; + Big5PFreq[49][32] = 238; + Big5PFreq[1][65] = 237; + Big5PFreq[38][25] = 236; + Big5PFreq[39][4] = 235; + Big5PFreq[42][62] = 234; + Big5PFreq[35][40] = 233; + Big5PFreq[24][2] = 232; + Big5PFreq[53][49] = 231; + Big5PFreq[41][133] = 230; + Big5PFreq[43][134] = 229; + Big5PFreq[3][83] = 228; + Big5PFreq[38][158] = 227; + Big5PFreq[24][17] = 226; + Big5PFreq[52][59] = 225; + Big5PFreq[38][41] = 224; + Big5PFreq[37][127] = 223; + Big5PFreq[22][175] = 222; + Big5PFreq[44][30] = 221; + Big5PFreq[47][178] = 220; + Big5PFreq[43][99] = 219; + Big5PFreq[19][4] = 218; + Big5PFreq[37][97] = 217; + Big5PFreq[38][181] = 216; + Big5PFreq[45][103] = 215; + Big5PFreq[1][86] = 214; + Big5PFreq[40][15] = 213; + Big5PFreq[22][136] = 212; + Big5PFreq[75][165] = 211; + Big5PFreq[36][15] = 210; + Big5PFreq[46][80] = 209; + Big5PFreq[59][55] = 208; + Big5PFreq[37][108] = 207; + Big5PFreq[21][109] = 206; + Big5PFreq[24][165] = 205; + Big5PFreq[79][158] = 204; + Big5PFreq[44][139] = 203; + Big5PFreq[36][124] = 202; + Big5PFreq[42][185] = 201; + Big5PFreq[39][186] = 200; + Big5PFreq[22][128] = 199; + Big5PFreq[40][44] = 198; + Big5PFreq[41][105] = 197; + Big5PFreq[1][70] = 196; + Big5PFreq[1][68] = 195; + Big5PFreq[53][22] = 194; + Big5PFreq[36][54] = 193; + Big5PFreq[47][147] = 192; + Big5PFreq[35][36] = 191; + Big5PFreq[35][185] = 190; + Big5PFreq[45][37] = 189; + Big5PFreq[43][163] = 188; + Big5PFreq[56][115] = 187; + Big5PFreq[38][164] = 186; + Big5PFreq[35][141] = 185; + Big5PFreq[42][132] = 184; + Big5PFreq[46][120] = 183; + Big5PFreq[69][142] = 182; + Big5PFreq[38][175] = 181; + Big5PFreq[22][112] = 180; + Big5PFreq[38][142] = 179; + Big5PFreq[40][37] = 178; + Big5PFreq[37][109] = 177; + Big5PFreq[40][144] = 176; + Big5PFreq[44][117] = 175; + Big5PFreq[35][181] = 174; + Big5PFreq[26][105] = 173; + Big5PFreq[16][48] = 172; + Big5PFreq[44][122] = 171; + Big5PFreq[12][86] = 170; + Big5PFreq[84][53] = 169; + Big5PFreq[17][44] = 168; + Big5PFreq[59][54] = 167; + Big5PFreq[36][98] = 166; + Big5PFreq[45][115] = 165; + Big5PFreq[73][9] = 164; + Big5PFreq[44][123] = 163; + Big5PFreq[37][188] = 162; + Big5PFreq[51][117] = 161; + Big5PFreq[15][156] = 160; + Big5PFreq[36][155] = 159; + Big5PFreq[44][25] = 158; + Big5PFreq[38][12] = 157; + Big5PFreq[38][140] = 156; + Big5PFreq[23][4] = 155; + Big5PFreq[45][149] = 154; + Big5PFreq[22][189] = 153; + Big5PFreq[38][147] = 152; + Big5PFreq[27][5] = 151; + Big5PFreq[22][42] = 150; + Big5PFreq[3][68] = 149; + Big5PFreq[39][51] = 148; + Big5PFreq[36][29] = 147; + Big5PFreq[20][108] = 146; + Big5PFreq[50][57] = 145; + Big5PFreq[55][104] = 144; + Big5PFreq[22][46] = 143; + Big5PFreq[18][164] = 142; + Big5PFreq[50][159] = 141; + Big5PFreq[85][131] = 140; + Big5PFreq[26][79] = 139; + Big5PFreq[38][100] = 138; + Big5PFreq[53][112] = 137; + Big5PFreq[20][190] = 136; + Big5PFreq[14][69] = 135; + Big5PFreq[23][11] = 134; + Big5PFreq[40][114] = 133; + Big5PFreq[40][148] = 132; + Big5PFreq[53][130] = 131; + Big5PFreq[36][2] = 130; + Big5PFreq[66][82] = 129; + Big5PFreq[45][166] = 128; + Big5PFreq[4][88] = 127; + Big5PFreq[16][57] = 126; + Big5PFreq[22][116] = 125; + Big5PFreq[36][108] = 124; + Big5PFreq[13][48] = 123; + Big5PFreq[54][12] = 122; + Big5PFreq[40][136] = 121; + Big5PFreq[36][128] = 120; + Big5PFreq[23][6] = 119; + Big5PFreq[38][125] = 118; + Big5PFreq[45][154] = 117; + Big5PFreq[51][127] = 116; + Big5PFreq[44][163] = 115; + Big5PFreq[16][173] = 114; + Big5PFreq[43][49] = 113; + Big5PFreq[20][112] = 112; + Big5PFreq[15][168] = 111; + Big5PFreq[35][129] = 110; + Big5PFreq[20][45] = 109; + Big5PFreq[38][10] = 108; + Big5PFreq[57][171] = 107; + Big5PFreq[44][190] = 106; + Big5PFreq[40][56] = 105; + Big5PFreq[36][156] = 104; + Big5PFreq[3][88] = 103; + Big5PFreq[50][122] = 102; + Big5PFreq[36][7] = 101; + Big5PFreq[39][43] = 100; + Big5PFreq[15][166] = 99; + Big5PFreq[42][136] = 98; + Big5PFreq[22][131] = 97; + Big5PFreq[44][23] = 96; + Big5PFreq[54][147] = 95; + Big5PFreq[41][32] = 94; + Big5PFreq[23][121] = 93; + Big5PFreq[39][108] = 92; + Big5PFreq[2][78] = 91; + Big5PFreq[40][155] = 90; + Big5PFreq[55][51] = 89; + Big5PFreq[19][34] = 88; + Big5PFreq[48][128] = 87; + Big5PFreq[48][159] = 86; + Big5PFreq[20][70] = 85; + Big5PFreq[34][71] = 84; + Big5PFreq[16][31] = 83; + Big5PFreq[42][157] = 82; + Big5PFreq[20][44] = 81; + Big5PFreq[11][92] = 80; + Big5PFreq[44][180] = 79; + Big5PFreq[84][33] = 78; + Big5PFreq[16][116] = 77; + Big5PFreq[61][163] = 76; + Big5PFreq[35][164] = 75; + Big5PFreq[36][42] = 74; + Big5PFreq[13][40] = 73; + Big5PFreq[43][176] = 72; + Big5PFreq[2][66] = 71; + Big5PFreq[20][133] = 70; + Big5PFreq[36][65] = 69; + Big5PFreq[38][33] = 68; + Big5PFreq[12][91] = 67; + Big5PFreq[36][26] = 66; + Big5PFreq[15][174] = 65; + Big5PFreq[77][32] = 64; + Big5PFreq[16][1] = 63; + Big5PFreq[25][86] = 62; + Big5PFreq[17][13] = 61; + Big5PFreq[5][75] = 60; + Big5PFreq[36][52] = 59; + Big5PFreq[51][164] = 58; + Big5PFreq[12][85] = 57; + Big5PFreq[39][168] = 56; + Big5PFreq[43][16] = 55; + Big5PFreq[40][69] = 54; + Big5PFreq[26][108] = 53; + Big5PFreq[51][56] = 52; + Big5PFreq[16][37] = 51; + Big5PFreq[40][29] = 50; + Big5PFreq[46][171] = 49; + Big5PFreq[40][128] = 48; + Big5PFreq[72][114] = 47; + Big5PFreq[21][103] = 46; + Big5PFreq[22][44] = 45; + Big5PFreq[40][115] = 44; + Big5PFreq[43][7] = 43; + Big5PFreq[43][153] = 42; + Big5PFreq[17][20] = 41; + Big5PFreq[16][49] = 40; + Big5PFreq[36][57] = 39; + Big5PFreq[18][38] = 38; + Big5PFreq[45][184] = 37; + Big5PFreq[37][167] = 36; + Big5PFreq[26][106] = 35; + Big5PFreq[61][121] = 34; + Big5PFreq[89][140] = 33; + Big5PFreq[46][61] = 32; + Big5PFreq[39][163] = 31; + Big5PFreq[40][62] = 30; + Big5PFreq[38][165] = 29; + Big5PFreq[47][37] = 28; + Big5PFreq[18][155] = 27; + Big5PFreq[20][33] = 26; + Big5PFreq[29][90] = 25; + Big5PFreq[20][103] = 24; + Big5PFreq[37][51] = 23; + Big5PFreq[57][0] = 22; + Big5PFreq[40][31] = 21; + Big5PFreq[45][32] = 20; + Big5PFreq[59][23] = 19; + Big5PFreq[18][47] = 18; + Big5PFreq[45][134] = 17; + Big5PFreq[37][59] = 16; + Big5PFreq[21][128] = 15; + Big5PFreq[36][106] = 14; + Big5PFreq[31][39] = 13; + Big5PFreq[40][182] = 12; + Big5PFreq[52][155] = 11; + Big5PFreq[42][166] = 10; + Big5PFreq[35][27] = 9; + Big5PFreq[38][3] = 8; + Big5PFreq[13][44] = 7; + Big5PFreq[58][157] = 6; + Big5PFreq[47][51] = 5; + Big5PFreq[41][37] = 4; + Big5PFreq[41][172] = 3; + Big5PFreq[51][165] = 2; + Big5PFreq[15][161] = 1; + Big5PFreq[24][181] = 0; + EUC_TWFreq[48][49] = 599; + EUC_TWFreq[35][65] = 598; + EUC_TWFreq[41][27] = 597; + EUC_TWFreq[35][0] = 596; + EUC_TWFreq[39][19] = 595; + EUC_TWFreq[35][42] = 594; + EUC_TWFreq[38][66] = 593; + EUC_TWFreq[35][8] = 592; + EUC_TWFreq[35][6] = 591; + EUC_TWFreq[35][66] = 590; + EUC_TWFreq[43][14] = 589; + EUC_TWFreq[69][80] = 588; + EUC_TWFreq[50][48] = 587; + EUC_TWFreq[36][71] = 586; + EUC_TWFreq[37][10] = 585; + EUC_TWFreq[60][52] = 584; + EUC_TWFreq[51][21] = 583; + EUC_TWFreq[40][2] = 582; + EUC_TWFreq[67][35] = 581; + EUC_TWFreq[38][78] = 580; + EUC_TWFreq[49][18] = 579; + EUC_TWFreq[35][23] = 578; + EUC_TWFreq[42][83] = 577; + EUC_TWFreq[79][47] = 576; + EUC_TWFreq[61][82] = 575; + EUC_TWFreq[38][7] = 574; + EUC_TWFreq[35][29] = 573; + EUC_TWFreq[37][77] = 572; + EUC_TWFreq[54][67] = 571; + EUC_TWFreq[38][80] = 570; + EUC_TWFreq[52][74] = 569; + EUC_TWFreq[36][37] = 568; + EUC_TWFreq[74][8] = 567; + EUC_TWFreq[41][83] = 566; + EUC_TWFreq[36][75] = 565; + EUC_TWFreq[49][63] = 564; + EUC_TWFreq[42][58] = 563; + EUC_TWFreq[56][33] = 562; + EUC_TWFreq[37][76] = 561; + EUC_TWFreq[62][39] = 560; + EUC_TWFreq[35][21] = 559; + EUC_TWFreq[70][19] = 558; + EUC_TWFreq[77][88] = 557; + EUC_TWFreq[51][14] = 556; + EUC_TWFreq[36][17] = 555; + EUC_TWFreq[44][51] = 554; + EUC_TWFreq[38][72] = 553; + EUC_TWFreq[74][90] = 552; + EUC_TWFreq[35][48] = 551; + EUC_TWFreq[35][69] = 550; + EUC_TWFreq[66][86] = 549; + EUC_TWFreq[57][20] = 548; + EUC_TWFreq[35][53] = 547; + EUC_TWFreq[36][87] = 546; + EUC_TWFreq[84][67] = 545; + EUC_TWFreq[70][56] = 544; + EUC_TWFreq[71][54] = 543; + EUC_TWFreq[60][70] = 542; + EUC_TWFreq[80][1] = 541; + EUC_TWFreq[39][59] = 540; + EUC_TWFreq[39][51] = 539; + EUC_TWFreq[35][44] = 538; + EUC_TWFreq[48][4] = 537; + EUC_TWFreq[55][24] = 536; + EUC_TWFreq[52][4] = 535; + EUC_TWFreq[54][26] = 534; + EUC_TWFreq[36][31] = 533; + EUC_TWFreq[37][22] = 532; + EUC_TWFreq[37][9] = 531; + EUC_TWFreq[46][0] = 530; + EUC_TWFreq[56][46] = 529; + EUC_TWFreq[47][93] = 528; + EUC_TWFreq[37][25] = 527; + EUC_TWFreq[39][8] = 526; + EUC_TWFreq[46][73] = 525; + EUC_TWFreq[38][48] = 524; + EUC_TWFreq[39][83] = 523; + EUC_TWFreq[60][92] = 522; + EUC_TWFreq[70][11] = 521; + EUC_TWFreq[63][84] = 520; + EUC_TWFreq[38][65] = 519; + EUC_TWFreq[45][45] = 518; + EUC_TWFreq[63][49] = 517; + EUC_TWFreq[63][50] = 516; + EUC_TWFreq[39][93] = 515; + EUC_TWFreq[68][20] = 514; + EUC_TWFreq[44][84] = 513; + EUC_TWFreq[66][34] = 512; + EUC_TWFreq[37][58] = 511; + EUC_TWFreq[39][0] = 510; + EUC_TWFreq[59][1] = 509; + EUC_TWFreq[47][8] = 508; + EUC_TWFreq[61][17] = 507; + EUC_TWFreq[53][87] = 506; + EUC_TWFreq[67][26] = 505; + EUC_TWFreq[43][46] = 504; + EUC_TWFreq[38][61] = 503; + EUC_TWFreq[45][9] = 502; + EUC_TWFreq[66][83] = 501; + EUC_TWFreq[43][88] = 500; + EUC_TWFreq[85][20] = 499; + EUC_TWFreq[57][36] = 498; + EUC_TWFreq[43][6] = 497; + EUC_TWFreq[86][77] = 496; + EUC_TWFreq[42][70] = 495; + EUC_TWFreq[49][78] = 494; + EUC_TWFreq[36][40] = 493; + EUC_TWFreq[42][71] = 492; + EUC_TWFreq[58][49] = 491; + EUC_TWFreq[35][20] = 490; + EUC_TWFreq[76][20] = 489; + EUC_TWFreq[39][25] = 488; + EUC_TWFreq[40][34] = 487; + EUC_TWFreq[39][76] = 486; + EUC_TWFreq[40][1] = 485; + EUC_TWFreq[59][0] = 484; + EUC_TWFreq[39][70] = 483; + EUC_TWFreq[46][14] = 482; + EUC_TWFreq[68][77] = 481; + EUC_TWFreq[38][55] = 480; + EUC_TWFreq[35][78] = 479; + EUC_TWFreq[84][44] = 478; + EUC_TWFreq[36][41] = 477; + EUC_TWFreq[37][62] = 476; + EUC_TWFreq[65][67] = 475; + EUC_TWFreq[69][66] = 474; + EUC_TWFreq[73][55] = 473; + EUC_TWFreq[71][49] = 472; + EUC_TWFreq[66][87] = 471; + EUC_TWFreq[38][33] = 470; + EUC_TWFreq[64][61] = 469; + EUC_TWFreq[35][7] = 468; + EUC_TWFreq[47][49] = 467; + EUC_TWFreq[56][14] = 466; + EUC_TWFreq[36][49] = 465; + EUC_TWFreq[50][81] = 464; + EUC_TWFreq[55][76] = 463; + EUC_TWFreq[35][19] = 462; + EUC_TWFreq[44][47] = 461; + EUC_TWFreq[35][15] = 460; + EUC_TWFreq[82][59] = 459; + EUC_TWFreq[35][43] = 458; + EUC_TWFreq[73][0] = 457; + EUC_TWFreq[57][83] = 456; + EUC_TWFreq[42][46] = 455; + EUC_TWFreq[36][0] = 454; + EUC_TWFreq[70][88] = 453; + EUC_TWFreq[42][22] = 452; + EUC_TWFreq[46][58] = 451; + EUC_TWFreq[36][34] = 450; + EUC_TWFreq[39][24] = 449; + EUC_TWFreq[35][55] = 448; + EUC_TWFreq[44][91] = 447; + EUC_TWFreq[37][51] = 446; + EUC_TWFreq[36][19] = 445; + EUC_TWFreq[69][90] = 444; + EUC_TWFreq[55][35] = 443; + EUC_TWFreq[35][54] = 442; + EUC_TWFreq[49][61] = 441; + EUC_TWFreq[36][67] = 440; + EUC_TWFreq[88][34] = 439; + EUC_TWFreq[35][17] = 438; + EUC_TWFreq[65][69] = 437; + EUC_TWFreq[74][89] = 436; + EUC_TWFreq[37][31] = 435; + EUC_TWFreq[43][48] = 434; + EUC_TWFreq[89][27] = 433; + EUC_TWFreq[42][79] = 432; + EUC_TWFreq[69][57] = 431; + EUC_TWFreq[36][13] = 430; + EUC_TWFreq[35][62] = 429; + EUC_TWFreq[65][47] = 428; + EUC_TWFreq[56][8] = 427; + EUC_TWFreq[38][79] = 426; + EUC_TWFreq[37][64] = 425; + EUC_TWFreq[64][64] = 424; + EUC_TWFreq[38][53] = 423; + EUC_TWFreq[38][31] = 422; + EUC_TWFreq[56][81] = 421; + EUC_TWFreq[36][22] = 420; + EUC_TWFreq[43][4] = 419; + EUC_TWFreq[36][90] = 418; + EUC_TWFreq[38][62] = 417; + EUC_TWFreq[66][85] = 416; + EUC_TWFreq[39][1] = 415; + EUC_TWFreq[59][40] = 414; + EUC_TWFreq[58][93] = 413; + EUC_TWFreq[44][43] = 412; + EUC_TWFreq[39][49] = 411; + EUC_TWFreq[64][2] = 410; + EUC_TWFreq[41][35] = 409; + EUC_TWFreq[60][22] = 408; + EUC_TWFreq[35][91] = 407; + EUC_TWFreq[78][1] = 406; + EUC_TWFreq[36][14] = 405; + EUC_TWFreq[82][29] = 404; + EUC_TWFreq[52][86] = 403; + EUC_TWFreq[40][16] = 402; + EUC_TWFreq[91][52] = 401; + EUC_TWFreq[50][75] = 400; + EUC_TWFreq[64][30] = 399; + EUC_TWFreq[90][78] = 398; + EUC_TWFreq[36][52] = 397; + EUC_TWFreq[55][87] = 396; + EUC_TWFreq[57][5] = 395; + EUC_TWFreq[57][31] = 394; + EUC_TWFreq[42][35] = 393; + EUC_TWFreq[69][50] = 392; + EUC_TWFreq[45][8] = 391; + EUC_TWFreq[50][87] = 390; + EUC_TWFreq[69][55] = 389; + EUC_TWFreq[92][3] = 388; + EUC_TWFreq[36][43] = 387; + EUC_TWFreq[64][10] = 386; + EUC_TWFreq[56][25] = 385; + EUC_TWFreq[60][68] = 384; + EUC_TWFreq[51][46] = 383; + EUC_TWFreq[50][0] = 382; + EUC_TWFreq[38][30] = 381; + EUC_TWFreq[50][85] = 380; + EUC_TWFreq[60][54] = 379; + EUC_TWFreq[73][6] = 378; + EUC_TWFreq[73][28] = 377; + EUC_TWFreq[56][19] = 376; + EUC_TWFreq[62][69] = 375; + EUC_TWFreq[81][66] = 374; + EUC_TWFreq[40][32] = 373; + EUC_TWFreq[76][31] = 372; + EUC_TWFreq[35][10] = 371; + EUC_TWFreq[41][37] = 370; + EUC_TWFreq[52][82] = 369; + EUC_TWFreq[91][72] = 368; + EUC_TWFreq[37][29] = 367; + EUC_TWFreq[56][30] = 366; + EUC_TWFreq[37][80] = 365; + EUC_TWFreq[81][56] = 364; + EUC_TWFreq[70][3] = 363; + EUC_TWFreq[76][15] = 362; + EUC_TWFreq[46][47] = 361; + EUC_TWFreq[35][88] = 360; + EUC_TWFreq[61][58] = 359; + EUC_TWFreq[37][37] = 358; + EUC_TWFreq[57][22] = 357; + EUC_TWFreq[41][23] = 356; + EUC_TWFreq[90][66] = 355; + EUC_TWFreq[39][60] = 354; + EUC_TWFreq[38][0] = 353; + EUC_TWFreq[37][87] = 352; + EUC_TWFreq[46][2] = 351; + EUC_TWFreq[38][56] = 350; + EUC_TWFreq[58][11] = 349; + EUC_TWFreq[48][10] = 348; + EUC_TWFreq[74][4] = 347; + EUC_TWFreq[40][42] = 346; + EUC_TWFreq[41][52] = 345; + EUC_TWFreq[61][92] = 344; + EUC_TWFreq[39][50] = 343; + EUC_TWFreq[47][88] = 342; + EUC_TWFreq[88][36] = 341; + EUC_TWFreq[45][73] = 340; + EUC_TWFreq[82][3] = 339; + EUC_TWFreq[61][36] = 338; + EUC_TWFreq[60][33] = 337; + EUC_TWFreq[38][27] = 336; + EUC_TWFreq[35][83] = 335; + EUC_TWFreq[65][24] = 334; + EUC_TWFreq[73][10] = 333; + EUC_TWFreq[41][13] = 332; + EUC_TWFreq[50][27] = 331; + EUC_TWFreq[59][50] = 330; + EUC_TWFreq[42][45] = 329; + EUC_TWFreq[55][19] = 328; + EUC_TWFreq[36][77] = 327; + EUC_TWFreq[69][31] = 326; + EUC_TWFreq[60][7] = 325; + EUC_TWFreq[40][88] = 324; + EUC_TWFreq[57][56] = 323; + EUC_TWFreq[50][50] = 322; + EUC_TWFreq[42][37] = 321; + EUC_TWFreq[38][82] = 320; + EUC_TWFreq[52][25] = 319; + EUC_TWFreq[42][67] = 318; + EUC_TWFreq[48][40] = 317; + EUC_TWFreq[45][81] = 316; + EUC_TWFreq[57][14] = 315; + EUC_TWFreq[42][13] = 314; + EUC_TWFreq[78][0] = 313; + EUC_TWFreq[35][51] = 312; + EUC_TWFreq[41][67] = 311; + EUC_TWFreq[64][23] = 310; + EUC_TWFreq[36][65] = 309; + EUC_TWFreq[48][50] = 308; + EUC_TWFreq[46][69] = 307; + EUC_TWFreq[47][89] = 306; + EUC_TWFreq[41][48] = 305; + EUC_TWFreq[60][56] = 304; + EUC_TWFreq[44][82] = 303; + EUC_TWFreq[47][35] = 302; + EUC_TWFreq[49][3] = 301; + EUC_TWFreq[49][69] = 300; + EUC_TWFreq[45][93] = 299; + EUC_TWFreq[60][34] = 298; + EUC_TWFreq[60][82] = 297; + EUC_TWFreq[61][61] = 296; + EUC_TWFreq[86][42] = 295; + EUC_TWFreq[89][60] = 294; + EUC_TWFreq[48][31] = 293; + EUC_TWFreq[35][75] = 292; + EUC_TWFreq[91][39] = 291; + EUC_TWFreq[53][19] = 290; + EUC_TWFreq[39][72] = 289; + EUC_TWFreq[69][59] = 288; + EUC_TWFreq[41][7] = 287; + EUC_TWFreq[54][13] = 286; + EUC_TWFreq[43][28] = 285; + EUC_TWFreq[36][6] = 284; + EUC_TWFreq[45][75] = 283; + EUC_TWFreq[36][61] = 282; + EUC_TWFreq[38][21] = 281; + EUC_TWFreq[45][14] = 280; + EUC_TWFreq[61][43] = 279; + EUC_TWFreq[36][63] = 278; + EUC_TWFreq[43][30] = 277; + EUC_TWFreq[46][51] = 276; + EUC_TWFreq[68][87] = 275; + EUC_TWFreq[39][26] = 274; + EUC_TWFreq[46][76] = 273; + EUC_TWFreq[36][15] = 272; + EUC_TWFreq[35][40] = 271; + EUC_TWFreq[79][60] = 270; + EUC_TWFreq[46][7] = 269; + EUC_TWFreq[65][72] = 268; + EUC_TWFreq[69][88] = 267; + EUC_TWFreq[47][18] = 266; + EUC_TWFreq[37][0] = 265; + EUC_TWFreq[37][49] = 264; + EUC_TWFreq[67][37] = 263; + EUC_TWFreq[36][91] = 262; + EUC_TWFreq[75][48] = 261; + EUC_TWFreq[75][63] = 260; + EUC_TWFreq[83][87] = 259; + EUC_TWFreq[37][44] = 258; + EUC_TWFreq[73][54] = 257; + EUC_TWFreq[51][61] = 256; + EUC_TWFreq[46][57] = 255; + EUC_TWFreq[55][21] = 254; + EUC_TWFreq[39][66] = 253; + EUC_TWFreq[47][11] = 252; + EUC_TWFreq[52][8] = 251; + EUC_TWFreq[82][81] = 250; + EUC_TWFreq[36][57] = 249; + EUC_TWFreq[38][54] = 248; + EUC_TWFreq[43][81] = 247; + EUC_TWFreq[37][42] = 246; + EUC_TWFreq[40][18] = 245; + EUC_TWFreq[80][90] = 244; + EUC_TWFreq[37][84] = 243; + EUC_TWFreq[57][15] = 242; + EUC_TWFreq[38][87] = 241; + EUC_TWFreq[37][32] = 240; + EUC_TWFreq[53][53] = 239; + EUC_TWFreq[89][29] = 238; + EUC_TWFreq[81][53] = 237; + EUC_TWFreq[75][3] = 236; + EUC_TWFreq[83][73] = 235; + EUC_TWFreq[66][13] = 234; + EUC_TWFreq[48][7] = 233; + EUC_TWFreq[46][35] = 232; + EUC_TWFreq[35][86] = 231; + EUC_TWFreq[37][20] = 230; + EUC_TWFreq[46][80] = 229; + EUC_TWFreq[38][24] = 228; + EUC_TWFreq[41][68] = 227; + EUC_TWFreq[42][21] = 226; + EUC_TWFreq[43][32] = 225; + EUC_TWFreq[38][20] = 224; + EUC_TWFreq[37][59] = 223; + EUC_TWFreq[41][77] = 222; + EUC_TWFreq[59][57] = 221; + EUC_TWFreq[68][59] = 220; + EUC_TWFreq[39][43] = 219; + EUC_TWFreq[54][39] = 218; + EUC_TWFreq[48][28] = 217; + EUC_TWFreq[54][28] = 216; + EUC_TWFreq[41][44] = 215; + EUC_TWFreq[51][64] = 214; + EUC_TWFreq[47][72] = 213; + EUC_TWFreq[62][67] = 212; + EUC_TWFreq[42][43] = 211; + EUC_TWFreq[61][38] = 210; + EUC_TWFreq[76][25] = 209; + EUC_TWFreq[48][91] = 208; + EUC_TWFreq[36][36] = 207; + EUC_TWFreq[80][32] = 206; + EUC_TWFreq[81][40] = 205; + EUC_TWFreq[37][5] = 204; + EUC_TWFreq[74][69] = 203; + EUC_TWFreq[36][82] = 202; + EUC_TWFreq[46][59] = 201; + /* + * EUC_TWFreq[38][32] = 200; EUC_TWFreq[74][2] = 199; EUC_TWFreq[53][31] = 198; EUC_TWFreq[35][38] = 197; EUC_TWFreq[46][62] = + * 196; EUC_TWFreq[77][31] = 195; EUC_TWFreq[55][74] = 194; EUC_TWFreq[66][6] = 193; EUC_TWFreq[56][21] = 192; + * EUC_TWFreq[54][78] = 191; EUC_TWFreq[43][51] = 190; EUC_TWFreq[64][93] = 189; EUC_TWFreq[92][7] = 188; EUC_TWFreq[83][89] = + * 187; EUC_TWFreq[69][9] = 186; EUC_TWFreq[45][4] = 185; EUC_TWFreq[53][9] = 184; EUC_TWFreq[43][2] = 183; + * EUC_TWFreq[35][11] = 182; EUC_TWFreq[51][25] = 181; EUC_TWFreq[52][71] = 180; EUC_TWFreq[81][67] = 179; + * EUC_TWFreq[37][33] = 178; EUC_TWFreq[38][57] = 177; EUC_TWFreq[39][77] = 176; EUC_TWFreq[40][26] = 175; + * EUC_TWFreq[37][21] = 174; EUC_TWFreq[81][70] = 173; EUC_TWFreq[56][80] = 172; EUC_TWFreq[65][14] = 171; + * EUC_TWFreq[62][47] = 170; EUC_TWFreq[56][54] = 169; EUC_TWFreq[45][17] = 168; EUC_TWFreq[52][52] = 167; + * EUC_TWFreq[74][30] = 166; EUC_TWFreq[60][57] = 165; EUC_TWFreq[41][15] = 164; EUC_TWFreq[47][69] = 163; + * EUC_TWFreq[61][11] = 162; EUC_TWFreq[72][25] = 161; EUC_TWFreq[82][56] = 160; EUC_TWFreq[76][92] = 159; + * EUC_TWFreq[51][22] = 158; EUC_TWFreq[55][69] = 157; EUC_TWFreq[49][43] = 156; EUC_TWFreq[69][49] = 155; + * EUC_TWFreq[88][42] = 154; EUC_TWFreq[84][41] = 153; EUC_TWFreq[79][33] = 152; EUC_TWFreq[47][17] = 151; + * EUC_TWFreq[52][88] = 150; EUC_TWFreq[63][74] = 149; EUC_TWFreq[50][32] = 148; EUC_TWFreq[65][10] = 147; EUC_TWFreq[57][6] = + * 146; EUC_TWFreq[52][23] = 145; EUC_TWFreq[36][70] = 144; EUC_TWFreq[65][55] = 143; EUC_TWFreq[35][27] = 142; + * EUC_TWFreq[57][63] = 141; EUC_TWFreq[39][92] = 140; EUC_TWFreq[79][75] = 139; EUC_TWFreq[36][30] = 138; + * EUC_TWFreq[53][60] = 137; EUC_TWFreq[55][43] = 136; EUC_TWFreq[71][22] = 135; EUC_TWFreq[43][16] = 134; + * EUC_TWFreq[65][21] = 133; EUC_TWFreq[84][51] = 132; EUC_TWFreq[43][64] = 131; EUC_TWFreq[87][91] = 130; + * EUC_TWFreq[47][45] = 129; EUC_TWFreq[65][29] = 128; EUC_TWFreq[88][16] = 127; EUC_TWFreq[50][5] = 126; EUC_TWFreq[47][33] = + * 125; EUC_TWFreq[46][27] = 124; EUC_TWFreq[85][2] = 123; EUC_TWFreq[43][77] = 122; EUC_TWFreq[70][9] = 121; + * EUC_TWFreq[41][54] = 120; EUC_TWFreq[56][12] = 119; EUC_TWFreq[90][65] = 118; EUC_TWFreq[91][50] = 117; + * EUC_TWFreq[48][41] = 116; EUC_TWFreq[35][89] = 115; EUC_TWFreq[90][83] = 114; EUC_TWFreq[44][40] = 113; + * EUC_TWFreq[50][88] = 112; EUC_TWFreq[72][39] = 111; EUC_TWFreq[45][3] = 110; EUC_TWFreq[71][33] = 109; EUC_TWFreq[39][12] = + * 108; EUC_TWFreq[59][24] = 107; EUC_TWFreq[60][62] = 106; EUC_TWFreq[44][33] = 105; EUC_TWFreq[53][70] = 104; + * EUC_TWFreq[77][90] = 103; EUC_TWFreq[50][58] = 102; EUC_TWFreq[54][1] = 101; EUC_TWFreq[73][19] = 100; EUC_TWFreq[37][3] = + * 99; EUC_TWFreq[49][91] = 98; EUC_TWFreq[88][43] = 97; EUC_TWFreq[36][78] = 96; EUC_TWFreq[44][20] = 95; + * EUC_TWFreq[64][15] = 94; EUC_TWFreq[72][28] = 93; EUC_TWFreq[70][13] = 92; EUC_TWFreq[65][83] = 91; EUC_TWFreq[58][68] = + * 90; EUC_TWFreq[59][32] = 89; EUC_TWFreq[39][13] = 88; EUC_TWFreq[55][64] = 87; EUC_TWFreq[56][59] = 86; + * EUC_TWFreq[39][17] = 85; EUC_TWFreq[55][84] = 84; EUC_TWFreq[77][85] = 83; EUC_TWFreq[60][19] = 82; EUC_TWFreq[62][82] = + * 81; EUC_TWFreq[78][16] = 80; EUC_TWFreq[66][8] = 79; EUC_TWFreq[39][42] = 78; EUC_TWFreq[61][24] = 77; EUC_TWFreq[57][67] = + * 76; EUC_TWFreq[38][83] = 75; EUC_TWFreq[36][53] = 74; EUC_TWFreq[67][76] = 73; EUC_TWFreq[37][91] = 72; + * EUC_TWFreq[44][26] = 71; EUC_TWFreq[72][86] = 70; EUC_TWFreq[44][87] = 69; EUC_TWFreq[45][50] = 68; EUC_TWFreq[58][4] = + * 67; EUC_TWFreq[86][65] = 66; EUC_TWFreq[45][56] = 65; EUC_TWFreq[79][49] = 64; EUC_TWFreq[35][3] = 63; EUC_TWFreq[48][83] = + * 62; EUC_TWFreq[71][21] = 61; EUC_TWFreq[77][93] = 60; EUC_TWFreq[87][92] = 59; EUC_TWFreq[38][35] = 58; + * EUC_TWFreq[66][17] = 57; EUC_TWFreq[37][66] = 56; EUC_TWFreq[51][42] = 55; EUC_TWFreq[57][73] = 54; EUC_TWFreq[51][54] = + * 53; EUC_TWFreq[75][64] = 52; EUC_TWFreq[35][5] = 51; EUC_TWFreq[49][40] = 50; EUC_TWFreq[58][35] = 49; EUC_TWFreq[67][88] = + * 48; EUC_TWFreq[60][51] = 47; EUC_TWFreq[36][92] = 46; EUC_TWFreq[44][41] = 45; EUC_TWFreq[58][29] = 44; + * EUC_TWFreq[43][62] = 43; EUC_TWFreq[56][23] = 42; EUC_TWFreq[67][44] = 41; EUC_TWFreq[52][91] = 40; EUC_TWFreq[42][81] = + * 39; EUC_TWFreq[64][25] = 38; EUC_TWFreq[35][36] = 37; EUC_TWFreq[47][73] = 36; EUC_TWFreq[36][1] = 35; EUC_TWFreq[65][84] = + * 34; EUC_TWFreq[73][1] = 33; EUC_TWFreq[79][66] = 32; EUC_TWFreq[69][14] = 31; EUC_TWFreq[65][28] = 30; EUC_TWFreq[60][93] = + * 29; EUC_TWFreq[72][79] = 28; EUC_TWFreq[48][0] = 27; EUC_TWFreq[73][43] = 26; EUC_TWFreq[66][47] = 25; EUC_TWFreq[41][18] = + * 24; EUC_TWFreq[51][10] = 23; EUC_TWFreq[59][7] = 22; EUC_TWFreq[53][27] = 21; EUC_TWFreq[86][67] = 20; EUC_TWFreq[49][87] = + * 19; EUC_TWFreq[52][28] = 18; EUC_TWFreq[52][12] = 17; EUC_TWFreq[42][30] = 16; EUC_TWFreq[65][35] = 15; + * EUC_TWFreq[46][64] = 14; EUC_TWFreq[71][7] = 13; EUC_TWFreq[56][57] = 12; EUC_TWFreq[56][31] = 11; EUC_TWFreq[41][31] = + * 10; EUC_TWFreq[48][59] = 9; EUC_TWFreq[63][92] = 8; EUC_TWFreq[62][57] = 7; EUC_TWFreq[65][87] = 6; EUC_TWFreq[70][10] = + * 5; EUC_TWFreq[52][40] = 4; EUC_TWFreq[40][22] = 3; EUC_TWFreq[65][91] = 2; EUC_TWFreq[50][25] = 1; EUC_TWFreq[35][84] = + * 0; + */ + GBKFreq[52][132] = 600; + GBKFreq[73][135] = 599; + GBKFreq[49][123] = 598; + GBKFreq[77][146] = 597; + GBKFreq[81][123] = 596; + GBKFreq[82][144] = 595; + GBKFreq[51][179] = 594; + GBKFreq[83][154] = 593; + GBKFreq[71][139] = 592; + GBKFreq[64][139] = 591; + GBKFreq[85][144] = 590; + GBKFreq[52][125] = 589; + GBKFreq[88][25] = 588; + GBKFreq[81][106] = 587; + GBKFreq[81][148] = 586; + GBKFreq[62][137] = 585; + GBKFreq[94][0] = 584; + GBKFreq[1][64] = 583; + GBKFreq[67][163] = 582; + GBKFreq[20][190] = 581; + GBKFreq[57][131] = 580; + GBKFreq[29][169] = 579; + GBKFreq[72][143] = 578; + GBKFreq[0][173] = 577; + GBKFreq[11][23] = 576; + GBKFreq[61][141] = 575; + GBKFreq[60][123] = 574; + GBKFreq[81][114] = 573; + GBKFreq[82][131] = 572; + GBKFreq[67][156] = 571; + GBKFreq[71][167] = 570; + GBKFreq[20][50] = 569; + GBKFreq[77][132] = 568; + GBKFreq[84][38] = 567; + GBKFreq[26][29] = 566; + GBKFreq[74][187] = 565; + GBKFreq[62][116] = 564; + GBKFreq[67][135] = 563; + GBKFreq[5][86] = 562; + GBKFreq[72][186] = 561; + GBKFreq[75][161] = 560; + GBKFreq[78][130] = 559; + GBKFreq[94][30] = 558; + GBKFreq[84][72] = 557; + GBKFreq[1][67] = 556; + GBKFreq[75][172] = 555; + GBKFreq[74][185] = 554; + GBKFreq[53][160] = 553; + GBKFreq[123][14] = 552; + GBKFreq[79][97] = 551; + GBKFreq[85][110] = 550; + GBKFreq[78][171] = 549; + GBKFreq[52][131] = 548; + GBKFreq[56][100] = 547; + GBKFreq[50][182] = 546; + GBKFreq[94][64] = 545; + GBKFreq[106][74] = 544; + GBKFreq[11][102] = 543; + GBKFreq[53][124] = 542; + GBKFreq[24][3] = 541; + GBKFreq[86][148] = 540; + GBKFreq[53][184] = 539; + GBKFreq[86][147] = 538; + GBKFreq[96][161] = 537; + GBKFreq[82][77] = 536; + GBKFreq[59][146] = 535; + GBKFreq[84][126] = 534; + GBKFreq[79][132] = 533; + GBKFreq[85][123] = 532; + GBKFreq[71][101] = 531; + GBKFreq[85][106] = 530; + GBKFreq[6][184] = 529; + GBKFreq[57][156] = 528; + GBKFreq[75][104] = 527; + GBKFreq[50][137] = 526; + GBKFreq[79][133] = 525; + GBKFreq[76][108] = 524; + GBKFreq[57][142] = 523; + GBKFreq[84][130] = 522; + GBKFreq[52][128] = 521; + GBKFreq[47][44] = 520; + GBKFreq[52][152] = 519; + GBKFreq[54][104] = 518; + GBKFreq[30][47] = 517; + GBKFreq[71][123] = 516; + GBKFreq[52][107] = 515; + GBKFreq[45][84] = 514; + GBKFreq[107][118] = 513; + GBKFreq[5][161] = 512; + GBKFreq[48][126] = 511; + GBKFreq[67][170] = 510; + GBKFreq[43][6] = 509; + GBKFreq[70][112] = 508; + GBKFreq[86][174] = 507; + GBKFreq[84][166] = 506; + GBKFreq[79][130] = 505; + GBKFreq[57][141] = 504; + GBKFreq[81][178] = 503; + GBKFreq[56][187] = 502; + GBKFreq[81][162] = 501; + GBKFreq[53][104] = 500; + GBKFreq[123][35] = 499; + GBKFreq[70][169] = 498; + GBKFreq[69][164] = 497; + GBKFreq[109][61] = 496; + GBKFreq[73][130] = 495; + GBKFreq[62][134] = 494; + GBKFreq[54][125] = 493; + GBKFreq[79][105] = 492; + GBKFreq[70][165] = 491; + GBKFreq[71][189] = 490; + GBKFreq[23][147] = 489; + GBKFreq[51][139] = 488; + GBKFreq[47][137] = 487; + GBKFreq[77][123] = 486; + GBKFreq[86][183] = 485; + GBKFreq[63][173] = 484; + GBKFreq[79][144] = 483; + GBKFreq[84][159] = 482; + GBKFreq[60][91] = 481; + GBKFreq[66][187] = 480; + GBKFreq[73][114] = 479; + GBKFreq[85][56] = 478; + GBKFreq[71][149] = 477; + GBKFreq[84][189] = 476; + GBKFreq[104][31] = 475; + GBKFreq[83][82] = 474; + GBKFreq[68][35] = 473; + GBKFreq[11][77] = 472; + GBKFreq[15][155] = 471; + GBKFreq[83][153] = 470; + GBKFreq[71][1] = 469; + GBKFreq[53][190] = 468; + GBKFreq[50][135] = 467; + GBKFreq[3][147] = 466; + GBKFreq[48][136] = 465; + GBKFreq[66][166] = 464; + GBKFreq[55][159] = 463; + GBKFreq[82][150] = 462; + GBKFreq[58][178] = 461; + GBKFreq[64][102] = 460; + GBKFreq[16][106] = 459; + GBKFreq[68][110] = 458; + GBKFreq[54][14] = 457; + GBKFreq[60][140] = 456; + GBKFreq[91][71] = 455; + GBKFreq[54][150] = 454; + GBKFreq[78][177] = 453; + GBKFreq[78][117] = 452; + GBKFreq[104][12] = 451; + GBKFreq[73][150] = 450; + GBKFreq[51][142] = 449; + GBKFreq[81][145] = 448; + GBKFreq[66][183] = 447; + GBKFreq[51][178] = 446; + GBKFreq[75][107] = 445; + GBKFreq[65][119] = 444; + GBKFreq[69][176] = 443; + GBKFreq[59][122] = 442; + GBKFreq[78][160] = 441; + GBKFreq[85][183] = 440; + GBKFreq[105][16] = 439; + GBKFreq[73][110] = 438; + GBKFreq[104][39] = 437; + GBKFreq[119][16] = 436; + GBKFreq[76][162] = 435; + GBKFreq[67][152] = 434; + GBKFreq[82][24] = 433; + GBKFreq[73][121] = 432; + GBKFreq[83][83] = 431; + GBKFreq[82][145] = 430; + GBKFreq[49][133] = 429; + GBKFreq[94][13] = 428; + GBKFreq[58][139] = 427; + GBKFreq[74][189] = 426; + GBKFreq[66][177] = 425; + GBKFreq[85][184] = 424; + GBKFreq[55][183] = 423; + GBKFreq[71][107] = 422; + GBKFreq[11][98] = 421; + GBKFreq[72][153] = 420; + GBKFreq[2][137] = 419; + GBKFreq[59][147] = 418; + GBKFreq[58][152] = 417; + GBKFreq[55][144] = 416; + GBKFreq[73][125] = 415; + GBKFreq[52][154] = 414; + GBKFreq[70][178] = 413; + GBKFreq[79][148] = 412; + GBKFreq[63][143] = 411; + GBKFreq[50][140] = 410; + GBKFreq[47][145] = 409; + GBKFreq[48][123] = 408; + GBKFreq[56][107] = 407; + GBKFreq[84][83] = 406; + GBKFreq[59][112] = 405; + GBKFreq[124][72] = 404; + GBKFreq[79][99] = 403; + GBKFreq[3][37] = 402; + GBKFreq[114][55] = 401; + GBKFreq[85][152] = 400; + GBKFreq[60][47] = 399; + GBKFreq[65][96] = 398; + GBKFreq[74][110] = 397; + GBKFreq[86][182] = 396; + GBKFreq[50][99] = 395; + GBKFreq[67][186] = 394; + GBKFreq[81][74] = 393; + GBKFreq[80][37] = 392; + GBKFreq[21][60] = 391; + GBKFreq[110][12] = 390; + GBKFreq[60][162] = 389; + GBKFreq[29][115] = 388; + GBKFreq[83][130] = 387; + GBKFreq[52][136] = 386; + GBKFreq[63][114] = 385; + GBKFreq[49][127] = 384; + GBKFreq[83][109] = 383; + GBKFreq[66][128] = 382; + GBKFreq[78][136] = 381; + GBKFreq[81][180] = 380; + GBKFreq[76][104] = 379; + GBKFreq[56][156] = 378; + GBKFreq[61][23] = 377; + GBKFreq[4][30] = 376; + GBKFreq[69][154] = 375; + GBKFreq[100][37] = 374; + GBKFreq[54][177] = 373; + GBKFreq[23][119] = 372; + GBKFreq[71][171] = 371; + GBKFreq[84][146] = 370; + GBKFreq[20][184] = 369; + GBKFreq[86][76] = 368; + GBKFreq[74][132] = 367; + GBKFreq[47][97] = 366; + GBKFreq[82][137] = 365; + GBKFreq[94][56] = 364; + GBKFreq[92][30] = 363; + GBKFreq[19][117] = 362; + GBKFreq[48][173] = 361; + GBKFreq[2][136] = 360; + GBKFreq[7][182] = 359; + GBKFreq[74][188] = 358; + GBKFreq[14][132] = 357; + GBKFreq[62][172] = 356; + GBKFreq[25][39] = 355; + GBKFreq[85][129] = 354; + GBKFreq[64][98] = 353; + GBKFreq[67][127] = 352; + GBKFreq[72][167] = 351; + GBKFreq[57][143] = 350; + GBKFreq[76][187] = 349; + GBKFreq[83][181] = 348; + GBKFreq[84][10] = 347; + GBKFreq[55][166] = 346; + GBKFreq[55][188] = 345; + GBKFreq[13][151] = 344; + GBKFreq[62][124] = 343; + GBKFreq[53][136] = 342; + GBKFreq[106][57] = 341; + GBKFreq[47][166] = 340; + GBKFreq[109][30] = 339; + GBKFreq[78][114] = 338; + GBKFreq[83][19] = 337; + GBKFreq[56][162] = 336; + GBKFreq[60][177] = 335; + GBKFreq[88][9] = 334; + GBKFreq[74][163] = 333; + GBKFreq[52][156] = 332; + GBKFreq[71][180] = 331; + GBKFreq[60][57] = 330; + GBKFreq[72][173] = 329; + GBKFreq[82][91] = 328; + GBKFreq[51][186] = 327; + GBKFreq[75][86] = 326; + GBKFreq[75][78] = 325; + GBKFreq[76][170] = 324; + GBKFreq[60][147] = 323; + GBKFreq[82][75] = 322; + GBKFreq[80][148] = 321; + GBKFreq[86][150] = 320; + GBKFreq[13][95] = 319; + GBKFreq[0][11] = 318; + GBKFreq[84][190] = 317; + GBKFreq[76][166] = 316; + GBKFreq[14][72] = 315; + GBKFreq[67][144] = 314; + GBKFreq[84][44] = 313; + GBKFreq[72][125] = 312; + GBKFreq[66][127] = 311; + GBKFreq[60][25] = 310; + GBKFreq[70][146] = 309; + GBKFreq[79][135] = 308; + GBKFreq[54][135] = 307; + GBKFreq[60][104] = 306; + GBKFreq[55][132] = 305; + GBKFreq[94][2] = 304; + GBKFreq[54][133] = 303; + GBKFreq[56][190] = 302; + GBKFreq[58][174] = 301; + GBKFreq[80][144] = 300; + GBKFreq[85][113] = 299; + /* + * GBKFreq[83][15] = 298; GBKFreq[105][80] = 297; GBKFreq[7][179] = 296; GBKFreq[93][4] = 295; GBKFreq[123][40] = 294; + * GBKFreq[85][120] = 293; GBKFreq[77][165] = 292; GBKFreq[86][67] = 291; GBKFreq[25][162] = 290; GBKFreq[77][183] = 289; + * GBKFreq[83][71] = 288; GBKFreq[78][99] = 287; GBKFreq[72][177] = 286; GBKFreq[71][97] = 285; GBKFreq[58][111] = 284; + * GBKFreq[77][175] = 283; GBKFreq[76][181] = 282; GBKFreq[71][142] = 281; GBKFreq[64][150] = 280; GBKFreq[5][142] = 279; + * GBKFreq[73][128] = 278; GBKFreq[73][156] = 277; GBKFreq[60][188] = 276; GBKFreq[64][56] = 275; GBKFreq[74][128] = 274; + * GBKFreq[48][163] = 273; GBKFreq[54][116] = 272; GBKFreq[73][127] = 271; GBKFreq[16][176] = 270; GBKFreq[62][149] = 269; + * GBKFreq[105][96] = 268; GBKFreq[55][186] = 267; GBKFreq[4][51] = 266; GBKFreq[48][113] = 265; GBKFreq[48][152] = 264; + * GBKFreq[23][9] = 263; GBKFreq[56][102] = 262; GBKFreq[11][81] = 261; GBKFreq[82][112] = 260; GBKFreq[65][85] = 259; + * GBKFreq[69][125] = 258; GBKFreq[68][31] = 257; GBKFreq[5][20] = 256; GBKFreq[60][176] = 255; GBKFreq[82][81] = 254; + * GBKFreq[72][107] = 253; GBKFreq[3][52] = 252; GBKFreq[71][157] = 251; GBKFreq[24][46] = 250; GBKFreq[69][108] = 249; + * GBKFreq[78][178] = 248; GBKFreq[9][69] = 247; GBKFreq[73][144] = 246; GBKFreq[63][187] = 245; GBKFreq[68][36] = 244; + * GBKFreq[47][151] = 243; GBKFreq[14][74] = 242; GBKFreq[47][114] = 241; GBKFreq[80][171] = 240; GBKFreq[75][152] = 239; + * GBKFreq[86][40] = 238; GBKFreq[93][43] = 237; GBKFreq[2][50] = 236; GBKFreq[62][66] = 235; GBKFreq[1][183] = 234; + * GBKFreq[74][124] = 233; GBKFreq[58][104] = 232; GBKFreq[83][106] = 231; GBKFreq[60][144] = 230; GBKFreq[48][99] = 229; + * GBKFreq[54][157] = 228; GBKFreq[70][179] = 227; GBKFreq[61][127] = 226; GBKFreq[57][135] = 225; GBKFreq[59][190] = 224; + * GBKFreq[77][116] = 223; GBKFreq[26][17] = 222; GBKFreq[60][13] = 221; GBKFreq[71][38] = 220; GBKFreq[85][177] = 219; + * GBKFreq[59][73] = 218; GBKFreq[50][150] = 217; GBKFreq[79][102] = 216; GBKFreq[76][118] = 215; GBKFreq[67][132] = 214; + * GBKFreq[73][146] = 213; GBKFreq[83][184] = 212; GBKFreq[86][159] = 211; GBKFreq[95][120] = 210; GBKFreq[23][139] = 209; + * GBKFreq[64][183] = 208; GBKFreq[85][103] = 207; GBKFreq[41][90] = 206; GBKFreq[87][72] = 205; GBKFreq[62][104] = 204; + * GBKFreq[79][168] = 203; GBKFreq[79][150] = 202; GBKFreq[104][20] = 201; GBKFreq[56][114] = 200; GBKFreq[84][26] = 199; + * GBKFreq[57][99] = 198; GBKFreq[62][154] = 197; GBKFreq[47][98] = 196; GBKFreq[61][64] = 195; GBKFreq[112][18] = 194; + * GBKFreq[123][19] = 193; GBKFreq[4][98] = 192; GBKFreq[47][163] = 191; GBKFreq[66][188] = 190; GBKFreq[81][85] = 189; + * GBKFreq[82][30] = 188; GBKFreq[65][83] = 187; GBKFreq[67][24] = 186; GBKFreq[68][179] = 185; GBKFreq[55][177] = 184; + * GBKFreq[2][122] = 183; GBKFreq[47][139] = 182; GBKFreq[79][158] = 181; GBKFreq[64][143] = 180; GBKFreq[100][24] = 179; + * GBKFreq[73][103] = 178; GBKFreq[50][148] = 177; GBKFreq[86][97] = 176; GBKFreq[59][116] = 175; GBKFreq[64][173] = 174; + * GBKFreq[99][91] = 173; GBKFreq[11][99] = 172; GBKFreq[78][179] = 171; GBKFreq[18][17] = 170; GBKFreq[58][185] = 169; + * GBKFreq[47][165] = 168; GBKFreq[67][131] = 167; GBKFreq[94][40] = 166; GBKFreq[74][153] = 165; GBKFreq[79][142] = 164; + * GBKFreq[57][98] = 163; GBKFreq[1][164] = 162; GBKFreq[55][168] = 161; GBKFreq[13][141] = 160; GBKFreq[51][31] = 159; + * GBKFreq[57][178] = 158; GBKFreq[50][189] = 157; GBKFreq[60][167] = 156; GBKFreq[80][34] = 155; GBKFreq[109][80] = 154; + * GBKFreq[85][54] = 153; GBKFreq[69][183] = 152; GBKFreq[67][143] = 151; GBKFreq[47][120] = 150; GBKFreq[45][75] = 149; + * GBKFreq[82][98] = 148; GBKFreq[83][22] = 147; GBKFreq[13][103] = 146; GBKFreq[49][174] = 145; GBKFreq[57][181] = 144; + * GBKFreq[64][127] = 143; GBKFreq[61][131] = 142; GBKFreq[52][180] = 141; GBKFreq[74][134] = 140; GBKFreq[84][187] = 139; + * GBKFreq[81][189] = 138; GBKFreq[47][160] = 137; GBKFreq[66][148] = 136; GBKFreq[7][4] = 135; GBKFreq[85][134] = 134; + * GBKFreq[88][13] = 133; GBKFreq[88][80] = 132; GBKFreq[69][166] = 131; GBKFreq[86][18] = 130; GBKFreq[79][141] = 129; + * GBKFreq[50][108] = 128; GBKFreq[94][69] = 127; GBKFreq[81][110] = 126; GBKFreq[69][119] = 125; GBKFreq[72][161] = 124; + * GBKFreq[106][45] = 123; GBKFreq[73][124] = 122; GBKFreq[94][28] = 121; GBKFreq[63][174] = 120; GBKFreq[3][149] = 119; + * GBKFreq[24][160] = 118; GBKFreq[113][94] = 117; GBKFreq[56][138] = 116; GBKFreq[64][185] = 115; GBKFreq[86][56] = 114; + * GBKFreq[56][150] = 113; GBKFreq[110][55] = 112; GBKFreq[28][13] = 111; GBKFreq[54][190] = 110; GBKFreq[8][180] = 109; + * GBKFreq[73][149] = 108; GBKFreq[80][155] = 107; GBKFreq[83][172] = 106; GBKFreq[67][174] = 105; GBKFreq[64][180] = 104; + * GBKFreq[84][46] = 103; GBKFreq[91][74] = 102; GBKFreq[69][134] = 101; GBKFreq[61][107] = 100; GBKFreq[47][171] = 99; + * GBKFreq[59][51] = 98; GBKFreq[109][74] = 97; GBKFreq[64][174] = 96; GBKFreq[52][151] = 95; GBKFreq[51][176] = 94; + * GBKFreq[80][157] = 93; GBKFreq[94][31] = 92; GBKFreq[79][155] = 91; GBKFreq[72][174] = 90; GBKFreq[69][113] = 89; + * GBKFreq[83][167] = 88; GBKFreq[83][122] = 87; GBKFreq[8][178] = 86; GBKFreq[70][186] = 85; GBKFreq[59][153] = 84; + * GBKFreq[84][68] = 83; GBKFreq[79][39] = 82; GBKFreq[47][180] = 81; GBKFreq[88][53] = 80; GBKFreq[57][154] = 79; + * GBKFreq[47][153] = 78; GBKFreq[3][153] = 77; GBKFreq[76][134] = 76; GBKFreq[51][166] = 75; GBKFreq[58][176] = 74; + * GBKFreq[27][138] = 73; GBKFreq[73][126] = 72; GBKFreq[76][185] = 71; GBKFreq[52][186] = 70; GBKFreq[81][151] = 69; + * GBKFreq[26][50] = 68; GBKFreq[76][173] = 67; GBKFreq[106][56] = 66; GBKFreq[85][142] = 65; GBKFreq[11][103] = 64; + * GBKFreq[69][159] = 63; GBKFreq[53][142] = 62; GBKFreq[7][6] = 61; GBKFreq[84][59] = 60; GBKFreq[86][3] = 59; + * GBKFreq[64][144] = 58; GBKFreq[1][187] = 57; GBKFreq[82][128] = 56; GBKFreq[3][66] = 55; GBKFreq[68][133] = 54; + * GBKFreq[55][167] = 53; GBKFreq[52][130] = 52; GBKFreq[61][133] = 51; GBKFreq[72][181] = 50; GBKFreq[25][98] = 49; + * GBKFreq[84][149] = 48; GBKFreq[91][91] = 47; GBKFreq[47][188] = 46; GBKFreq[68][130] = 45; GBKFreq[22][44] = 44; + * GBKFreq[81][121] = 43; GBKFreq[72][140] = 42; GBKFreq[55][133] = 41; GBKFreq[55][185] = 40; GBKFreq[56][105] = 39; + * GBKFreq[60][30] = 38; GBKFreq[70][103] = 37; GBKFreq[62][141] = 36; GBKFreq[70][144] = 35; GBKFreq[59][111] = 34; + * GBKFreq[54][17] = 33; GBKFreq[18][190] = 32; GBKFreq[65][164] = 31; GBKFreq[83][125] = 30; GBKFreq[61][121] = 29; + * GBKFreq[48][13] = 28; GBKFreq[51][189] = 27; GBKFreq[65][68] = 26; GBKFreq[7][0] = 25; GBKFreq[76][188] = 24; + * GBKFreq[85][117] = 23; GBKFreq[45][33] = 22; GBKFreq[78][187] = 21; GBKFreq[106][48] = 20; GBKFreq[59][52] = 19; + * GBKFreq[86][185] = 18; GBKFreq[84][121] = 17; GBKFreq[82][189] = 16; GBKFreq[68][156] = 15; GBKFreq[55][125] = 14; + * GBKFreq[65][175] = 13; GBKFreq[7][140] = 12; GBKFreq[50][106] = 11; GBKFreq[59][124] = 10; GBKFreq[67][115] = 9; + * GBKFreq[82][114] = 8; GBKFreq[74][121] = 7; GBKFreq[106][69] = 6; GBKFreq[94][27] = 5; GBKFreq[78][98] = 4; + * GBKFreq[85][186] = 3; GBKFreq[108][90] = 2; GBKFreq[62][160] = 1; GBKFreq[60][169] = 0; + */ + KRFreq[31][43] = 600; + KRFreq[19][56] = 599; + KRFreq[38][46] = 598; + KRFreq[3][3] = 597; + KRFreq[29][77] = 596; + KRFreq[19][33] = 595; + KRFreq[30][0] = 594; + KRFreq[29][89] = 593; + KRFreq[31][26] = 592; + KRFreq[31][38] = 591; + KRFreq[32][85] = 590; + KRFreq[15][0] = 589; + KRFreq[16][54] = 588; + KRFreq[15][76] = 587; + KRFreq[31][25] = 586; + KRFreq[23][13] = 585; + KRFreq[28][34] = 584; + KRFreq[18][9] = 583; + KRFreq[29][37] = 582; + KRFreq[22][45] = 581; + KRFreq[19][46] = 580; + KRFreq[16][65] = 579; + KRFreq[23][5] = 578; + KRFreq[26][70] = 577; + KRFreq[31][53] = 576; + KRFreq[27][12] = 575; + KRFreq[30][67] = 574; + KRFreq[31][57] = 573; + KRFreq[20][20] = 572; + KRFreq[30][31] = 571; + KRFreq[20][72] = 570; + KRFreq[15][51] = 569; + KRFreq[3][8] = 568; + KRFreq[32][53] = 567; + KRFreq[27][85] = 566; + KRFreq[25][23] = 565; + KRFreq[15][44] = 564; + KRFreq[32][3] = 563; + KRFreq[31][68] = 562; + KRFreq[30][24] = 561; + KRFreq[29][49] = 560; + KRFreq[27][49] = 559; + KRFreq[23][23] = 558; + KRFreq[31][91] = 557; + KRFreq[31][46] = 556; + KRFreq[19][74] = 555; + KRFreq[27][27] = 554; + KRFreq[3][17] = 553; + KRFreq[20][38] = 552; + KRFreq[21][82] = 551; + KRFreq[28][25] = 550; + KRFreq[32][5] = 549; + KRFreq[31][23] = 548; + KRFreq[25][45] = 547; + KRFreq[32][87] = 546; + KRFreq[18][26] = 545; + KRFreq[24][10] = 544; + KRFreq[26][82] = 543; + KRFreq[15][89] = 542; + KRFreq[28][36] = 541; + KRFreq[28][31] = 540; + KRFreq[16][23] = 539; + KRFreq[16][77] = 538; + KRFreq[19][84] = 537; + KRFreq[23][72] = 536; + KRFreq[38][48] = 535; + KRFreq[23][2] = 534; + KRFreq[30][20] = 533; + KRFreq[38][47] = 532; + KRFreq[39][12] = 531; + KRFreq[23][21] = 530; + KRFreq[18][17] = 529; + KRFreq[30][87] = 528; + KRFreq[29][62] = 527; + KRFreq[29][87] = 526; + KRFreq[34][53] = 525; + KRFreq[32][29] = 524; + KRFreq[35][0] = 523; + KRFreq[24][43] = 522; + KRFreq[36][44] = 521; + KRFreq[20][30] = 520; + KRFreq[39][86] = 519; + KRFreq[22][14] = 518; + KRFreq[29][39] = 517; + KRFreq[28][38] = 516; + KRFreq[23][79] = 515; + KRFreq[24][56] = 514; + KRFreq[29][63] = 513; + KRFreq[31][45] = 512; + KRFreq[23][26] = 511; + KRFreq[15][87] = 510; + KRFreq[30][74] = 509; + KRFreq[24][69] = 508; + KRFreq[20][4] = 507; + KRFreq[27][50] = 506; + KRFreq[30][75] = 505; + KRFreq[24][13] = 504; + KRFreq[30][8] = 503; + KRFreq[31][6] = 502; + KRFreq[25][80] = 501; + KRFreq[36][8] = 500; + KRFreq[15][18] = 499; + KRFreq[39][23] = 498; + KRFreq[16][24] = 497; + KRFreq[31][89] = 496; + KRFreq[15][71] = 495; + KRFreq[15][57] = 494; + KRFreq[30][11] = 493; + KRFreq[15][36] = 492; + KRFreq[16][60] = 491; + KRFreq[24][45] = 490; + KRFreq[37][35] = 489; + KRFreq[24][87] = 488; + KRFreq[20][45] = 487; + KRFreq[31][90] = 486; + KRFreq[32][21] = 485; + KRFreq[19][70] = 484; + KRFreq[24][15] = 483; + KRFreq[26][92] = 482; + KRFreq[37][13] = 481; + KRFreq[39][2] = 480; + KRFreq[23][70] = 479; + KRFreq[27][25] = 478; + KRFreq[15][69] = 477; + KRFreq[19][61] = 476; + KRFreq[31][58] = 475; + KRFreq[24][57] = 474; + KRFreq[36][74] = 473; + KRFreq[21][6] = 472; + KRFreq[30][44] = 471; + KRFreq[15][91] = 470; + KRFreq[27][16] = 469; + KRFreq[29][42] = 468; + KRFreq[33][86] = 467; + KRFreq[29][41] = 466; + KRFreq[20][68] = 465; + KRFreq[25][47] = 464; + KRFreq[22][0] = 463; + KRFreq[18][14] = 462; + KRFreq[31][28] = 461; + KRFreq[15][2] = 460; + KRFreq[23][76] = 459; + KRFreq[38][32] = 458; + KRFreq[29][82] = 457; + KRFreq[21][86] = 456; + KRFreq[24][62] = 455; + KRFreq[31][64] = 454; + KRFreq[38][26] = 453; + KRFreq[32][86] = 452; + KRFreq[22][32] = 451; + KRFreq[19][59] = 450; + KRFreq[34][18] = 449; + KRFreq[18][54] = 448; + KRFreq[38][63] = 447; + KRFreq[36][23] = 446; + KRFreq[35][35] = 445; + KRFreq[32][62] = 444; + KRFreq[28][35] = 443; + KRFreq[27][13] = 442; + KRFreq[31][59] = 441; + KRFreq[29][29] = 440; + KRFreq[15][64] = 439; + KRFreq[26][84] = 438; + KRFreq[21][90] = 437; + KRFreq[20][24] = 436; + KRFreq[16][18] = 435; + KRFreq[22][23] = 434; + KRFreq[31][14] = 433; + KRFreq[15][1] = 432; + KRFreq[18][63] = 431; + KRFreq[19][10] = 430; + KRFreq[25][49] = 429; + KRFreq[36][57] = 428; + KRFreq[20][22] = 427; + KRFreq[15][15] = 426; + KRFreq[31][51] = 425; + KRFreq[24][60] = 424; + KRFreq[31][70] = 423; + KRFreq[15][7] = 422; + KRFreq[28][40] = 421; + KRFreq[18][41] = 420; + KRFreq[15][38] = 419; + KRFreq[32][0] = 418; + KRFreq[19][51] = 417; + KRFreq[34][62] = 416; + KRFreq[16][27] = 415; + KRFreq[20][70] = 414; + KRFreq[22][33] = 413; + KRFreq[26][73] = 412; + KRFreq[20][79] = 411; + KRFreq[23][6] = 410; + KRFreq[24][85] = 409; + KRFreq[38][51] = 408; + KRFreq[29][88] = 407; + KRFreq[38][55] = 406; + KRFreq[32][32] = 405; + KRFreq[27][18] = 404; + KRFreq[23][87] = 403; + KRFreq[35][6] = 402; + KRFreq[34][27] = 401; + KRFreq[39][35] = 400; + KRFreq[30][88] = 399; + KRFreq[32][92] = 398; + KRFreq[32][49] = 397; + KRFreq[24][61] = 396; + KRFreq[18][74] = 395; + KRFreq[23][77] = 394; + KRFreq[23][50] = 393; + KRFreq[23][32] = 392; + KRFreq[23][36] = 391; + KRFreq[38][38] = 390; + KRFreq[29][86] = 389; + KRFreq[36][15] = 388; + KRFreq[31][50] = 387; + KRFreq[15][86] = 386; + KRFreq[39][13] = 385; + KRFreq[34][26] = 384; + KRFreq[19][34] = 383; + KRFreq[16][3] = 382; + KRFreq[26][93] = 381; + KRFreq[19][67] = 380; + KRFreq[24][72] = 379; + KRFreq[29][17] = 378; + KRFreq[23][24] = 377; + KRFreq[25][19] = 376; + KRFreq[18][65] = 375; + KRFreq[30][78] = 374; + KRFreq[27][52] = 373; + KRFreq[22][18] = 372; + KRFreq[16][38] = 371; + KRFreq[21][26] = 370; + KRFreq[34][20] = 369; + KRFreq[15][42] = 368; + KRFreq[16][71] = 367; + KRFreq[17][17] = 366; + KRFreq[24][71] = 365; + KRFreq[18][84] = 364; + KRFreq[15][40] = 363; + KRFreq[31][62] = 362; + KRFreq[15][8] = 361; + KRFreq[16][69] = 360; + KRFreq[29][79] = 359; + KRFreq[38][91] = 358; + KRFreq[31][92] = 357; + KRFreq[20][77] = 356; + KRFreq[3][16] = 355; + KRFreq[27][87] = 354; + KRFreq[16][25] = 353; + KRFreq[36][33] = 352; + KRFreq[37][76] = 351; + KRFreq[30][12] = 350; + KRFreq[26][75] = 349; + KRFreq[25][14] = 348; + KRFreq[32][26] = 347; + KRFreq[23][22] = 346; + KRFreq[20][90] = 345; + KRFreq[19][8] = 344; + KRFreq[38][41] = 343; + KRFreq[34][2] = 342; + KRFreq[39][4] = 341; + KRFreq[27][89] = 340; + KRFreq[28][41] = 339; + KRFreq[28][44] = 338; + KRFreq[24][92] = 337; + KRFreq[34][65] = 336; + KRFreq[39][14] = 335; + KRFreq[21][38] = 334; + KRFreq[19][31] = 333; + KRFreq[37][39] = 332; + KRFreq[33][41] = 331; + KRFreq[38][4] = 330; + KRFreq[23][80] = 329; + KRFreq[25][24] = 328; + KRFreq[37][17] = 327; + KRFreq[22][16] = 326; + KRFreq[22][46] = 325; + KRFreq[33][91] = 324; + KRFreq[24][89] = 323; + KRFreq[30][52] = 322; + KRFreq[29][38] = 321; + KRFreq[38][85] = 320; + KRFreq[15][12] = 319; + KRFreq[27][58] = 318; + KRFreq[29][52] = 317; + KRFreq[37][38] = 316; + KRFreq[34][41] = 315; + KRFreq[31][65] = 314; + KRFreq[29][53] = 313; + KRFreq[22][47] = 312; + KRFreq[22][19] = 311; + KRFreq[26][0] = 310; + KRFreq[37][86] = 309; + KRFreq[35][4] = 308; + KRFreq[36][54] = 307; + KRFreq[20][76] = 306; + KRFreq[30][9] = 305; + KRFreq[30][33] = 304; + KRFreq[23][17] = 303; + KRFreq[23][33] = 302; + KRFreq[38][52] = 301; + KRFreq[15][19] = 300; + KRFreq[28][45] = 299; + KRFreq[29][78] = 298; + KRFreq[23][15] = 297; + KRFreq[33][5] = 296; + KRFreq[17][40] = 295; + KRFreq[30][83] = 294; + KRFreq[18][1] = 293; + KRFreq[30][81] = 292; + KRFreq[19][40] = 291; + KRFreq[24][47] = 290; + KRFreq[17][56] = 289; + KRFreq[39][80] = 288; + KRFreq[30][46] = 287; + KRFreq[16][61] = 286; + KRFreq[26][78] = 285; + KRFreq[26][57] = 284; + KRFreq[20][46] = 283; + KRFreq[25][15] = 282; + KRFreq[25][91] = 281; + KRFreq[21][83] = 280; + KRFreq[30][77] = 279; + KRFreq[35][30] = 278; + KRFreq[30][34] = 277; + KRFreq[20][69] = 276; + KRFreq[35][10] = 275; + KRFreq[29][70] = 274; + KRFreq[22][50] = 273; + KRFreq[18][0] = 272; + KRFreq[22][64] = 271; + KRFreq[38][65] = 270; + KRFreq[22][70] = 269; + KRFreq[24][58] = 268; + KRFreq[19][66] = 267; + KRFreq[30][59] = 266; + KRFreq[37][14] = 265; + KRFreq[16][56] = 264; + KRFreq[29][85] = 263; + KRFreq[31][15] = 262; + KRFreq[36][84] = 261; + KRFreq[39][15] = 260; + KRFreq[39][90] = 259; + KRFreq[18][12] = 258; + KRFreq[21][93] = 257; + KRFreq[24][66] = 256; + KRFreq[27][90] = 255; + KRFreq[25][90] = 254; + KRFreq[22][24] = 253; + KRFreq[36][67] = 252; + KRFreq[33][90] = 251; + KRFreq[15][60] = 250; + KRFreq[23][85] = 249; + KRFreq[34][1] = 248; + KRFreq[39][37] = 247; + KRFreq[21][18] = 246; + KRFreq[34][4] = 245; + KRFreq[28][33] = 244; + KRFreq[15][13] = 243; + KRFreq[32][22] = 242; + KRFreq[30][76] = 241; + KRFreq[20][21] = 240; + KRFreq[38][66] = 239; + KRFreq[32][55] = 238; + KRFreq[32][89] = 237; + KRFreq[25][26] = 236; + KRFreq[16][80] = 235; + KRFreq[15][43] = 234; + KRFreq[38][54] = 233; + KRFreq[39][68] = 232; + KRFreq[22][88] = 231; + KRFreq[21][84] = 230; + KRFreq[21][17] = 229; + KRFreq[20][28] = 228; + KRFreq[32][1] = 227; + KRFreq[33][87] = 226; + KRFreq[38][71] = 225; + KRFreq[37][47] = 224; + KRFreq[18][77] = 223; + KRFreq[37][58] = 222; + KRFreq[34][74] = 221; + KRFreq[32][54] = 220; + KRFreq[27][33] = 219; + KRFreq[32][93] = 218; + KRFreq[23][51] = 217; + KRFreq[20][57] = 216; + KRFreq[22][37] = 215; + KRFreq[39][10] = 214; + KRFreq[39][17] = 213; + KRFreq[33][4] = 212; + KRFreq[32][84] = 211; + KRFreq[34][3] = 210; + KRFreq[28][27] = 209; + KRFreq[15][79] = 208; + KRFreq[34][21] = 207; + KRFreq[34][69] = 206; + KRFreq[21][62] = 205; + KRFreq[36][24] = 204; + KRFreq[16][89] = 203; + KRFreq[18][48] = 202; + KRFreq[38][15] = 201; + KRFreq[36][58] = 200; + KRFreq[21][56] = 199; + KRFreq[34][48] = 198; + KRFreq[21][15] = 197; + KRFreq[39][3] = 196; + KRFreq[16][44] = 195; + KRFreq[18][79] = 194; + KRFreq[25][13] = 193; + KRFreq[29][47] = 192; + KRFreq[38][88] = 191; + KRFreq[20][71] = 190; + KRFreq[16][58] = 189; + KRFreq[35][57] = 188; + KRFreq[29][30] = 187; + KRFreq[29][23] = 186; + KRFreq[34][93] = 185; + KRFreq[30][85] = 184; + KRFreq[15][80] = 183; + KRFreq[32][78] = 182; + KRFreq[37][82] = 181; + KRFreq[22][40] = 180; + KRFreq[21][69] = 179; + KRFreq[26][85] = 178; + KRFreq[31][31] = 177; + KRFreq[28][64] = 176; + KRFreq[38][13] = 175; + KRFreq[25][2] = 174; + KRFreq[22][34] = 173; + KRFreq[28][28] = 172; + KRFreq[24][91] = 171; + KRFreq[33][74] = 170; + KRFreq[29][40] = 169; + KRFreq[15][77] = 168; + KRFreq[32][80] = 167; + KRFreq[30][41] = 166; + KRFreq[23][30] = 165; + KRFreq[24][63] = 164; + KRFreq[30][53] = 163; + KRFreq[39][70] = 162; + KRFreq[23][61] = 161; + KRFreq[37][27] = 160; + KRFreq[16][55] = 159; + KRFreq[22][74] = 158; + KRFreq[26][50] = 157; + KRFreq[16][10] = 156; + KRFreq[34][63] = 155; + KRFreq[35][14] = 154; + KRFreq[17][7] = 153; + KRFreq[15][59] = 152; + KRFreq[27][23] = 151; + KRFreq[18][70] = 150; + KRFreq[32][56] = 149; + KRFreq[37][87] = 148; + KRFreq[17][61] = 147; + KRFreq[18][83] = 146; + KRFreq[23][86] = 145; + KRFreq[17][31] = 144; + KRFreq[23][83] = 143; + KRFreq[35][2] = 142; + KRFreq[18][64] = 141; + KRFreq[27][43] = 140; + KRFreq[32][42] = 139; + KRFreq[25][76] = 138; + KRFreq[19][85] = 137; + KRFreq[37][81] = 136; + KRFreq[38][83] = 135; + KRFreq[35][7] = 134; + KRFreq[16][51] = 133; + KRFreq[27][22] = 132; + KRFreq[16][76] = 131; + KRFreq[22][4] = 130; + KRFreq[38][84] = 129; + KRFreq[17][83] = 128; + KRFreq[24][46] = 127; + KRFreq[33][15] = 126; + KRFreq[20][48] = 125; + KRFreq[17][30] = 124; + KRFreq[30][93] = 123; + KRFreq[28][11] = 122; + KRFreq[28][30] = 121; + KRFreq[15][62] = 120; + KRFreq[17][87] = 119; + KRFreq[32][81] = 118; + KRFreq[23][37] = 117; + KRFreq[30][22] = 116; + KRFreq[32][66] = 115; + KRFreq[33][78] = 114; + KRFreq[21][4] = 113; + KRFreq[31][17] = 112; + KRFreq[39][61] = 111; + KRFreq[18][76] = 110; + KRFreq[15][85] = 109; + KRFreq[31][47] = 108; + KRFreq[19][57] = 107; + KRFreq[23][55] = 106; + KRFreq[27][29] = 105; + KRFreq[29][46] = 104; + KRFreq[33][0] = 103; + KRFreq[16][83] = 102; + KRFreq[39][78] = 101; + KRFreq[32][77] = 100; + KRFreq[36][25] = 99; + KRFreq[34][19] = 98; + KRFreq[38][49] = 97; + KRFreq[19][25] = 96; + KRFreq[23][53] = 95; + KRFreq[28][43] = 94; + KRFreq[31][44] = 93; + KRFreq[36][34] = 92; + KRFreq[16][34] = 91; + KRFreq[35][1] = 90; + KRFreq[19][87] = 89; + KRFreq[18][53] = 88; + KRFreq[29][54] = 87; + KRFreq[22][41] = 86; + KRFreq[38][18] = 85; + KRFreq[22][2] = 84; + KRFreq[20][3] = 83; + KRFreq[39][69] = 82; + KRFreq[30][29] = 81; + KRFreq[28][19] = 80; + KRFreq[29][90] = 79; + KRFreq[17][86] = 78; + KRFreq[15][9] = 77; + KRFreq[39][73] = 76; + KRFreq[15][37] = 75; + KRFreq[35][40] = 74; + KRFreq[33][77] = 73; + KRFreq[27][86] = 72; + KRFreq[36][79] = 71; + KRFreq[23][18] = 70; + KRFreq[34][87] = 69; + KRFreq[39][24] = 68; + KRFreq[26][8] = 67; + KRFreq[33][48] = 66; + KRFreq[39][30] = 65; + KRFreq[33][28] = 64; + KRFreq[16][67] = 63; + KRFreq[31][78] = 62; + KRFreq[32][23] = 61; + KRFreq[24][55] = 60; + KRFreq[30][68] = 59; + KRFreq[18][60] = 58; + KRFreq[15][17] = 57; + KRFreq[23][34] = 56; + KRFreq[20][49] = 55; + KRFreq[15][78] = 54; + KRFreq[24][14] = 53; + KRFreq[19][41] = 52; + KRFreq[31][55] = 51; + KRFreq[21][39] = 50; + KRFreq[35][9] = 49; + KRFreq[30][15] = 48; + KRFreq[20][52] = 47; + KRFreq[35][71] = 46; + KRFreq[20][7] = 45; + KRFreq[29][72] = 44; + KRFreq[37][77] = 43; + KRFreq[22][35] = 42; + KRFreq[20][61] = 41; + KRFreq[31][60] = 40; + KRFreq[20][93] = 39; + KRFreq[27][92] = 38; + KRFreq[28][16] = 37; + KRFreq[36][26] = 36; + KRFreq[18][89] = 35; + KRFreq[21][63] = 34; + KRFreq[22][52] = 33; + KRFreq[24][65] = 32; + KRFreq[31][8] = 31; + KRFreq[31][49] = 30; + KRFreq[33][30] = 29; + KRFreq[37][15] = 28; + KRFreq[18][18] = 27; + KRFreq[25][50] = 26; + KRFreq[29][20] = 25; + KRFreq[35][48] = 24; + KRFreq[38][75] = 23; + KRFreq[26][83] = 22; + KRFreq[21][87] = 21; + KRFreq[27][71] = 20; + KRFreq[32][91] = 19; + KRFreq[25][73] = 18; + KRFreq[16][84] = 17; + KRFreq[25][31] = 16; + KRFreq[17][90] = 15; + KRFreq[18][40] = 14; + KRFreq[17][77] = 13; + KRFreq[17][35] = 12; + KRFreq[23][52] = 11; + KRFreq[23][35] = 10; + KRFreq[16][5] = 9; + KRFreq[23][58] = 8; + KRFreq[19][60] = 7; + KRFreq[30][32] = 6; + KRFreq[38][34] = 5; + KRFreq[23][4] = 4; + KRFreq[23][1] = 3; + KRFreq[27][57] = 2; + KRFreq[39][38] = 1; + KRFreq[32][33] = 0; + JPFreq[3][74] = 600; + JPFreq[3][45] = 599; + JPFreq[3][3] = 598; + JPFreq[3][24] = 597; + JPFreq[3][30] = 596; + JPFreq[3][42] = 595; + JPFreq[3][46] = 594; + JPFreq[3][39] = 593; + JPFreq[3][11] = 592; + JPFreq[3][37] = 591; + JPFreq[3][38] = 590; + JPFreq[3][31] = 589; + JPFreq[3][41] = 588; + JPFreq[3][5] = 587; + JPFreq[3][10] = 586; + JPFreq[3][75] = 585; + JPFreq[3][65] = 584; + JPFreq[3][72] = 583; + JPFreq[37][91] = 582; + JPFreq[0][27] = 581; + JPFreq[3][18] = 580; + JPFreq[3][22] = 579; + JPFreq[3][61] = 578; + JPFreq[3][14] = 577; + JPFreq[24][80] = 576; + JPFreq[4][82] = 575; + JPFreq[17][80] = 574; + JPFreq[30][44] = 573; + JPFreq[3][73] = 572; + JPFreq[3][64] = 571; + JPFreq[38][14] = 570; + JPFreq[33][70] = 569; + JPFreq[3][1] = 568; + JPFreq[3][16] = 567; + JPFreq[3][35] = 566; + JPFreq[3][40] = 565; + JPFreq[4][74] = 564; + JPFreq[4][24] = 563; + JPFreq[42][59] = 562; + JPFreq[3][7] = 561; + JPFreq[3][71] = 560; + JPFreq[3][12] = 559; + JPFreq[15][75] = 558; + JPFreq[3][20] = 557; + JPFreq[4][39] = 556; + JPFreq[34][69] = 555; + JPFreq[3][28] = 554; + JPFreq[35][24] = 553; + JPFreq[3][82] = 552; + JPFreq[28][47] = 551; + JPFreq[3][67] = 550; + JPFreq[37][16] = 549; + JPFreq[26][93] = 548; + JPFreq[4][1] = 547; + JPFreq[26][85] = 546; + JPFreq[31][14] = 545; + JPFreq[4][3] = 544; + JPFreq[4][72] = 543; + JPFreq[24][51] = 542; + JPFreq[27][51] = 541; + JPFreq[27][49] = 540; + JPFreq[22][77] = 539; + JPFreq[27][10] = 538; + JPFreq[29][68] = 537; + JPFreq[20][35] = 536; + JPFreq[41][11] = 535; + JPFreq[24][70] = 534; + JPFreq[36][61] = 533; + JPFreq[31][23] = 532; + JPFreq[43][16] = 531; + JPFreq[23][68] = 530; + JPFreq[32][15] = 529; + JPFreq[3][32] = 528; + JPFreq[19][53] = 527; + JPFreq[40][83] = 526; + JPFreq[4][14] = 525; + JPFreq[36][9] = 524; + JPFreq[4][73] = 523; + JPFreq[23][10] = 522; + JPFreq[3][63] = 521; + JPFreq[39][14] = 520; + JPFreq[3][78] = 519; + JPFreq[33][47] = 518; + JPFreq[21][39] = 517; + JPFreq[34][46] = 516; + JPFreq[36][75] = 515; + JPFreq[41][92] = 514; + JPFreq[37][93] = 513; + JPFreq[4][34] = 512; + JPFreq[15][86] = 511; + JPFreq[46][1] = 510; + JPFreq[37][65] = 509; + JPFreq[3][62] = 508; + JPFreq[32][73] = 507; + JPFreq[21][65] = 506; + JPFreq[29][75] = 505; + JPFreq[26][51] = 504; + JPFreq[3][34] = 503; + JPFreq[4][10] = 502; + JPFreq[30][22] = 501; + JPFreq[35][73] = 500; + JPFreq[17][82] = 499; + JPFreq[45][8] = 498; + JPFreq[27][73] = 497; + JPFreq[18][55] = 496; + JPFreq[25][2] = 495; + JPFreq[3][26] = 494; + JPFreq[45][46] = 493; + JPFreq[4][22] = 492; + JPFreq[4][40] = 491; + JPFreq[18][10] = 490; + JPFreq[32][9] = 489; + JPFreq[26][49] = 488; + JPFreq[3][47] = 487; + JPFreq[24][65] = 486; + JPFreq[4][76] = 485; + JPFreq[43][67] = 484; + JPFreq[3][9] = 483; + JPFreq[41][37] = 482; + JPFreq[33][68] = 481; + JPFreq[43][31] = 480; + JPFreq[19][55] = 479; + JPFreq[4][30] = 478; + JPFreq[27][33] = 477; + JPFreq[16][62] = 476; + JPFreq[36][35] = 475; + JPFreq[37][15] = 474; + JPFreq[27][70] = 473; + JPFreq[22][71] = 472; + JPFreq[33][45] = 471; + JPFreq[31][78] = 470; + JPFreq[43][59] = 469; + JPFreq[32][19] = 468; + JPFreq[17][28] = 467; + JPFreq[40][28] = 466; + JPFreq[20][93] = 465; + JPFreq[18][15] = 464; + JPFreq[4][23] = 463; + JPFreq[3][23] = 462; + JPFreq[26][64] = 461; + JPFreq[44][92] = 460; + JPFreq[17][27] = 459; + JPFreq[3][56] = 458; + JPFreq[25][38] = 457; + JPFreq[23][31] = 456; + JPFreq[35][43] = 455; + JPFreq[4][54] = 454; + JPFreq[35][19] = 453; + JPFreq[22][47] = 452; + JPFreq[42][0] = 451; + JPFreq[23][28] = 450; + JPFreq[46][33] = 449; + JPFreq[36][85] = 448; + JPFreq[31][12] = 447; + JPFreq[3][76] = 446; + JPFreq[4][75] = 445; + JPFreq[36][56] = 444; + JPFreq[4][64] = 443; + JPFreq[25][77] = 442; + JPFreq[15][52] = 441; + JPFreq[33][73] = 440; + JPFreq[3][55] = 439; + JPFreq[43][82] = 438; + JPFreq[27][82] = 437; + JPFreq[20][3] = 436; + JPFreq[40][51] = 435; + JPFreq[3][17] = 434; + JPFreq[27][71] = 433; + JPFreq[4][52] = 432; + JPFreq[44][48] = 431; + JPFreq[27][2] = 430; + JPFreq[17][39] = 429; + JPFreq[31][8] = 428; + JPFreq[44][54] = 427; + JPFreq[43][18] = 426; + JPFreq[43][77] = 425; + JPFreq[4][61] = 424; + JPFreq[19][91] = 423; + JPFreq[31][13] = 422; + JPFreq[44][71] = 421; + JPFreq[20][0] = 420; + JPFreq[23][87] = 419; + JPFreq[21][14] = 418; + JPFreq[29][13] = 417; + JPFreq[3][58] = 416; + JPFreq[26][18] = 415; + JPFreq[4][47] = 414; + JPFreq[4][18] = 413; + JPFreq[3][53] = 412; + JPFreq[26][92] = 411; + JPFreq[21][7] = 410; + JPFreq[4][37] = 409; + JPFreq[4][63] = 408; + JPFreq[36][51] = 407; + JPFreq[4][32] = 406; + JPFreq[28][73] = 405; + JPFreq[4][50] = 404; + JPFreq[41][60] = 403; + JPFreq[23][1] = 402; + JPFreq[36][92] = 401; + JPFreq[15][41] = 400; + JPFreq[21][71] = 399; + JPFreq[41][30] = 398; + JPFreq[32][76] = 397; + JPFreq[17][34] = 396; + JPFreq[26][15] = 395; + JPFreq[26][25] = 394; + JPFreq[31][77] = 393; + JPFreq[31][3] = 392; + JPFreq[46][34] = 391; + JPFreq[27][84] = 390; + JPFreq[23][8] = 389; + JPFreq[16][0] = 388; + JPFreq[28][80] = 387; + JPFreq[26][54] = 386; + JPFreq[33][18] = 385; + JPFreq[31][20] = 384; + JPFreq[31][62] = 383; + JPFreq[30][41] = 382; + JPFreq[33][30] = 381; + JPFreq[45][45] = 380; + JPFreq[37][82] = 379; + JPFreq[15][33] = 378; + JPFreq[20][12] = 377; + JPFreq[18][5] = 376; + JPFreq[28][86] = 375; + JPFreq[30][19] = 374; + JPFreq[42][43] = 373; + JPFreq[36][31] = 372; + JPFreq[17][93] = 371; + JPFreq[4][15] = 370; + JPFreq[21][20] = 369; + JPFreq[23][21] = 368; + JPFreq[28][72] = 367; + JPFreq[4][20] = 366; + JPFreq[26][55] = 365; + JPFreq[21][5] = 364; + JPFreq[19][16] = 363; + JPFreq[23][64] = 362; + JPFreq[40][59] = 361; + JPFreq[37][26] = 360; + JPFreq[26][56] = 359; + JPFreq[4][12] = 358; + JPFreq[33][71] = 357; + JPFreq[32][39] = 356; + JPFreq[38][40] = 355; + JPFreq[22][74] = 354; + JPFreq[3][25] = 353; + JPFreq[15][48] = 352; + JPFreq[41][82] = 351; + JPFreq[41][9] = 350; + JPFreq[25][48] = 349; + JPFreq[31][71] = 348; + JPFreq[43][29] = 347; + JPFreq[26][80] = 346; + JPFreq[4][5] = 345; + JPFreq[18][71] = 344; + JPFreq[29][0] = 343; + JPFreq[43][43] = 342; + JPFreq[23][81] = 341; + JPFreq[4][42] = 340; + JPFreq[44][28] = 339; + JPFreq[23][93] = 338; + JPFreq[17][81] = 337; + JPFreq[25][25] = 336; + JPFreq[41][23] = 335; + JPFreq[34][35] = 334; + JPFreq[4][53] = 333; + JPFreq[28][36] = 332; + JPFreq[4][41] = 331; + JPFreq[25][60] = 330; + JPFreq[23][20] = 329; + JPFreq[3][43] = 328; + JPFreq[24][79] = 327; + JPFreq[29][41] = 326; + JPFreq[30][83] = 325; + JPFreq[3][50] = 324; + JPFreq[22][18] = 323; + JPFreq[18][3] = 322; + JPFreq[39][30] = 321; + JPFreq[4][28] = 320; + JPFreq[21][64] = 319; + JPFreq[4][68] = 318; + JPFreq[17][71] = 317; + JPFreq[27][0] = 316; + JPFreq[39][28] = 315; + JPFreq[30][13] = 314; + JPFreq[36][70] = 313; + JPFreq[20][82] = 312; + JPFreq[33][38] = 311; + JPFreq[44][87] = 310; + JPFreq[34][45] = 309; + JPFreq[4][26] = 308; + JPFreq[24][44] = 307; + JPFreq[38][67] = 306; + JPFreq[38][6] = 305; + JPFreq[30][68] = 304; + JPFreq[15][89] = 303; + JPFreq[24][93] = 302; + JPFreq[40][41] = 301; + JPFreq[38][3] = 300; + JPFreq[28][23] = 299; + JPFreq[26][17] = 298; + JPFreq[4][38] = 297; + JPFreq[22][78] = 296; + JPFreq[15][37] = 295; + JPFreq[25][85] = 294; + JPFreq[4][9] = 293; + JPFreq[4][7] = 292; + JPFreq[27][53] = 291; + JPFreq[39][29] = 290; + JPFreq[41][43] = 289; + JPFreq[25][62] = 288; + JPFreq[4][48] = 287; + JPFreq[28][28] = 286; + JPFreq[21][40] = 285; + JPFreq[36][73] = 284; + JPFreq[26][39] = 283; + JPFreq[22][54] = 282; + JPFreq[33][5] = 281; + JPFreq[19][21] = 280; + JPFreq[46][31] = 279; + JPFreq[20][64] = 278; + JPFreq[26][63] = 277; + JPFreq[22][23] = 276; + JPFreq[25][81] = 275; + JPFreq[4][62] = 274; + JPFreq[37][31] = 273; + JPFreq[40][52] = 272; + JPFreq[29][79] = 271; + JPFreq[41][48] = 270; + JPFreq[31][57] = 269; + JPFreq[32][92] = 268; + JPFreq[36][36] = 267; + JPFreq[27][7] = 266; + JPFreq[35][29] = 265; + JPFreq[37][34] = 264; + JPFreq[34][42] = 263; + JPFreq[27][15] = 262; + JPFreq[33][27] = 261; + JPFreq[31][38] = 260; + JPFreq[19][79] = 259; + JPFreq[4][31] = 258; + JPFreq[4][66] = 257; + JPFreq[17][32] = 256; + JPFreq[26][67] = 255; + JPFreq[16][30] = 254; + JPFreq[26][46] = 253; + JPFreq[24][26] = 252; + JPFreq[35][10] = 251; + JPFreq[18][37] = 250; + JPFreq[3][19] = 249; + JPFreq[33][69] = 248; + JPFreq[31][9] = 247; + JPFreq[45][29] = 246; + JPFreq[3][15] = 245; + JPFreq[18][54] = 244; + JPFreq[3][44] = 243; + JPFreq[31][29] = 242; + JPFreq[18][45] = 241; + JPFreq[38][28] = 240; + JPFreq[24][12] = 239; + JPFreq[35][82] = 238; + JPFreq[17][43] = 237; + JPFreq[28][9] = 236; + JPFreq[23][25] = 235; + JPFreq[44][37] = 234; + JPFreq[23][75] = 233; + JPFreq[23][92] = 232; + JPFreq[0][24] = 231; + JPFreq[19][74] = 230; + JPFreq[45][32] = 229; + JPFreq[16][72] = 228; + JPFreq[16][93] = 227; + JPFreq[45][13] = 226; + JPFreq[24][8] = 225; + JPFreq[25][47] = 224; + JPFreq[28][26] = 223; + JPFreq[43][81] = 222; + JPFreq[32][71] = 221; + JPFreq[18][41] = 220; + JPFreq[26][62] = 219; + JPFreq[41][24] = 218; + JPFreq[40][11] = 217; + JPFreq[43][57] = 216; + JPFreq[34][53] = 215; + JPFreq[20][32] = 214; + JPFreq[34][43] = 213; + JPFreq[41][91] = 212; + JPFreq[29][57] = 211; + JPFreq[15][43] = 210; + JPFreq[22][89] = 209; + JPFreq[33][83] = 208; + JPFreq[43][20] = 207; + JPFreq[25][58] = 206; + JPFreq[30][30] = 205; + JPFreq[4][56] = 204; + JPFreq[17][64] = 203; + JPFreq[23][0] = 202; + JPFreq[44][12] = 201; + JPFreq[25][37] = 200; + JPFreq[35][13] = 199; + JPFreq[20][30] = 198; + JPFreq[21][84] = 197; + JPFreq[29][14] = 196; + JPFreq[30][5] = 195; + JPFreq[37][2] = 194; + JPFreq[4][78] = 193; + JPFreq[29][78] = 192; + JPFreq[29][84] = 191; + JPFreq[32][86] = 190; + JPFreq[20][68] = 189; + JPFreq[30][39] = 188; + JPFreq[15][69] = 187; + JPFreq[4][60] = 186; + JPFreq[20][61] = 185; + JPFreq[41][67] = 184; + JPFreq[16][35] = 183; + JPFreq[36][57] = 182; + JPFreq[39][80] = 181; + JPFreq[4][59] = 180; + JPFreq[4][44] = 179; + JPFreq[40][54] = 178; + JPFreq[30][8] = 177; + JPFreq[44][30] = 176; + JPFreq[31][93] = 175; + JPFreq[31][47] = 174; + JPFreq[16][70] = 173; + JPFreq[21][0] = 172; + JPFreq[17][35] = 171; + JPFreq[21][67] = 170; + JPFreq[44][18] = 169; + JPFreq[36][29] = 168; + JPFreq[18][67] = 167; + JPFreq[24][28] = 166; + JPFreq[36][24] = 165; + JPFreq[23][5] = 164; + JPFreq[31][65] = 163; + JPFreq[26][59] = 162; + JPFreq[28][2] = 161; + JPFreq[39][69] = 160; + JPFreq[42][40] = 159; + JPFreq[37][80] = 158; + JPFreq[15][66] = 157; + JPFreq[34][38] = 156; + JPFreq[28][48] = 155; + JPFreq[37][77] = 154; + JPFreq[29][34] = 153; + JPFreq[33][12] = 152; + JPFreq[4][65] = 151; + JPFreq[30][31] = 150; + JPFreq[27][92] = 149; + JPFreq[4][2] = 148; + JPFreq[4][51] = 147; + JPFreq[23][77] = 146; + JPFreq[4][35] = 145; + JPFreq[3][13] = 144; + JPFreq[26][26] = 143; + JPFreq[44][4] = 142; + JPFreq[39][53] = 141; + JPFreq[20][11] = 140; + JPFreq[40][33] = 139; + JPFreq[45][7] = 138; + JPFreq[4][70] = 137; + JPFreq[3][49] = 136; + JPFreq[20][59] = 135; + JPFreq[21][12] = 134; + JPFreq[33][53] = 133; + JPFreq[20][14] = 132; + JPFreq[37][18] = 131; + JPFreq[18][17] = 130; + JPFreq[36][23] = 129; + JPFreq[18][57] = 128; + JPFreq[26][74] = 127; + JPFreq[35][2] = 126; + JPFreq[38][58] = 125; + JPFreq[34][68] = 124; + JPFreq[29][81] = 123; + JPFreq[20][69] = 122; + JPFreq[39][86] = 121; + JPFreq[4][16] = 120; + JPFreq[16][49] = 119; + JPFreq[15][72] = 118; + JPFreq[26][35] = 117; + JPFreq[32][14] = 116; + JPFreq[40][90] = 115; + JPFreq[33][79] = 114; + JPFreq[35][4] = 113; + JPFreq[23][33] = 112; + JPFreq[19][19] = 111; + JPFreq[31][41] = 110; + JPFreq[44][1] = 109; + JPFreq[22][56] = 108; + JPFreq[31][27] = 107; + JPFreq[32][18] = 106; + JPFreq[27][32] = 105; + JPFreq[37][39] = 104; + JPFreq[42][11] = 103; + JPFreq[29][71] = 102; + JPFreq[32][58] = 101; + JPFreq[46][10] = 100; + JPFreq[17][30] = 99; + JPFreq[38][15] = 98; + JPFreq[29][60] = 97; + JPFreq[4][11] = 96; + JPFreq[38][31] = 95; + JPFreq[40][79] = 94; + JPFreq[28][49] = 93; + JPFreq[28][84] = 92; + JPFreq[26][77] = 91; + JPFreq[22][32] = 90; + JPFreq[33][17] = 89; + JPFreq[23][18] = 88; + JPFreq[32][64] = 87; + JPFreq[4][6] = 86; + JPFreq[33][51] = 85; + JPFreq[44][77] = 84; + JPFreq[29][5] = 83; + JPFreq[46][25] = 82; + JPFreq[19][58] = 81; + JPFreq[4][46] = 80; + JPFreq[15][71] = 79; + JPFreq[18][58] = 78; + JPFreq[26][45] = 77; + JPFreq[45][66] = 76; + JPFreq[34][10] = 75; + JPFreq[19][37] = 74; + JPFreq[33][65] = 73; + JPFreq[44][52] = 72; + JPFreq[16][38] = 71; + JPFreq[36][46] = 70; + JPFreq[20][26] = 69; + JPFreq[30][37] = 68; + JPFreq[4][58] = 67; + JPFreq[43][2] = 66; + JPFreq[30][18] = 65; + JPFreq[19][35] = 64; + JPFreq[15][68] = 63; + JPFreq[3][36] = 62; + JPFreq[35][40] = 61; + JPFreq[36][32] = 60; + JPFreq[37][14] = 59; + JPFreq[17][11] = 58; + JPFreq[19][78] = 57; + JPFreq[37][11] = 56; + JPFreq[28][63] = 55; + JPFreq[29][61] = 54; + JPFreq[33][3] = 53; + JPFreq[41][52] = 52; + JPFreq[33][63] = 51; + JPFreq[22][41] = 50; + JPFreq[4][19] = 49; + JPFreq[32][41] = 48; + JPFreq[24][4] = 47; + JPFreq[31][28] = 46; + JPFreq[43][30] = 45; + JPFreq[17][3] = 44; + JPFreq[43][70] = 43; + JPFreq[34][19] = 42; + JPFreq[20][77] = 41; + JPFreq[18][83] = 40; + JPFreq[17][15] = 39; + JPFreq[23][61] = 38; + JPFreq[40][27] = 37; + JPFreq[16][48] = 36; + JPFreq[39][78] = 35; + JPFreq[41][53] = 34; + JPFreq[40][91] = 33; + JPFreq[40][72] = 32; + JPFreq[18][52] = 31; + JPFreq[35][66] = 30; + JPFreq[39][93] = 29; + JPFreq[19][48] = 28; + JPFreq[26][36] = 27; + JPFreq[27][25] = 26; + JPFreq[42][71] = 25; + JPFreq[42][85] = 24; + JPFreq[26][48] = 23; + JPFreq[28][15] = 22; + JPFreq[3][66] = 21; + JPFreq[25][24] = 20; + JPFreq[27][43] = 19; + JPFreq[27][78] = 18; + JPFreq[45][43] = 17; + JPFreq[27][72] = 16; + JPFreq[40][29] = 15; + JPFreq[41][0] = 14; + JPFreq[19][57] = 13; + JPFreq[15][59] = 12; + JPFreq[29][29] = 11; + JPFreq[4][25] = 10; + JPFreq[21][42] = 9; + JPFreq[23][35] = 8; + JPFreq[33][1] = 7; + JPFreq[4][57] = 6; + JPFreq[17][60] = 5; + JPFreq[25][19] = 4; + JPFreq[22][65] = 3; + JPFreq[42][29] = 2; + JPFreq[27][66] = 1; + JPFreq[26][89] = 0; + } + } + + class Encoding { + // Supported Encoding Types + public static int GB2312 = 0; + + public static int GBK = 1; + + public static int GB18030 = 2; + + public static int HZ = 3; + + public static int BIG5 = 4; + + public static int CNS11643 = 5; + + public static int UTF8 = 6; + + public static int UTF8T = 7; + + public static int UTF8S = 8; + + public static int UNICODE = 9; + + public static int UNICODET = 10; + + public static int UNICODES = 11; + + public static int ISO2022CN = 12; + + public static int ISO2022CN_CNS = 13; + + public static int ISO2022CN_GB = 14; + + public static int EUC_KR = 15; + + public static int CP949 = 16; + + public static int ISO2022KR = 17; + + public static int JOHAB = 18; + + public static int SJIS = 19; + + public static int EUC_JP = 20; + + public static int ISO2022JP = 21; + + public static int ASCII = 22; + + public static int OTHER = 23; + + public static int TOTALTYPES = 24; + + public final static int SIMP = 0; + + public final static int TRAD = 1; + + // Names of the encodings as understood by Java + public static String[] javaname; + + // Names of the encodings for human viewing + public static String[] nicename; + + // Names of charsets as used in charset parameter of HTML Meta tag + public static String[] htmlname; + + // Constructor + public Encoding() { + javaname = new String[TOTALTYPES]; + nicename = new String[TOTALTYPES]; + htmlname = new String[TOTALTYPES]; + // Assign encoding names + javaname[GB2312] = "GB2312"; + javaname[GBK] = "GBK"; + javaname[GB18030] = "GB18030"; + javaname[HZ] = "ASCII"; // What to put here? Sun doesn't support HZ + javaname[ISO2022CN_GB] = "ISO2022CN_GB"; + javaname[BIG5] = "BIG5"; + javaname[CNS11643] = "EUC-TW"; + javaname[ISO2022CN_CNS] = "ISO2022CN_CNS"; + javaname[ISO2022CN] = "ISO2022CN"; + javaname[UTF8] = "UTF-8"; + javaname[UTF8T] = "UTF-8"; + javaname[UTF8S] = "UTF-8"; + javaname[UNICODE] = "Unicode"; + javaname[UNICODET] = "Unicode"; + javaname[UNICODES] = "Unicode"; + javaname[EUC_KR] = "EUC_KR"; + javaname[CP949] = "MS949"; + javaname[ISO2022KR] = "ISO2022KR"; + javaname[JOHAB] = "Johab"; + javaname[SJIS] = "SJIS"; + javaname[EUC_JP] = "EUC_JP"; + javaname[ISO2022JP] = "ISO2022JP"; + javaname[ASCII] = "ASCII"; + javaname[OTHER] = "ISO8859_1"; + // Assign encoding names + htmlname[GB2312] = "GB2312"; + htmlname[GBK] = "GBK"; + htmlname[GB18030] = "GB18030"; + htmlname[HZ] = "HZ-GB-2312"; + htmlname[ISO2022CN_GB] = "ISO-2022-CN-EXT"; + htmlname[BIG5] = "BIG5"; + htmlname[CNS11643] = "EUC-TW"; + htmlname[ISO2022CN_CNS] = "ISO-2022-CN-EXT"; + htmlname[ISO2022CN] = "ISO-2022-CN"; + htmlname[UTF8] = "UTF-8"; + htmlname[UTF8T] = "UTF-8"; + htmlname[UTF8S] = "UTF-8"; + htmlname[UNICODE] = "UTF-16"; + htmlname[UNICODET] = "UTF-16"; + htmlname[UNICODES] = "UTF-16"; + htmlname[EUC_KR] = "EUC-KR"; + htmlname[CP949] = "x-windows-949"; + htmlname[ISO2022KR] = "ISO-2022-KR"; + htmlname[JOHAB] = "x-Johab"; + htmlname[SJIS] = "Shift_JIS"; + htmlname[EUC_JP] = "EUC-JP"; + htmlname[ISO2022JP] = "ISO-2022-JP"; + htmlname[ASCII] = "ASCII"; + htmlname[OTHER] = "ISO8859-1"; + // Assign Human readable names + nicename[GB2312] = "GB-2312"; + nicename[GBK] = "GBK"; + nicename[GB18030] = "GB18030"; + nicename[HZ] = "HZ"; + nicename[ISO2022CN_GB] = "ISO2022CN-GB"; + nicename[BIG5] = "Big5"; + nicename[CNS11643] = "CNS11643"; + nicename[ISO2022CN_CNS] = "ISO2022CN-CNS"; + nicename[ISO2022CN] = "ISO2022 CN"; + nicename[UTF8] = "UTF-8"; + nicename[UTF8T] = "UTF-8 (Trad)"; + nicename[UTF8S] = "UTF-8 (Simp)"; + nicename[UNICODE] = "Unicode"; + nicename[UNICODET] = "Unicode (Trad)"; + nicename[UNICODES] = "Unicode (Simp)"; + nicename[EUC_KR] = "EUC-KR"; + nicename[CP949] = "CP949"; + nicename[ISO2022KR] = "ISO 2022 KR"; + nicename[JOHAB] = "Johab"; + nicename[SJIS] = "Shift-JIS"; + nicename[EUC_JP] = "EUC-JP"; + nicename[ISO2022JP] = "ISO 2022 JP"; + nicename[ASCII] = "ASCII"; + nicename[OTHER] = "OTHER"; + } + + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java b/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java similarity index 80% rename from designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java rename to designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java index ceebd0c01f..ff96907a7b 100644 --- a/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java +++ b/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java @@ -4,25 +4,25 @@ import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.remote.ui.AuthorityManagerPane; -import com.fr.workspace.server.authority.AuthorityOperator; - import com.fr.log.FineLoggerFactory; import com.fr.report.DesignAuthority; import com.fr.workspace.WorkContext; +import com.fr.workspace.server.authority.AuthorityOperator; import java.awt.event.ActionEvent; /** * @author yaohwu */ -public class RemoteDesignAuthorityManagerAction extends UpdateAction { +public class RemoteDesignAuthManagerAction extends UpdateAction { - public RemoteDesignAuthorityManagerAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager")); - this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png")); + public RemoteDesignAuthManagerAction() { + this.setName(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager")); + this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@1x.png")); } @@ -49,7 +49,6 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction { @Override public void doOk() { - DesignAuthority[] authorities = managerPane.update(); if (!WorkContext.getCurrent().isLocal()) { boolean success = false; @@ -58,15 +57,9 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction { } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - FineLoggerFactory.getLogger().info("update remote design authority: " + success); + FineLoggerFactory.getLogger().debug("update remote design authority: " + success); } } - - @Override - public void doCancel() { - - super.doCancel(); - } }); dialog.setModal(true); dialog.setVisible(true); diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java b/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java index f917e92198..1d027ac8a1 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java @@ -10,6 +10,7 @@ import com.fr.design.gui.controlpane.ShortCut4JControlPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.Toolkit; import com.fr.design.icon.IconPathConstants; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.menu.ShortCut; @@ -19,7 +20,6 @@ import com.fr.design.remote.ui.list.AuthorityList; import com.fr.design.remote.ui.list.AuthorityListCellRenderer; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; - import com.fr.log.FineLoggerFactory; import com.fr.report.DesignAuthority; import com.fr.stable.ArrayUtils; @@ -78,7 +78,7 @@ public class AuthorityListControlPane extends BasicPane { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.authorityCreators = new RemoteDesignAuthorityCreator[]{ new RemoteDesignAuthorityCreator( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Design_User"), + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_User"), BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"), DesignAuthority.class, AuthorityEditorPane.class) @@ -247,6 +247,27 @@ public class AuthorityListControlPane extends BasicPane { } + /** + * 添加 RemoteDesignAuthority + * + * @param authorities authority + */ + public void setAuthority(List authorities) { + DefaultListModel model = (DefaultListModel) authorityList.getModel(); + model.clear(); + if (authorities != null && !authorities.isEmpty()) { + for (DesignAuthority authority : authorities) { + model.addElement(authority); + } + int size = model.getSize() - 1; + authorityList.setSelectedIndex(size); + authorityList.ensureIndexIsVisible(size); + } + authorityList.revalidate(); + authorityList.repaint(); + } + + protected DefaultListModel getModel() { return (DefaultListModel) this.authorityList.getModel(); } @@ -465,12 +486,12 @@ public class AuthorityListControlPane extends BasicPane { } /** - * 添加按钮 + * 选择按钮 */ private class AddItemUpdateAction extends UpdateAction { AddItemUpdateAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Action_Add")); + this.setName(Toolkit.i18nText("Fine-Design_Basic_Action_Choose")); this.setMnemonic('A'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); } @@ -480,29 +501,54 @@ public class AuthorityListControlPane extends BasicPane { final UserManagerPane userManagerPane = new UserManagerPane(); BasicDialog dialog = userManagerPane.showWindow(SwingUtilities.getWindowAncestor(AuthorityListControlPane.this)); + // 刷新用户管理面板展示信息 + final DesignAuthority[] authorities = AuthorityListControlPane.this.update(); + dialog.addDialogActionListener(new DialogActionAdapter() { @Override public void doOk() { // 获取添加的用户到权限编辑面板 List members = userManagerPane.update(); + + List oldAuthorities = new ArrayList<>(); + + // 已有的未修改的 + for (RemoteDesignMember member : members) { + for (DesignAuthority authority : authorities) { + if (member.getUserId().equals(authority.getUserId())) { + oldAuthorities.add(authority); + } + } + } + // 保留已有且仍选择的,删除不再选择的 + setAuthority(oldAuthorities); + + // 新增的 for (RemoteDesignMember member : members) { DesignAuthority authority = new DesignAuthority(); authority.setUsername(member.getUsername()); authority.setUserId(member.getUserId()); authority.setRealName(member.getRealName()); - AuthorityListControlPane.this.addAuthority(authority, getModel().getSize()); + addAuthority(authority, getModel().getSize()); } - } - @Override - public void doCancel() { - super.doCancel(); } }); - dialog.setModal(true); - dialog.setVisible(true); + List members = new ArrayList<>(); + + for (DesignAuthority authority : authorities) { + RemoteDesignMember m = new RemoteDesignMember(); + m.setUsername(authority.getUsername()); + m.setUserId(authority.getUserId()); + m.setRealName(authority.getRealName()); + m.setSelected(true); + members.add(m); + } + userManagerPane.populate(members); + dialog.setModal(true); + dialog.setVisible(true); } } @@ -511,7 +557,7 @@ public class AuthorityListControlPane extends BasicPane { */ private class RemoveItemAction extends UpdateAction { RemoveItemAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Action_Remove")); + this.setName(Toolkit.i18nText("Fine-Design_Basic_Action_Remove")); this.setMnemonic('R'); this.setSmallIcon(BaseUtils .readIcon(IconPathConstants.TD_REMOVE_ICON_PATH)); diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java b/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java index f84bff5c90..7dbf8ed4ea 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java @@ -1,7 +1,7 @@ package com.fr.design.remote.ui; import com.fr.design.dialog.BasicPane; - +import com.fr.design.i18n.Toolkit; import com.fr.report.DesignAuthority; import javax.swing.BorderFactory; @@ -23,7 +23,7 @@ public class AuthorityManagerPane extends BasicPane { @Override protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager"); + return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager"); } public void populate(DesignAuthority[] authorities) { diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java index bb3f222b99..1e22dc8083 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java @@ -1,5 +1,6 @@ package com.fr.design.remote.ui; +import com.fr.base.BaseUtils; import com.fr.design.border.UITitledBorder; import com.fr.design.constants.LayoutConstants; import com.fr.design.dialog.BasicPane; @@ -208,10 +209,23 @@ public class UserManagerPane extends BasicPane { BorderLayout.CENTER); } + public void populate(List addedMembers) { + + // 已选信息 + resetAddedMembers(); + this.addedMembers.addAll(addedMembers); + + // 刷新右侧面板 + addToAddedMemberList(); + + // 刷新左侧展示信息 + addToMemberList(); + } + @Override protected String title4PopupWindow() { - return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Add_Member"); + return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_Member"); } private JPanel createLeftPanel() { @@ -227,13 +241,14 @@ public class UserManagerPane extends BasicPane { ); // 搜索 - JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - searchPanel.setBorder(BorderFactory.createEmptyBorder()); - keyField.setPreferredSize(new Dimension(250, 20)); + JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5)); + searchPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + keyField.setPreferredSize(new Dimension(270, 20)); keyField.requestFocus(); keyField.addKeyListener(keyFieldKeyListener); keyField.getDocument().addDocumentListener(documentListener); - keyButton.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Search")); + keyButton.setIcon(BaseUtils.readIcon("com/fr/design/images/buttonicon/user_search_normal.png")); + keyButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Search")); keyButton.addActionListener(keyButtonActionListener); searchPanel.add(keyField); searchPanel.add(keyButton); @@ -354,9 +369,9 @@ public class UserManagerPane extends BasicPane { final SwingWorker getMemberWorker = new SwingWorker, Void>() { @Override protected List doInBackground() { - addingMembers.clear(); - String username = WorkContext.getConnector().currentUser(); + String username = WorkContext.getCurrent().getConnection().getUserName(); synchronized (addingMembers) { + addingMembers.clear(); Collection more = WorkContext.getCurrent().get(DecisionOperator.class).getMembers(username, keyword); pageNum = 1; if (!more.isEmpty()) { @@ -382,7 +397,8 @@ public class UserManagerPane extends BasicPane { final SwingWorker loadMoreWorker = new SwingWorker, Void>() { @Override protected List doInBackground() { - String username = WorkContext.getConnector().currentUser(); + + String username = WorkContext.getCurrent().getConnection().getUserName(); synchronized (addingMembers) { addingMembers.remove(RemoteDesignMember.DEFAULT_MEMBER); Collection more = diff --git a/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java b/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java index ef8f8276e6..a412e0a8a8 100644 --- a/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java +++ b/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java @@ -36,26 +36,17 @@ import java.util.Enumeration; */ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSourceChange { - private static final int REPORT_PLATEFORM_MANAGE = 0; - private static final int FS_MANAGE = 1; private static final int LEFT_GAP = -125; - private static boolean isSupportFS = false; - private TreePath treePath = null; - private static ReportAndFSManagePane singleton = new ReportAndFSManagePane(); private static RoleTree roleTree; - // carl:我先屏了,现在半拉子,等客户要了再好好做 -// private AddAction addAction = new AddAction(); -// private RemoveAction removeAction = new RemoveAction(); private RefreshAction refreshAction = new RefreshAction(); private UIHeadGroup buttonGroup; private RoleSourceOP op; - protected String[] roleNames = new String[2]; + private String roleNames; public synchronized static ReportAndFSManagePane getInstance() { singleton.op = new RoleSourceOP(); - singleton.op.setDataMode(isSupportFS ? FS_MANAGE : REPORT_PLATEFORM_MANAGE); singleton.setDefaultSelectedRole(); return singleton; @@ -99,29 +90,15 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo } protected void setTabRoleName(String roleName) { - roleNames[getMode()] = roleTree.getSelectedRoleName(); + roleNames = roleTree.getSelectedRoleName(); } }; roleTree.setEnabled(true); roleTree.setEditable(false); -// RoleTreeCellEditor treeCellEditor = new RoleTreeCellEditor(new UITextField()); -// treeCellEditor.addCellEditorListener(treeCellEditor); -// roleTree.setCellEditor(treeCellEditor); roleTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { super.mouseClicked(e); roleTree.setEditable(false); -// int row = roleTree.getRowForLocation(e.getX(), e.getY()); -// TreePath path = roleTree.getPathForLocation(e.getX(), e.getY()); -// if (e.getClickCount() == 2 && buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { -// PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); -// AuthenticationProvider ap = pm.getAuthenticationProvider(); -// if (!(ap instanceof DaoAuthenticationProvider)) { -// roleTree.setEditable(true); -// roleTree.startEditingAtPath(path); -// treePath = path; -// } -// } } }); } @@ -141,7 +118,7 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); String selectedRole = null; if (singleton != null) { - selectedRole = roleNames[getMode()]; + selectedRole = roleNames; } if (selectedRole == null) { if (node.getChildCount() <= 0 || node.getFirstChild().getChildCount() <= 0) { @@ -190,13 +167,12 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo public void tabChanged(int index) { roleTree.setEditable(false); if (op != null) { - op.setDataMode(getMode()); //判断是否可编辑 refreshDockingView(); } setDefaultSelectedRole(); if (singleton != null) { - changeAlreadyEditedPaneRole(roleNames[getMode()]); + changeAlreadyEditedPaneRole(roleNames); } } }; @@ -204,37 +180,11 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo buttonGroup.setNeedLeftRightOutLine(false); } - private int getMode(){ - return isSupportFS?FS_MANAGE: REPORT_PLATEFORM_MANAGE; - } - - -// /** -// * 检查看看是否可以增删刷新按钮是都可以编辑,并且检查角色树是不是可以编辑 -// */ -// public void checkToolButtonsEnabled() { -// if (buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { -// PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); -// AuthenticationProvider ap = pm.getAuthenticationProvider(); -// PrivilegeFilter pf = pm.getPrivilegeFilter(); -// boolean isClickable = !(ap instanceof DaoAuthenticationProvider) -// && pf instanceof AuthorityControlFilter; -// addAction.setEnabled(isClickable); -// removeAction.setEnabled(isClickable); -// } else { -// addAction.setEnabled(false); -// removeAction.setEnabled(false); -// } -// -// } - - /** * 刷新界面 */ public void refreshDockingView() { populate(new RoleSourceOP()); -// this.checkToolButtonsEnabled(); } private void populate(RoleSourceOP op) { @@ -276,85 +226,6 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo } -// private class AddAction extends UpdateAction { -// public AddAction() { -// this.setName(com.fr.design.i18n.Toolkit.i18nText("Add")); -// this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); -// } -// -// @Override -// public void actionPerformed(ActionEvent e) { -// refreshDockingView(); -// -// DefaultTreeModel treeModel = (DefaultTreeModel) roleTree.getModel(); -// ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); -// ExpandMutableTreeNode parentNode = (ExpandMutableTreeNode) root.getChildAt(0); -// String newName = com.fr.design.i18n.Toolkit.i18nText("newNode") + (++newIndex); -// parentNode.add(new ExpandMutableTreeNode(newName)); -// op.addAction(newName); -// roleTree.updateUI(); -// -// try { -// synchronized (AuthorityRoleDAOManager.class) { -// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); -// -// if (AuthorityRoleDAOManager.getAuthorityAllocation(pf, newName) != null) { -// newName = com.fr.design.i18n.Toolkit.i18nText("newNode") + (++newIndex); -// roleTree.refreshTreeNode(); -// expandTree(roleTree, true); -// } -// -// AuthorityRoleDAOManager.addAuthorityRole(pf, new Authority(newName), new Allocation(), false, true); -// -// AuthorityRoleDAOManager.doEnd(pf); -// } -// } catch (Exception e1) { -// FRContext.getLogger().error(e1.getMessage(), e1); -// } -// } -// } - -// private class RemoveAction extends UpdateAction { -// -// public RemoveAction() { -// this.setName(com.fr.design.i18n.Toolkit.i18nText("Remove")); -// this.setSmallIcon(UIConstants.CLEAR_ICON); -// } -// -// @Override -// public void actionPerformed(ActionEvent e) { -// -// -// NameObject selectedNO = roleTree.getSelectedNameObject(); -// -// if (selectedNO == null) { -// return; -// } -// -// int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + ":" + selectedNO.getName() + "?", -// com.fr.design.i18n.Toolkit.i18nText("Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); -// if (returnVal == JOptionPane.OK_OPTION) { -// op.removeAction(selectedNO.getName()); -// -// try { -// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); -// -// AuthorityRoleDAOManager.removeAuthorityRole(pf, new Authority(selectedNO.getName()), true); -// AuthorityRoleDAOManager.doEnd(pf); -// } catch (Exception e1) { -// FRContext.getLogger().error(e1.getMessage(), e1); -// } -// -// roleTree.refreshTreeNode(); -// expandTree(roleTree, true); -// roleTree.updateUI(); -// roleTree.requestFocus(); -// roleTree.setSelectionRow(roleTree.getRowCount() - 1); -// } -// } -// } - - /* * 刷新ReportletsTree */ @@ -373,144 +244,6 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo } } - -// private class RoleTreeCellEditor extends DefaultCellEditor implements TreeCellEditor, CellEditorListener { -// -// private NameObject editingNO; -// private String oldName; -// private String newName; -// private UITextField jTextField; -// -// public RoleTreeCellEditor(final UITextField textField) { -// super(textField); -// this.jTextField = textField; -// this.jTextField.setPreferredSize(new Dimension(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth() - 5, this.jTextField.getHeight())); -// } -// -// @Override -// public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { -// editingNO = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); -// oldName = editingNO.getName(); -// -// delegate.setValue(oldName); -// -// editorComponent.setPreferredSize(new java.awt.Dimension(ReportAndFSManagePane.this.getPreferredSize().width, editorComponent.getPreferredSize().height)); -// -// return editorComponent; -// } -// -// @Override -// -// public boolean isCellEditable(EventObject anEvent) { -// NameObject no = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); -// return !(no.getName() == com.fr.design.i18n.Toolkit.i18nText("Role")); -// } -// -// @Override -// public Object getCellEditorValue() { -// newName = super.getCellEditorValue().toString(); -// editingNO.setName(newName); -// return editingNO; -// } -// -// -// private boolean checkRoleNameNotEmpty() { -// refreshDockingView(); -// -// String currentText = delegate.getCellEditorValue().toString(); -// boolean isContained = false; -// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); -// if (pf != null && -// !ComparatorUtils.equals(oldName, currentText)) { -// try { -// Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); -// -// while (iterator.hasNext()) { -// AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) -// .getValue(); -// Authority _authority = authorityAllocation.getAuthority(); -// if(ComparatorUtils.equals(_authority.getName(), currentText)){ -// isContained = true; -// break; -// } -// } -// } catch (Exception e) { -// } -// } -// -// if (currentText.isEmpty() || isContained) { -// JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("RoleName_Can_Not_Be_Null") + "!"); -// roleTree.refreshTreeNode(); -// expandTree(roleTree, true); -// delegate.setValue(oldName); -// return false; -// } -// return true; -// } -// -// /* -// * 下面两个方法是CellEditorListener的 -// */ -// @Override -// public void editingCanceled(ChangeEvent e) { -// if (!checkRoleNameNotEmpty()) { -// treePath = null; -// return; -// } -// roleTree.stopEditing(); -// if (treePath == null) { -// return; -// } -// changeValue(); -// roleTree.refreshTreeNode(); -// expandTree(roleTree, true); -// } -// -// @Override -// public void editingStopped(ChangeEvent e) { -// if (!checkRoleNameNotEmpty()) { -// treePath = null; -// return; -// } -// changeValue(); -// roleTree.refreshTreeNode(); -// expandTree(roleTree, true); -// roleTree.updateUI(); -// } -// -// private void changeValue() { -// newName = delegate.getCellEditorValue().toString(); -// if (!newName.isEmpty() && newName != oldName) { -// roleTree.setSelectedRoleName(newName); -// op.rename(oldName, newName); -// -// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); -// if (pf != null) { -// try { -// Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); -// -// while (iterator.hasNext()) { -// AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) -// .getValue(); -// Authority _authority = authorityAllocation.getAuthority(); -// if (ComparatorUtils.equals(_authority.getName(), oldName)) { -// _authority.setName(newName); -// } -// } -// } catch (Exception e) { -// } -// } -// -// try { -// AuthorityRoleDAOManager.doEnd(pf); -// } catch (Exception e) { -// FRContext.getLogger().error(e.getMessage(), e); -// } -// } -// } -// } - - /** * 展开树 * @param tree 树 diff --git a/designer-base/src/main/java/com/fr/design/roleAuthority/RoleSourceOP.java b/designer-base/src/main/java/com/fr/design/roleAuthority/RoleSourceOP.java index 1b90df3df2..50bf900369 100644 --- a/designer-base/src/main/java/com/fr/design/roleAuthority/RoleSourceOP.java +++ b/designer-base/src/main/java/com/fr/design/roleAuthority/RoleSourceOP.java @@ -1 +1,99 @@ -package com.fr.design.roleAuthority; import com.fr.general.NameObject; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.UserObjectOP; import java.util.*; /** * Author : daisy * Date: 13-8-30 * Time: 下午3:36 */ public class RoleSourceOP implements UserObjectOP { private static final int REPORT_PLATEFORM_MANAGE = 0; private static final int FS_MANAGE = 1; public static int manageMode = -1; public RoleSourceOP() { super(); } public List> init() { //用于存放角色 List> allRoles = new ArrayList>(); Map report_roles = new LinkedHashMap(); Map FS_roles = new LinkedHashMap(); addReportRoles(report_roles); addFSRoles(FS_roles); allRoles.add(report_roles); allRoles.add(FS_roles); return allRoles; } /** * 获取报表平台的角色 */ protected void addReportRoles(Map report_roles) { RoleDataWrapper tdw = new RoleDataWrapper(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Server_Platform_Manager")); report_roles.put(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Role"), tdw); } /** * 获取数据决策系统的角色 */ protected void addFSRoles(Map FS_roles) { RoleDataWrapper tdw = new RoleDataWrapper(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FS_Name_Duplicate")); FS_roles.put(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Role"), tdw); } public boolean interceptButtonEnabled() { return true; } /** * 移除名字是name的角色 * * @param name */ public void removeAction(String name) { //删除对应模式下的角色 switch (manageMode) { case REPORT_PLATEFORM_MANAGE: //删除报表平台的角色 break; case FS_MANAGE: //删除数据决策系统的角色 break; } } public void addAction(String name) { switch (manageMode) { case REPORT_PLATEFORM_MANAGE: //增加报表平台的角色 break; case FS_MANAGE: //增加数据决策系统的角色 break; } } public void rename(String oldName, String newName) { switch (manageMode) { case REPORT_PLATEFORM_MANAGE: //修改报表平台的角色 break; case FS_MANAGE: //修改数据决策系统的角色 break; } } /** * 根据不同模式生成子节点 * * @return */ @Override public ExpandMutableTreeNode[] load() { Map report_roles = null; Map FS_roles = null; if (this != null) { report_roles = this.init().get(0); FS_roles = this.init().get(1); } else { report_roles = Collections.emptyMap(); FS_roles = Collections.emptyMap(); } List list = new ArrayList(); //所有的角色 List reportlist = new ArrayList(); //报表平台橘色 List FSlist = new ArrayList(); //数据决策系统角色 list.add(initReportRolseNode(report_roles)); addNodeToList(report_roles, reportlist); list.add(initFSRolseNode(FS_roles)); addNodeToList(FS_roles, FSlist); switch (manageMode) { case REPORT_PLATEFORM_MANAGE: return reportlist.toArray(new ExpandMutableTreeNode[reportlist.size()]); case FS_MANAGE: return FSlist.toArray(new ExpandMutableTreeNode[FSlist.size()]); default: return list.toArray(new ExpandMutableTreeNode[list.size()]); } } protected void setDataMode(int i) { manageMode = i; } protected void addNodeToList(Map roleMap, List roleList) { ExpandMutableTreeNode[] roleNode = getNodeArrayFromMap(roleMap); for (int i = 0; i < roleNode.length; i++) { roleList.add(roleNode[i]); } } protected ExpandMutableTreeNode initReportRolseNode(Map report_roles) { ExpandMutableTreeNode templateNode = new ExpandMutableTreeNode(new NameObject(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Server_Platform_Manager"), REPORT_PLATEFORM_MANAGE), true); templateNode.addChildTreeNodes(getNodeArrayFromMap(report_roles)); return templateNode; } protected ExpandMutableTreeNode initFSRolseNode(Map FS_roles) { ExpandMutableTreeNode templateNode = new ExpandMutableTreeNode(new NameObject(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FS_Name_Duplicate"), FS_MANAGE), true); templateNode.addChildTreeNodes(getNodeArrayFromMap(FS_roles)); return templateNode; } protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map map) { List roleList = new ArrayList(); Iterator> entryIt = map.entrySet().iterator(); while (entryIt.hasNext()) { Map.Entry entry = entryIt.next(); String name = entry.getKey(); RoleDataWrapper t = entry.getValue(); ExpandMutableTreeNode newChildTreeNode = new ExpandMutableTreeNode(new NameObject(name, t)); roleList.add(newChildTreeNode); newChildTreeNode.add(new ExpandMutableTreeNode()); } return roleList.toArray(new ExpandMutableTreeNode[roleList.size()]); } } \ No newline at end of file +package com.fr.design.roleAuthority; + +import com.fr.general.NameObject; +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.gui.itree.refreshabletree.UserObjectOP; + + +import java.util.*; + +/** + * Author : daisy + * Date: 13-8-30 + * Time: 下午3:36 + */ +public class RoleSourceOP implements UserObjectOP { + private static final int REPORT_PLATEFORM_MANAGE = 0; + + public RoleSourceOP() { + super(); + } + + + public List> init() { + + //用于存放角色 + List> allRoles = new ArrayList>(); + Map report_roles = new LinkedHashMap(); + addReportRoles(report_roles); + allRoles.add(report_roles); + + return allRoles; + } + + + /** + * 获取报表平台的角色 + */ + protected void addReportRoles(Map report_roles) { + RoleDataWrapper tdw = new RoleDataWrapper(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Server_Platform_Manager")); + report_roles.put(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Role"), tdw); + } + + + public boolean interceptButtonEnabled() { + return true; + } + + /** + * 移除名字是name的角色 + * + * @param name + */ + public void removeAction(String name) { + + } + + /** + * 根据不同模式生成子节点 + * + * @return + */ + @Override + public ExpandMutableTreeNode[] load() { + Map report_roles = this.init().get(REPORT_PLATEFORM_MANAGE); + List reportlist = new ArrayList(); //报表平台橘色 + addNodeToList(report_roles, reportlist); + return reportlist.toArray(new ExpandMutableTreeNode[reportlist.size()]); + } + + protected void addNodeToList(Map roleMap, List roleList) { + ExpandMutableTreeNode[] roleNode = getNodeArrayFromMap(roleMap); + for (int i = 0; i < roleNode.length; i++) { + roleList.add(roleNode[i]); + } + } + + + protected ExpandMutableTreeNode initReportRolseNode(Map report_roles) { + ExpandMutableTreeNode templateNode = new ExpandMutableTreeNode(new NameObject(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Server_Platform_Manager"), REPORT_PLATEFORM_MANAGE), true); + templateNode.addChildTreeNodes(getNodeArrayFromMap(report_roles)); + return templateNode; + } + + + protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map map) { + List roleList = new ArrayList(); + Iterator> entryIt = map.entrySet().iterator(); + while (entryIt.hasNext()) { + Map.Entry entry = entryIt.next(); + String name = entry.getKey(); + RoleDataWrapper t = entry.getValue(); + + ExpandMutableTreeNode newChildTreeNode = new ExpandMutableTreeNode(new NameObject(name, t)); + roleList.add(newChildTreeNode); + newChildTreeNode.add(new ExpandMutableTreeNode()); + } + return roleList.toArray(new ExpandMutableTreeNode[roleList.size()]); + } +} diff --git a/designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java b/designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java index ef576ba0f3..b52561c055 100644 --- a/designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java +++ b/designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java @@ -1,23 +1,23 @@ package com.fr.design.roleAuthority; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.constants.UIConstants; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.itree.checkboxtree.CheckBoxTree; import com.fr.design.gui.itree.checkboxtree.CheckBoxTreeSelectionModel; -import com.fr.general.NameObject; -import com.fr.design.constants.UIConstants; -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree; import com.fr.design.mainframe.AuthorityPropertyPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.general.ComparatorUtils; +import com.fr.general.NameObject; +import com.fr.start.server.FineEmbedServer; - -import javax.swing.SwingUtilities; -import javax.swing.JTree; import javax.swing.JComponent; +import javax.swing.JTree; +import javax.swing.SwingUtilities; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; @@ -54,13 +54,6 @@ public class RoleTree extends UserObjectRefreshJTree { this.replaceMouseListener(this, handler, 0); this.replaceKeyListener(this, handler, 0); this.addTreeSelectionListener(handler); -// this.removeMouseListener(treeMouseListener); -// this.addTreeSelectionListener(new TreeSelectionListener() { -// public void valueChanged(TreeSelectionEvent e) { -// doWithValueChanged(e); -// } -// }); - } public boolean isCheckBoxVisible(TreePath path) { @@ -68,6 +61,13 @@ public class RoleTree extends UserObjectRefreshJTree { } + @Override + protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode selectedTreeNode) { + // 启动平台模块加载角色列表, server内部已经做了启动状态与Workspace判断. + FineEmbedServer.start(); + return super.loadChildTreeNodes(selectedTreeNode); + } + /** * Creates the mouse listener and key listener used by RoleTree. * @@ -100,26 +100,8 @@ public class RoleTree extends UserObjectRefreshJTree { return null; } -// if (clicksInCheckBox(e, path)) { - return path; -// } else { -// return null; -// } - } - -// protected boolean clicksInCheckBox(MouseEvent e, TreePath path) { -// if (!_tree.isCheckBoxVisible(path)) { -// return false; -// } else { -// Rectangle bounds = _tree.getPathBounds(path); -// if (_tree.getComponentOrientation().isLeftToRight()) { -// return e.getX() < bounds.x + _hotspot; -// } else { -// return e.getX() > bounds.x + bounds.width - _hotspot; -// } -// } -// } + } private TreePath preventToggleEvent(MouseEvent e) { TreePath pathForMouseEvent = getTreePathForMouseEvent(e); @@ -220,9 +202,6 @@ public class RoleTree extends UserObjectRefreshJTree { TreePath tmpTreePath = treePaths[i]; toggleSelection(tmpTreePath); } -// for (TreePath treePath : treePaths) { -// toggleSelection(treePath); -// } } } @@ -366,9 +345,6 @@ public class RoleTree extends UserObjectRefreshJTree { for (int i = 0, length = listeners.length; i < length; i++) { component.removeMouseListener(listeners[i]); } -// for (MouseListener listener : listeners) { -// component.removeMouseListener(listener); -// } for (int i = 0; i < listeners.length; i++) { MouseListener listener = listeners[i]; if (index == i) { @@ -399,9 +375,6 @@ public class RoleTree extends UserObjectRefreshJTree { for (int i = 0, length = listeners.length; i < length; i++) { component.removeKeyListener(listeners[i]); } -// for (MouseListener listener : listeners) { -// component.removeMouseListener(listener); -// } for (int i = 0; i < listeners.length; i++) { KeyListener listener = listeners[i]; if (index == i) { diff --git a/designer-base/src/main/java/com/fr/design/roleAuthority/RolesEditedSourceOP.java b/designer-base/src/main/java/com/fr/design/roleAuthority/RolesEditedSourceOP.java index 88563e8dbf..a21cd20e74 100644 --- a/designer-base/src/main/java/com/fr/design/roleAuthority/RolesEditedSourceOP.java +++ b/designer-base/src/main/java/com/fr/design/roleAuthority/RolesEditedSourceOP.java @@ -1 +1,38 @@ -package com.fr.design.roleAuthority; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.mainframe.JTemplate; import com.fr.general.NameObject; import com.fr.privilege.PrivilegeEditedRoleProvider; /** * Author : daisy * Date: 13-9-25 * Time: 下午4:57 */ public class RolesEditedSourceOP extends RoleSourceOP { /** * 获取报表平台的角色 */ protected void addReportRoles(Map report_roles) { RoleDataWrapper tdw = new RoleDataWrapper(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Server_Platform_Manager")); report_roles.put(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Server_Platform_Manager"), tdw); } /** * 获取数据决策系统的角色 */ protected void addFSRoles(Map FS_roles) { RoleDataWrapper tdw = new RoleDataWrapper(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FS_Name_Duplicate")); FS_roles.put(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FS_Name_Duplicate"), tdw); } /** * 生成子节点 * * @return */ @Override public ExpandMutableTreeNode[] load() { Map report_roles = null; // Map FS_roles = null; if (this != null) { report_roles = this.init().get(0); // FS_roles = this.init().get(1); } else { report_roles = Collections.emptyMap(); // FS_roles = Collections.emptyMap(); } List list = new ArrayList(); //所有的角色 List reportlist = new ArrayList(); //报表平台橘色 // List FSlist = new ArrayList(); //数据决策系统角色 list.add(initReportRolseNode(report_roles)); addNodeToList(report_roles, reportlist); // list.add(initFSRolseNode(FS_roles)); // addNodeToList(FS_roles, FSlist); return list.toArray(new ExpandMutableTreeNode[list.size()]); } protected ExpandMutableTreeNode initReportRolseNode(Map report_roles) { ExpandMutableTreeNode templateNode = new ExpandMutableTreeNode(new NameObject(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Roles_Already_Authority_Edited"), 0), true); templateNode.addChildTreeNodes(getNodeArrayFromMap(report_roles)); return templateNode; } protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map map) { List roleList = new ArrayList(); Iterator> entryIt = map.entrySet().iterator(); while (entryIt.hasNext()) { Map.Entry entry = entryIt.next(); String name = entry.getKey(); RoleDataWrapper t = entry.getValue(); JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); PrivilegeEditedRoleProvider pe = (PrivilegeEditedRoleProvider) jt.getTarget(); ExpandMutableTreeNode[] expand = t.load(Arrays.asList(pe.getAllEditedRoleSet())); for (ExpandMutableTreeNode expandMutableTreeNode : expand) { roleList.add(expandMutableTreeNode); } } return roleList.toArray(new ExpandMutableTreeNode[roleList.size()]); } } \ No newline at end of file +package com.fr.design.roleAuthority; + +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.mainframe.JTemplate; +import com.fr.privilege.PrivilegeEditedRoleProvider; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * Author : daisy + * Date: 13-9-25 + * Time: 下午4:57 + */ +public class RolesEditedSourceOP extends RoleSourceOP { + + protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map map) { + List roleList = new ArrayList(); + Iterator> entryIt = map.entrySet().iterator(); + while (entryIt.hasNext()) { + Map.Entry entry = entryIt.next(); + RoleDataWrapper t = entry.getValue(); + + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + PrivilegeEditedRoleProvider pe = (PrivilegeEditedRoleProvider) jt.getTarget(); + + ExpandMutableTreeNode[] expand = t.load(Arrays.asList(pe.getAllEditedRoleSet())); + for (ExpandMutableTreeNode expandMutableTreeNode : expand) { + roleList.add(expandMutableTreeNode); + } + } + return roleList.toArray(new ExpandMutableTreeNode[roleList.size()]); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java index 90b859fcc2..155ac4168b 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java @@ -73,7 +73,7 @@ public class ColorPicker extends JDialog implements ActionListener try { Thread.sleep(100); // 等待弹窗关闭 } catch (InterruptedException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } colorPickerPanel.captureScreen(); } diff --git a/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java b/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java index 543ad98e9a..fcb272dd54 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java @@ -44,7 +44,7 @@ public abstract class CustomJobPane extends BasicBeanPane { UIButton editButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit")); editButton.setPreferredSize(new Dimension( - GraphHelper.getLocTextWidth("Fine-Design_Basic_Edit") + 20, + GraphHelper.getWidth(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select")) + 20, classNameTextField.getPreferredSize().height)); reportletNamePane.add(browserButton); diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 31cbabd14c..769c843cc5 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -20,7 +20,7 @@ import com.fr.stable.StringUtils; import com.fr.third.guava.base.Strings; import com.fr.workspace.WorkContext; import com.fr.workspace.connect.AuthException; -import com.fr.workspace.connect.WorkspaceConnection; +import com.fr.workspace.connect.WorkspaceConnectionInfo; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -270,7 +270,7 @@ public class RemoteEnvPane extends BasicBeanPane { @Override public void populateBean(RemoteDesignerWorkspaceInfo ob) { - WorkspaceConnection connection = ob.getConnection(); + WorkspaceConnectionInfo connection = ob.getConnection(); if (connection != null) { this.remoteWorkspaceURL = Strings.isNullOrEmpty(connection.getUrl()) ? RemoteWorkspaceURL.createDefaultURL() @@ -303,7 +303,7 @@ public class RemoteEnvPane extends BasicBeanPane { @Override public RemoteDesignerWorkspaceInfo updateBean() { - WorkspaceConnection connection = new WorkspaceConnection( + WorkspaceConnectionInfo connection = new WorkspaceConnectionInfo( this.remoteWorkspaceURL.getURL(), this.usernameInput.getText(), new String(this.passwordInput.getPassword()), @@ -518,7 +518,7 @@ public class RemoteEnvPane extends BasicBeanPane { final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); - WorkspaceConnection connection = remoteEnv.getConnection(); + WorkspaceConnectionInfo connection = remoteEnv.getConnection(); DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath()); DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey()); try { @@ -587,7 +587,7 @@ public class RemoteEnvPane extends BasicBeanPane { message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); okButton.setEnabled(false); - dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"), true); + dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), UIManager.getString("OptionPane.messageDialogTitle"), true); dialog.setSize(new Dimension(268, 118)); okButton.setEnabled(false); diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane2.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane2.java deleted file mode 100644 index dc0ee27bf2..0000000000 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane2.java +++ /dev/null @@ -1,185 +0,0 @@ -//package com.fr.env; -// -//import com.fr.design.beans.BasicBeanPane; -//import com.fr.design.border.UITitledBorder; -//import com.fr.design.env.DesignerWorkspaceInfo; -//import com.fr.design.env.DesignerWorkspaceType; -//import com.fr.design.gui.ibutton.UIButton; -//import com.fr.design.gui.ilable.UILabel; -//import com.fr.design.gui.ipasswordfield.UIPassWordField; -//import com.fr.design.gui.itextfield.UIIntNumberField; -//import com.fr.design.gui.itextfield.UITextField; -//import com.fr.design.layout.TableLayout; -//import com.fr.design.layout.TableLayoutHelper; -//import com.fr.design.utils.gui.GUICoreUtils; -// -//import com.fr.workspace.WorkContext; -//import com.fr.workspace.connect.WorkspaceConnection; -// -//import javax.swing.*; -//import javax.swing.border.EmptyBorder; -//import java.awt.*; -//import java.awt.event.ActionEvent; -//import java.awt.event.ActionListener; -//import java.awt.event.WindowAdapter; -//import java.awt.event.WindowEvent; -// -///** -// * 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane -// */ -//public class RemoteEnvPane2 extends BasicBeanPane { -// -// private UITextField urlTextField; -// private UITextField usernameTextField; -// private UIPassWordField passwordTextField; -// private JDialog dialog; -// private UILabel message; -// private UIButton okButton; -// private UIButton cancelButton; -// -// public RemoteEnvPane2() { -// initComponents(); -// } -// -// private void initComponents() { -// setLayout(new BorderLayout()); -// -// JPanel contentPanel = new JPanel(new BorderLayout()); -// add(contentPanel, BorderLayout.CENTER); -// -// contentPanel.setBorder( -// BorderFactory.createCompoundBorder( -// new EmptyBorder(6, 0, 0, 0), -// UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Config"))) -// ); -// -// double p = TableLayout.PREFERRED; -// double f = TableLayout.FILL; -// double[] rowSize = new double[]{p, p, p, p}; -// double[] columnSize = new double[]{p, f}; -// UIButton testConnectionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Try")); -// urlTextField = new UITextField(); -// urlTextField.setPlaceholder("http://192.168.100.200/webroot/decision"); -// JPanel valuePane = TableLayoutHelper.createTableLayoutPane( -// new Component[][]{ -// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), urlTextField}, -// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_User") + ":", SwingConstants.RIGHT), usernameTextField = new UITextField()}, -// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()}, -// {null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)} -// }, -// rowSize, columnSize -// ); -// testConnectionButton.addActionListener(new ActionListener() { -// @Override -// public void actionPerformed(ActionEvent e) { -// tryConnectRemoteEnv(); -// } -// }); -// contentPanel.add(valuePane, BorderLayout.CENTER); -// -// message = new UILabel(); -// okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("OK")); -// cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Cancel")); -// } -// -// private void tryConnectRemoteEnv() { -// final SwingWorker worker = new SwingWorker() { -// -// @Override -// protected Void doInBackground() throws Exception { -// -// final DesignerWorkspaceInfo remoteEnv = updateBean(); -// WorkContext.getConnector().testConnection(remoteEnv.getConnection()); -// return null; -// } -// -// @Override -// protected void done() { -// okButton.setEnabled(true); -// try { -// get(); -// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Connect_Successful")); -// } catch (Exception e) { -// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Connect_Failed")); -// } -// } -// }; -// worker.execute(); -// initMessageDialog(); -// okButton.addActionListener(new ActionListener() { -// public void actionPerformed(ActionEvent e) { -// dialog.dispose(); -// } -// }); -// cancelButton.addActionListener(new ActionListener() { -// public void actionPerformed(ActionEvent e) { -// dialog.dispose(); -// worker.cancel(true); -// } -// }); -// -// dialog.addWindowListener(new WindowAdapter() { -// public void windowClosed(WindowEvent e) { -// worker.cancel(true); -// } -// }); -// -// dialog.setVisible(true); -// dialog.dispose(); -// } -// -// private void initMessageDialog() { -// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Try") + "..."); -// message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); -// okButton.setEnabled(false); -// -// dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), com.fr.design.i18n.Toolkit.i18nText("Datasource-Test_Connection"), true); -// -// dialog.setSize(new Dimension(268, 118)); -// okButton.setEnabled(false); -// JPanel jp = new JPanel(); -// JPanel upPane = new JPanel(); -// JPanel downPane = new JPanel(); -// UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon")); -// upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); -// upPane.add(uiLabel); -// upPane.add(message); -// downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0)); -// downPane.add(okButton); -// downPane.add(cancelButton); -// jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); -// jp.add(upPane); -// jp.add(downPane); -// dialog.add(jp); -// dialog.setResizable(false); -// dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this)); -// } -// -// @Override -// protected String title4PopupWindow() { -// return "RemoteEnv"; -// } -// -// @Override -// public void populateBean(DesignerWorkspaceInfo config) { -// if (config == null) { -// return; -// } -// WorkspaceConnection connection = config.getConnection(); -// if (connection != null) { -// urlTextField.setText(connection.getUrl()); -// usernameTextField.setText(connection.getUserName()); -// passwordTextField.setText(connection.getPassword()); -// } -// } -// -// @Override -// public DesignerWorkspaceInfo updateBean() { -// -// DesignerWorkspaceInfo config = new DesignerWorkspaceInfo(); -// WorkspaceConnection connection = new WorkspaceConnection(urlTextField.getText(), usernameTextField.getText(), passwordTextField.getText()); -// config.setConnection(connection); -// config.setType(DesignerWorkspaceType.Remote); -// return config; -// } -//} diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvUtils.java b/designer-base/src/main/java/com/fr/env/RemoteEnvUtils.java deleted file mode 100644 index 13d251010c..0000000000 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvUtils.java +++ /dev/null @@ -1,167 +0,0 @@ -//package com.fr.env; -// -//import com.fr.base.EnvException; -//import com.fr.base.FRContext; -//import com.fr.report.DesignAuthority; -//import com.fr.report.util.AuthorityXMLUtils; -//import com.fr.stable.EncodeConstants; -//import com.fr.third.org.apache.commons.io.IOUtils; -//import com.fr.third.org.apache.http.HttpResponse; -//import com.fr.third.org.apache.http.HttpStatus; -//import com.fr.third.org.apache.http.client.ClientProtocolException; -//import com.fr.third.org.apache.http.client.ResponseHandler; -//import com.fr.third.org.apache.http.client.methods.HttpUriRequest; -//import com.fr.third.org.apache.http.client.methods.RequestBuilder; -//import com.fr.third.org.apache.http.entity.ContentType; -//import com.fr.third.org.apache.http.entity.InputStreamEntity; -//import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; -//import com.fr.third.org.apache.http.impl.client.HttpClients; -// -//import java.io.ByteArrayInputStream; -//import java.io.ByteArrayOutputStream; -//import java.io.IOException; -//import java.io.InputStream; -//import java.net.URLEncoder; -//import java.util.Map; -// -//public class RemoteEnvUtils { -// -// private RemoteEnvUtils() { -// } -// -// private static ResponseHandler responseHandler = new ResponseHandler() { -// @Override -// public InputStream handleResponse(HttpResponse response) throws IOException { -// int statusCode = response.getStatusLine().getStatusCode(); -// if (statusCode != HttpStatus.SC_OK) { -// throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString()); -// } -// InputStream in = response.getEntity().getContent(); -// if (in == null) { -// return null; -// } -// // 读取并返回 -// ByteArrayOutputStream out = new ByteArrayOutputStream(); -// IOUtils.copy(in, out); -// return new ByteArrayInputStream(out.toByteArray()); -// } -// }; -// -// public static InputStream simulateRPCByHttpPost(byte[] bytes, Map parameters, boolean isSignIn, RemoteEnv env) throws EnvException { -// String path = env.getPath(); -// RequestBuilder builder = RequestBuilder.post(path); -// -// InputStream inputStream = null; -// -// for (Map.Entry entry : parameters.entrySet()) { -// builder.addParameter(entry.getKey(), entry.getValue()); -// } -// if (!isSignIn) { -// builder.addParameter("id", env.getUserID()); -// } -// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes)); -// -// try (CloseableHttpClient httpClient = HttpClients.createSystem()) { -// HttpUriRequest request = builder -// .setEntity(reqEntity) -// .build(); -// inputStream = httpClient.execute(request, responseHandler); -// } catch (IOException e) { -// FRContext.getLogger().error(e.getMessage()); -// } -// return inputStream; -// } -// -// public static InputStream simulateRPCByHttpPost(Map parameters, boolean isSignIn, RemoteEnv env) throws EnvException { -// String path = env.getPath(); -// RequestBuilder builder = RequestBuilder.post(path); -// -// InputStream inputStream = null; -// -// for (Map.Entry entry : parameters.entrySet()) { -// builder.addParameter(entry.getKey(), entry.getValue()); -// } -// if (!isSignIn) { -// builder.addParameter("id", env.getUserID()); -// } -// -// try (CloseableHttpClient httpClient = HttpClients.createSystem()) { -// HttpUriRequest request = builder -// .build(); -// inputStream = httpClient.execute(request, responseHandler); -// } catch (IOException e) { -// FRContext.getLogger().error(e.getMessage()); -// } -// return inputStream; -// } -// -// public static InputStream simulateRPCByHttpGet(Map parameters, boolean isSignIn, RemoteEnv env) throws EnvException { -// String path = env.getPath(); -// RequestBuilder builder = RequestBuilder.get(path); -// -// InputStream inputStream = null; -// -// for (Map.Entry entry : parameters.entrySet()) { -// builder.addParameter(entry.getKey(), entry.getValue()); -// } -// if (!isSignIn) { -// builder.addParameter("id", env.getUserID()); -// } -// try (CloseableHttpClient httpClient = HttpClients.createSystem()) { -// HttpUriRequest request = builder.build(); -// inputStream = httpClient.execute(request, responseHandler); -// -// } catch (IOException e) { -// FRContext.getLogger().error(e.getMessage()); -// } -// return inputStream; -// } -// -// -// public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) { -// String path = env.getPath(); -// // 远程设计临时用户id -// String userID = env.getUserID(); -// InputStream inputStream = null; -// -// ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); -// AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream); -// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML); -// -// try (CloseableHttpClient httpClient = HttpClients.createSystem()) { -// HttpUriRequest request = RequestBuilder.post(path) -// .addParameter("id", userID) -// .addParameter("op", "remote_design_authority") -// .addParameter("cmd", "update_authorities") -// .setEntity(reqEntity) -// .build(); -// inputStream = httpClient.execute(request, responseHandler); -// } catch (IOException e) { -// FRContext.getLogger().error(e.getMessage()); -// } -// -// return inputStream; -// -// } -// -// public static InputStream getAuthorities(RemoteEnv env) throws EnvException { -// String path = env.getPath(); -// // 远程设计临时用户id -// String userID = env.getUserID(); -// InputStream inputStream = null; -// -// try (CloseableHttpClient httpClient = HttpClients.createSystem();) { -// HttpUriRequest request = RequestBuilder.get(path) -// .addParameter("id", userID) -// .addParameter("op", "remote_design_authority") -// .addParameter("cmd", "get_authorities") -// .build(); -// inputStream = httpClient.execute(request, responseHandler); -// } catch (IOException e) { -// FRContext.getLogger().error(e.getMessage()); -// } -// return inputStream; -// } -// -// -//} diff --git a/designer-base/src/main/java/com/fr/file/FILE.java b/designer-base/src/main/java/com/fr/file/FILE.java index 3977ee87e7..8c1f734cf9 100644 --- a/designer-base/src/main/java/com/fr/file/FILE.java +++ b/designer-base/src/main/java/com/fr/file/FILE.java @@ -1,93 +1,106 @@ package com.fr.file; import javax.swing.Icon; +import java.io.InputStream; +import java.io.OutputStream; public interface FILE { /** - * 后缀 - * @return 后缀 + * 前缀 + * + * @return 前缀 */ - public String prefix(); + String prefix(); /** * 是否是目录 + * * @return 是则返回true */ - public boolean isDirectory(); - - // Name - public String getName(); - - // Icon - public Icon getIcon(); - - // 当前目录的Path - public String getPath(); - - public void setPath(String path); - - // 取当前目录的上级目录 - public FILE getParent(); + boolean isDirectory(); + + // Name + String getName(); + + // Icon + Icon getIcon(); + + // 当前目录的Path + String getPath(); + + void setPath(String path); + + // 取当前目录的上级目录 + FILE getParent(); /** * 列出当前目录下所有的文件及文件夹 + * * @return 文件 */ - public FILE[] listFiles(); + FILE[] listFiles(); /** * 新建一个目录 + * * @param name 名字 * @return 新建目录 */ - public boolean createFolder(String name); + boolean createFolder(String name); /** * 新建文件 + * * @return 是否新建成功 * @throws Exception 异常 */ - public boolean mkfile() throws Exception; + boolean mkfile() throws Exception; /** * 是否存在 + * * @return 是否存在 */ - public boolean exists(); + boolean exists(); /** * 关闭文件 + * * @throws Exception 异常 */ - public void closeTemplate() throws Exception; + void closeTemplate() throws Exception; /** * 作为输入流 + * * @return 输入流 * @throws Exception 异常 */ - public java.io.InputStream asInputStream() throws Exception; + InputStream asInputStream() throws Exception; /** * 作为输出流 + * * @return 输出流 * @throws Exception 异常 */ - public java.io.OutputStream asOutputStream() throws Exception; - - public String getEnvFullName(); + OutputStream asOutputStream() throws Exception; + + String getEnvFullName(); /** * 是否是内存文件 + * * @return 是则返回true */ - public boolean isMemFile(); + boolean isMemFile(); /** * 是否是环境文件 + * * @return 是则返回true */ - public boolean isEnvFile(); + boolean isEnvFile(); } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 3629dfdf9b..1e4ec0d659 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -3,17 +3,19 @@ package com.fr.file; import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.extension.FileExtension; -import com.fr.file.filetree.LocalFileNodes; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.UIDialog; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.DefaultCompletionFilter; import com.fr.design.gui.itextfield.UIAutoCompletionField; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -21,37 +23,64 @@ import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.file.filetree.FileNode; +import com.fr.file.filetree.LocalFileNodes; import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.FILEFilter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; - import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; -import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.os.windows.WindowsDetector; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; -import javax.swing.*; +import javax.swing.AbstractAction; +import javax.swing.AbstractListModel; +import javax.swing.ActionMap; +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.Icon; +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.KeyStroke; +import javax.swing.ListModel; +import javax.swing.ListSelectionModel; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.filechooser.FileSystemView; import javax.swing.plaf.basic.BasicArrowButton; import javax.swing.plaf.basic.BasicButtonUI; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.awt.Window; 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.KeyListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; @@ -68,6 +97,7 @@ import java.util.regex.Pattern; * 该文件选择器,整理行为如下: */ public class FILEChooserPane extends BasicPane { + /** * Return value if OK is chosen. */ @@ -81,17 +111,22 @@ public class FILEChooserPane extends BasicPane { public static final int JOPTIONPANE_CANCEL_OPTION = 3; + + /** + * alex:之所以在Pattern那里加个+,是因为有些路径会有两个甚至多个分隔符放在一起 + */ + private static final Pattern SEPARATOR_PATTERN = Pattern.compile("[/\\\\]+"); + private static final FILEChooserPane INSTANCE = new FILEChooserPane(); - public FILE currentDirectory; // 当前路径,在subFileList中显示这个路径下所有的文件 + private FILE currentDirectory; // 当前路径,在subFileList中显示这个路径下所有的文件 - private List filterList = new ArrayList(); + private List filterList = new ArrayList<>(); private FILEFilter filter; private LocationButtonPane locationBtnPane; // 显示location的Panel - private UIButton createFolderButton; + private UIButton mkdirButton; - private PlaceListModel model; private JList placesList; // File.listRoots() + Env + Favourite private JList subFileList; // 当前选中目录下的文件夹及文件 @@ -100,7 +135,6 @@ public class FILEChooserPane extends BasicPane { private UIComboBox postfixComboBox; // 文件后缀名的下拉列表框 private UIButton okButton; - private UIButton cancelButton; protected int type; @@ -110,7 +144,7 @@ public class FILEChooserPane extends BasicPane { private UIDialog dialog; - private int returnValue = CANCEL_OPTION; + private int option = CANCEL_OPTION; protected String suffix; @@ -138,7 +172,7 @@ public class FILEChooserPane extends BasicPane { INSTANCE.showEnv = showEnv; INSTANCE.showLoc = showLoc; INSTANCE.showWebReport = false; - INSTANCE.setModelOfPlaceList(); + INSTANCE.setPlaceListModel(); INSTANCE.removeAllFilter(); return INSTANCE; } @@ -150,7 +184,7 @@ public class FILEChooserPane extends BasicPane { */ public static FILEChooserPane getInstance(boolean showEnv, FILEFilter filter) { INSTANCE.showEnv = showEnv; - INSTANCE.setModelOfPlaceList(); + INSTANCE.setPlaceListModel(); INSTANCE.removeAllFilter(); INSTANCE.addChooseFILEFilter(filter, 0); return INSTANCE; @@ -166,7 +200,7 @@ public class FILEChooserPane extends BasicPane { INSTANCE.showEnv = showEnv; INSTANCE.showLoc = showLoc; INSTANCE.showWebReport = false; - INSTANCE.setModelOfPlaceList(); + INSTANCE.setPlaceListModel(); INSTANCE.removeAllFilter(); INSTANCE.addChooseFILEFilter(filter, 0); return INSTANCE; @@ -183,7 +217,7 @@ public class FILEChooserPane extends BasicPane { INSTANCE.showEnv = showEnv; INSTANCE.showLoc = showLoc; INSTANCE.showWebReport = showWebReport; - INSTANCE.setModelOfPlaceList(); + INSTANCE.setPlaceListModel(); INSTANCE.removeAllFilter(); INSTANCE.addChooseFILEFilterToFist(filter, 0); return INSTANCE; @@ -202,7 +236,7 @@ public class FILEChooserPane extends BasicPane { actionMap.put("dialogExit", new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { - returnValue = CANCEL_OPTION; + option = CANCEL_OPTION; dialogExit(); } }); @@ -211,8 +245,8 @@ public class FILEChooserPane extends BasicPane { // locationPane.setLayout(FRGUIPaneFactory.createBorderLayout()); locationPane.add(locationBtnPane = new LocationButtonPane(), BorderLayout.CENTER); - createFolderButton = createFolderButton(); - locationPane.add(createFolderButton, BorderLayout.EAST); + mkdirButton = initMkdirButton(); + locationPane.add(mkdirButton, BorderLayout.EAST); JPanel centerLeftPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); // centerLeftPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -222,32 +256,161 @@ public class FILEChooserPane extends BasicPane { centerLeftPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY)); centerLeftPanel.setPreferredSize(new Dimension(120, 1)); placesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - placesList.setCellRenderer(placelistRenderer); - placesList.addListSelectionListener(placeListener); - placesList.addMouseListener(placeMouseListener); + placesList.setCellRenderer(new DefaultListCellRenderer() { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof FILE) { + FILE dir = (FILE) value; + + String name = dir.getName(); + if (name != null && !StringUtils.isBlank(name)) { + this.setText(name); + } else { + this.setText(GeneralContext.getCurrentAppNameOfEnv()); + } + Icon icon = dir.getIcon(); + if (icon != null) { + this.setIcon(icon); + } + } + + return this; + } + + }); + // placeList listener + placesList.addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + Object selValue = placesList.getSelectedValue(); + if (selValue instanceof FILE) { + setSelectedDirectory((FILE) selValue); + } + } + }); + /* + * placeList mouseListener + */ + placesList.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + Object selValue = placesList.getSelectedValue(); + if (selValue instanceof FILE) { + setSelectedDirectory((FILE) selValue); + } + } + }); // centerRightPane JPanel centerRightPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel subFilePanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - // subFilePanel.setLayout(FRGUIPaneFactory.createBorderLayout()); // - // TODO alex_GUI // 以后rightPanel要用JTable - subFileList = new JList(new DefaultListModel()); - subFileList.setCellRenderer(listRenderer); - subFileList.addMouseListener(subFileListMouseListener); - subFileList.addKeyListener(subFileListKeyListener); + subFileList = new JList(new DefaultListModel<>()); + /* + * JList的CellRenderer + */ + subFileList.setCellRenderer(new DefaultListCellRenderer() { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof FILE) { + FILE dir = (FILE) value; + + String name = dir.getName(); + if (name != null) { + this.setText(name); + } + Icon icon = dir.getIcon(); + if (icon != null) { + this.setIcon(icon); + } + } + + return this; + } + + }); + /* + * 鼠标点击JList时的listener + */ + subFileList.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + Object source = e.getSource(); + if (!(source instanceof JList)) { + return; + } + + if (e.getClickCount() < 1) { + return; + } + + JList list = (JList) source; + + Object selValue = list.getSelectedValue(); + if (selValue instanceof FILE) { + if (e.getClickCount() == 1) { + fileNameTextField.removeDocumentListener(); + setFileTextField((FILE) selValue); + fileNameTextField.addDocumentListener(); + } else { + setSelectedDirectory((FILE) selValue); + if (!((FILE) selValue).isDirectory()) { + doOK(); + } + } + } + } + }); + /* + * right list. + */ + // Richie:按下Enter的时候打开文件夹或者打开文件 + subFileList.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + Object source = e.getSource(); + if (!(source instanceof JList)) { + return; + } + + JList list = (JList) source; + + Object selValue = list.getSelectedValue(); + if (selValue instanceof FILE) { + setFileTextField((FILE) selValue); + // if (((FILE)selValue).isDirectory()) { + // fileNameTextField.setText(""); + // } + // Richie:按下Enter的时候打开文件夹或者打开文件 + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + setSelectedDirectory((FILE) selValue); + if (!((FILE) selValue).isDirectory()) { + doOK(); + } + } + } + + } + }); scrollPane = new JScrollPane(subFileList); subFilePanel.add(scrollPane, BorderLayout.CENTER); centerRightPane.add(subFilePanel, BorderLayout.CENTER); // 用createTableLayoutPane布局下fileNamePane + UIButton cancelButton; Component[][] coms = new Component[][]{ - new Component[]{GUICoreUtils.createBorderPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_File_Name") + ":"), BorderLayout.WEST), - fileNameTextField = new UIAutoCompletionField(), okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Design_File_Open")) + new Component[]{GUICoreUtils.createBorderPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Utils_File_Name") + ":"), BorderLayout.WEST), + fileNameTextField = new UIAutoCompletionField(), okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Utils_Design_File_Open")) }, - new Component[]{GUICoreUtils.createBorderPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_File_Type") + ":"), BorderLayout.WEST), - postfixComboBox = new UIComboBox(), cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Design_Action_Cancel")) + new Component[]{GUICoreUtils.createBorderPane(new UILabel(Toolkit.i18nText("Fine-Design_Report_Utils_File_Type") + ":"), BorderLayout.WEST), + postfixComboBox = new UIComboBox(), cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Utils_Design_Action_Cancel")) }}; JPanel fileNamePane = TableLayoutHelper.createGapTableLayoutPane(coms, new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, @@ -255,7 +418,7 @@ public class FILEChooserPane extends BasicPane { centerRightPane.add(fileNamePane, BorderLayout.SOUTH); Component[][] outComponents = new Component[][]{ - new Component[]{GUICoreUtils.createBorderPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_App_File_Lookup_range") + ":"), BorderLayout.WEST), locationPane}, + new Component[]{GUICoreUtils.createBorderPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_App_File_Lookup_range") + ":"), BorderLayout.WEST), locationPane}, new Component[]{centerLeftPanel, centerRightPane}}; JPanel contentPane = TableLayoutHelper.createTableLayoutPane(outComponents, new double[]{TableLayout.PREFERRED, TableLayout.FILL}, new double[]{TableLayout.PREFERRED, TableLayout.FILL}); @@ -269,7 +432,7 @@ public class FILEChooserPane extends BasicPane { cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - returnValue = CANCEL_OPTION; + option = CANCEL_OPTION; doCancel(); } }); @@ -277,7 +440,7 @@ public class FILEChooserPane extends BasicPane { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { - returnValue = CANCEL_OPTION; + option = CANCEL_OPTION; doOK(); } } @@ -309,7 +472,7 @@ public class FILEChooserPane extends BasicPane { this(); this.showEnv = showEnv; this.showLoc = showLoc; - this.setModelOfPlaceList(); + this.setPlaceListModel(); } @@ -320,7 +483,7 @@ public class FILEChooserPane extends BasicPane { */ public FILE getSelectedFILE() { String fileName = fileNameTextField.getText().trim(); - if (!fileName.endsWith(suffix) && fileName.indexOf(CoreConstants.DOT) == -1) { + if (!fileName.endsWith(suffix) && !fileName.contains(CoreConstants.DOT)) { fileName += this.suffix; } if (currentDirectory == null) { @@ -334,7 +497,7 @@ public class FILEChooserPane extends BasicPane { } protected String getEnvProjectName() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Report_Env_Directory"); + return Toolkit.i18nText("Fine-Design_Basic_Utils_Report_Env_Directory"); } /** @@ -360,9 +523,6 @@ public class FILEChooserPane extends BasicPane { this.filterList.add(index, filter); } - // August:上面的方法在包含时直接return了,应该把改filter放在第一个 - // 不然在多次打开两个FILEchooserpane时,filter会出错 - /** * 若是已经存在,则将之删去之后,在指定的位置增加 * @@ -427,22 +587,15 @@ public class FILEChooserPane extends BasicPane { fileNameTextField.removeDocumentListener(); fileNameTextField.setText(text); fileNameTextField.addDocumentListener(); - if (currentDirectory != null) { + if (currentDirectory == null) { return; } - FILE[] res_array = currentDirectory.listFiles(); - String[] name_array = new String[res_array.length]; - for (int i = 0; i < res_array.length; i++) { - name_array[i] = res_array[i].getName(); + FILE[] files = currentDirectory.listFiles(); + String[] names = new String[files.length]; + for (int i = 0; i < files.length; i++) { + names[i] = files[i].getName(); } - fileNameTextField.setFilter(new DefaultCompletionFilter(name_array)); - } - - /** - * @return - */ - public String getFileNameTextField() { - return this.fileNameTextField.getText(); + fileNameTextField.setFilter(new DefaultCompletionFilter(names)); } @@ -514,7 +667,7 @@ public class FILEChooserPane extends BasicPane { @Override public void windowClosing(WindowEvent e) { - returnValue = CANCEL_OPTION; + option = CANCEL_OPTION; dialogExit(); } }); @@ -527,15 +680,13 @@ public class FILEChooserPane extends BasicPane { chooseType(); // richer:当文件类型被选定时,显示的文件就仅仅显示被选定的类型 // 如果是保存对话框,给个默认名字 - if (type == JFileChooser.SAVE_DIALOG) { - this.getFileNameTextField(); - } else { + if (type != JFileChooser.SAVE_DIALOG) { fileNameTextField.removeDocumentListener(); fileNameTextField.setText(""); fileNameTextField.addDocumentListener(); } dialog.setVisible(true); - return returnValue; + return option; } protected void fileType() { @@ -546,39 +697,39 @@ public class FILEChooserPane extends BasicPane { EnumSet fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT); if (type == JFileChooser.OPEN_DIALOG) { if (WorkContext.getCurrent().isLocal()) { //本地连接 - this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_File"))); + this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); } else { - this.addChooseFILEFilter(new ChooseFileFilter(fileExtensions, appName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_File"))); + this.addChooseFILEFilter(new ChooseFileFilter(fileExtensions, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); } } // ben:filefilter设置初值为cpt过滤 - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_File"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPTX, appName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_File"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPTX, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); // richer:form文件 daniel 改成三个字 - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_File"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRMX, appName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_File"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRMX, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); } else { if (type == JFileChooser.OPEN_DIALOG) { - this.addChooseFILEFilter(new ChooseFileFilter(EnumSet.of(FileExtension.XLS, FileExtension.XLSX), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Import_Excel_Source"))); + this.addChooseFILEFilter(new ChooseFileFilter(EnumSet.of(FileExtension.XLS, FileExtension.XLSX), Toolkit.i18nText("Fine-Design_Basic_Import_Excel_Source"))); } } // 添加 xls 文件类型过滤 kt if (WorkContext.getCurrent().isLocal()) { //本地连接 - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Import_Excel_Source"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLSX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Import_Excel2007_Source"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLS, Toolkit.i18nText("Fine-Design_Basic_Import_Excel_Source"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLSX, Toolkit.i18nText("Fine-Design_Basic_Import_Excel2007_Source"))); } if (FileExtension.PNG.matchExtension(suffix)) { - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.PNG, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_App_Export_png"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.PNG, Toolkit.i18nText("Fine-Design_Basic_App_Export_png"))); } if (type == JFileChooser.SAVE_DIALOG) { - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.PDF, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Import_Export_PDF"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.SVG, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Import_Export_SVG"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CSV, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Import_Export_CSV"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.DOC, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Import_Export_Word"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.TXT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Import_Export_Text"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.PDF, Toolkit.i18nText("Fine-Design_Basic_Import_Export_PDF"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.SVG, Toolkit.i18nText("Fine-Design_Basic_Import_Export_SVG"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CSV, Toolkit.i18nText("Fine-Design_Basic_Import_Export_CSV"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.DOC, Toolkit.i18nText("Fine-Design_Basic_Import_Export_Word"))); + this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.TXT, Toolkit.i18nText("Fine-Design_Basic_Import_Export_Text"))); } } @@ -586,12 +737,12 @@ public class FILEChooserPane extends BasicPane { private void chooseType() { DefaultComboBoxModel defaultComboBoxModel = (DefaultComboBoxModel) postfixComboBox.getModel(); defaultComboBoxModel.removeAllElements(); - for (FILEFilter aFilterList : filterList) { - defaultComboBoxModel.addElement(aFilterList); + for (FILEFilter filter : filterList) { + defaultComboBoxModel.addElement(filter); } if (WorkContext.getCurrent().isLocal()) { //本地连接 if (!showWebReport) { - defaultComboBoxModel.addElement(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_App_AllFiles") + "(*.*)"); + defaultComboBoxModel.addElement(Toolkit.i18nText("Fine-Design_Basic_Utils_App_AllFiles") + "(*.*)"); } } // 默认选取的文件类型(.cpt)类型 @@ -643,11 +794,11 @@ public class FILEChooserPane extends BasicPane { if (this.subFileList.getSelectedValue() == null) { FILE file = this.getSelectedFILE(); if (file.exists()) { - returnValue = OK_OPTION; + option = OK_OPTION; saveDictionary(); dialogExit(); } else { - JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_App_Template_Report_Not_Exist")); + JOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Basic_App_Template_Report_Not_Exist")); return; } } @@ -657,7 +808,7 @@ public class FILEChooserPane extends BasicPane { if (selectedSubFile != null && selectedSubFile.isDirectory()) { setSelectedDirectory((FILE) this.subFileList.getSelectedValue()); } else { - returnValue = OK_OPTION; + option = OK_OPTION; saveDictionary(); dialogExit(); } @@ -678,34 +829,42 @@ public class FILEChooserPane extends BasicPane { fileNameTextField.setText(filename + this.suffix); } } - returnValue = OK_OPTION; + option = OK_OPTION; FILE selectedFile = this.getSelectedFILE(); - boolean access = false; + if (access(selectedFile) && access(currentDirectory)) { + if (selectedFile.exists()) { + int selVal = JOptionPane.showConfirmDialog(dialog, Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Cover_The_Current_File") + " ?", + ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); + if (selVal == JOptionPane.YES_OPTION) { + option = JOPTIONPANE_OK_OPTION; + saveDictionary(); + dialogExit(); + } else { + option = JOPTIONPANE_CANCEL_OPTION; + } + + } else { + dialogExit(); + saveDictionary(); + } + } else { + JOptionPane.showMessageDialog(FILEChooserPane.this, Toolkit.i18nText("Fine-Design_Basic_App_Privilege_No") + "!", Toolkit.i18nText("Fine-Design_Basic_App_File_Message"), JOptionPane.WARNING_MESSAGE); + + } + } + + private boolean access(FILE selectedFile) { + boolean access = false; try { access = FRContext.getOrganizationOperator().canAccess(selectedFile.getPath()); + if (selectedFile.isEnvFile() && selectedFile instanceof FileNodeFILE) { + access = access && ((FileNodeFILE) selectedFile).hasFullAuth(); + } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - if (!access) { - JOptionPane.showMessageDialog(FILEChooserPane.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_App_Privilege_No") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_App_File_Message"), JOptionPane.WARNING_MESSAGE); - return; - } - if (selectedFile.exists()) { - int selVal = JOptionPane.showConfirmDialog(dialog, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Cover_The_Current_File") + " ?", - ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); - if (selVal == JOptionPane.YES_OPTION) { - returnValue = JOPTIONPANE_OK_OPTION; - saveDictionary(); - dialogExit(); - } else { - returnValue = JOPTIONPANE_CANCEL_OPTION; - } - - } else { - dialogExit(); - saveDictionary(); - } + return access; } private void saveDictionary() { @@ -730,18 +889,11 @@ public class FILEChooserPane extends BasicPane { dialog = null; } - /** - * @return - */ - public int getReturnValue() { - return this.returnValue; - } - /* * dialog的名字 */ private String dialogName() { - return type == JFileChooser.OPEN_DIALOG ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Design_File_Open") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_App_Template_Save"); + return type == JFileChooser.OPEN_DIALOG ? Toolkit.i18nText("Fine-Design_Basic_Utils_Design_File_Open") : Toolkit.i18nText("Fine-Design_Basic_App_Template_Save"); } /* @@ -756,7 +908,6 @@ public class FILEChooserPane extends BasicPane { for (int i = 0, len = model.getSize(); i < len; i++) { if (ComparatorUtils.equals(name, ((FILE) model.getElementAt(i)).getName())) { subFileList.setSelectedIndex(i); - // TODO alex_GUI 怎么ScrollIntoView? break; } } @@ -782,20 +933,12 @@ public class FILEChooserPane extends BasicPane { }; } if (FILEChooserPane.this.showWebReport) { - // webReportFILE = new FileFILE(new - // File(FRContext.getCommonOperator().getWebReportPath())); webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebRootPath()); - // String webReportPath = - // FRContext.getCommonOperator().getWebReportPath(); - // String webReportParentPath = new - // File(webReportPath).getParent(); - // webReportFILE = new FileNodeFILE(new FileNode("WebReport", - // true),webReportParentPath); } if (FILEChooserPane.this.showLoc) { - if (OperatingSystem.isWindows()) { + if (WindowsDetector.detect(true)) { // windows下展示桌面 File[] desktop = FileSystemView.getFileSystemView().getRoots(); if (desktop != null) { @@ -805,7 +948,8 @@ public class FILEChooserPane extends BasicPane { } } } - } else { // *nix下展示家目录 + } else { + // *nix下展示家目录 filesOfSystem.add(new FileFILE(FileSystemView.getFileSystemView().getDefaultDirectory())); } @@ -847,11 +991,11 @@ public class FILEChooserPane extends BasicPane { } } - private void setCD(final FILE lastdirctory) { + private void setCD(final FILE lastDirectory) { for (int i = 0; i < this.getSize(); i++) { FILE file = this.getElementAt(i); - if (ComparatorUtils.equals(lastdirctory.prefix(), file.prefix())) { - setCurrentDirectory(lastdirctory); + if (ComparatorUtils.equals(lastDirectory.prefix(), file.prefix())) { + setCurrentDirectory(lastDirectory); return; } } @@ -859,16 +1003,17 @@ public class FILEChooserPane extends BasicPane { } } - protected void setModelOfPlaceList() { + private void setPlaceListModel() { if (placesList == null) { return; } - model = new PlaceListModel(); + PlaceListModel model = new PlaceListModel(); placesList.setModel(model); - String lastdirctorypath = DesignerEnvManager.getEnvManager().getDialogCurrentDirectory(); + String lastDirectoryPath = DesignerEnvManager.getEnvManager().getDialogCurrentDirectory(); String prefix = DesignerEnvManager.getEnvManager().getCurrentDirectoryPrefix(); - FILE lastdirctory = FILEFactory.createFolder(prefix + lastdirctorypath); - model.setCD(lastdirctory); + FILE lastDirectory = FILEFactory.createFolder(prefix + lastDirectoryPath); + + model.setCD(lastDirectory); if (currentDirectory != null) { return; @@ -884,159 +1029,10 @@ public class FILEChooserPane extends BasicPane { } } - private ListCellRenderer placelistRenderer = new DefaultListCellRenderer() { - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - if (value instanceof FILE) { - FILE dir = (FILE) value; - - String name = dir.getName(); - if (name != null && !StringUtils.isBlank(name)) { - this.setText(name); - } else { - this.setText(GeneralContext.getCurrentAppNameOfEnv()); - } - Icon icon = dir.getIcon(); - if (icon != null) { - this.setIcon(icon); - } - } - - return this; - } - - }; - /* - * JList的CellRenderer - */ - private ListCellRenderer listRenderer = new DefaultListCellRenderer() { - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - if (value instanceof FILE) { - FILE dir = (FILE) value; - - String name = dir.getName(); - if (name != null) { - this.setText(name); - } - Icon icon = dir.getIcon(); - if (icon != null) { - this.setIcon(icon); - } - } - - return this; - } - - }; - // placeList listener - ListSelectionListener placeListener = new ListSelectionListener() { - @Override - public void valueChanged(ListSelectionEvent e) { - Object selValue = placesList.getSelectedValue(); - if (selValue instanceof FILE) { - setSelectedDirectory((FILE) selValue); - } - } - }; - - /** - * placeList mouseListener - */ - private MouseListener placeMouseListener = new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - Object selValue = placesList.getSelectedValue(); - if (selValue instanceof FILE) { - setSelectedDirectory((FILE) selValue); - } - } - }; - - /** - * right list. - */ - private KeyListener subFileListKeyListener = new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - Object source = e.getSource(); - if (!(source instanceof JList)) { - return; - } - - JList list = (JList) source; - - Object selValue = list.getSelectedValue(); - if (selValue instanceof FILE) { - setFileTextField((FILE) selValue); - // if (((FILE)selValue).isDirectory()) { - // fileNameTextField.setText(""); - // } - // Richie:按下Enter的时候打开文件夹或者打开文件 - if (e.getKeyCode() == KeyEvent.VK_ENTER) { - setSelectedDirectory((FILE) selValue); - if (!((FILE) selValue).isDirectory()) { - doOK(); - } - } - } - - } - }; - /* - * 鼠标点击JList时的listener - */ - private MouseListener subFileListMouseListener = new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - Object source = e.getSource(); - if (!(source instanceof JList)) { - return; - } - - if (e.getClickCount() < 1) { - return; - } - - JList list = (JList) source; - - Object selValue = list.getSelectedValue(); - if (selValue instanceof FILE) { - if (e.getClickCount() == 1) { - fileNameTextField.removeDocumentListener(); - setFileTextField((FILE) selValue); - fileNameTextField.addDocumentListener(); - } else { - setSelectedDirectory((FILE) selValue); - if (!((FILE) selValue).isDirectory()) { - doOK(); - } - } - } - } - }; - /* * 选中文件 */ private void setFileTextField(FILE file) { - // clickedFILE = file; - - // String okButtonText; - // if (file != null && file.isDirectory() - // && this.fileNameTextField.getText().length() == 0) { - // okButtonText = com.fr.design.i18n.Toolkit.i18nText("Open");// + "(O)"; - // } else { - // okButtonText = dialogName(); - // } - // okButton.setText(okButtonText); - if (file != null && !file.isDirectory()) { fileNameTextField.setText(file.getName()); if (file instanceof FileFILE) { @@ -1066,7 +1062,7 @@ public class FILEChooserPane extends BasicPane { for (int i = 0; i < defaultListModel.getSize(); i++) { if (defaultListModel.getElementAt(i) instanceof FileFILE) { FileFILE popDir = (FileFILE) defaultListModel.getElementAt(i); - if (popDir != null && dir != null && dir.getPath().indexOf(popDir.getPath()) == 0) { + if (popDir != null && dir.getPath().indexOf(popDir.getPath()) == 0) { placesList.setSelectedIndex(i); break; } @@ -1089,7 +1085,7 @@ public class FILEChooserPane extends BasicPane { currentDirectory = dir; this.locationBtnPane.populate(currentDirectory); - this.createFolderButton.setEnabled(currentDirectory != null); + this.mkdirButton.setEnabled(currentDirectory != null); refreshSubFileListModel(); } @@ -1127,7 +1123,7 @@ public class FILEChooserPane extends BasicPane { private BasicArrowButton leftArrowButton; private BasicArrowButton rightArrowButton; - private List buttonList = new ArrayList(); + private List buttonList = new ArrayList<>(); private int pathIndex = 0; private int maxPathIndex = 0; @@ -1198,7 +1194,6 @@ public class FILEChooserPane extends BasicPane { if (dir == null) { return; } - String path = dir.getPath(); isWebAppNamePath = ComparatorUtils.equals(dir.prefix(), FILEFactory.WEBREPORT_PREFIX); // 确保最后一个字符是分隔符 @@ -1209,9 +1204,7 @@ public class FILEChooserPane extends BasicPane { if (StringUtils.isBlank(path) && isWebAppNamePath) { this.buttonList.add(createBlankButton(new SetDirectoryAction(webAppName + '/'))); } - - Pattern seperatorPattern = Pattern.compile("[/\\\\]+"); // alex:之所以在Pattern那里加个+,是因为有些路径会有两个甚至多个分隔符放在一起 - Matcher matcher = seperatorPattern.matcher(path); + Matcher matcher = SEPARATOR_PATTERN.matcher(path); int node_start = 0; while (matcher.find()) { int start = matcher.start(); @@ -1223,7 +1216,7 @@ public class FILEChooserPane extends BasicPane { this.buttonList.add(createBlankButton((new SetDirectoryAction(btn_text + '/', // alex:dir.prefix不和btn_path一起参与pathJoin,因为btn_path是否以/打头在unix,linux // OS中意义很不一样 - FILEFactory.createFolder(dir.prefix() + StableUtils.pathJoin(new String[]{btn_path, "/"})))))); + FILEFactory.createFolder(dir.prefix() + StableUtils.pathJoin(btn_path, "/")))))); node_start = matcher.end(); } maxPathIndex = calculateMaxPathIndex(); @@ -1350,40 +1343,44 @@ public class FILEChooserPane extends BasicPane { private UIButton createBlankButton(SetDirectoryAction setDirectoryAction) { + + final Color brighter = this.getBackground().brighter(); + final Color darker = this.getBackground().darker(); + final UIButton blankButton = new UIButton(setDirectoryAction); blankButton.setMargin(new Insets(0, 0, 0, 0)); blankButton.setUI(new BasicButtonUI()); blankButton.setHorizontalTextPosition(SwingConstants.CENTER); blankButton.setBorderPainted(false); blankButton.setBorder(BorderFactory.createRaisedBevelBorder()); - blankButton.setBackground(FILEChooserPane.this.getBackground().darker()); + blankButton.setBackground(darker); blankButton.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { - blankButton.setBackground(FILEChooserPane.this.getBackground().brighter()); + blankButton.setBackground(brighter); blankButton.setBorderPainted(true); - repaint(); + blankButton.repaint(); } @Override public void mouseExited(MouseEvent e) { - blankButton.setBackground(FILEChooserPane.this.getBackground().darker()); + blankButton.setBackground(darker); blankButton.setBorderPainted(false); - repaint(); + blankButton.repaint(); } @Override public void mousePressed(MouseEvent e) { - blankButton.setBackground(FILEChooserPane.this.getBackground().brighter()); + blankButton.setBackground(brighter); blankButton.setBorderPainted(false); - repaint(); + blankButton.repaint(); } @Override public void mouseReleased(MouseEvent e) { - blankButton.setBackground(FILEChooserPane.this.getBackground().brighter()); + blankButton.setBackground(darker); blankButton.setBorderPainted(true); - repaint(); + blankButton.repaint(); } @@ -1391,61 +1388,227 @@ public class FILEChooserPane extends BasicPane { return blankButton; } + /* + * 新建文件夹的Button + */ + private UIButton initMkdirButton() { + UIButton folderButton = new UIButton(); + folderButton.setIcon(BaseUtils.readIcon("com/fr/design/images/icon_NewFolderIcon_normal.png")); + folderButton.setUI(new UIButtonUI()); + folderButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Utils_New_Folder")); + folderButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent evt) { + if (currentDirectory == null) { + return; + } + + if (access(currentDirectory)) { + new MkdirDialog(); + } else { + JOptionPane.showMessageDialog( + FILEChooserPane.this, + Toolkit.i18nText("Fine-Design_Basic_App_Privilege_No") + "!", + Toolkit.i18nText("Fine-Design_Basic_App_File_Message"), + JOptionPane.WARNING_MESSAGE); + } - private ActionListener createFolderActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - if (currentDirectory == null) { - return; - } - boolean access = false; - try { - access = FRContext.getOrganizationOperator().canAccess(currentDirectory.getPath()); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - if (!access) { - JOptionPane.showMessageDialog(FILEChooserPane.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_App_Privilege_No") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_App_File_Message"), JOptionPane.WARNING_MESSAGE); - return; } + }); + return folderButton; + } - String res = JOptionPane.showInputDialog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Please_Input_A_New_Name")); - if (res != null) { - currentDirectory.createFolder(res); - refreshSubFileListModel(); + /** + * 新建文件夹对话框 + * 支持快捷键Enter,ESC + */ + private class MkdirDialog extends JDialog { + + private UITextField nameField; + + private UILabel warnLabel; + + private UIButton confirmButton; + + + private MkdirDialog() { + + this.setLayout(new BorderLayout()); + this.setModal(true); + + // 输入框前提示 + UILabel newNameLabel = new UILabel(Toolkit.i18nText( + "Fine-Design_Basic_Enter_New_Folder_Name") + ); + newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT); + newNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); + newNameLabel.setPreferredSize(new Dimension(118, 15)); + + // 文件名输入框 + nameField = new UITextField(); + nameField.getDocument().addDocumentListener(new DocumentListener() { + + public void changedUpdate(DocumentEvent e) { + validInput(); + } + + public void insertUpdate(DocumentEvent e) { + validInput(); + } + + public void removeUpdate(DocumentEvent e) { + validInput(); + } + }); + nameField.selectAll(); + nameField.setPreferredSize(new Dimension(180, 20)); + + JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5)); + topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15)); + topPanel.add(newNameLabel); + topPanel.add(nameField); + + // 增加enter以及esc快捷键的支持 + nameField.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + dispose(); + } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { + if (confirmButton.isEnabled()) { + confirmClose(); + } + } + } + }); + // 重名提示 + warnLabel = new UILabel(); + warnLabel.setPreferredSize(new Dimension(300, 30)); + warnLabel.setHorizontalAlignment(SwingConstants.LEFT); + warnLabel.setForeground(Color.RED); + warnLabel.setVisible(false); + + JPanel midPanel = new JPanel(new BorderLayout()); + midPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); + midPanel.add(warnLabel, BorderLayout.WEST); + + // 确认按钮 + confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm")); + confirmButton.setPreferredSize(new Dimension(60, 25)); + confirmButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + confirmClose(); + } + }); + + // 取消按钮 + UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); + cancelButton.setPreferredSize(new Dimension(60, 25)); + + cancelButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + + JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); + bottomPanel.add(confirmButton); + bottomPanel.add(cancelButton); + + this.add( + TableLayoutHelper.createTableLayoutPane( + new Component[][]{ + new Component[]{topPanel}, + new Component[]{midPanel}, + new Component[]{bottomPanel} + }, + new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL}, + new double[]{TableLayout.FILL} + ), + BorderLayout.CENTER); + + + this.setSize(340, 180); + this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Mkdir")); + this.setResizable(false); + this.setAlwaysOnTop(true); + this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + GUICoreUtils.centerWindow(this); + this.setVisible(true); + } + + private void confirmClose() { - setSelectedFileName(res); + String userInput = nameField.getText().trim(); + + // 处理不合法的文件夹名称 + userInput = userInput.replaceAll("[\\\\/:*?\"<>|]", StringUtils.EMPTY); + + if (currentDirectory.createFolder(userInput)) { + refreshSubFileListModel(); + setSelectedFileName(userInput); // ben:这里处理有些不妥,取文件时没有考虑filefilter,不过效果一样,取的时候应该用subfilelist得data FILE[] allFiles = currentDirectory.listFiles(); int place = 0; for (int i = 0; i < allFiles.length; i++) { - if (ComparatorUtils.equals(allFiles[i].getName(), res) && allFiles[i].isDirectory()) { + if (ComparatorUtils.equals(allFiles[i].getName(), userInput) && allFiles[i].isDirectory()) { place = i; break; } } - scrollPane.validate(); + scrollPane.revalidate(); + scrollPane.repaint(); int total = scrollPane.getVerticalScrollBar().getMaximum(); int value = total * place / subFileList.getModel().getSize(); scrollPane.getVerticalScrollBar().setValue(value); + + } else { + JOptionPane.showConfirmDialog(FILEChooserPane.this, + Toolkit.i18nText("Fine-Design_Basic_Make_Failure"), + UIManager.getString("OptionPane.messageDialogTitle"), + JOptionPane.DEFAULT_OPTION, + JOptionPane.ERROR_MESSAGE); } + this.dispose(); } - }; - /* - * 新建文件夹的Button - */ - private UIButton createFolderButton() { - UIButton folderButton = new UIButton(); - folderButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/file/newfolder.png")); - folderButton.setEnabled(false); - folderButton.setMargin(new Insets(0, 0, 0, 0)); - folderButton.setUI(new BasicButtonUI()); - folderButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_New_Folder")); - folderButton.addActionListener(createFolderActionListener); - return folderButton; + private void validInput() { + + String userInput = nameField.getText().trim(); + + if (StringUtils.isEmpty(userInput)) { + confirmButton.setEnabled(false); + } + + boolean duplicate = false; + // ben:这里处理有些不妥,取文件时没有考虑filefilter,不过效果一样,取的时候应该用subfilelist得data + FILE[] allFiles = currentDirectory.listFiles(); + for (int i = 0; i < allFiles.length; i++) { + if (ComparatorUtils.equals(allFiles[i].getName(), userInput) && allFiles[i].isDirectory()) { + duplicate = true; + break; + } + } + + if (duplicate) { + nameField.selectAll(); + // 如果文件名已存在,则灰掉确认按钮 + warnLabel.setText( + Toolkit.i18nText( + "Fine-Design_Basic_Folder_Name_Duplicate", + userInput)); + warnLabel.setVisible(true); + confirmButton.setEnabled(false); + } else { + warnLabel.setVisible(false); + confirmButton.setEnabled(true); + } + } } } diff --git a/designer-base/src/main/java/com/fr/file/FILEFactory.java b/designer-base/src/main/java/com/fr/file/FILEFactory.java index f5d690b212..5a19108ee3 100644 --- a/designer-base/src/main/java/com/fr/file/FILEFactory.java +++ b/designer-base/src/main/java/com/fr/file/FILEFactory.java @@ -1,6 +1,7 @@ package com.fr.file; import com.fr.base.FRContext; +import com.fr.design.file.NodeAuthProcessor; import com.fr.file.filetree.FileNode; import com.fr.workspace.WorkContext; @@ -19,7 +20,7 @@ public class FILEFactory { * 也有可能就是一个普通的路径d:/foo/bar */ public static FILE createFILE(String path) { - + String envPath = WorkContext.getCurrent().getPath().replaceAll("/", "\\\\"); if (path == null) { return null; @@ -45,7 +46,8 @@ public class FILEFactory { } else if (path.startsWith(MEM_PREFIX)) { return new MemFILE(path.substring(MEM_PREFIX.length())); } else if (path.startsWith(ENV_PREFIX)) { - return new FileNodeFILE(new FileNode(path.substring(ENV_PREFIX.length()), true)); + return NodeAuthProcessor.getInstance(). + fixFILENodeAuth(new FileNode(path.substring(ENV_PREFIX.length()), true)); } else if (path.startsWith(WEBREPORT_PREFIX)) { return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true), FRContext.getCommonOperator().getWebRootPath()); diff --git a/designer-base/src/main/java/com/fr/file/FileFILE.java b/designer-base/src/main/java/com/fr/file/FileFILE.java index 5242495be7..ee92205f50 100644 --- a/designer-base/src/main/java/com/fr/file/FileFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileFILE.java @@ -4,11 +4,11 @@ import com.fr.base.io.XMLEncryptUtils; import com.fr.design.gui.itree.filetree.FileComparator; import com.fr.design.gui.itree.filetree.FileTreeIcon; import com.fr.general.ComparatorUtils; -import com.fr.web.session.SessionLocalManager; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.web.session.SessionLocalManager; -import javax.swing.*; +import javax.swing.Icon; import javax.swing.filechooser.FileSystemView; import java.io.File; import java.io.FileOutputStream; @@ -16,6 +16,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class FileFILE implements FILE { @@ -30,9 +32,9 @@ public class FileFILE implements FILE { } /** - * 后缀 + * 前缀 * - * @return 后缀 + * @return 前缀 */ public String prefix() { return FILEFactory.FILE_PREFIX; @@ -44,7 +46,7 @@ public class FileFILE implements FILE { * @returns 是则返回true */ public boolean isDirectory() { - return file == null ? false : file.isDirectory(); + return file != null && file.isDirectory(); } @Override @@ -118,22 +120,22 @@ public class FileFILE implements FILE { return new FILE[]{this}; } - File[] file_array = file.listFiles(); - if (file_array == null) { + File[] fileArray = file.listFiles(); + if (fileArray == null) { return new FILE[0]; } - java.util.Arrays.sort(file_array, new FileComparator()); + Arrays.sort(fileArray, new FileComparator()); - java.util.List res_list = new ArrayList(file_array.length); + List resList = new ArrayList(fileArray.length); - for (int i = 0; i < file_array.length; i++) { + for (int i = 0; i < fileArray.length; i++) { // 因为有一些系统文件,比如虚拟内存等,会在listFiles的时候出现,但却not exists - if (file_array[i].exists()) { - res_list.add(new FileFILE(file_array[i])); + if (fileArray[i].exists()) { + resList.add(new FileFILE(fileArray[i])); } } - return res_list.toArray(new FILE[res_list.size()]); + return resList.toArray(new FILE[resList.size()]); } /** @@ -147,9 +149,7 @@ public class FileFILE implements FILE { return false; } - File new_file = new File(StableUtils.pathJoin(new String[]{ - file.getAbsolutePath(), name - })); + File new_file = new File(StableUtils.pathJoin(file.getAbsolutePath(), name)); if (new_file.exists()) { return false; @@ -164,7 +164,7 @@ public class FileFILE implements FILE { * @return 是否存在 */ public boolean exists() { - return file == null ? false : file.exists(); + return file != null && file.exists(); } /** @@ -192,14 +192,14 @@ public class FileFILE implements FILE { * 作为输出流 * * @return 输出流 - * @throws Exception 异常 */ - public OutputStream asOutputStream() throws Exception { - if (file == null || !file.exists()) { + public OutputStream asOutputStream() { + if (file == null) { return null; } - java.io.OutputStream out = null; + OutputStream out; try { + StableUtils.makesureFileExist(file); out = new FileOutputStream(file); } catch (Exception e) { throw SessionLocalManager.createLogPackedException(e); @@ -209,10 +209,8 @@ public class FileFILE implements FILE { /** * 关闭文件 - * - * @throws Exception 异常 */ - public void closeTemplate() throws Exception { + public void closeTemplate() { } @Override @@ -225,10 +223,10 @@ public class FileFILE implements FILE { } /** - * 返回hash码 - * - * @return 返回hash码 - */ + * 返回hash码 + * + * @return 返回hash码 + */ public int hashCode() { int hash = 7; hash = 97 * hash + (this.file != null ? this.file.hashCode() : 0); @@ -251,17 +249,19 @@ public class FileFILE implements FILE { } /** - * 是否是内存文件 - * @return 是则返回true - */ + * 是否是内存文件 + * + * @return 是则返回true + */ public boolean isMemFile() { return false; } /** - * 是否是环境文件 - * @return 是则返回true - */ + * 是否是环境文件 + * + * @return 是则返回true + */ public boolean isEnvFile() { return false; } diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index f64f961cb7..84724df35e 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -3,32 +3,40 @@ package com.fr.file; import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.io.XMLEncryptUtils; +import com.fr.design.file.NodeAuthProcessor; import com.fr.design.gui.itree.filetree.FileNodeComparator; import com.fr.design.gui.itree.filetree.FileTreeIcon; +import com.fr.design.i18n.Toolkit; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; - -import com.fr.workspace.resource.WorkResourceOutputStream; import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; +import com.fr.workspace.resource.WorkResourceTempRenameStream; +import com.fr.workspace.server.lock.TplOperator; -import javax.swing.*; +import javax.swing.Icon; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.OutputStream; +import java.util.Arrays; public class FileNodeFILE implements FILE { - + private FileNode node; - - // carl:记录下FILE对应的运行环境,每次创建都设置下当前的运行环境 + + //记录下FILE对应的运行环境,每次创建都设置下当前的运行环境 private String envPath; - + + /** + * 是否有全部权限 + */ + private boolean hasFullAuth = true; + public FileNodeFILE(FileNodeFILE parent, String name, boolean isDir) { - + FileNode fn = parent.node; String parentDir; if (fn.isDirectory()) { @@ -36,156 +44,187 @@ public class FileNodeFILE implements FILE { } else { parentDir = fn.getParent(); } - + this.node = new FileNode(StableUtils.pathJoin(parentDir, name), isDir); this.envPath = WorkContext.getCurrent().getPath(); + this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node); } - + + public FileNodeFILE(FileNode node) { - this.node = node; this.envPath = WorkContext.getCurrent().getPath(); + this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node); + } + + public FileNodeFILE(FileNode node, boolean hasFullAuth) { + this(node); + this.hasFullAuth = hasFullAuth; } - + public FileNodeFILE(String envPath) { - this.node = null; this.envPath = envPath; } - + public FileNodeFILE(FileNode node, String envPath) { - this.node = node; this.envPath = envPath; + this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node); + } + + public FileNodeFILE(FileNode node, String envPath, boolean hasFullAuth) { + this(node, envPath); + this.hasFullAuth = hasFullAuth; + } + + + /** + * @return 是否有完整权限 + */ + public boolean hasFullAuth() { + return hasFullAuth; } - + /** - * prefix 后缀 + * 前缀 * - * @return 返回后缀 + * @return 前缀 */ + @Override public String prefix() { - + if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebRootPath())) { return FILEFactory.WEBREPORT_PREFIX; } return FILEFactory.ENV_PREFIX; } - + /** * @return */ public String getEnvPath() { - + return this.envPath; } - + /** * 是否是目录 * * @return 是则返回true */ + @Override public boolean isDirectory() { - - return ComparatorUtils.equals(node, null) ? true : node.isDirectory(); + + return ComparatorUtils.equals(node, null) || node.isDirectory(); } - + /** * @return */ + @Override public String getName() { - + if (node == null) { return null; } - + if (ComparatorUtils.equals(node.getEnvPath(), ProjectConstants.REPORTLETS_NAME)) { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Report_Runtime_Env"); + return Toolkit.i18nText("Fine-Design_Basic_Utils_Report_Runtime_Env"); } else { return node.getName(); } } - + /** * @return */ + @Override public Icon getIcon() { - + if (node == null) { return null; } - + if (ComparatorUtils.equals(node.getEnvPath(), ProjectConstants.REPORTLETS_NAME)) { return BaseUtils.readIcon("/com/fr/base/images/oem/logo.png"); } else { + + if (!hasFullAuth) { + return FileTreeIcon.getFolderHalfImageIcon(); + } + return FileTreeIcon.getIcon(node); } } - + /** * @return */ + @Override public String getPath() { - + if (node == null) { return ""; } - + return node.getEnvPath(); } - + /** * @param path */ + @Override public void setPath(String path) { - + node.setEnvPath(path); } - + /** * @return */ + @Override public FILE getParent() { - + if (node == null) { return null; } - + return new FileNodeFILE(new FileNode(node.getParent(), true)); } - + /** * 文件 * * @return 文件组 */ + @Override public FILE[] listFiles() { - + if (ComparatorUtils.equals(node, null)) { node = new FileNode(CoreConstants.SEPARATOR, true); - //return new FILE[0]; } if (!node.isDirectory()) { return new FILE[]{this}; } - + try { - FileNode[] node_array; - node_array = listFile(node.getEnvPath()); - java.util.Arrays.sort(node_array, new FileNodeComparator()); - - FILE[] res_array = new FILE[node_array.length]; - for (int i = 0; i < node_array.length; i++) { - res_array[i] = new FileNodeFILE(node_array[i], envPath); - } - - return res_array; + FileNode[] nodeArray; + nodeArray = listFile(node.getEnvPath()); + Arrays.sort(nodeArray, new FileNodeComparator()); + + return fileNodeArray2FILEArray(nodeArray, envPath); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return new FILE[0]; } } - + + private FILE[] fileNodeArray2FILEArray(FileNode[] nodeArray, String envPath) { + return NodeAuthProcessor.getInstance().parser2FILEArray(nodeArray, envPath); + } + + /** * 根目录文件地址 * @@ -193,7 +232,7 @@ public class FileNodeFILE implements FILE { * @return 返回文件节点 */ private FileNode[] listFile(String rootFilePath) { - + try { if (ComparatorUtils.equals(envPath, FRContext.getCommonOperator().getWebRootPath())) { return FRContext.getFileNodes().listWebRootFile(rootFilePath); @@ -205,19 +244,20 @@ public class FileNodeFILE implements FILE { } return new FileNode[0]; } - + /** * 创建文件夹 * * @param name 文件夹名字 * @return 创建成功返回true */ + @Override public boolean createFolder(String name) { - + if (ComparatorUtils.equals(node, null) || !node.isDirectory()) { return false; } - + try { return WorkContext.getWorkResource().createDirectory(StableUtils.pathJoin(node.getEnvPath(), name)); } catch (Exception e) { @@ -225,18 +265,18 @@ public class FileNodeFILE implements FILE { return false; } } - + /** * 是否锁住 * * @return 文件被锁返回true */ public boolean isLocked() { - + if (node == null) { return false; } - + try { return FRContext.getCommonOperator().fileLocked(node.getEnvPath()); } catch (Exception e) { @@ -244,14 +284,15 @@ public class FileNodeFILE implements FILE { return false; } } - + /** * 是否存在 * * @return 文件存在返回 true */ + @Override public boolean exists() { - + if (node == null) { return false; } @@ -259,7 +300,7 @@ public class FileNodeFILE implements FILE { if (!isCurrentEnv()) { return false; } - + try { return WorkContext.getWorkResource().exist(node.getEnvPath()); } catch (Exception e) { @@ -267,28 +308,29 @@ public class FileNodeFILE implements FILE { return false; } } - + /** * 是否是当前环境 * * @return 是报表当前环境返回true */ public boolean isCurrentEnv() { - + return ComparatorUtils.equals(WorkContext.getCurrent().getPath(), envPath); } - + /** * 创建文件 * * @return 成功返回true */ + @Override public boolean mkfile() { - + if (node == null) { return false; } - + try { return WorkContext.getWorkResource().createFile(node.getEnvPath()); } catch (Exception e) { @@ -296,102 +338,114 @@ public class FileNodeFILE implements FILE { return false; } } - + /** * 作为输入流 * * @return 输入流 * @throws Exception */ + @Override public InputStream asInputStream() throws Exception { - + if (node == null) { return null; } - + String envPath = node.getEnvPath(); // envPath必须以reportlets开头 if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { return null; } - - InputStream in = new ByteArrayInputStream(WorkContext.getWorkResource().readFully(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)))); - + InputStream in = new ByteArrayInputStream( + WorkContext.getCurrent().get(TplOperator.class).readAndLockFile( + StableUtils.pathJoin( + ProjectConstants.REPORTLETS_NAME, + envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1) + ) + ) + ); + return envPath.endsWith(".cpt") || envPath.endsWith(".frm") - ? XMLEncryptUtils.decodeInputStream(in) : in; + ? XMLEncryptUtils.decodeInputStream(in) : in; } - + /** * 作为输出流 * * @return 返回输出流 * @throws Exception */ + @Override public OutputStream asOutputStream() throws Exception { - + if (ComparatorUtils.equals(node, null)) { return null; } - + String envPath = node.getEnvPath(); // envPath必须以reportlets开头 if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { return null; } - return new WorkResourceOutputStream(envPath); + return new WorkResourceTempRenameStream(envPath); } - + /** * 关闭模板 * * @throws Exception */ + @Override public void closeTemplate() throws Exception { - + if (node == null) { return; } - + String envPath = node.getEnvPath(); // envPath必须以reportlets开头 if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { return; } - + FRContext.getCommonOperator().unlockTemplate( - envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)); + envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)); } - + /** * 得到环境的全名 * * @return */ + @Override public String getEnvFullName() { - + return this.node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1); } - + /** * 是否是内存文件 * * @return 是则返回true */ + @Override public boolean isMemFile() { - + return false; } - + /** * 是否是环境文件 * * @return 是则返回true */ + @Override public boolean isEnvFile() { - + return true; } - + /** * 是佛相同 * @@ -399,34 +453,34 @@ public class FileNodeFILE implements FILE { * @return */ public boolean equals(Object obj) { - + if (!(obj instanceof FileNodeFILE)) { return false; } - + return ComparatorUtils.equals(this.envPath, ((FileNodeFILE) obj).envPath) && ComparatorUtils.equals(this.node, ((FileNodeFILE) obj).node); } - + /** * 返回hash码 * * @return 返回hash码 */ public int hashCode() { - + int hash = 5; hash = 61 * hash + (this.node != null ? this.node.hashCode() : 0); hash = 61 * hash + (this.envPath != null ? this.envPath.hashCode() : 0); return hash; } - + /** * 作为字符串返回 * * @return String 字符串 */ public String toString() { - + return prefix() + (this.node != null ? this.node.getEnvPath() : ""); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/file/MemFILE.java b/designer-base/src/main/java/com/fr/file/MemFILE.java index fa76ab0473..f35151eb93 100644 --- a/designer-base/src/main/java/com/fr/file/MemFILE.java +++ b/designer-base/src/main/java/com/fr/file/MemFILE.java @@ -1,10 +1,9 @@ package com.fr.file; +import javax.swing.Icon; import java.io.InputStream; import java.io.OutputStream; -import javax.swing.Icon; - public class MemFILE implements FILE { private String name; @@ -103,9 +102,9 @@ public class MemFILE implements FILE { } /** - * 后缀 + * 前缀 * - * @return 后缀 + * @return 前缀 */ public String prefix() { return FILEFactory.MEM_PREFIX; diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 932a1ebb8b..3e466ed1f3 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -31,6 +31,10 @@ import java.lang.reflect.Method; * The main class of Report Designer. */ public abstract class BaseDesigner extends ToolBarMenuDock { + private static final int PERCENT_TEN = 10; + private static final int PERCENT_SIXTY = 60; + private static final int PERCENT_NINTY= 90; + private static final int PERCENT_COMPLETE= 100; private static final int LOAD_TREE_MAXNUM = 10; @@ -51,15 +55,15 @@ public abstract class BaseDesigner extends ToolBarMenuDock { public void show(final String[] args) { collectUserInformation(); - DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(10); + DesignerContext.getDesignerFrame().updateProgress(PERCENT_TEN); showDesignerFrame(args, DesignerContext.getDesignerFrame(), false); - DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(60); + DesignerContext.getDesignerFrame().updateProgress(PERCENT_SIXTY); DesignerContext.getDesignerFrame().refreshEnv(); - DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(90); + DesignerContext.getDesignerFrame().updateProgress(PERCENT_NINTY); for (int i = 0; !TemplateTreePane.getInstance().getTemplateFileTree().isTemplateShowing() && i < LOAD_TREE_MAXNUM; i++) { TemplateTreePane.getInstance().getTemplateFileTree().refresh(); } - DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(100); + DesignerContext.getDesignerFrame().updateProgress(PERCENT_COMPLETE); } diff --git a/designer-base/src/main/java/com/fr/start/ServerStarter.java b/designer-base/src/main/java/com/fr/start/ServerStarter.java index 2141870b1c..3115730d17 100644 --- a/designer-base/src/main/java/com/fr/start/ServerStarter.java +++ b/designer-base/src/main/java/com/fr/start/ServerStarter.java @@ -5,10 +5,20 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.utils.BrowseUtils; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.OperatingSystem; import com.fr.stable.StableUtils; import com.fr.start.server.FineEmbedServer; +import com.fr.start.server.FineEmbedServerMonitor; import com.fr.workspace.WorkContext; +import javax.swing.JOptionPane; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; public class ServerStarter { @@ -47,9 +57,23 @@ public class ServerStarter { * * @param url 指定路径 */ - public static void browserURLWithLocalEnv(String url) { - - FineEmbedServer.start(); - BrowseUtils.browser(url); + public static void browserURLWithLocalEnv(final String url) { + + if(!FineEmbedServerMonitor.getInstance().isComplete()){ + FineEmbedServerMonitor.getInstance().monitor(); + ExecutorService service = Executors.newSingleThreadExecutor(); + service.submit(new Runnable() { + + @Override + public void run() { + FineEmbedServer.start(); + BrowseUtils.browser(url); + } + }); + service.shutdown(); + }else{ + FineEmbedServer.start(); + BrowseUtils.browser(url); + } } } diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java index 176db579af..982b3633dc 100644 --- a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java +++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java @@ -30,11 +30,15 @@ public class FineEmbedServerActivator extends Activator { public synchronized void start() { try { + FineEmbedServerMonitor.getInstance().reset(); //初始化tomcat initTomcat(); tomcat.start(); + } catch (LifecycleException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + }finally { + FineEmbedServerMonitor.getInstance().setComplete(); } } diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java new file mode 100644 index 0000000000..ee54a80de7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java @@ -0,0 +1,90 @@ +package com.fr.start.server; + +import com.fr.design.mainframe.DesignerContext; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.event.Null; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * 内置服务器启动监视器 + * Created by zack on 2018/8/21. + */ +public class FineEmbedServerMonitor { + private int progress; + private static final int COMPLETE = 100;//启动完成 + private static final int STEP = 5;//随便设置一个假的进度条 + private static final int STEP_HEARTBEAT = 2000;//2秒更新进度 + private static volatile FineEmbedServerMonitor monitor; + + private FineEmbedServerMonitor() { + } + + static { + EventDispatcher.listen(EmbedServerEvent.AfterStop, new Listener() { + @Override + public void on(Event event, Null aNull) { + getInstance().reset(); + DesignerContext.getDesignerFrame().hideProgressDialog(); + } + }); + } + + public static FineEmbedServerMonitor getInstance() { + if (monitor == null) { + synchronized (FineEmbedServerMonitor.class) { + if (monitor == null) { + monitor = new FineEmbedServerMonitor(); + } + } + } + return monitor; + } + + public int getProgress() { + if (progress == COMPLETE) { + return progress; + } else { + progress += STEP; + return progress; + } + } + + public void setComplete() { + this.progress = COMPLETE; + } + + public void reset() { + this.progress = 0; + } + + public boolean isComplete() { + return this.progress == COMPLETE; + } + + public void monitor() { + ExecutorService service = Executors.newSingleThreadExecutor(); + service.submit(new Runnable() { + + @Override + public void run() { + while (!isComplete()) { + if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) { + DesignerContext.getDesignerFrame().showProgressDialog(); + DesignerContext.getDesignerFrame().getProgressDialog().updateLoadingText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server")); + } + DesignerContext.getDesignerFrame().updateProgress(getProgress()); + try { + Thread.sleep(STEP_HEARTBEAT); + } catch (InterruptedException ignore) { + } + } + DesignerContext.getDesignerFrame().hideProgressDialog(); + } + }); + service.shutdown(); + } +} diff --git a/designer-base/src/main/java/com/fr/start/server/ServerTray.java b/designer-base/src/main/java/com/fr/start/server/ServerTray.java index ce2da0407d..01cfc53fc6 100644 --- a/designer-base/src/main/java/com/fr/start/server/ServerTray.java +++ b/designer-base/src/main/java/com/fr/start/server/ServerTray.java @@ -17,32 +17,32 @@ import java.awt.event.MouseEvent; * Create server tray. */ public class ServerTray { - + private static ServerTray INSTANCE; - + private MenuItem startMenu; - + private MenuItem stopMenu; - + private Image trayStartedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStarted.png"); - + private Image trayStoppedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStopped.png"); - + private ServerManageFrame serverManageFrame; - + private TrayIcon trayIcon; - - + + private ServerTray() { - + listen(); //p:首先构建右键菜单 PopupMenu popup = new PopupMenu(); MenuItem manangeMenu = new MenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Open_Service_Manager")); manangeMenu.addActionListener(new ActionListener() { - + public void actionPerformed(ActionEvent e) { - + serverManageFrame = ServerManageFrame.getServerManageFrame(); if (!serverManageFrame.isVisible()) { serverManageFrame.setVisible(true); @@ -55,9 +55,9 @@ public class ServerTray { MenuItem exitMenu = new MenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Exit")); //创建打开监听器 ActionListener startListener = new ActionListener() { - + public void actionPerformed(ActionEvent e) { - + try { FineEmbedServer.start(); } catch (Exception exp) { @@ -66,9 +66,9 @@ public class ServerTray { } }; ActionListener stopListener = new ActionListener() { - + public void actionPerformed(ActionEvent e) { - + try { FineEmbedServer.stop(); } catch (Throwable exp) { @@ -80,13 +80,13 @@ public class ServerTray { stopMenu.addActionListener(stopListener); //创建退出菜单监听器 ActionListener exitListener = new ActionListener() { - + public void actionPerformed(ActionEvent e) { - + exit(); } }; - + exitMenu.addActionListener(exitListener); popup.add(manangeMenu); popup.addSeparator(); @@ -94,18 +94,18 @@ public class ServerTray { popup.add(stopMenu); popup.addSeparator(); popup.add(exitMenu); - + //p:开始创建托盘. trayIcon = new TrayIcon(trayStartedImage, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Embedded_Server"), popup); trayIcon.setImageAutoSize(true); trayIcon.addMouseListener(new MouseAdapter() { - + public void mouseClicked(MouseEvent e) { - + if (e.getClickCount() < 2) { return; } - + ServerManageFrame serverManageFrame = ServerManageFrame.getServerManageFrame(); if (!serverManageFrame.isVisible()) { serverManageFrame.setVisible(true); @@ -113,56 +113,56 @@ public class ServerTray { serverManageFrame.toFront();//p:到第一个. } }); - + TrayIcon[] icons = SystemTray.getSystemTray().getTrayIcons(); for (TrayIcon icon : icons) { SystemTray.getSystemTray().remove(icon); } - + try { SystemTray.getSystemTray().add(trayIcon); } catch (AWTException e) { System.err.println("Can not create the System Tray:" + e); } - + checkPopupMenuItemEnabled(); } - + private void listen() { - + ListenerAdaptor listenerAdaptor = new ListenerAdaptor() { - + @Override protected void on(Event event) { - + checkPopupMenuItemEnabled(); } }; EventDispatcher.listen(EmbedServerEvent.AfterStart, listenerAdaptor); EventDispatcher.listen(EmbedServerEvent.AfterStop, listenerAdaptor); } - + private void exit() { - + FineEmbedServer.stop(); SystemTray.getSystemTray().remove(trayIcon); } - + private void checkPopupMenuItemEnabled() { - + try { if (FineEmbedServer.isRunning()) { startMenu.setEnabled(false); stopMenu.setEnabled(true); - + trayIcon.setImage(trayStartedImage); } else { startMenu.setEnabled(true); stopMenu.setEnabled(false); - + trayIcon.setImage(trayStoppedImage); } - + if (serverManageFrame != null) { serverManageFrame.checkButtonEnabled(); serverManageFrame.repaint(); @@ -171,10 +171,9 @@ public class ServerTray { FRContext.getLogger().error(exp.getMessage(), exp); } } - + public static void init() { - - INSTANCE = new ServerTray(); - + if (INSTANCE == null) + INSTANCE = new ServerTray(); } } \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/bbs.png b/designer-base/src/main/resources/com/fr/design/images/bbs/bbs.png index 4fd2df684a..7fa4a98993 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/bbs/bbs.png and b/designer-base/src/main/resources/com/fr/design/images/bbs/bbs.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/bug.png b/designer-base/src/main/resources/com/fr/design/images/bbs/bug.png index 24393bc4be..866aa85891 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/bbs/bug.png and b/designer-base/src/main/resources/com/fr/design/images/bbs/bug.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/center.png b/designer-base/src/main/resources/com/fr/design/images/bbs/center.png index 1d464ba9bf..c5ccd688d8 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/bbs/center.png and b/designer-base/src/main/resources/com/fr/design/images/bbs/center.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/demand.png b/designer-base/src/main/resources/com/fr/design/images/bbs/demand.png index b237026fa1..cf115b543f 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/bbs/demand.png and b/designer-base/src/main/resources/com/fr/design/images/bbs/demand.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/help.png b/designer-base/src/main/resources/com/fr/design/images/bbs/help.png index c13f2f1926..796d7da6c9 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/bbs/help.png and b/designer-base/src/main/resources/com/fr/design/images/bbs/help.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/need.png b/designer-base/src/main/resources/com/fr/design/images/bbs/need.png index 486ff9846a..2c95e50ee4 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/bbs/need.png and b/designer-base/src/main/resources/com/fr/design/images/bbs/need.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/question.png b/designer-base/src/main/resources/com/fr/design/images/bbs/question.png index c8c6fd8a1b..ffdbdacb8f 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/bbs/question.png and b/designer-base/src/main/resources/com/fr/design/images/bbs/question.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/sign.png b/designer-base/src/main/resources/com/fr/design/images/bbs/sign.png index b1556f7ed1..c48caf0152 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/bbs/sign.png and b/designer-base/src/main/resources/com/fr/design/images/bbs/sign.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/solution.png b/designer-base/src/main/resources/com/fr/design/images/bbs/solution.png index f092306746..f22f85d238 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/bbs/solution.png and b/designer-base/src/main/resources/com/fr/design/images/bbs/solution.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/video.png b/designer-base/src/main/resources/com/fr/design/images/bbs/video.png index 1971f26156..7178b11a02 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/bbs/video.png and b/designer-base/src/main/resources/com/fr/design/images/bbs/video.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/user_search_normal.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/user_search_normal.png new file mode 100644 index 0000000000..9a9a2e65a4 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/user_search_normal.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/user_search_normal@2x.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/user_search_normal@2x.png new file mode 100644 index 0000000000..13829dcb61 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/user_search_normal@2x.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/icon_NewFolderIcon_normal.png b/designer-base/src/main/resources/com/fr/design/images/icon_NewFolderIcon_normal.png new file mode 100644 index 0000000000..9ea75fc6d8 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/icon_NewFolderIcon_normal.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart-Map.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart-Map.png index 2f68dcf8f9..f2f2d480f5 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart-Map.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart-Map.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Column.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Column.png index 33af5fd2fe..d5e0cbfa7c 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Column.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Column.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Comb_Chart.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Comb_Chart.png index 9ff66acafd..e92444ceb8 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Comb_Chart.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Comb_Chart.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Donut.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Donut.png index 8fd08de553..51e1636580 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Donut.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Donut.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Funnel.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Funnel.png index b838ac93b3..32cee18154 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Funnel.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Funnel.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gantt.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gantt.png index 6b651248c3..f1c6de1854 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gantt.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gantt.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gis.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gis.png index 9435a61d7a..d4bf13edd5 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gis.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gis.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Meter.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Meter.png index 2c62da86be..8af36d06a3 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Meter.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Meter.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Pie.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Pie.png index 055502cb22..e204e06595 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Pie.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Pie.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Radar.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Radar.png index 754781f9fd..e2c400e63e 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Radar.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Radar.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Range_Chart.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Range_Chart.png index 0d0cb9e063..9466e8326a 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Range_Chart.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Range_Chart.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Stock.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Stock.png index 073de2b09b..a1b373190c 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Stock.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Stock.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-XYScatter.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-XYScatter.png index 24a2aaa3e9..3a06f0ec66 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-XYScatter.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-XYScatter.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart_BubbleChart.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart_BubbleChart.png index e1ab5c3131..d2730204a0 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart_BubbleChart.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart_BubbleChart.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/FR-Chart-Bit_Map.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/FR-Chart-Bit_Map.png index 2f68dcf8f9..a249901249 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/FR-Chart-Bit_Map.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/FR-Chart-Bit_Map.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Area.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Area.png index 473baff558..6bfd8bbb9b 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Area.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Area.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Bar.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Bar.png index 1f28a09436..e0e124def5 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Bar.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Bar.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Pie.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Pie.png index 055502cb22..db64b46e6d 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Pie.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Pie.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Plugin-ChartF_VerticalLine.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Plugin-ChartF_VerticalLine.png index 63c460d69e..6bd4ebbb7f 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Plugin-ChartF_VerticalLine.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Plugin-ChartF_VerticalLine.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Poly-Report_Block.png b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Poly-Report_Block.png index 5b8f0ff2f6..3fc1a0269f 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Poly-Report_Block.png and b/designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Poly-Report_Block.png differ diff --git a/designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png b/designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@1x.png similarity index 100% rename from designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png rename to designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@1x.png diff --git a/designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@2x.png b/designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@2x.png similarity index 100% rename from designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@2x.png rename to designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@2x.png diff --git a/designer-base/src/test/java/com/fr/env/RemoteEnvPaneTest.java b/designer-base/src/test/java/com/fr/env/RemoteEnvPaneTest.java new file mode 100644 index 0000000000..d2bf952202 --- /dev/null +++ b/designer-base/src/test/java/com/fr/env/RemoteEnvPaneTest.java @@ -0,0 +1,54 @@ +//package com.fr.env; +// +//import org.fest.swing.annotation.RunsInEDT; +//import org.fest.swing.core.ComponentLookupScope; +//import org.fest.swing.core.Robot; +//import org.fest.swing.edt.GuiQuery; +//import org.fest.swing.fixture.JPanelFixture; +//import org.fest.swing.junit.testcase.FestSwingJUnitTestCase; +//import org.junit.Test; +// +//import javax.swing.JFrame; +//import javax.swing.WindowConstants; +// +//import static org.fest.swing.edt.GuiActionRunner.execute; +// +//public class RemoteEnvPaneTest extends FestSwingJUnitTestCase { +// +// @Override +// protected void onSetUp() { +// +// } +// +// @Test +// public void test() { +// +// Robot robot = robot(); +// +// robot.settings().componentLookupScope(ComponentLookupScope.ALL); +// +// JPanelFixture rootFixture = new JPanelFixture(robot, createNewEditor()); +// rootFixture.checkBox("httpsCheckbox").check(); +// +// rootFixture.checkBox("httpsCheckbox").requireSelected(); +// } +// +// @RunsInEDT +// private static RemoteEnvPane createNewEditor() { +// +// return execute(new GuiQuery() { +// @Override +// protected RemoteEnvPane executeInEDT() { +// RemoteEnvPane envPane = new RemoteEnvPane(); +// JFrame frame = new JFrame(); +// frame.getContentPane().add(envPane); +// frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); +// frame.setResizable(false); +// frame.pack(); +// frame.setLocationRelativeTo(null); +// frame.setVisible(true); +// return envPane; +// } +// }); +// } +//} diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java index 2f69013ced..f693a45f64 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java @@ -477,7 +477,7 @@ public class UIGroupExtensionPane extends BasicPane { try { list.setSelectedIndices(null); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java index 5248fb08b1..09d92c9780 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java @@ -81,7 +81,7 @@ public class TableDataPane extends FurtherBasicBeanPane{ * @return 返回标题. */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Tabledata"); + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TableData"); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java index 75c7f47b8f..df5d99fbdb 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java @@ -5,8 +5,8 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.icombobox.UIComboBox; -import javax.swing.*; -import java.awt.*; +import javax.swing.JSeparator; +import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; @@ -47,31 +47,16 @@ public abstract class AbstractTableDataContentPane extends BasicBeanPane list = new ArrayList(); for (int i = 0; i < chartSummaryColumnArray.length; i++) { ChartSummaryColumn column = chartSummaryColumnArray[i]; - String[] nameArray = {column.getName(), column.getCustomName(), getFunctionString(column.getFunction())}; + String[] nameArray = {column.getName(), column.getCustomName(), DataPaneHelper.getFunctionString(column.getFunction())}; list.add(nameArray); } seriesDataPane.populateBean(list); @@ -212,16 +212,6 @@ public class SeriesNameUseFieldNamePane extends FurtherBasicBeanPane extends AbstractReportDataContentPane { + private TinyFormulaPane seriesPane; + private TinyFormulaPane valuePane; + public AbstractExtendedChartReportDataPane() { initComponents(); } protected void initComponents() { String[] labels = fieldLabel(); - TinyFormulaPane[] formulaPanes = formulaPanes(); + Component[] formulaPanes = fieldComponents(); int len = Math.min(labels.length, formulaPanes.length); - Component[][] components = new Component[len][2]; + Component[][] components = new Component[len + (hasCustomFieldPane() ? 2 : 0)][2]; for (int i = 0; i < len; i++) { components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), formulaPanes[i]}; } + if (hasCustomFieldPane()) { + seriesPane = new TinyFormulaPane(); + valuePane = new TinyFormulaPane(); + components[len] = new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"), SwingConstants.LEFT), seriesPane}; + components[len + 1] = new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), valuePane}; + } + double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {f, COMPONENT_WIDTH}; - double[] rowSize = new double[len]; + double[] rowSize = new double[len + (hasCustomFieldPane() ? 2 : 0)]; Arrays.fill(rowSize, p); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 24, 6); - panel.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); + panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 15)); + + this.setLayout(new FlowLayout()); + this.add(panel); + this.add(addSouthPane()); + } + protected JPanel addSouthPane() { + return new JPanel(); + } + + protected boolean hasCustomFieldPane() { + return false; + } - this.setLayout(new BorderLayout()); - this.add(panel, BorderLayout.CENTER); + protected Component[] fieldComponents() { + return formulaPanes(); } protected abstract String[] fieldLabel(); @@ -70,6 +94,11 @@ public abstract class AbstractExtendedChartReportDataPane fieldList = new ArrayList(); + if (hasCustomFieldPane()) { + fieldList.add(new ExtendedField(seriesPane.updateBean())); + fieldList.add(new ExtendedField(valuePane.updateBean())); + } + dataConfig.setCustomFields(fieldList); chart.setFilterDefinition(dataSet); } diff --git a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java index f9beeca2bd..19a7b8e16b 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java @@ -11,11 +11,11 @@ import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.general.GeneralUtils; +import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; import java.util.Arrays; import java.util.List; @@ -24,7 +24,7 @@ import java.util.List; */ public abstract class AbstractExtendedChartTableDataPane extends AbstractTableDataContentPane { - private CalculateComboBox function; + private ExtendedCustomFieldComboBoxPane customFieldComboBoxPane; public AbstractExtendedChartTableDataPane() { initComponents(); @@ -37,28 +37,27 @@ public abstract class AbstractExtendedChartTableDataPane { + private static final String[] HEADS = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Field_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Summary_Method")}; + + private UseFieldValuePane useFieldValuePane; + private CustomFieldNamePane customFieldNamePane; + + private List fieldList = new ArrayList(); + + @Override + protected void initLayout() { + this.setLayout(new BorderLayout(0, 6)); + JPanel northPane = new JPanel(new BorderLayout()); + northPane.add(jcb, BorderLayout.CENTER); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); + label.setPreferredSize(new Dimension(82, 20)); + northPane.add(label, BorderLayout.WEST); + this.add(northPane, BorderLayout.NORTH); + this.add(cardPane, BorderLayout.CENTER); + } + + @Override + protected List> initPaneList() { + useFieldValuePane = new UseFieldValuePane(); + customFieldNamePane = new CustomFieldNamePane(); + List> list = new ArrayList>(); + list.add(useFieldValuePane); + list.add(customFieldNamePane); + return list; + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + + public void checkBoxUse(boolean hasUse) { + jcb.setEnabled(hasUse); + useFieldValuePane.checkBoxUse(hasUse); + } + + public void clearAllBoxList() { + useFieldValuePane.clearAllBoxList(); + fieldList.clear(); + } + + protected void refreshBoxListWithSelectTableData(List columnNameList) { + useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList); + fieldList = columnNameList; + } + + @Override + public void populateBean(AbstractDataConfig ob) { + if (ob.isCustomName()) { + customFieldNamePane.populateBean(ob); + jcb.setSelectedIndex(1); + } else { + useFieldValuePane.populateBean(ob); + jcb.setSelectedIndex(0); + } + } + + @Override + public void updateBean(AbstractDataConfig ob) { + if (jcb.getSelectedIndex() == 0) { + ob.setCustomName(false); + useFieldValuePane.updateBean(ob); + } else { + ob.setCustomName(true); + customFieldNamePane.updateBean(ob); + } + } + + private class UseFieldValuePane extends FurtherBasicBeanPane { + private UIComboBox series; + private UIComboBox value; + private CalculateComboBox function; + + private UseFieldValuePane() { + initComponents(); + } + + private void initComponents() { + + series = new UIComboBox(); + value = new UIComboBox(); + function = new CalculateComboBox(); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(HEADS[1], SwingConstants.LEFT), series}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value}, + new Component[]{new UILabel(HEADS[2], SwingConstants.LEFT), function}, + }; + + double p = TableLayout.PREFERRED; + double[] columnSize = {76, 120}; + double[] rowSize = {p, p, p}; + + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + + this.setLayout(new BorderLayout(0, 6)); + this.add(panel, BorderLayout.CENTER); + } + + public void checkBoxUse(boolean hasUse) { + series.setEnabled(hasUse); + value.setEnabled(hasUse); + function.setEnabled(hasUse); + } + + public void clearAllBoxList() { + DataPaneHelper.clearBoxItems(series); + DataPaneHelper.clearBoxItems(value); + } + + public void refreshBoxListWithSelectTableData(List columnNameList) { + DataPaneHelper.refreshBoxItems(series, columnNameList); + DataPaneHelper.refreshBoxItems(value, columnNameList); + } + + @Override + public void populateBean(AbstractDataConfig ob) { + List list = ob.getCustomFields(); + if (list.size() == 2) { + series.setSelectedItem(list.get(0).getFieldName()); + value.setSelectedItem(list.get(1).getFieldName()); + function.populateBean((AbstractDataFunction) list.get(1).getDataFunction()); + } + } + + @Override + public void updateBean(AbstractDataConfig ob) { + List list = new ArrayList(); + + list.add(new ExtendedField(Utils.objectToString(series.getSelectedItem()))); + ExtendedField field = new ExtendedField(Utils.objectToString(value.getSelectedItem())); + field.setDataFunction(function.updateBean()); + list.add(field); + + ob.setCustomFields(list); + } + + @Override + public boolean accept(Object ob) { + return true; + } + + @Override + public void reset() { + } + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Value"); + } + + @Override + public AbstractDataConfig updateBean() { + return null; + } + } + + private class CustomFieldNamePane extends FurtherBasicBeanPane { + + private UICorrelationPane correlationPane; + + public CustomFieldNamePane() { + initComponents(); + } + + private void initComponents() { + + correlationPane = new UICorrelationPane(HEADS) { + @Override + protected ActionListener getAddButtonListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + tablePane.addLine(new String[]{StringUtils.EMPTY, StringUtils.EMPTY, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}); + fireTargetChanged(); + } + }; + } + + public UITableEditor createUITableEditor() { + return new Editor() { + @Override + protected UICorrelationPane getParent() { + return correlationPane; + } + }; + } + }; + + this.setLayout(new BorderLayout()); + this.add(correlationPane, BorderLayout.CENTER); + + } + + @Override + public void populateBean(AbstractDataConfig ob) { + List customFields = ob.getCustomFields(); + + List list = new ArrayList(); + for (ExtendedField field : customFields) { + String[] array = {field.getFieldName(), field.getCustomName(), DataPaneHelper.getFunctionString(field.getDataFunction())}; + list.add(array); + } + correlationPane.populateBean(list); + } + + + @Override + public void updateBean(AbstractDataConfig ob) { + List list = correlationPane.updateBean(); + + List customFields = new ArrayList(); + for (Object[] line : list) { + ExtendedField field = new ExtendedField(Utils.objectToString(line[0])); + field.setCustomName(Utils.objectToString(line[1])); + if (line.length > 2) { + field.setDataFunction(DataPaneHelper.getFunctionByName(Utils.objectToString(line[2]))); + } + customFields.add(field); + } + + ob.setCustomFields(customFields); + + } + + @Override + public boolean accept(Object ob) { + return true; + } + + @Override + public void reset() { + } + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name"); + } + + @Override + public AbstractDataConfig updateBean() { + return null; + } + } + + private abstract class Editor extends UITableEditor { + private JComponent editorComponent; + + protected abstract UICorrelationPane getParent(); + + @Override + public Object getCellEditorValue() { + if (editorComponent instanceof UIComboBox) { + return ((UIComboBox) editorComponent).getSelectedItem(); + } else if (editorComponent instanceof UITextField) { + return ((UITextField) editorComponent).getText(); + } else if (editorComponent instanceof CalculateComboBox) { + return ((CalculateComboBox) editorComponent).getSelectedItem(); + } + return super.getCellEditorValue(); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, final int row, int column) { + + switch (column) { + case 0: + editorComponent = createComboBoxEdit(row, value); + break; + case 1: + editorComponent = createTextEdit(value); + break; + default: + editorComponent = createCalculateComboBox(value); + break; + + } + return editorComponent; + } + + private void setDefaultName(int row) { + UITable table = getParent().getTable(); + Object object = table.getValueAt(row, 0); + if (object != null) { + table.setValueAt(object, row, 1); + } + } + + private UIComboBox createComboBoxEdit(final int row, Object value) { + UIComboBox uiComboBox = new UIComboBox(fieldList.toArray()); + + uiComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + getParent().stopCellEditing(); + getParent().fireTargetChanged(); + setDefaultName(row); + } + }); + + if (value != null && StringUtils.isNotEmpty(value.toString())) { + uiComboBox.getModel().setSelectedItem(value); + } else { + uiComboBox.getModel().setSelectedItem(value); + } + + return uiComboBox; + } + + private UITextField createTextEdit(Object value) { + UITextField uiTextField = new UITextField(); + if (value != null) { + uiTextField.setText(value.toString()); + } + + uiTextField.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + getParent().fireTargetChanged(); + } + }); + + return uiTextField; + } + + private CalculateComboBox createCalculateComboBox(Object value) { + CalculateComboBox calculateComboBox = new CalculateComboBox(); + if (value != null) { + calculateComboBox.setSelectedItem(value); + } + calculateComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + getParent().stopCellEditing(); + getParent().fireTargetChanged(); + } + }); + return calculateComboBox; + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/CustomPlotDesignerPaneFactory.java b/designer-chart/src/main/java/com/fr/van/chart/custom/CustomPlotDesignerPaneFactory.java index 783a35b877..372b1041e5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/CustomPlotDesignerPaneFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/CustomPlotDesignerPaneFactory.java @@ -59,7 +59,7 @@ public class CustomPlotDesignerPaneFactory { Constructor > constructor = cl.getConstructor(); return constructor.newInstance(); } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return null; @@ -89,7 +89,7 @@ public class CustomPlotDesignerPaneFactory { Constructor constructor = cl.getConstructor(ChartDataPane.class); return constructor.newInstance(parent); } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new CategoryPlotTableDataContentPane(parent); @@ -125,7 +125,7 @@ public class CustomPlotDesignerPaneFactory { return constructor.newInstance(plot, parent); } } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartAxisPane(plot,parent); diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java index c037e182d7..133cba525f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java @@ -250,7 +250,7 @@ public class VanChartCustomPlotSelectPane extends BasicBeanPane { } } } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java index d5eb3e7542..7c46b8b085 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java @@ -198,7 +198,7 @@ public class PlotFactory { Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); return constructor.newInstance(plot, stylePane); } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartPlotLabelPane(plot, stylePane); @@ -218,7 +218,7 @@ public class PlotFactory { Constructor constructor = cl.getConstructor(VanChartStylePane.class); return constructor.newInstance(stylePane); } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartPlotLegendPane(stylePane); @@ -238,7 +238,7 @@ public class PlotFactory { Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); return constructor.newInstance(plot, stylePane); } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartPlotTooltipPane(plot, stylePane); @@ -259,7 +259,7 @@ public class PlotFactory { Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); return constructor.newInstance(parent, showOnPane); } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartLabelContentPane(parent, showOnPane); @@ -280,7 +280,7 @@ public class PlotFactory { Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); return constructor.newInstance(parent, showOnPane); } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartTooltipContentPane(parent, showOnPane); @@ -301,7 +301,7 @@ public class PlotFactory { Constructor constructor = cl.getConstructor(Plot.class); return constructor.newInstance(plot); } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartPlotRefreshTooltipPane(plot); @@ -321,7 +321,7 @@ public class PlotFactory { Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); return constructor.newInstance(parent, showOnPane); } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartRefreshTooltipContentPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPane.java index 749fed8c9e..314408c682 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPane.java @@ -114,7 +114,7 @@ public class VanChartBackgroundPane extends BasicPane { } - private void fireStateChanged() { + protected void fireStateChanged() { Object[] listeners = listenerList.getListenerList(); ChangeEvent e = null; diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/data/data/component/ComboBoxWithButtonPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/data/data/component/ComboBoxWithButtonPane.java index 75ad743def..c00109db92 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/data/data/component/ComboBoxWithButtonPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/data/data/component/ComboBoxWithButtonPane.java @@ -4,6 +4,7 @@ import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -62,29 +63,14 @@ public abstract class ComboBoxWithButtonPane extends JPanel { * 刷新Box的选项. */ public void refreshBoxItems(java.util.List list) { - if(comboBoxName == null) { - return; - } - - Object ob = comboBoxName.getSelectedItem(); - comboBoxName.removeAllItems(); - - int length = list.size(); - for(int i = 0; i < length; i++) { - comboBoxName.addItem(list.get(i)); - } - - comboBoxName.getModel().setSelectedItem(ob); + DataPaneHelper.refreshBoxItems(comboBoxName, list); } /** * 清空box里所有东西 */ public void clearBoxItems(){ - if(comboBoxName == null){ - return; - } - comboBoxName.removeAllItems(); + DataPaneHelper.clearBoxItems(comboBoxName); } diff --git a/designer-chart/src/main/resources/com/fr/design/images/form/toolbar/treeMap.png b/designer-chart/src/main/resources/com/fr/design/images/form/toolbar/treeMap.png index 09edd2b77e..f90e6afedd 100644 Binary files a/designer-chart/src/main/resources/com/fr/design/images/form/toolbar/treeMap.png and b/designer-chart/src/main/resources/com/fr/design/images/form/toolbar/treeMap.png differ diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormWidgetEditAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormWidgetEditAction.java index 753dc812b4..300086040a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormWidgetEditAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormWidgetEditAction.java @@ -3,9 +3,14 @@ package com.fr.design.designer.beans.actions; import com.fr.design.actions.TemplateComponentAction; import com.fr.design.designer.beans.actions.behavior.UpdateBehavior; import com.fr.design.mainframe.FormDesigner; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; +import com.fr.record.analyzer.EnableMetrics; +import javax.swing.JButton; import java.awt.event.ActionEvent; +@EnableMetrics public abstract class FormWidgetEditAction extends TemplateComponentAction { private UpdateBehavior updateBehavior = new UpdateBehavior() { @@ -27,9 +32,24 @@ public abstract class FormWidgetEditAction extends TemplateComponentAction{ - //工具栏容器 - private MobileToolBarPane mobileToolBarPane; // 模版设置面板 private FormMobileTemplateSettingsPane formMobileTemplateSettingsPane; // 其他 @@ -33,7 +31,6 @@ public class FormMobileAttrPane extends BasicBeanPane{ panel.setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, PADDING, PADDING)); panel.add(formMobileTemplateSettingsPane = new FormMobileTemplateSettingsPane()); - panel.add(mobileToolBarPane = new MobileToolBarPane()); panel.add(formMobileOthersPane = new FormMobileOthersPane()); JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -47,7 +44,6 @@ public class FormMobileAttrPane extends BasicBeanPane{ if (ob == null) { ob = new FormMobileAttr(); } - this.mobileToolBarPane.populateBean(ob); this.formMobileTemplateSettingsPane.populateBean(ob); this.formMobileOthersPane.populateBean(ob); } @@ -55,7 +51,6 @@ public class FormMobileAttrPane extends BasicBeanPane{ @Override public FormMobileAttr updateBean() { FormMobileAttr formMobileAttr = new FormMobileAttr(); - this.mobileToolBarPane.updateBean(formMobileAttr); this.formMobileTemplateSettingsPane.updateBean(formMobileAttr); this.formMobileOthersPane.updateBean(formMobileAttr); return formMobileAttr; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java index 762b412f1b..b42d1b41ef 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java @@ -540,16 +540,16 @@ public class FormArea extends JComponent implements ScrollRulerComponent { layout(); if (isValid) { XLayoutContainer root = designer.getRootComponent(); - setScrollBarProperties(root.getWidth() - designer.getWidth(), horScrollBar); + setScrollBarProperties(root.getWidth() - designer.getWidth(), horScrollBar, horizontalValue); //计算滚动条值的时候应该算上参数面板的高度 - setScrollBarProperties(designer.getParaHeight() + root.getHeight() - designer.getHeight(), verScrollBar); + setScrollBarProperties(designer.getParaHeight() + root.getHeight() - designer.getHeight(), verScrollBar, verticalValue); } } /** * 设置滚动条的属性 */ - private void setScrollBarProperties(int value, FormScrollBar bar) { + private void setScrollBarProperties(int value, FormScrollBar bar, int oldValue) { if (value == 0 && isScrollNotVisible(bar)) { return; } @@ -560,12 +560,11 @@ public class FormArea extends JComponent implements ScrollRulerComponent { bar.setValue(0); bar.setEnabled(false); } else { - //参数面板拖拽过程中value一直为当前value - int oldValue = verticalValue; setScrollBarMax(value, bar); bar.setEnabled(true); bar.setMaximum(value); bar.setValue(value); + //参数面板拖拽过程中value一直为当前value bar.setValue(oldValue); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 25fc777e61..e59069f71f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -951,7 +951,6 @@ public class JForm extends JTemplate implements BaseJForm { super.previewMenuActionPerformed(provider); } - @Override public String route() { return ViewRequestConstants.FORM_VIEW_PATH; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/actions/FormMobileAttrAction.java b/designer-form/src/main/java/com/fr/design/mainframe/actions/FormMobileAttrAction.java index 255793e04b..df6139da9d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/actions/FormMobileAttrAction.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/actions/FormMobileAttrAction.java @@ -14,6 +14,9 @@ import com.fr.design.menu.MenuKeySet; import com.fr.file.FILE; import com.fr.form.main.Form; import com.fr.form.main.mobile.FormMobileAttr; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; +import com.fr.record.analyzer.EnableMetrics; import javax.swing.*; @@ -22,6 +25,7 @@ import java.awt.event.ActionEvent; /** * Created by fanglei on 2016/11/14. */ +@EnableMetrics public class FormMobileAttrAction extends JTemplateAction { public FormMobileAttrAction(JForm jf) { @@ -64,6 +68,7 @@ public class FormMobileAttrAction extends JTemplateAction { // 放到后面。如果提前 return 了,则仍然处于未设置状态,不要添加 jf.getTarget().addAttrMark(new MobileOnlyTemplateAttrMark()); } + recordFunction(); // 设置移动端属性并刷新界面 formTpl.setFormMobileAttr(formMobileAttr); // 会调整 body 的自适应布局,放到最后 ((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified(); @@ -74,6 +79,11 @@ public class FormMobileAttrAction extends JTemplateAction { dialog.setVisible(true); } + @Focus(id = "com.fr.mobile.mobile_template_frm", text = "Fine-Design_Function_Mobile_Template_Frm", source = Original.EMBED) + private void recordFunction() { + // do nothing + } + private static final MenuKeySet REPORT_APP_ATTR = new MenuKeySet() { @Override public char getMnemonic() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyWatermarkEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyWatermarkEditor.java index c5acb61148..a0567bad1d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyWatermarkEditor.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyWatermarkEditor.java @@ -7,6 +7,9 @@ import com.fr.design.mainframe.widget.editors.ITextComponent; import com.fr.design.mainframe.widget.renderer.WatermarkRenderer; import com.fr.design.mainframe.widget.wrappers.WatermarkWrapper; import com.fr.design.report.WatermarkPane; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; +import com.fr.record.analyzer.EnableMetrics; import javax.swing.*; import java.awt.*; @@ -15,6 +18,7 @@ import java.awt.*; * Created by plough on 2018/5/15. */ +@EnableMetrics public class AccessibleBodyWatermarkEditor extends UneditableAccessibleEditor { private WatermarkPane watermarkPane; @@ -40,9 +44,15 @@ public class AccessibleBodyWatermarkEditor extends UneditableAccessibleEditor { public void doOk() { setValue(watermarkPane.update()); fireStateChanged(); + recordFunction(); } }); watermarkPane.populate((WatermarkAttr) getValue()); dlg.setVisible(true); } + + @Focus(id = "com.fr.watermark", text = "Fine-Design_Form_WaterMark", source = Original.EMBED) + private void recordFunction() { + // do nothing + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java index 1302c0c369..bdd011f032 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java @@ -193,7 +193,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { formDesigner.getSelectionModel().setSelectedCreator(xfl); return true; } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java index 137e0e0d46..8be0e931ca 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java @@ -201,7 +201,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify { FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); } } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/report/ReportMobileAttrAction.java b/designer-realize/src/main/java/com/fr/design/actions/report/ReportMobileAttrAction.java index 40d4e68a41..a31108f2c4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/report/ReportMobileAttrAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/report/ReportMobileAttrAction.java @@ -11,7 +11,9 @@ import com.fr.design.report.mobile.ReportMobileAttrPane; import com.fr.file.FILE; import com.fr.general.IOUtils; +import com.fr.intelli.record.Focus; import com.fr.main.TemplateWorkBook; +import com.fr.record.analyzer.EnableMetrics; import com.fr.report.mobile.ElementCaseMobileAttr; import javax.swing.*; @@ -22,6 +24,7 @@ import java.awt.event.ActionEvent; * * Created by Administrator on 2016/5/12/0012. */ +@EnableMetrics public class ReportMobileAttrAction extends JWorkBookAction{ public ReportMobileAttrAction(JWorkBook jwb) { @@ -64,6 +67,7 @@ public class ReportMobileAttrAction extends JWorkBookAction{ // 放到后面。如果提前 return 了,则仍然处于未设置状态,不要添加 wbTpl.addAttrMark(new MobileOnlyTemplateAttrMark()); } + recordFunction(); // 设置移动端属性并刷新界面 wbTpl.setReportMobileAttr(elementCaseMobileAttr); // 会同时修改页面设置,放到最后 jwb.fireTargetModified(); @@ -72,6 +76,11 @@ public class ReportMobileAttrAction extends JWorkBookAction{ dialog.setVisible(true); } + @Focus(id = "com.fr.mobile.mobile_template_cpt", text = "Fine-Design_Function_Mobile_Template_Cpt") + private void recordFunction() { + // do nothing + } + private static final MenuKeySet REPORT_APP_ATTR = new MenuKeySet() { @Override public char getMnemonic() { return 'P'; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java b/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java index db1d10f9d1..a07df219f9 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java @@ -8,7 +8,10 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JWorkBook; import com.fr.design.menu.KeySetUtils; import com.fr.design.report.WatermarkPane; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; import com.fr.main.impl.WorkBook; +import com.fr.record.analyzer.EnableMetrics; import com.fr.report.core.ReportUtils; import java.awt.event.ActionEvent; @@ -16,6 +19,7 @@ import java.awt.event.ActionEvent; /** * Created by plough on 2018/5/15. */ +@EnableMetrics public class ReportWatermarkAction extends JWorkBookAction { public ReportWatermarkAction(JWorkBook jwb) { super(jwb); @@ -42,7 +46,13 @@ public class ReportWatermarkAction extends JWorkBookAction { public void doOk() { wbTpl.addAttrMark(watermarkPane.update()); jwb.fireTargetModified(); + recordFunction(); } }).setVisible(true); } + + @Focus(id = "com.fr.watermark", text = "Fine-Design_Form_WaterMark", source = Original.EMBED) + private void recordFunction() { + // do nothing + } } diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java index e051b36670..b8031b238f 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java @@ -340,7 +340,7 @@ public class RichTextToolBar extends BasicPane{ try { doc.insertString(start, content, attrs); } catch (BadLocationException e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } }).setVisible(true); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java index ce336b23fb..1fc891c8b3 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -273,7 +273,7 @@ public class AuthorityToolBarPane extends BasicBeanPane([\\s\\S]*?)class=\"jiaoyes\">YES
"; + + public static final String BOTTOM_REGEX_SECOND = "

"; + + public static final String LINK_REGEX = "javascript:;\"([\\s\\S]*?)','"; + + public static final String LINK_REGEX_ANOTHER = "javascript:([\\s\\S]*?)url=\""; + + public static final String ALPHA_ROBOT_SEARCH_TOKEN = "K8dl0Np6l0gs"; + + public static final String SIMILAR_SEARCH_URL_PREFIX = CloudCenter.getInstance().acquireUrlByKind("af.similar_search"); + + public static final String COMPLEMENT_ADVICE_SEARCH_URL_PREFIX = CloudCenter.getInstance().acquireUrlByKind("af.advice_search"); + + public static final String ALPHA_HOT_SEARCH = CloudCenter.getInstance().acquireUrlByKind("af.hot_search"); + + public static final String ALPHA_GO_TO_FORUM = CloudCenter.getInstance().acquireUrlByKind("af.go_fourm"); + + public static final String ALPHA_GO_TO_WEB = CloudCenter.getInstance().acquireUrlByKind("af.go_web"); + + public static final String ALPHA_PREVIEW = CloudCenter.getInstance().acquireUrlByKind("af.preview"); + + public static final String JAVASCRIPT_PREFIX = "javascript:SendJava"; + + public static final String CHINESE_CHARACTERS = "[\\u4e00-\\u9fa5]"; + + public static final String FIRST_PAGE = "-1"; + public static final FileExtension[] FILE_EXTENSIONS= new FileExtension[]{FileExtension.CPT, FileExtension.FRM}; + public static final int RECOMMEND_MAX_ITEM_NUM = 3; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index de409fda74..93e60182c2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -4,13 +4,23 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; +import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.NoResultModel; +import com.fr.design.mainframe.alphafine.cell.model.RobotModel; import com.fr.design.mainframe.alphafine.component.AlphaFineDialog; import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.impl.HotIssuesManager; +import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; - +import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger; import com.fr.general.ProcessCanceledException; +import com.fr.general.http.HttpToolbox; +import com.fr.json.JSONArray; +import com.fr.json.JSONException; +import com.fr.json.JSONObject; +import com.fr.json.JSONUtils; import com.fr.stable.StringUtils; import java.util.List; @@ -21,6 +31,7 @@ import java.util.List; public class AlphaFineHelper { public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed")); private static AlphaFineDialog alphaFineDialog; + private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com"; /** * 弹出alphafine搜索面板 @@ -97,5 +108,60 @@ public class AlphaFineHelper { return filterResult; } + public static SearchResult getModelListFromJSONArray(String result, String keyword) throws ClassCastException, JSONException { + SearchResult allModelList = new SearchResult(); + JSONArray jsonArray = (JSONArray) JSONUtils.jsonDecode(result); + for (int i = 0; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); + JSONObject jsonObject = jsonArray.optJSONObject(i); + + String temp = jsonObject.optString(keyword); + if (StringUtils.isNotEmpty(temp)) { + RobotModel robotModel = new RobotModel(temp, null); + if (!allModelList.contains(robotModel)) { + allModelList.add(robotModel); + } + } + } + return allModelList; + } + /** + * 网络异常时的处理 + * @param object + * @return + */ + public static SearchResult getNoConnectList(Object object) { + if (isNetworkOk()){ + return null; + } + SearchResult result = new SearchResult(); + if (object instanceof RecommendSearchManager) { + result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"))); + } else if (object instanceof DocumentSearchManager) { + result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); + } else if (object instanceof PluginSearchManager) { + result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); + } else if (object instanceof SimilarSearchManeger) { + result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Relation_Item"))); + } else if (object instanceof HotIssuesManager) { + return new SearchResult(); + } + result.add(AlphaFineHelper.NO_CONNECTION_MODEL); + return result; + } + + /** + * 判断网络是否异常 + * @return + */ + public static boolean isNetworkOk(){ + try { + HttpToolbox.get(URL_FOR_TEST_NETWORK); + return true; + } catch (Exception ignore) { + // 网络异常 + return false; + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java index 0f4f61a42b..3d533e47bb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java @@ -4,7 +4,7 @@ package com.fr.design.mainframe.alphafine; * Created by XiaXiang on 2017/4/27. */ public enum CellType { - RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5), NO_RESULT(6), MORE(7); + RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5), NO_RESULT(6), MORE(7), RECOMMEND_ROBOT(8), BOTTOM(9), ROBOT(10); private int typeValue; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java index d838f50a9d..83ab319a6b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java @@ -6,6 +6,7 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger; import com.fr.json.JSONObject; /** @@ -31,7 +32,10 @@ public class CellModelHelper { case REUSE: cellModel = PluginSearchManager.getModelFromCloud(object.optJSONObject(RESULT)); break; - + case ROBOT: + case RECOMMEND_ROBOT: + cellModel = SimilarSearchManeger.getModelFromCloud(object.optJSONObject(RESULT)); + break; } return cellModel; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java index 324006f939..cd878af5a4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java @@ -51,14 +51,14 @@ public class ActionModel extends AlphaCellModel { } @Override - public JSONObject ModelToJson() { + public JSONObject modelToJson() { JSONObject object = JSONObject.create(); try { JSONObject modelObject = JSONObject.create(); modelObject.put("className", getAction().getClass().getName()).put("searchCount", getSearchCount()); object.put("result", modelObject).put("cellType", getType().getTypeValue()); } catch (JSONException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return object; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java index 04af821950..23be9bd9d2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java @@ -75,7 +75,7 @@ public abstract class AlphaCellModel implements Comparable { * @return * @throws JSONException */ - abstract public JSONObject ModelToJson() throws JSONException; + abstract public JSONObject modelToJson() throws JSONException; /** * 获取需要保存到云中心的信息 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java new file mode 100644 index 0000000000..c8f92721cb --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java @@ -0,0 +1,58 @@ +package com.fr.design.mainframe.alphafine.cell.model; + +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.CellType; +import com.fr.json.JSONException; +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +/** + * Created by alexsung on 2018/7/30. + */ +public class BottomModel extends AlphaCellModel { + /** + * 找不到答案?去论坛提问 + */ + public String getGoToWeb() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Internet_Forum"); + } + + public BottomModel(String name, String content) { + super(name, content, CellType.BOTTOM); + } + + public BottomModel() { + super(null, null, CellType.BOTTOM); + } + + @Override + public JSONObject modelToJson() throws JSONException { + return JSONObject.EMPTY; + } + + @Override + public String getStoreInformation() { + return ""; + } + + @Override + public boolean hasAction() { + return true; + } + + @Override + public void doAction() { + try { + Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_GO_TO_FORUM)); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } catch (URISyntaxException e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java index 4cb7cd16d8..e149229796 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java @@ -40,7 +40,7 @@ public class DocumentModel extends AlphaCellModel { } @Override - public JSONObject ModelToJson() { + public JSONObject modelToJson() { JSONObject object = JSONObject.create(); try { JSONObject modelObject = JSONObject.create(); @@ -62,9 +62,9 @@ public class DocumentModel extends AlphaCellModel { try { Desktop.getDesktop().browse(new URI(getDocumentUrl())); } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } catch (URISyntaxException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/FileModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/FileModel.java index 377c2c8ebd..28c60bb5e4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/FileModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/FileModel.java @@ -35,14 +35,14 @@ public class FileModel extends AlphaCellModel { } @Override - public JSONObject ModelToJson() { + public JSONObject modelToJson() { JSONObject object = JSONObject.create(); try { JSONObject modelObject = JSONObject.create(); modelObject.put("filePath", getFilePath()).put("searchCount", getSearchCount()); object.put("result", modelObject).put("cellType", getType().getTypeValue()); } catch (JSONException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return object; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java index 2b808a0f80..860b2ff085 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java @@ -37,7 +37,7 @@ public class MoreModel extends AlphaCellModel { } @Override - public JSONObject ModelToJson() throws JSONException { + public JSONObject modelToJson() throws JSONException { return null; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java index 81b19e7634..15bd931e6d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java @@ -13,7 +13,7 @@ public class NoResultModel extends AlphaCellModel { } @Override - public JSONObject ModelToJson() throws JSONException { + public JSONObject modelToJson() throws JSONException { return null; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java index 8416afdec9..119d2991bd 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java @@ -85,14 +85,14 @@ public class PluginModel extends AlphaCellModel { } @Override - public JSONObject ModelToJson() { + public JSONObject modelToJson() { JSONObject object = JSONObject.create(); try { JSONObject modelObject = JSONObject.create(); modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("id", getId()).put("pluginid", getPluginId()).put("type", getType().getTypeValue()).put("price", getPrice()).put("link", getLink()).put("searchCount", getSearchCount()); object.put("result", modelObject).put("cellType", getType().getTypeValue()); } catch (JSONException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return object; @@ -109,7 +109,7 @@ public class PluginModel extends AlphaCellModel { if (StringUtils.isBlank(this.pluginId) || !WorkContext.getCurrent().isLocal()) { return; } - WebViewDlgHelper.showPluginInStore(getName(), "[" + ModelToJson().optString("result") + "]"); + WebViewDlgHelper.showPluginInStore(getName(), "[" + modelToJson().optString("result") + "]"); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java new file mode 100644 index 0000000000..273b29fef0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java @@ -0,0 +1,107 @@ +package com.fr.design.mainframe.alphafine.cell.model; + +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.CellType; +import com.fr.general.http.HttpToolbox; +import com.fr.json.JSONException; +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.AssistUtils; +import com.fr.stable.StringUtils; +import org.apache.commons.codec.digest.DigestUtils; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +/** + * Created by alex.sung on 2018/8/3. + */ +public class RobotModel extends AlphaCellModel { + + private String title; + private String content; + + //热门问题列表的list不需要渲染图标,所以这里需要区分一下 + private boolean hotItemModel = false; + + public boolean isHotItemModel() { + return hotItemModel; + } + + public void setHotItemModel(boolean hotItemModel) { + this.hotItemModel = hotItemModel; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public static String getContent(String titleStr) { + String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + titleStr); + String url = AlphaFineConstants.ALPHA_GO_TO_WEB + titleStr + "&token=" + token; + + try { + String result = HttpToolbox.get(url); + if(StringUtils.isEmpty(result)){ + return StringUtils.EMPTY; + } + JSONObject jsonObject = new JSONObject(result); + return jsonObject.optString("msg"); + } catch (JSONException | IOException e) { + FineLoggerFactory.getLogger().error("get robotmodel content error: " + e.getMessage()); + } + return null; + } + + public RobotModel(String title, String content) { + super(title, content, CellType.ROBOT); + this.title = title; + } + + @Override + public JSONObject modelToJson() throws JSONException { + JSONObject object = JSONObject.create(); + try { + JSONObject modelObject = JSONObject.create(); + modelObject.put("title", getTitle()).put("content", getContent()).put("searchCount", getSearchCount()); + object.put("result", modelObject).put("cellType", getType().getTypeValue()); + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("RobotModel: " + e.getMessage()); + } + return object; + } + + @Override + public String getStoreInformation() { + return null; + } + + @Override + public void doAction() { + try { + Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + super.getName())); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } catch (URISyntaxException e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } + } + + @Override + public final boolean equals(Object obj) { + return obj instanceof RobotModel + && AssistUtils.equals(this.title, ((RobotModel)obj).title) + && AssistUtils.equals(this.content, ((RobotModel) obj).content); + } + + @Override + public int hashCode() { + return AssistUtils.hashCode(title, content); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java new file mode 100644 index 0000000000..824fc3bfc0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java @@ -0,0 +1,39 @@ +package com.fr.design.mainframe.alphafine.cell.render; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.cell.model.BottomModel; + +import javax.swing.*; +import java.awt.Component; +import java.awt.BorderLayout; +import java.awt.Dimension; + +/** + * Created by alex.sung on 2018/8/3. + */ +public class BottomCellRender implements ListCellRenderer { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + UILabel goToWebLabel = new UILabel(); + BottomModel bottomModel = (BottomModel) value; + JPanel panel = new JPanel(new BorderLayout()); + panel.setBackground(null); + panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + + JPanel line = new JPanel(); + line.setPreferredSize(new Dimension(200, 1)); + line.setBackground(AlphaFineConstants.GRAY); + panel.add(line, BorderLayout.NORTH); + + goToWebLabel.setFont(AlphaFineConstants.MEDIUM_FONT); + goToWebLabel.setText(bottomModel.getGoToWeb()); + goToWebLabel.setForeground(AlphaFineConstants.BLUE); + goToWebLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); + panel.add(goToWebLabel, BorderLayout.EAST); + + panel.setPreferredSize(new Dimension(list.getFixedCellWidth(), AlphaFineConstants.CELL_TITLE_HEIGHT)); + return panel; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java index d8cd66d97e..07f5b4d4ed 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java @@ -4,11 +4,19 @@ import com.bulenkov.iconloader.IconLoader; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; +import com.fr.design.mainframe.alphafine.cell.model.BottomModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.design.mainframe.alphafine.cell.model.RobotModel; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; /** * Created by XiaXiang on 2017/4/20. @@ -19,6 +27,14 @@ public class ContentCellRender implements ListCellRenderer { private static final String CELL_PATH = AlphaFineConstants.IMAGE_URL + "alphafine"; private static final String SUFFIX = ".png"; + private String searchText; + private String[] segmentationResult; + + public ContentCellRender(String searchText, String[] segmentationResult) { + this.searchText = searchText; + this.segmentationResult = segmentationResult; + } + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { UILabel titleLabel = new UILabel(); @@ -26,24 +42,36 @@ public class ContentCellRender implements ListCellRenderer { if (value instanceof MoreModel) { return new TitleCellRender().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } + if (value instanceof BottomModel) { + return new BottomCellRender().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } AlphaCellModel model = (AlphaCellModel) value; JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(null); panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); - titleLabel.setText(" " + model.getName()); if (model.hasAction()) { if (isSelected) { + titleLabel.setText(StringUtils.BLANK + model.getName()); String iconUrl = SELECTED_PATH + model.getType().getTypeValue() + SUFFIX; panel.setBackground(AlphaFineConstants.BLUE); titleLabel.setForeground(Color.WHITE); - titleLabel.setIcon(IconLoader.getIcon(iconUrl)); + if (value instanceof RobotModel && ((RobotModel) value).isHotItemModel()) { + titleLabel.setIcon(null); + } else { + titleLabel.setIcon(IconLoader.getIcon(iconUrl)); + } } else { + titleLabel.setText(highLightModelName(model.getName(), segmentationResult)); String iconUrl = CELL_PATH + model.getType().getTypeValue() + SUFFIX; - titleLabel.setIcon(IconLoader.getIcon(iconUrl)); - titleLabel.setForeground(AlphaFineConstants.BLACK); + if (value instanceof RobotModel && ((RobotModel) value).isHotItemModel()) { + titleLabel.setIcon(null); + } else { + titleLabel.setIcon(IconLoader.getIcon(iconUrl)); + } } } else { + titleLabel.setText(model.getName()); titleLabel.setIcon(null); titleLabel.setForeground(AlphaFineConstants.MEDIUM_GRAY); } @@ -66,4 +94,41 @@ public class ContentCellRender implements ListCellRenderer { panel.setPreferredSize(new Dimension(list.getFixedCellWidth(), AlphaFineConstants.CELL_HEIGHT)); return panel; } + + /** + * 处理model的显示颜色,将搜索词高亮 + * + * @param modelName + * @param strings + * @return + */ + public String highLightModelName(String modelName, String[] strings) { + if (strings == null) { + return modelName; + } + for (int i = 0; i < strings.length; i++) { + String primaryStr = getReplacedString(modelName, strings[i]); + modelName = modelName.replaceAll("(?i)" + strings[i], "|" + strings[i] + "|"); + if (StringUtils.isNotEmpty(primaryStr)) { + modelName = modelName.replaceAll(strings[i], primaryStr); + } + } + modelName = "" + modelName.replaceAll("\\|", StringUtils.EMPTY) + ""; + return modelName; + } + + private String getReplacedString(String modelName, String string) { + int index = modelName.toLowerCase().indexOf(string.toLowerCase()); + if (index == -1) { + return StringUtils.EMPTY; + } + return modelName.substring(index, index + string.length()); + + } + + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index ef791195d5..5137d56f13 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -12,22 +12,27 @@ import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.cell.CellModelHelper; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; +import com.fr.design.mainframe.alphafine.cell.model.BottomModel; import com.fr.design.mainframe.alphafine.cell.model.FileModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.PluginModel; +import com.fr.design.mainframe.alphafine.cell.model.RobotModel; import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender; -import com.fr.design.mainframe.alphafine.listener.DocumentAdapter; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.preview.DocumentPreviewPane; import com.fr.design.mainframe.alphafine.preview.FilePreviewPane; import com.fr.design.mainframe.alphafine.preview.NoResultPane; import com.fr.design.mainframe.alphafine.preview.PluginPreviewPane; +import com.fr.design.mainframe.alphafine.preview.RobotPreviewPane; import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.impl.HotIssuesManager; import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.impl.SegmentationManager; +import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger; import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.form.main.Form; @@ -48,20 +53,24 @@ import javax.imageio.ImageIO; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.ImageIcon; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.JTextField; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; -import javax.swing.event.DocumentEvent; +import javax.swing.Timer; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.AWTEvent; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.Frame; import java.awt.Graphics; +import java.awt.GridLayout; import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; @@ -74,6 +83,7 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionListener; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; @@ -81,6 +91,8 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.HashMap; import java.util.concurrent.ExecutionException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Created by XiaXiang on 2017/3/21. @@ -99,8 +111,11 @@ public class AlphaFineDialog extends UIDialog { private static final String DS_NAME = "dsname=\""; private static final String PLUGIN_MARK_SHORT = "k:4 "; private static final String PLUGIN_MARK = "k:shop "; + private static final String SIMILAR_MARK = "k:robot "; private static final String PLACE_HOLDER = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine"); private static final int MAX_SHOW_SIZE = 12; + private static final int TIMER_DELAY = 300; + private static final int ONLY_ONE_AVAILABLE_MODEL = 2; private AlphaFineTextField searchTextField; private UIButton closeButton; @@ -116,9 +131,26 @@ public class AlphaFineDialog extends UIDialog { private SwingWorker searchWorker; private SwingWorker showWorker; private String storeText; + private String[] segmentationResult; //是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下 private boolean forceOpen; + private JPanel hotPane; + private JPanel backPane; + SearchResult modeList = null; + private static String beforeSearchStr = ""; + private static boolean alreadySearch = false; + private static boolean alreadyInitHot = false; + private String[][] hotData; + + public String[][] getHotData() { + return hotData; + } + + public void setHotData(String[][] hotData) { + this.hotData = hotData; + } + public AlphaFineDialog(Frame parent, boolean forceOpen) { super(parent); this.forceOpen = forceOpen; @@ -190,6 +222,46 @@ public class AlphaFineDialog extends UIDialog { }); topPane.add(closeButton, BorderLayout.EAST); add(topPane, BorderLayout.CENTER); + + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + initHotPane(); + } + } + + /** + * 初始化热门界面 + */ + private void initHotPane() { + removeHotPane(); + hotPane = new JPanel(); + hotPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + hotPane.setPreferredSize(AlphaFineConstants.CONTENT_SIZE); + hotPane.setLayout(new BorderLayout()); + + UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot")); + uiLabel.setFont(AlphaFineConstants.SMALL_FONT); + uiLabel.setForeground(AlphaFineConstants.DARK_GRAY); + + GridLayout gridLayout = new GridLayout(2, 3, 3, 3); + JPanel panel = new JPanel(); + panel.setLayout(gridLayout); + if(AlphaFineHelper.isNetworkOk()) { + if (hotData == null) { + hotData = HotIssuesManager.getInstance().getHotIssues(); + } + for (int i = 0; i < hotData.length; i++) { + panel.add(new HotIssueJpanel(hotData[i], i + 1)); + } + }else { + hotData = null; + for (int i = 0; i < AlphaFineConstants.HOT_ITEMS; i++) { + panel.add(new HotIssueJpanel(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed")}, i + 1)); + } + } + hotPane.add(uiLabel, BorderLayout.NORTH); + hotPane.add(panel, BorderLayout.CENTER); + add(hotPane, BorderLayout.SOUTH); + setSize(AlphaFineConstants.FULL_SIZE); } /** @@ -208,7 +280,7 @@ public class AlphaFineDialog extends UIDialog { */ private void initProperties() { setUndecorated(true); - //addComponentListener(new ComponentHandler()); +//addComponentListener(new ComponentHandler()); setSize(AlphaFineConstants.FIELD_SIZE); centerWindow(this); @@ -230,21 +302,10 @@ public class AlphaFineDialog extends UIDialog { if (winSize.width > screenSize.width) { winSize.width = screenSize.width; } - //这里设置位置:水平居中,竖直偏上 +//这里设置位置:水平居中,竖直偏上 win.setLocation((screenSize.width - winSize.width) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE); } - // TODO: 2017/5/8 xiaxiang: 窗体圆角setShape()有毛边,重写paint方法可以解决毛边问题,但带来了别的问题,处理比较麻烦,暂用setShape(); -// public void paint(Graphics g){ -// Graphics2D g2 = (Graphics2D) g.create(); -// RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); -// qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); -// g2.setRenderingHints(qualityHints); -// g2.setPaint(Color.WHITE); -// g2.fillRoundRect(0, 0, getWidth(), getHeight(), 15, 15); -// g2.dispose(); -// } - /** * 执行搜索 * @@ -254,16 +315,19 @@ public class AlphaFineDialog extends UIDialog { showSearchResult(text); } - boolean isNoNeedSearch(String text) { - return ComparatorUtils.equals(PLACE_HOLDER, text) || text.contains("'") || StringUtils.isBlank(text); - } - @Override public void setVisible(boolean isVisible) { if (!isVisible) { dispose(); return; } + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + initHotPane(); + } else { + removeHotPane(); + setSize(AlphaFineConstants.FIELD_SIZE); + refreshContainer(); + } super.setVisible(isVisible); } @@ -289,8 +353,7 @@ public class AlphaFineDialog extends UIDialog { remove(searchResultPane); searchResultPane = null; } - setSize(AlphaFineConstants.FIELD_SIZE); - refreshContainer(); + } /** @@ -307,6 +370,8 @@ public class AlphaFineDialog extends UIDialog { * 初始化搜索面板 */ private void initSearchResultComponents() { + + searchResultList = new AlphaFineList(); searchResultList.setFixedCellHeight(AlphaFineConstants.CELL_HEIGHT); searchListModel = new SearchListModel(new SearchResult()); @@ -314,7 +379,7 @@ public class AlphaFineDialog extends UIDialog { searchResultPane = new JPanel(); searchResultPane.setPreferredSize(AlphaFineConstants.CONTENT_SIZE); searchResultPane.setLayout(new BorderLayout()); - searchResultList.setCellRenderer(new ContentCellRender()); + searchResultList.setCellRenderer(new ContentCellRender(storeText, segmentationResult)); leftSearchResultPane = new UIScrollPane(searchResultList); leftSearchResultPane.setBorder(null); @@ -424,17 +489,19 @@ public class AlphaFineDialog extends UIDialog { */ private void dealWithSearchText(String searchText) { if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) { - buildActionList(getStoreText(searchText)); + buildActionList(new String[]{getStoreText(searchText)}); } else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) { - buildDocumentList(getStoreText(searchText)); + buildDocumentList(new String[]{getStoreText(searchText)}); } else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) { - buildFileList(getStoreText(searchText)); + buildFileList(getStoreText(searchText), new String[]{getStoreText(searchText)}); } else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) { - buildFileList(searchText); + buildFileList(getStoreText(searchText), new String[]{searchText}); } else if (searchText.startsWith(DS_MARK)) { - buildFileList(DS_NAME + getStoreText(searchText)); + buildFileList(getStoreText(searchText), new String[]{DS_NAME + getStoreText(searchText)}); } else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) { - buildPluginList(getStoreText(searchText)); + buildPluginList(new String[]{getStoreText(searchText)}); + } else if (searchText.startsWith(SIMILAR_MARK)) { + buildSimilarList(new String[]{getStoreText(searchText)}); } } @@ -467,39 +534,47 @@ public class AlphaFineDialog extends UIDialog { * @param searchText */ private void doNormalSearch(String searchText) { - buildRecentList(searchText); - buildRecommendList(searchText); - buildActionList(searchText); - buildFileList(searchText); - buildDocumentList(searchText); - buildPluginList(searchText); + if (segmentationResult != null) { + buildRecentList(segmentationResult); + buildRecommendList(segmentationResult); + buildActionList(segmentationResult); + buildFileList(searchText, segmentationResult); + buildDocumentList(segmentationResult); + buildPluginList(segmentationResult); + buildSimilarList(segmentationResult); + } + searchListModel.addElement(new BottomModel()); } - private void buildDocumentList(final String searchText) { + private void buildDocumentList(final String[] searchText) { addSearchResult(DocumentSearchManager.getInstance().getLessSearchResult(searchText)); } - private void buildFileList(final String searchText) { - addSearchResult(FileSearchManager.getInstance().getLessSearchResult(searchText)); + private void buildFileList(String searchStr, final String[] searchText) { + addSearchResult(FileSearchManager.getInstance().getLessSearchResult(searchStr, searchText)); } - private void buildActionList(final String searchText) { + private void buildActionList(final String[] searchText) { addSearchResult(ActionSearchManager.getInstance().getLessSearchResult(searchText)); } - private void buildPluginList(final String searchText) { + private void buildPluginList(final String[] searchText) { addSearchResult(PluginSearchManager.getInstance().getLessSearchResult(searchText)); } - private void buildRecommendList(final String searchText) { + private void buildRecommendList(final String[] searchText) { addSearchResult(RecommendSearchManager.getInstance().getLessSearchResult(searchText)); } - private void buildRecentList(final String searchText) { + private void buildRecentList(final String[] searchText) { addSearchResult(RecentSearchManager.getInstance().getLessSearchResult(searchText)); } + private void buildSimilarList(final String[] searchText) { + addSearchResult(SimilarSearchManeger.getInstance().getLessSearchResult(searchText)); + } + private synchronized void addSearchResult(SearchResult searchResult) { for (AlphaCellModel object : searchResult) { AlphaFineHelper.checkCancel(); @@ -526,7 +601,7 @@ public class AlphaFineDialog extends UIDialog { try { form = FormIO.readForm(fileName); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return FormIO.exportFormAsImage(form); } @@ -538,9 +613,9 @@ public class AlphaFineDialog extends UIDialog { try { rightSearchResultPane.add(new FilePreviewPane(get())); } catch (InterruptedException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } catch (ExecutionException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } validate(); repaint(); @@ -558,7 +633,7 @@ public class AlphaFineDialog extends UIDialog { try { workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(fileName); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } BufferedImage bufferedImage = new ImageExporter().exportToImage(workBook); return bufferedImage; @@ -573,9 +648,9 @@ public class AlphaFineDialog extends UIDialog { validate(); repaint(); } catch (InterruptedException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } catch (ExecutionException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -610,7 +685,7 @@ public class AlphaFineDialog extends UIDialog { try { bufferedImage = ImageIO.read(getClass().getResource("/com/fr/design/mainframe/alphafine/images/default_product.png")); } catch (IOException e1) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return bufferedImage; @@ -625,12 +700,50 @@ public class AlphaFineDialog extends UIDialog { validate(); repaint(); } - } catch (InterruptedException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } catch (ExecutionException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + } catch (Exception e) { } + } + }; + this.showWorker.execute(); + break; + case ROBOT: + case RECOMMEND_ROBOT: + showDefaultPreviewPane(); + checkWorker(); + this.showWorker = new SwingWorker() { + @Override + protected String doInBackground() { + if (com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha_Hot_No_Item").equals((selectedValue).getName())) { + return StringUtils.EMPTY; + } + String content = RobotModel.getContent((selectedValue).getName()); + if (StringUtils.isNotEmpty(content)) { + //1.去掉小帆底部的信息。2.修改链接标签,使点击能够正常跳转。 + content = content.replaceAll(AlphaFineConstants.BOTTOM_REGEX_FIRST, StringUtils.EMPTY) + .replaceAll(AlphaFineConstants.BOTTOM_REGEX_SECOND, StringUtils.EMPTY) + .replaceAll(AlphaFineConstants.LINK_REGEX, StringUtils.EMPTY) + .replaceAll("'\\)", StringUtils.EMPTY) + .replaceAll(AlphaFineConstants.LINK_REGEX_ANOTHER, StringUtils.EMPTY); + return content; + } else { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha_Hot_No_Item"); + } + } + @Override + protected void done() { + if (!isCancelled() && rightSearchResultPane != null) { + rightSearchResultPane.removeAll(); + try { + rightSearchResultPane.add(new RobotPreviewPane(selectedValue, get())); + } catch (InterruptedException e) { + FineLoggerFactory.getLogger().error("get hot item content error: " + e.getMessage()); + } catch (ExecutionException e) { + FineLoggerFactory.getLogger().error("get hot item content execution error: " + e.getMessage()); + } + validate(); + repaint(); + } } }; this.showWorker.execute(); @@ -702,24 +815,72 @@ public class AlphaFineDialog extends UIDialog { } }); - searchTextField.getDocument().addDocumentListener(new DocumentAdapter() { + Timer timer = new Timer(TIMER_DELAY, new ActionListener() { @Override - protected void textChanged(DocumentEvent e) { - if (isNoNeedSearch(searchTextField.getText())) { + public void actionPerformed(ActionEvent e) { + if (!alreadyInitHot && StringUtils.isEmpty(searchTextField.getText())) { + alreadyInitHot = true; removeSearchResult(); - } else { - try { - Thread.sleep(10); + refreshContainer(); + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + initHotPane(); + setSize(AlphaFineConstants.FULL_SIZE); + } else { + setSize(AlphaFineConstants.FIELD_SIZE); + } + refreshContainer(); + return; + } else if (beforeSearchStr.equals(searchTextField.getText()) && StringUtils.isNotEmpty(beforeSearchStr)) { + if (alreadySearch) { + return; + } else { + removeHotPane(); + removeSearchResult(); + refreshContainer(); + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedSegmentationCheckbox()) { + //是高级搜索 + if (searchTextField.getText().toLowerCase().startsWith(ADVANCED_SEARCH_MARK)) { + segmentationResult = SegmentationManager.getInstance().startSegmentation(getStoreText(searchTextField.getText().toLowerCase())); + } + //是普通搜索 + else { + segmentationResult = SegmentationManager.getInstance().startSegmentation(searchTextField.getText().toLowerCase()); + } + } else { + if (StringUtils.isEmpty(getRealSearchText(searchTextField.getText()))) { + segmentationResult = null; + } else { + segmentationResult = new String[]{getRealSearchText(searchTextField.getText())}; + } + } doSearch(searchTextField.getText().toLowerCase()); - } catch (InterruptedException e1) { - FineLoggerFactory.getLogger().error(e1.getMessage()); + alreadySearch = true; } - + } else { + beforeSearchStr = searchTextField.getText(); + alreadySearch = false; + } + if (beforeSearchStr.equals(searchTextField.getText()) && beforeSearchStr.length() != 0) { + alreadyInitHot = false; } } - }); + }); + timer.start(); + } + /** + * 去除特殊字符,空格等 + */ + private String getRealSearchText(String searchText) { + searchText = searchText.toLowerCase(); + Pattern p = Pattern.compile(AlphaFineConstants.SPECIAL_CHARACTER_REGEX); + Matcher m = p.matcher(searchText); + searchText = m.replaceAll("").trim().replaceAll(" ", ""); + if (searchText.length() == 0) { + return null; + } + return searchText; } /** @@ -760,7 +921,7 @@ public class AlphaFineDialog extends UIDialog { @Override public void checkValid() throws Exception { - //不处理 +//不处理 } /** @@ -780,6 +941,9 @@ public class AlphaFineDialog extends UIDialog { * @param cellModel */ private void saveLocalHistory(final AlphaCellModel cellModel) { + if (cellModel instanceof BottomModel) { + return; + } Thread sendThread = new Thread(new Runnable() { @Override public void run() { @@ -812,7 +976,7 @@ public class AlphaFineDialog extends UIDialog { try { object.put("uuid", uuid).put("activityKey", activityKey).put("username", username).put("createTime", createTime).put("key", key).put("resultKind", resultKind).put("resultValue", resultValue); } catch (JSONException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } final HashMap para = new HashMap<>(); String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); @@ -883,6 +1047,13 @@ public class AlphaFineDialog extends UIDialog { case ACTION: moreResult = ActionSearchManager.getInstance().getMoreSearchResult(searchTextField.getText()); break; + case ROBOT: + case RECOMMEND_ROBOT: + moreResult = SimilarSearchManeger.getInstance().getMoreSearchResult(searchTextField.getText()); + break; + case RECOMMEND: + moreResult = RecommendSearchManager.getInstance().getMoreSearchResult(searchTextField.getText()); + break; default: moreResult = new SearchResult(); } @@ -953,7 +1124,7 @@ public class AlphaFineDialog extends UIDialog { /** * +-------------------------------------+ - * | 自定义JList | + * | 自定义JList | * +-------------------------------------+ */ private class AlphaFineList extends JList { @@ -1004,6 +1175,8 @@ public class AlphaFineDialog extends UIDialog { } else if (e.getClickCount() == 1) { if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) { dealWithMoreOrLessResult(selectedIndex, (MoreModel) selectedValue); + } else if (selectedValue instanceof BottomModel) { + dealWithSearchResult(selectedValue); } } } @@ -1018,6 +1191,24 @@ public class AlphaFineDialog extends UIDialog { } }); + addMouseMotionListener(new MouseMotionListener() { + @Override + public void mouseMoved(MouseEvent e) { + final int x = e.getX(); + final int y = e.getY(); + final Rectangle cellBounds = getCellBounds(getModel().getSize() - 1, getModel().getSize() - 1); + if (cellBounds != null && cellBounds.contains(x, y) && getModel().getElementAt(getModel().getSize() - 1) instanceof BottomModel) { + setCursor(new Cursor(Cursor.HAND_CURSOR)); + } else { + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + } + + @Override + public void mouseDragged(MouseEvent e) { + } + }); + addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { @@ -1030,7 +1221,7 @@ public class AlphaFineDialog extends UIDialog { /** * +-------------------------------------+ - * | 自定义ListModel | + * | 自定义ListModel | * +-------------------------------------+ */ private class SearchListModel extends DefaultListModel { @@ -1135,4 +1326,144 @@ public class AlphaFineDialog extends UIDialog { } } + public void showIssuesList() { + if (this.searchWorker != null && !this.searchWorker.isDone()) { + this.searchWorker.cancel(true); + this.searchWorker = null; + } + this.searchWorker = new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + + resetContainer(); + if (modeList.size() == ONLY_ONE_AVAILABLE_MODEL && "".equals(modeList.get(1).getName())) { + RobotModel model = new RobotModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha_Hot_No_Item"), null); + searchListModel.addElement(model); + } else { + for (AlphaCellModel object : modeList) { + if (!searchListModel.contains(object)) { + searchListModel.addElement(object); + } + } + } + return null; + } + + @Override + protected void done() { + if (!isCancelled()) { + splitLabel.setIcon(null); + fireStopLoading(); + } + } + }; + this.searchWorker.execute(); + } + + /** + * 移除热门面板 + */ + private void removeHotPane() { + if (hotPane != null) { + remove(hotPane); + hotPane = null; + } + } + + /** + * 增加返回面板 + */ + private void initBackPane() { + backPane = new JPanel(new BorderLayout()); + JLabel jLabel = new JLabel(" < " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Back")); + jLabel.setPreferredSize(new Dimension(680, 20)); + jLabel.setFont(AlphaFineConstants.SMALL_FONT); + jLabel.setForeground(AlphaFineConstants.DARK_GRAY); + backPane.add(jLabel, BorderLayout.CENTER); + + jLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (searchResultPane != null) { + remove(searchResultPane); + searchResultPane = null; + } + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + initHotPane(); + setSize(AlphaFineConstants.FULL_SIZE); + } else { + setSize(AlphaFineConstants.FIELD_SIZE); + } + refreshContainer(); + } + }); + } + + /** + * +-------------------------------------+ + * | 自定义热门问题面板 | + * +-------------------------------------+ + */ + private class HotIssueJpanel extends JPanel { + + public HotIssueJpanel(String[] str, int pngIndex) { + this.setLayout(new BorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + this.setSize(AlphaFineConstants.HOT_ISSUES_JAPNEL_SIZE); + + JPanel pane1 = new JPanel(new BorderLayout()); + UILabel iconLabel = new UILabel(IconLoader.getIcon(AlphaFineConstants.IMAGE_URL + AlphaFineConstants.ALPHA_HOT_IMAGE_NAME + pngIndex + ".png")); + iconLabel.setOpaque(true); + iconLabel.setBackground(Color.WHITE); + iconLabel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0)); + pane1.add(iconLabel, BorderLayout.NORTH); + add(pane1, BorderLayout.NORTH); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.setBackground(Color.white); + UILabel title = new UILabel(); + if (StringUtils.isEmpty(str[0])) { + title.setText(StringUtils.EMPTY); + } + title.setText(str[0]); + title.setFont(AlphaFineConstants.MEDIUM_FONT_ANOTHER); + title.setForeground(AlphaFineConstants.DARK_GRAY); + title.setHorizontalAlignment(JTextField.CENTER); + centerPanel.add(title); + add(centerPanel, BorderLayout.CENTER); + + JPanel bottomPanel = new JPanel(new BorderLayout()); + bottomPanel.setBackground(Color.white); + + GridLayout gridLayout = new GridLayout(2, 2); + + + for (int i = 1; i < str.length; i++) { + final UILabel subTitle = new UILabel(str[i]); + subTitle.setForeground(AlphaFineConstants.DARK_GRAY); + subTitle.setFont(AlphaFineConstants.MEDIUM_FONT_ANOTHER); + subTitle.setCursor(new Cursor(Cursor.HAND_CURSOR)); + subTitle.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + segmentationResult = null; + removeHotPane(); + if (searchResultPane == null) { + initSearchResultComponents(); + } + initBackPane(); + searchResultPane.add(backPane, BorderLayout.NORTH); + refreshContainer(); + modeList = HotIssuesManager.getInstance().getTitleSearchResult(subTitle.getText()); + showIssuesList(); + } + }); + bottomPanel.add(subTitle); + } + bottomPanel.setLayout(gridLayout); + bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 22, 0)); + add(bottomPanel, BorderLayout.SOUTH); + } + } + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java index a60a763967..ba4d279fbc 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java @@ -3,7 +3,10 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.design.gui.itextfield.UITextField; import com.fr.report.web.button.Image; -import java.awt.*; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; + /** * Created by XiaXiang on 2017/3/21. @@ -23,18 +26,6 @@ public class AlphaFineTextField extends UITextField { this.placeHolder = null; } - - @Override - public String getText() { - String text = super.getText(); - - if (text.trim().length() == 0 && placeHolder != null) { - text = placeHolder; - } - - return text; - } - @Override public void paintComponent(Graphics g) { super.paintComponent(g); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java new file mode 100644 index 0000000000..4582d186be --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java @@ -0,0 +1,89 @@ +package com.fr.design.mainframe.alphafine.preview; + + +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.itextarea.UITextArea; +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; +import com.fr.design.mainframe.alphafine.cell.model.RobotModel; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JEditorPane; +import javax.swing.JPanel; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.text.html.HTMLEditorKit; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Desktop; +import java.awt.Dimension; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; + + +/** + * Created by alex.sung on 2018/8/3. + */ +public class RobotPreviewPane extends JPanel { + + private static final int TITLE_AREA_HEIGHT = 15; + private static final int HOT_TITLE_AREA_HEIGHT = 30; + + public RobotPreviewPane(AlphaCellModel model, String content) { + this.setLayout(new BorderLayout()); + this.setBackground(Color.WHITE); + this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT)); + UITextArea titleArea = new UITextArea(model.getName()); + titleArea.setBorder(null); + titleArea.setEditable(false); + titleArea.setForeground(AlphaFineConstants.BLUE); + titleArea.setFont(AlphaFineConstants.LARGE_FONT); + add(titleArea, BorderLayout.NORTH); + + final JEditorPane editorPane = new JEditorPane(); + editorPane.setEditorKit(new HTMLEditorKit()); + editorPane.setText(content + "


"); + editorPane.addHyperlinkListener(new HyperlinkListener() { + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) { + return; + } + if (e.getDescription().startsWith(AlphaFineConstants.JAVASCRIPT_PREFIX)) { + String s = e.getDescription().replaceAll(AlphaFineConstants.JAVASCRIPT_PREFIX, StringUtils.EMPTY) + .replaceAll("\\('", StringUtils.EMPTY) + .replaceAll("'\\)", StringUtils.EMPTY); + try { + Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + s)); + } catch (IOException e1) { + FineLoggerFactory.getLogger().error(e1.getMessage()); + } catch (URISyntaxException e1) { + FineLoggerFactory.getLogger().error(e1.getMessage()); + } + } + URL linkUrl = e.getURL(); + if (linkUrl != null) { + try { + Desktop.getDesktop().browse(e.getURL().toURI()); + } catch (IOException | URISyntaxException e1) { + FineLoggerFactory.getLogger().error(" Jump to webpage error: " + e1.getMessage()); + } + } + } + }); + editorPane.setEditable(false); + UIScrollPane jScrollPane = new UIScrollPane(editorPane); + jScrollPane.getVerticalScrollBar().setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); + jScrollPane.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 10, Color.white)); + if (((RobotModel) model).isHotItemModel()) { + this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT - HOT_TITLE_AREA_HEIGHT)); + } else { + this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT - TITLE_AREA_HEIGHT)); + } + add(jScrollPane, BorderLayout.CENTER); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java index 9d29433a23..b75aa894c4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java @@ -12,7 +12,7 @@ public interface AlphaFineSearchProvider { * @param searchText * @return */ - SearchResult getLessSearchResult(String searchText); + SearchResult getLessSearchResult(String[] searchText); /** * 获取剩余条数 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java index b17b14d068..1c4fec0903 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java @@ -12,8 +12,8 @@ import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvi import com.fr.design.mainframe.toolbar.UpdateActionManager; import com.fr.design.mainframe.toolbar.UpdateActionModel; import com.fr.general.ComparatorUtils; - import com.fr.json.JSONObject; +import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import java.util.List; @@ -22,7 +22,7 @@ import java.util.List; * Created by XiaXiang on 2017/3/27. */ public class ActionSearchManager implements AlphaFineSearchProvider { - private static ActionSearchManager instance; + private static volatile ActionSearchManager instance; private SearchResult filterModelList; private SearchResult lessModelList; private SearchResult moreModelList; @@ -57,21 +57,23 @@ public class ActionSearchManager implements AlphaFineSearchProvider { } @Override - public synchronized SearchResult getLessSearchResult(String searchText) { + public SearchResult getLessSearchResult(String[] searchText) { filterModelList = new SearchResult(); lessModelList = new SearchResult(); moreModelList = new SearchResult(); - if (StringUtils.isBlank(searchText)) { - lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"))); - return lessModelList; - } if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainAction()) { + if (ArrayUtils.isEmpty(searchText)) { + lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"))); + return lessModelList; + } List updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); for (UpdateActionModel updateActionModel : updateActions) { - AlphaFineHelper.checkCancel(); - if (StringUtils.isNotBlank(updateActionModel.getSearchKey())) { - if (updateActionModel.getSearchKey().contains(searchText) && updateActionModel.getAction().isEnabled()) { - filterModelList.add(new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction())); + for (int j = 0; j < searchText.length; j++) { + AlphaFineHelper.checkCancel(); + if (StringUtils.isNotBlank(updateActionModel.getSearchKey())) { + if (updateActionModel.getSearchKey().contains(searchText[j]) && updateActionModel.getAction().isEnabled()) { + filterModelList.add(new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction())); + } } } } @@ -91,7 +93,6 @@ public class ActionSearchManager implements AlphaFineSearchProvider { lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE)); moreModelList.addAll(result.subList(AlphaFineConstants.SHOW_SIZE, result.size())); } - } return lessModelList; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java new file mode 100644 index 0000000000..16182d5f19 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java @@ -0,0 +1,68 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineHelper; +import com.fr.design.mainframe.alphafine.cell.model.RobotModel; +import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.general.http.HttpToolbox; +import com.fr.json.JSONArray; +import com.fr.json.JSONException; +import com.fr.json.JSONObject; +import com.fr.json.JSONUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import java.io.IOException; +import com.fr.third.org.apache.commons.codec.digest.DigestUtils; + + +/** + * @author alex.sung created on 2018/7/23. + */ +public class ComplementAdviceManager { + + private static volatile ComplementAdviceManager instance; + private SearchResult allModelList; + + public static ComplementAdviceManager getInstance() { + if (instance == null) { + synchronized (ComplementAdviceManager.class) { + if (instance == null) { + instance = new ComplementAdviceManager(); + } + } + } + return instance; + } + + /** + * 从接口中获取补全建议结果 + * @param searchText + * @return + */ + public SearchResult getAllSearchResult(String[] searchText) { + allModelList = new SearchResult(); + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + SearchResult searchResult = new SearchResult(); + for (int j = 0; j < searchText.length; j++) { + String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + searchText[j]); + String url = AlphaFineConstants.COMPLEMENT_ADVICE_SEARCH_URL_PREFIX + "msg=" + searchText[j] + "&token=" + token; + try { + String result = HttpToolbox.get(url); + AlphaFineHelper.checkCancel(); + allModelList = AlphaFineHelper.getModelListFromJSONArray(result,"keywords"); + } catch(ClassCastException | JSONException e){ + FineLoggerFactory.getLogger().error("complement advice search error: " + e.getMessage()); + } catch (IOException e1) { + FineLoggerFactory.getLogger().error("complement advice get result error: " + e1.getMessage()); + } + } + if (searchResult.isEmpty()) { + return allModelList; + } else { + allModelList.addAll(searchResult); + } + } + return allModelList; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java index 59595229a3..b5b517c1c1 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java @@ -8,19 +8,20 @@ import com.fr.design.mainframe.alphafine.cell.model.DocumentModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; - -import com.fr.general.http.HttpClient; +import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; -import com.fr.stable.StringUtils; +import com.fr.stable.ArrayUtils; + +import java.io.IOException; /** * Created by XiaXiang on 2017/3/27. */ public class DocumentSearchManager implements AlphaFineSearchProvider { - private static DocumentSearchManager instance; + private static volatile DocumentSearchManager instance; private SearchResult lessModelList; private SearchResult moreModelList; @@ -50,65 +51,58 @@ public class DocumentSearchManager implements AlphaFineSearchProvider { } @Override - public synchronized SearchResult getLessSearchResult(String searchText) { + public SearchResult getLessSearchResult(String[] searchText) { lessModelList = new SearchResult(); moreModelList = new SearchResult(); - if (StringUtils.isBlank(searchText)) { - lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); - return lessModelList; - } if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainDocument()) { - String result; - String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText + "-1"; - HttpClient httpClient = new HttpClient(url); - httpClient.asGet(); - if (!httpClient.isServerAlive()) { - return getNoConnectList(); + if (ArrayUtils.isEmpty(searchText)) { + lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); + return lessModelList; + } + SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance); + if(noConnectList != null){ + return noConnectList; } - result = httpClient.getResponseText(); - AlphaFineHelper.checkCancel(); - try { - JSONObject jsonObject = new JSONObject(result); - JSONArray jsonArray = jsonObject.optJSONArray("docdata"); - if (jsonArray != null) { - SearchResult searchResult = new SearchResult(); - for (int i = 0; i < jsonArray.length(); i++) { - AlphaFineHelper.checkCancel(); - DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); - if (!AlphaFineHelper.getFilterResult().contains(cellModel)) { - searchResult.add(cellModel); + SearchResult searchResult = new SearchResult(); + for (int j = 0; j < searchText.length; j++) { + String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText[j] + AlphaFineConstants.FIRST_PAGE; + try { + String result = HttpToolbox.get(url); + AlphaFineHelper.checkCancel(); + JSONObject jsonObject = new JSONObject(result); + JSONArray jsonArray = jsonObject.optJSONArray("docdata"); + if (jsonArray != null) { + + for (int i = 0; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); + DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); + if (!AlphaFineHelper.getFilterResult().contains(cellModel) && !searchResult.contains(cellModel)) { + searchResult.add(cellModel); + } } } - if (searchResult.isEmpty()) { - return lessModelList; - } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { - lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); - lessModelList.addAll(searchResult); - } else { - lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.DOCUMENT)); - lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); - moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); - } + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("document search error: " + e.getMessage()); + } catch (IOException e) { + FineLoggerFactory.getLogger().error("document search get result error: " + e.getMessage()); } - } catch (JSONException e) { - FineLoggerFactory.getLogger().error("document search error: " + e.getMessage()); + } + lessModelList.clear(); + moreModelList.clear(); + if (searchResult.isEmpty()) { + return lessModelList; + } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); + lessModelList.addAll(searchResult); + } else { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.DOCUMENT)); + lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); } } return lessModelList; } - /** - * 无连接 - * - * @return - */ - private SearchResult getNoConnectList() { - SearchResult result = new SearchResult(); - result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); - result.add(AlphaFineHelper.NO_CONNECTION_MODEL); - return result; - } - @Override public SearchResult getMoreSearchResult(String searchText) { return moreModelList; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index d728598919..17c58998df 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java @@ -25,7 +25,7 @@ public class FileSearchManager implements AlphaFineSearchProvider { private static final String DS_NAME = "dsname=\""; private static final String FRM_PREFIX = "k:frm "; private static final String CPT_PREFIX = "k:cpt "; - private static FileSearchManager instance; + private static volatile FileSearchManager instance; private SearchResult filterModelList; private SearchResult lessModelList; private SearchResult moreModelList; @@ -33,7 +33,7 @@ public class FileSearchManager implements AlphaFineSearchProvider { private FileNode[] fileNodes = null; //停止搜索 - //隐藏的搜索功能,可根据特殊的字符标记判断搜索分类 +//隐藏的搜索功能,可根据特殊的字符标记判断搜索分类 private boolean isContainCpt = true; private boolean isContainFrm = true; @@ -62,20 +62,25 @@ public class FileSearchManager implements AlphaFineSearchProvider { return new FileModel(name, filePath, searchCount); } - public synchronized SearchResult getLessSearchResult(String searchText) { + + public SearchResult getLessSearchResult(String searchStr, String[] searchText) { this.filterModelList = new SearchResult(); this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); - this.searchText = dealWithSearchText(searchText); - if (StringUtils.isBlank(this.searchText) || ComparatorUtils.equals(this.searchText, DS_NAME)) { - lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates"))); - return lessModelList; + for (int j = 0; j < searchText.length; j++) { + this.searchText = dealWithSearchText(searchText[j]); + if (StringUtils.isBlank(this.searchText) || ComparatorUtils.equals(this.searchText, DS_NAME)) { + lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates"))); + return lessModelList; + } + AlphaFineHelper.checkCancel(); + fileNodes = FRContext.getFileNodes().list(ProjectConstants.REPORTLETS_NAME, AlphaFineConstants.FILE_EXTENSIONS, true); + isContainCpt = true; + isContainFrm = true; + doSearch(this.searchText); } - AlphaFineHelper.checkCancel(); - fileNodes = FRContext.getFileNodes().list(ProjectConstants.REPORTLETS_NAME, new FileExtension[]{FileExtension.CPT, FileExtension.FRM}, true); - isContainCpt = true; - isContainFrm = true; - doSearch(this.searchText); + doFileContentSearch(searchStr); + if (filterModelList.isEmpty()) { return new SearchResult(); } else if (filterModelList.size() < AlphaFineConstants.SHOW_SIZE + 1) { @@ -90,6 +95,11 @@ public class FileSearchManager implements AlphaFineSearchProvider { return lessModelList; } + @Override + public SearchResult getLessSearchResult(String[] searchText) { + return null; + } + @Override public SearchResult getMoreSearchResult(String searchText) { return moreModelList; @@ -108,6 +118,13 @@ public class FileSearchManager implements AlphaFineSearchProvider { } } + } + + /** + * 搜索模板内容 + * @param searchText + */ + private void doFileContentSearch(String searchText) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainFileContent()) { FileNode[] fileNodes = FRContext.getFileNodes().filterFiles(searchText, ProjectConstants.REPORTLETS_NAME, new FileExtension[]{FileExtension.CPT, FileExtension.FRM}, true); for (FileNode node : fileNodes) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java new file mode 100644 index 0000000000..c1dd0ea820 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java @@ -0,0 +1,149 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineHelper; +import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.design.mainframe.alphafine.cell.model.RobotModel; +import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.general.http.HttpToolbox; +import com.fr.json.JSONArray; +import com.fr.json.JSONException; +import com.fr.json.JSONObject; +import com.fr.json.JSONUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * Created by alex.sung on 2018/8/3. + */ +public class HotIssuesManager { + private static volatile HotIssuesManager instance; + private static final int HOT_ITEM_NUM = 6; + private static final int HOT_SUB_ITEM_NUM = 4; + private static final String HOT_ITEM = "item"; + private static final String HOT_ITEM_DATA = "itemData"; + private static final String HOT_ITEM_TEXT = "text"; + private static final String HOT_TYPE = "type"; + private static final String HOT_DATA = "data"; + + public static HotIssuesManager getInstance() { + if (instance == null) { + synchronized (HotIssuesManager.class) { + if (instance == null) { + instance = new HotIssuesManager(); + } + } + } + return instance; + } + + String[][] data = new String[HOT_ITEM_NUM][]; + Map map = new HashMap<>(); + + /** + * 将子标题下的数据塞入modeList + * @param subTitle + * @return + */ + public SearchResult getTitleSearchResult(String subTitle) { + SearchResult modeList = new SearchResult(); + modeList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText((subTitle)))); + + List issueList = map.get(subTitle); + for (int i = 0; i < issueList.size(); i++) { + RobotModel robotModel = new RobotModel(issueList.get(i), null); + robotModel.setHotItemModel(true); + modeList.add(robotModel); + } + return modeList; + } + + /** + * 从热门问题接口获取热门问题 + * @return + */ + public String[][] getHotIssues() { + + try { + String result = HttpToolbox.get(AlphaFineConstants.ALPHA_HOT_SEARCH); + JSONArray jsonArray = (JSONArray)JSONUtils.jsonDecode(result); + if(jsonArray != null){ + for (int i = 0; i < HOT_ITEM_NUM; i++) { + AlphaFineHelper.checkCancel(); + JSONObject jsonObject = jsonArray.optJSONObject(i); + data[i] = getTitleStrings(jsonObject); + } + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error("hotissues search error: " + e.getMessage()); + return null; + } + return data; + } + + /** + * 根据子标题获取该标题下数据 + * @param jsonObject + * @return + */ + private String[] getTitleStrings(JSONObject jsonObject) { + String[] temp = getSubTitleFromCloud(jsonObject.optJSONObject(HOT_DATA)); + String[] temp1 = new String[1]; + temp1[0] = jsonObject.optString(HOT_TYPE); + int strLen1 = temp.length; + int strLen2 = temp1.length; + + temp1 = Arrays.copyOf(temp1, strLen2 + strLen1); + System.arraycopy(temp, 0, temp1, strLen2, strLen1); + + getIssueStrings(jsonObject.optJSONObject(HOT_DATA)); + + return temp1; + } + + /** + * 获取子标题和子标题下的问题列表 + * @param data + * @return + */ + private void getIssueStrings(JSONObject data) { + try { + for (int j = 0; j < HOT_SUB_ITEM_NUM; j++) { + String temp = data.getString(HOT_ITEM + (j + 1)); + JSONArray jsonArray = data.getJSONArray(HOT_ITEM_DATA + (j + 1)); + List tempList = new ArrayList<>(); + for (int i = 0; i < jsonArray.length(); i++) { + tempList.add(jsonArray.optJSONObject(i).optString(HOT_ITEM_TEXT)); + } + map.put(temp, tempList); + } + + } catch (JSONException e) { + } + } + + /** + * 获取问题列表 + * @param data + * @return + */ + private String[] getSubTitleFromCloud(JSONObject data) { + ArrayList list = new ArrayList<>(); + for (int i = 0; i < HOT_SUB_ITEM_NUM; i++) { + String temp = data.optString(HOT_ITEM + (i + 1)); + if (!StringUtils.isEmpty(temp)) { + list.add(temp); + } + } + String[] strings = new String[list.size()]; + list.toArray(strings); + return strings; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 975e943119..826aa7db22 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -9,16 +9,17 @@ import com.fr.design.mainframe.alphafine.cell.model.PluginModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; import com.fr.general.ComparatorUtils; - -import com.fr.general.http.HttpClient; +import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.basic.version.Version; import com.fr.plugin.basic.version.VersionIntervalFactory; -import com.fr.stable.StringUtils; +import com.fr.stable.ArrayUtils; +import com.fr.stable.EncodeConstants; +import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -26,7 +27,7 @@ import java.net.URLEncoder; * Created by XiaXiang on 2017/3/27. */ public class PluginSearchManager implements AlphaFineSearchProvider { - private static PluginSearchManager instance; + private static volatile PluginSearchManager instance; private SearchResult lessModelList; private SearchResult moreModelList; @@ -95,63 +96,58 @@ public class PluginSearchManager implements AlphaFineSearchProvider { } @Override - public synchronized SearchResult getLessSearchResult(String searchText) { + public SearchResult getLessSearchResult(String[] searchText) { this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); - if (StringUtils.isBlank(searchText)) { - lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); - return lessModelList; - } + SearchResult searchResult = new SearchResult(); if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainPlugin()) { - String result; - try { - String encodedKey = URLEncoder.encode(searchText, "UTF-8"); - String url = AlphaFineConstants.PLUGIN_SEARCH_URL + "?keyword=" + encodedKey; - HttpClient httpClient = new HttpClient(url); - httpClient.asGet(); - if (!httpClient.isServerAlive()) { - return getNoConnectList(); - } - result = httpClient.getResponseText(); - AlphaFineHelper.checkCancel(); - JSONObject jsonObject = new JSONObject(result); - JSONArray jsonArray = jsonObject.optJSONArray("result"); - if (jsonArray != null) { - SearchResult searchResult = new SearchResult(); - for (int i = 0; i < jsonArray.length(); i++) { - AlphaFineHelper.checkCancel(); - PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); - if (cellModel != null && !AlphaFineHelper.getFilterResult().contains(cellModel)) { - searchResult.add(cellModel); + if (ArrayUtils.isEmpty(searchText)) { + lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); + return lessModelList; + } + SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance); + if(noConnectList != null){ + return noConnectList; + } + for (int j = 0; j < searchText.length; j++) { + try { + String encodedKey = URLEncoder.encode(searchText[j], EncodeConstants.ENCODING_UTF_8); + String url = AlphaFineConstants.PLUGIN_SEARCH_URL + "?keyword=" + encodedKey; + String result = HttpToolbox.get(url); + AlphaFineHelper.checkCancel(); + JSONObject jsonObject = new JSONObject(result); + JSONArray jsonArray = jsonObject.optJSONArray("result"); + if (jsonArray != null) { + for (int i = 0; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); + PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); + if (cellModel != null && !AlphaFineHelper.getFilterResult().contains(cellModel) && !searchResult.contains(cellModel)) { + searchResult.add(cellModel); + } } } - if (searchResult.isEmpty()) { - return this.lessModelList; - } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { - lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); - lessModelList.addAll(searchResult); - } else { - lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.PLUGIN)); - lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); - moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); - } + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("plugin search json error :" + e.getMessage()); + } catch (UnsupportedEncodingException e) { + FineLoggerFactory.getLogger().error("plugin search encode error :" + e.getMessage()); + } catch (IOException e) { + FineLoggerFactory.getLogger().error("plugin search get result error :" + e.getMessage()); } - } catch (JSONException e) { - FineLoggerFactory.getLogger().error("plugin search json error :" + e.getMessage()); - } catch (UnsupportedEncodingException e) { - FineLoggerFactory.getLogger().error("plugin search encode error :" + e.getMessage()); + } + if (searchResult.isEmpty()) { + return this.lessModelList; + } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); + lessModelList.addAll(searchResult); + } else { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.PLUGIN)); + lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); } } return this.lessModelList; } - private SearchResult getNoConnectList() { - SearchResult result = new SearchResult(); - result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); - result.add(AlphaFineHelper.NO_CONNECTION_MODEL); - return result; - } - @Override public SearchResult getMoreSearchResult(String searchText) { return this.moreModelList; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java index 481442faca..866c2c7349 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java @@ -45,7 +45,7 @@ import java.util.List; */ public class RecentSearchManager implements AlphaFineSearchProvider { private static final int MAX_SIZE = 100; - private static RecentSearchManager instance; + private static volatile RecentSearchManager instance; IndexReader indexReader = null; IndexSearcher indexSearcher = null; //索引存储路径 @@ -72,9 +72,11 @@ public class RecentSearchManager implements AlphaFineSearchProvider { } @Override - public SearchResult getLessSearchResult(String searchText) { + public SearchResult getLessSearchResult(String[] searchText) { this.modelList = new SearchResult(); - recentModelList = getRecentModelList(searchText); + for (int j = 0; j < searchText.length; j++) { + recentModelList = getRecentModelList(searchText[j]); + } if (recentModelList != null && recentModelList.size() > 0) { modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Latest"))); if (recentModelList.size() > AlphaFineConstants.LATEST_SHOW_SIZE) { @@ -107,7 +109,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider { directory = FSDirectory.open(new File(path)); indexWriter = new IndexWriter(directory, config); } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -121,7 +123,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider { indexReader = DirectoryReader.open(directory); indexSearcher = new IndexSearcher(indexReader); } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -132,11 +134,14 @@ public class RecentSearchManager implements AlphaFineSearchProvider { * @param cellModel */ public void addModel(String searchKey, AlphaCellModel cellModel) { + if(cellModel == null){ + return; + } try { initWriter(); Document doc = new Document(); doc.add(new StringField("searchKey", searchKey, Field.Store.YES)); - doc.add(new StringField("cellModel", cellModel.ModelToJson().toString(), Field.Store.YES)); + doc.add(new StringField("cellModel", cellModel.modelToJson().toString(), Field.Store.YES)); doc.add(new LongField("time", System.currentTimeMillis(), Field.Store.YES)); writeDoc(doc); } catch (JSONException e) { @@ -171,7 +176,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider { initReader(); IndexSearcher searcher = new IndexSearcher(indexReader); - //构建排序字段 + //构建排序字段 SortField[] sortField = new SortField[1]; sortField[0] = new SortField("time", SortField.Type.LONG, true); Sort sortKey = new Sort(sortField); @@ -181,7 +186,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider { TopFieldDocs docs = searcher.search(query, MAX_SIZE, sortKey); ScoreDoc[] scores = docs.scoreDocs; this.recentModelList = new SearchResult(); - //遍历结果 + //遍历结果 for (ScoreDoc scoreDoc : scores) { Document document = searcher.doc(scoreDoc.doc); AlphaCellModel model = CellModelHelper.getModelFromJson(new JSONObject(document.get("cellModel"))); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java index 8a2873e4b4..c97e621e35 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java @@ -10,15 +10,16 @@ import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; - -import com.fr.general.http.HttpClient; +import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; +import com.fr.stable.ArrayUtils; import com.fr.stable.CodeUtils; import com.fr.stable.StringUtils; +import java.io.IOException; import java.util.Iterator; import java.util.List; @@ -26,10 +27,13 @@ import java.util.List; * Created by XiaXiang on 2017/3/31. */ public class RecommendSearchManager implements AlphaFineSearchProvider { - private static RecommendSearchManager instance; + private static volatile RecommendSearchManager instance; private SearchResult modelList; private SearchResult recommendModelList; + private SearchResult complementAdviceModelList; + private SearchResult moreModelList = new SearchResult(); + public static RecommendSearchManager getInstance() { if (instance == null) { synchronized (RecentSearchManager.class) { @@ -42,37 +46,43 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { } @Override - public synchronized SearchResult getLessSearchResult(String searchText) { - searchText = searchText.replaceAll(StringUtils.BLANK, StringUtils.EMPTY); + public SearchResult getLessSearchResult(String[] searchText) { this.modelList = new SearchResult(); this.recommendModelList = new SearchResult(); if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) { - String result; - HttpClient httpClient = new HttpClient(AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText)); - httpClient.asGet(); - if (!httpClient.isServerAlive()) { - return getNoConnectList(); + if (ArrayUtils.isEmpty(searchText)) { + return new SearchResult(); + } + SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance); + if(noConnectList != null){ + return noConnectList; } - httpClient.setTimeout(3000); - result = httpClient.getResponseText(); - AlphaFineHelper.checkCancel(); - try { - JSONObject jsonObject = new JSONObject(result); - if (jsonObject.optString("status").equals("success")) { - JSONArray jsonArray = jsonObject.optJSONArray("result"); - if (jsonArray != null && jsonArray.length() > 0) { - for (int i = 0; i < jsonArray.length(); i++) { - AlphaFineHelper.checkCancel(); - AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i)); - if (alphaCellModel != null && !alreadyContain(alphaCellModel)) { - this.recommendModelList.add(alphaCellModel); + for (int j = 0; j < searchText.length; j++) { + searchText[j] = searchText[j].replaceAll(StringUtils.BLANK, StringUtils.EMPTY); + try { + String url = AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText[j]); + String result = HttpToolbox.get(url); + AlphaFineHelper.checkCancel(); + JSONObject jsonObject = new JSONObject(result); + if ("success".equals(jsonObject.optString("status"))) { + JSONArray jsonArray = jsonObject.optJSONArray("result"); + if (jsonArray != null && jsonArray.length() > 0) { + for (int i = 0; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); + AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i)); + if (alphaCellModel != null && !alreadyContain(alphaCellModel) && !this.recommendModelList.contains(alphaCellModel)) { + this.recommendModelList.add(alphaCellModel); + } } } } + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("recommend search error! :" + e.getMessage()); + } catch (IOException e) { + FineLoggerFactory.getLogger().error("recommend search get result error! :" + e.getMessage()); } - } catch (JSONException e) { - FineLoggerFactory.getLogger().error("recommend search error! :" + e.getMessage()); } + Iterator modelIterator = recommendModelList.iterator(); while (modelIterator.hasNext()) { AlphaCellModel model = modelIterator.next(); @@ -80,14 +90,90 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { modelIterator.remove(); } } - if (recommendModelList.size() > 0) { - modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false)); - modelList.addAll(recommendModelList); + complementAdviceModelList = ComplementAdviceManager.getInstance().getAllSearchResult(searchText); + moreModelList.clear(); + + if (!recommendModelList.isEmpty()) { + if (complementAdviceModelList.isEmpty()) { + getRecommendSearchResult(); + } else { + getRecommendAndAdviceSearchResult(); + } + } else { + if (!complementAdviceModelList.isEmpty()) { + getComplementAdviceSearchResult(); + } else { + return modelList; + } } } return modelList; } + /** + * 将推荐接口获取的数据分别放入“显示部分”,“显示更多”的list + */ + private void getRecommendSearchResult(){ + if (recommendModelList.size() > AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM) { + if (recommendModelList.size() > AlphaFineConstants.SHOW_SIZE) { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND)); + } else { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false)); + } + modelList.addAll(recommendModelList.subList(0, AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM)); + moreModelList.addAll(recommendModelList.subList(AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM, recommendModelList.size())); + } else { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false)); + modelList.addAll(recommendModelList); + } + } + + /** + * 将补全接口获取的数据分别放入“显示部分”,“显示更多”的list + */ + private void getComplementAdviceSearchResult(){ + if (complementAdviceModelList.size() > AlphaFineConstants.SHOW_SIZE) { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND)); + modelList.addAll(complementAdviceModelList.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(complementAdviceModelList.subList(AlphaFineConstants.SHOW_SIZE, complementAdviceModelList.size())); + } else { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false)); + modelList.addAll(complementAdviceModelList); + } + } + + /** + * 将推荐接口和补全接口获取的数据分别放入“显示部分”,“显示更多”的list + */ + private void getRecommendAndAdviceSearchResult(){ + if (recommendModelList.size() + complementAdviceModelList.size() > AlphaFineConstants.SHOW_SIZE) { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND)); + if (recommendModelList.size() > AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM) { + modelList.addAll(recommendModelList.subList(0, AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM)); + moreModelList.addAll(recommendModelList.subList(AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM, recommendModelList.size())); + + if (complementAdviceModelList.size() >= AlphaFineConstants.SHOW_SIZE - AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM) { + modelList.addAll(complementAdviceModelList.subList(0, 2)); + moreModelList.addAll(complementAdviceModelList.subList(2, complementAdviceModelList.size())); + } else { + modelList.addAll(complementAdviceModelList); + } + } else { + modelList.addAll(recommendModelList); + if (complementAdviceModelList.size() >= (AlphaFineConstants.SHOW_SIZE - recommendModelList.size())) { + modelList.addAll(complementAdviceModelList.subList(0, AlphaFineConstants.SHOW_SIZE - recommendModelList.size())); + moreModelList.addAll(complementAdviceModelList.subList(2, complementAdviceModelList.size())); + } else { + modelList.addAll(complementAdviceModelList); + } + } + } else { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false)); + modelList.addAll(recommendModelList); + modelList.addAll(complementAdviceModelList); + } + } + /** * 是否已包含该model * @@ -98,20 +184,17 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { return RecentSearchManager.getInstance().getRecentModelList().contains(cellModel) || this.recommendModelList.contains(cellModel); } - private SearchResult getNoConnectList() { - SearchResult result = new SearchResult(); - result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"))); - result.add(AlphaFineHelper.NO_CONNECTION_MODEL); - return result; - } - @Override public SearchResult getMoreSearchResult(String searchText) { - return new SearchResult(); + return moreModelList; } public List getRecommendModelList() { - return recommendModelList; + SearchResult result = new SearchResult(); + result.addAll(recommendModelList); + result.addAll(modelList); + result.addAll(moreModelList); + return result; } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java new file mode 100644 index 0000000000..6f1e3850a0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java @@ -0,0 +1,83 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.stable.StringUtils; + +import com.fr.third.ibm.icu.text.BreakIterator; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Created by alex.sung on 2018/8/3. + */ +public class SegmentationManager { + private static volatile SegmentationManager segmentationManager = null; + private static final int MAX_CHINESE_CHARACTERS_NUM = 4; + + public static SegmentationManager getInstance() { + if (segmentationManager == null) { + synchronized (SegmentationManager.class) { + if (segmentationManager == null) { + segmentationManager = new SegmentationManager(); + } + } + } + return segmentationManager; + } + + /** + * 判断是否需要分词 + * + * @param searchText + * @return + */ + public boolean isNeedSegmentation(String searchText) { + int count = 0; + Pattern p = Pattern.compile(AlphaFineConstants.CHINESE_CHARACTERS); + Matcher m = p.matcher(searchText); + while (m.find()) { + for (int i = 0; i <= m.groupCount(); i++) { + count = count + 1; + } + } + if (count >= MAX_CHINESE_CHARACTERS_NUM) { + return true; + } + return false; + } + + /** + * 对字符串进行分词 + * + * @param searchText + * @return + */ + public String[] startSegmentation(String searchText) { + Pattern p = Pattern.compile(AlphaFineConstants.SPECIAL_CHARACTER_REGEX); + Matcher m = p.matcher(searchText); + searchText = m.replaceAll(StringUtils.EMPTY).trim().replaceAll(StringUtils.BLANK, StringUtils.EMPTY); + if (StringUtils.isEmpty(searchText)) { + return null; + } + if (!isNeedSegmentation(searchText)) { + return new String[]{searchText}; + } + List result = new ArrayList<>(); + result.add(searchText); + BreakIterator itor = BreakIterator.getWordInstance(); + itor.setText(searchText); + int start = itor.first(); + for (int end = itor.next(); end != BreakIterator.DONE; start = end, end = itor.next()) { + String temp = searchText.substring(start, end); + if (!StringUtils.isEmpty(temp)) { + result.add(temp); + } + } + String[] strings = new String[result.size()]; + result.toArray(strings); + return strings; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java new file mode 100644 index 0000000000..1bc6411313 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java @@ -0,0 +1,95 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineHelper; +import com.fr.design.mainframe.alphafine.CellType; +import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.design.mainframe.alphafine.cell.model.RobotModel; +import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; +import com.fr.general.http.HttpToolbox; +import com.fr.json.JSONException; +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ArrayUtils; +import com.fr.third.org.apache.commons.codec.digest.DigestUtils; + +import java.io.IOException; + +/** + * Created by alex.sung on 2018/8/3. + */ +public class SimilarSearchManeger implements AlphaFineSearchProvider { + private static volatile SimilarSearchManeger instance; + private SearchResult lessModelList; + private SearchResult moreModelList = new SearchResult(); + + public static SimilarSearchManeger getInstance() { + if (instance == null) { + synchronized (SimilarSearchManeger.class){ + if (instance == null) { + instance = new SimilarSearchManeger(); + } + } + } + return instance; + } + + @Override + public SearchResult getLessSearchResult(String[] searchText) { + lessModelList = new SearchResult(); + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + if (ArrayUtils.isEmpty(searchText)) { + return new SearchResult(); + } + SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance); + if(noConnectList != null){ + return noConnectList; + } + SearchResult allModelList = new SearchResult(); + for (int j = 0; j < searchText.length; j++) { + String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + searchText[j]); + String url = AlphaFineConstants.SIMILAR_SEARCH_URL_PREFIX + "msg=" + searchText[j] + "&token=" + token; + try { + String result = HttpToolbox.get(url); + AlphaFineHelper.checkCancel(); + allModelList = AlphaFineHelper.getModelListFromJSONArray(result,"title"); + } catch (ClassCastException | JSONException e) { + FineLoggerFactory.getLogger().error("similar search error: " + e.getMessage()); + } catch (IOException e) { + FineLoggerFactory.getLogger().error("similar search get result error: " + e.getMessage()); + } + } + moreModelList.clear(); + if (allModelList.isEmpty()) { + return lessModelList; + } else if (allModelList.size() < AlphaFineConstants.SHOW_SIZE + 1) { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Relation_Item"))); + lessModelList.addAll(allModelList); + } else { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Relation_Item"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.ROBOT)); + lessModelList.addAll(allModelList.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(allModelList.subList(AlphaFineConstants.SHOW_SIZE, allModelList.size())); + } + } + return lessModelList; + } + + @Override + public SearchResult getMoreSearchResult(String searchText) { + return moreModelList; + } + + /** + * 根据json信息获取RobotModel + * + * @param object + * @return + */ + public static RobotModel getModelFromCloud(JSONObject object) { + String name = object.optString("title"); + String content = object.optString("content"); + return new RobotModel(name, content); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java index a381cd6d44..72fa9aba6f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java @@ -6,7 +6,6 @@ import com.fr.base.Style; import com.fr.base.TempNameStyle; import com.fr.base.extension.FileExtension; import com.fr.base.io.XMLEncryptUtils; -import com.fr.base.remote.RemoteDeziConstants; import com.fr.config.ServerPreferenceConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.server.StyleListAction; @@ -15,16 +14,16 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DecodeDialog; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.exception.PermissionDeniedException; +import com.fr.exception.TplLockedException; import com.fr.file.FILE; -import com.fr.general.ComparatorUtils; - -import com.fr.io.utils.ResourceIOUtils; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; -import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -34,44 +33,44 @@ import java.util.Iterator; * Created by juhaoyu on 2018/6/27. */ class CptApp extends AbstractWorkBookApp { - + @Override public String[] defaultExtensions() { - + return new String[]{FileExtension.CPT.getExtension()}; } - + @Override public WorkBook asIOFile(FILE file) { - + if (XMLEncryptUtils.isCptEncoded() && - !XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { + !XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { if (!new DecodeDialog(file).isPwdRight()) { FRContext.getLogger().error(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ECP_Error_Pwd")); return new WorkBook(); } } - + WorkBook tpl = new WorkBook(); // richer:打开报表通知 FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Opening_And_Waiting", file.getName()) + "..."); TempNameStyle namestyle = TempNameStyle.getInstance(); namestyle.clear(); - String checkStr = StringUtils.EMPTY; try { - checkStr = ResourceIOUtils.inputStream2String(file.asInputStream()); tpl.readStream(file.asInputStream()); + } catch (PermissionDeniedException exp) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp); + } catch (TplLockedException exp) { + FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); } catch (Exception exp) { - String errorMessage = ComparatorUtils.equals(RemoteDeziConstants.INVALID_USER, checkStr) ? Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") - : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_NS_Exception_ReadError"); - FineLoggerFactory.getLogger().error(errorMessage + file, exp); + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Report_NS_Exception_ReadError") + file, exp); } checkNameStyle(namestyle); return tpl; } - + private static void checkNameStyle(TempNameStyle namestyle) { - + Iterator it = namestyle.getIterator(); ArrayList al = new ArrayList(); while (it.hasNext()) { @@ -81,9 +80,9 @@ class CptApp extends AbstractWorkBookApp { showConfirmDialog(al); } } - + private static void showConfirmDialog(final ArrayList namelist) { - + final JDialog jd = new JDialog(); // 模态一下,因为可能会多个样式丢失 // jd.setModal(true); @@ -96,14 +95,14 @@ class CptApp extends AbstractWorkBookApp { jl.setHorizontalAlignment(SwingConstants.CENTER); jd.add(jl, BorderLayout.CENTER); JPanel jp = new JPanel(); - + // ”是“按钮,点击之后将生成一个全局样式,并写入xml UIButton confirmButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Yes")); confirmButton.addActionListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { - + try { for (String name : namelist) { ServerPreferenceConfig.getInstance().putStyle(name, Style.DEFAULT_STYLE); @@ -115,17 +114,17 @@ class CptApp extends AbstractWorkBookApp { new StyleListAction().actionPerformed(e);// 弹窗 } }); - + UIButton noButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_No")); noButton.addActionListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { - + jd.dispose(); } }); - + jp.add(confirmButton); jp.add(noButton); jd.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Custom_Style_Missed")); @@ -133,5 +132,5 @@ class CptApp extends AbstractWorkBookApp { GUICoreUtils.centerWindow(jd); jd.setVisible(true); } - + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java index 2f45b413fb..9350100498 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java @@ -3,8 +3,10 @@ package com.fr.design.mainframe.app; import com.fr.base.extension.FileExtension; import com.fr.base.frpx.exception.FRPackageRunTimeException; import com.fr.base.frpx.exception.InvalidWorkBookException; +import com.fr.design.i18n.Toolkit; +import com.fr.exception.PermissionDeniedException; +import com.fr.exception.TplLockedException; import com.fr.file.FILE; - import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBookAdapter; @@ -16,32 +18,38 @@ import java.io.InputStream; * Created by juhaoyu on 2018/6/27. */ class CptxApp extends AbstractWorkBookApp { - + @Override public String[] defaultExtensions() { - + return new String[]{FileExtension.CPTX.getExtension()}; } - + @Override public WorkBook asIOFile(FILE file) { - + FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Opening_And_Waiting", file.getName()) + "..."); - WorkBookX tpl; + WorkBookX tpl = new WorkBookX(); InputStream inputStream; try { inputStream = file.asInputStream(); long time = System.currentTimeMillis(); tpl = new WorkBookX(inputStream); FineLoggerFactory.getLogger().error("cost: " + (System.currentTimeMillis() - time) + " ms"); + + + } catch (PermissionDeniedException exp) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp); + } catch (TplLockedException exp) { + FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); } catch (Exception exp) { if (exp instanceof FRPackageRunTimeException) { throw (FRPackageRunTimeException) exp; } throw new InvalidWorkBookException(file + ":" + exp.getMessage(), exp); } - - + + return new WorkBookAdapter(tpl); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java index a45fdd2140..f0b93cdf2c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java @@ -2,13 +2,15 @@ package com.fr.design.mainframe.app; import com.fr.base.io.XMLEncryptUtils; import com.fr.design.DesignerEnvManager; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.AbstractAppProvider; import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.DecodeDialog; import com.fr.design.mainframe.JTemplate; +import com.fr.exception.PermissionDeniedException; +import com.fr.exception.TplLockedException; import com.fr.file.FILE; import com.fr.form.main.Form; - import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; import com.fr.stable.bridge.StableFactory; @@ -19,43 +21,46 @@ import java.util.HashMap; * Created by juhaoyu on 2018/6/27. */ class FormApp extends AbstractAppProvider { - + @Override public String[] defaultExtensions() { - + return new String[]{"frm", "form"}; } - + @Override @SuppressWarnings("unchecked") public JTemplate openTemplate(FILE tplFile) { - + HashMap classType = new HashMap(); classType.put(Constants.ARG_0, Form.class); classType.put(Constants.ARG_1, FILE.class); - + return (JTemplate) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, - new Object[]{asIOFile(tplFile), tplFile}, classType, BaseJForm.class); + new Object[]{asIOFile(tplFile), tplFile}, classType, BaseJForm.class); } - + @Override public Form asIOFile(FILE file) { - + if (XMLEncryptUtils.isCptEncoded() && - !XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { + !XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { if (!new DecodeDialog(file).isPwdRight()) { FineLoggerFactory.getLogger().error(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_ECP_Error_Password")); return new Form(); } } - - + // peter:打开新报表. Form tpl = new Form(); // richer:打开报表通知 FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("file.getName()", file.getName()) + "..."); try { tpl.readStream(file.asInputStream()); + } catch (PermissionDeniedException exp) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp); + } catch (TplLockedException exp) { + FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); } catch (Exception exp) { FineLoggerFactory.getLogger().error("Failed to generate frm from " + file, exp); return null; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java index 312335fb79..0118a8dac0 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java @@ -1,6 +1,9 @@ package com.fr.design.mainframe.app; import com.fr.base.extension.FileExtension; +import com.fr.design.i18n.Toolkit; +import com.fr.exception.PermissionDeniedException; +import com.fr.exception.TplLockedException; import com.fr.file.FILE; import com.fr.io.importer.ExcelReportImporter; import com.fr.log.FineLoggerFactory; @@ -10,19 +13,23 @@ import com.fr.main.impl.WorkBook; * Created by juhaoyu on 2018/6/27. */ class XlsApp extends AbstractWorkBookApp { - + @Override public String[] defaultExtensions() { - + return new String[]{FileExtension.XLS.getExtension()}; } - + @Override public WorkBook asIOFile(FILE tplFile) { - + WorkBook workbook = null; try { workbook = new ExcelReportImporter().generateWorkBookByStream(tplFile.asInputStream()); + } catch (PermissionDeniedException exp) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + tplFile, exp); + } catch (TplLockedException exp) { + FineLoggerFactory.getLogger().error(tplFile + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); } catch (Exception exp) { FineLoggerFactory.getLogger().error("Failed to generate xls from " + tplFile, exp); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java index f3b5fef76e..fe3f11e508 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java @@ -1,6 +1,9 @@ package com.fr.design.mainframe.app; import com.fr.base.extension.FileExtension; +import com.fr.design.i18n.Toolkit; +import com.fr.exception.PermissionDeniedException; +import com.fr.exception.TplLockedException; import com.fr.file.FILE; import com.fr.io.importer.Excel2007ReportImporter; import com.fr.log.FineLoggerFactory; @@ -10,19 +13,24 @@ import com.fr.main.impl.WorkBook; * Created by juhaoyu on 2018/6/27. */ class XlsxApp extends AbstractWorkBookApp { - + @Override public String[] defaultExtensions() { - + return new String[]{FileExtension.XLSX.getExtension()}; } - + @Override public WorkBook asIOFile(FILE tplFile) { - + WorkBook workbook = null; try { workbook = new Excel2007ReportImporter().generateWorkBookByStream(tplFile.asInputStream()); + + } catch (PermissionDeniedException exp) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + tplFile, exp); + } catch (TplLockedException exp) { + FineLoggerFactory.getLogger().error(tplFile + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); } catch (Exception exp) { FineLoggerFactory.getLogger().error("Failed to generate xlsx from " + tplFile, exp); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSDialog.java b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSDialog.java index dd3366273d..cfce02c720 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSDialog.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSDialog.java @@ -63,7 +63,7 @@ public class BBSDialog extends UIDialog { } }); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSLoginDialog.java b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSLoginDialog.java index d923e25173..82f8a84842 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSLoginDialog.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSLoginDialog.java @@ -281,7 +281,7 @@ public class BBSLoginDialog extends UIDialog { username = URLEncoder.encode(username, EncodeConstants.ENCODING_GBK); password = URLEncoder.encode(password, EncodeConstants.ENCODING_GBK); } catch (UnsupportedEncodingException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } String url = CloudCenter.getInstance().acquireUrlByKind("bbs.login") + "&username=" + username + "&password=" + password; String loginSuccessFlag = CloudCenter.getInstance().acquireUrlByKind("bbs"); @@ -294,7 +294,7 @@ public class BBSLoginDialog extends UIDialog { return true; } } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java index 05ee976406..2869b7915b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -149,7 +149,7 @@ public class UserInfoLabel extends UILabel { } Thread.sleep(DELAY_TIME); } catch (InterruptedException e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } HttpClient hc = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("bbs.popup")); if (!hc.isServerAlive()) { @@ -222,7 +222,7 @@ public class UserInfoLabel extends UILabel { try { Thread.sleep(millis); } catch (InterruptedException e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java index 56ce0dabd7..85299d24d6 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java @@ -142,7 +142,7 @@ public class UserInfoPane extends BasicPane { return dayNew - dayOld; } } catch (ParseException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return 1; } @@ -165,7 +165,7 @@ public class UserInfoPane extends BasicPane { } } catch (InterruptedException e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } String userName = MarketConfig.getInstance().getBbsUsername(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java index ba883874c9..8fdcfbbc34 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -134,7 +134,7 @@ public class FormElementCaseDesigner{ private ReportMobileTemplateSettingsPane reportMobileTemplateSettingsPane; // 模版设置面板 private AppFitBrowserPane appFitBrowserPane; - //工具栏容器 - private MobileToolBarPane mobileToolBarPane; // 其他 private MobileOthersPane mobileOthersPane; @@ -38,7 +36,6 @@ public class ReportMobileAttrPane extends BasicBeanPane{ appFitBrowserPane.setAppFitPreviewPane(appFitPreviewPane); jPanel.add(appFitBrowserPane); - jPanel.add(mobileToolBarPane = new MobileToolBarPane()); jPanel.add(mobileOthersPane = new MobileOthersPane()); jPanel.add(appFitPreviewPane); @@ -52,7 +49,6 @@ public class ReportMobileAttrPane extends BasicBeanPane{ ob = new ElementCaseMobileAttr(); } appFitBrowserPane.populateBean(ob); - mobileToolBarPane.populateBean(ob); mobileOthersPane.populateBean(ob); reportMobileTemplateSettingsPane.populateBean(ob); } @@ -60,7 +56,6 @@ public class ReportMobileAttrPane extends BasicBeanPane{ @Override public ElementCaseMobileAttr updateBean() { ElementCaseMobileAttr caseMobileAttr = appFitBrowserPane.updateBean(); - mobileToolBarPane.updateBean(caseMobileAttr); mobileOthersPane.updateBean(caseMobileAttr); reportMobileTemplateSettingsPane.updateBean(caseMobileAttr); diff --git a/designer-realize/src/main/java/com/fr/design/report/share/ConfusionTableDataPane.java b/designer-realize/src/main/java/com/fr/design/report/share/ConfusionTableDataPane.java index 62d281da9c..69594b03dc 100644 --- a/designer-realize/src/main/java/com/fr/design/report/share/ConfusionTableDataPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/share/ConfusionTableDataPane.java @@ -193,7 +193,7 @@ public class ConfusionTableDataPane extends BasicBeanPane{ InputStream in = IOUtils.readResource("/com/fr/design/report/share/shareToolTip.html"); return IOUtils.inputStream2String(in); } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage(), e); } return StringUtils.EMPTY; 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 9cc57ce503..9fc67c3fc8 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 @@ -40,7 +40,6 @@ import com.fr.report.web.button.write.StashButton; 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; public class ReportWebWidgetConstants { private ReportWebWidgetConstants() { @@ -57,7 +56,7 @@ public class ReportWebWidgetConstants { 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, + APPENDCOLUMNROW, DELETECOLUMNROW, SETPRINTEROFFSET, CUSTOM_BUTTON, WRITESTASH, WRITESTASHCLEAR, IMPORTEXCELDATA_CUSTOMIZED, IMPORTEXCEL, IMPORTEXCEL_COVER, IMPORTEXCEL_CLEAN, IMPORTEXCEL_APPEND}; } @@ -151,9 +150,6 @@ public class ReportWebWidgetConstants { public static final WidgetOption CUSTOM_BUTTON = WidgetOptionFactory .createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Custom_Form_Button"), CustomToolBarButton.class); - // 输出离线html报表 - public static final WidgetOption WRITEOFFLINEHTML = WidgetOptionFactory - .createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Export-Offline-Html"), BaseUtils.readIcon("/com/fr/web/images/writeOffline.png"), WriteOfflineHTML.class); // 数据暂存 public static final WidgetOption WRITESTASH = WidgetOptionFactory .createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine-Write_Stash"), BaseUtils.readIcon("/com/fr/web/images/edit/stash.png"), StashButton.class); diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java index dbdf2ff6f6..a000cc2096 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java @@ -10,14 +10,16 @@ import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UIBasicSpinner; +import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.report.UnitFieldPane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; - import com.fr.report.stable.ReportConstants; +import com.fr.stable.Constants; import com.fr.stable.StringUtils; import javax.print.DocFlavor; @@ -45,22 +47,33 @@ import java.util.regex.Pattern; * Created by plough on 2018/3/5. */ public class NativePrintSettingPane extends JPanel { + private static final int ODD_INDEX = 0; + private static final int EVEN_INDEX = 1; + private static final String CUSTOM_PAPERSIZE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom"); + private static final PaperSize DEFAULT_PAPERSIZE = PaperSize.PAPERSIZE_A4; + private UICheckBox isShowDialogCheck; private UIComboBox printerComboBox; private UIBasicSpinner copySpinner; // 份数 private UIRadioButton allPageRadioButton; private UIRadioButton currentPageRadioButton; private UIRadioButton customPageRadioButton; + private UIRadioButton doublePrintRadioButton; + private UIComboBox doublePrintComboBox; private UITextField specifiedAreaField; private UIComboBox predefinedPaperSizeComboBox; private UICheckBox inheritPagePaperSettingCheck; private UICheckBox inheritPageLayoutSettingCheck; private UICheckBox inheritPageMarginSettingCheck; private UICheckBox fitPaperSizeCheck; // 缩放 + private UINumberField scalePercentField; // 缩放百分比 private UIRadioButton portraitRadioButton; private UIRadioButton landscapeRadioButton; private PageMarginSettingPane pageMarginSettingPane; private JPanel centerPane; + private JPanel customPaperSizePane; + private UnitFieldPane customWidthFieldPane; + private UnitFieldPane customHeightFieldPane; public NativePrintSettingPane() { initComponents(); @@ -100,6 +113,7 @@ public class NativePrintSettingPane extends JPanel { allPageRadioButton.addItemListener(getPageRaidoListener()); currentPageRadioButton.addItemListener(getPageRaidoListener()); customPageRadioButton.addItemListener(getPageRaidoListener()); + doublePrintRadioButton.addItemListener(getPageRaidoListener()); isShowDialogCheck.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { @@ -125,6 +139,12 @@ public class NativePrintSettingPane extends JPanel { super.focusLost(e); } }); + predefinedPaperSizeComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + updateCustomPaperSizeArea(); + } + }); } private ItemListener getPageRaidoListener() { @@ -132,6 +152,7 @@ public class NativePrintSettingPane extends JPanel { @Override public void itemStateChanged(ItemEvent e) { specifiedAreaField.setEnabled(customPageRadioButton.isSelected()); + doublePrintComboBox.setEnabled(doublePrintRadioButton.isSelected()); } }; } @@ -145,7 +166,7 @@ public class NativePrintSettingPane extends JPanel { printerPane.add(printerComboBox); // 份数 - copySpinner = new UIBasicSpinner(new SpinnerNumberModel(1, 0, Integer.MAX_VALUE, 1)); + copySpinner = new UIBasicSpinner(new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1)); GUICoreUtils.setColumnForSpinner(copySpinner, 5); JPanel copyPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); copyPane.add(copySpinner); @@ -174,10 +195,13 @@ public class NativePrintSettingPane extends JPanel { // 缩放 fitPaperSizeCheck = GUICoreUtils.createNoBorderCheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_To_Fit_Paper_Size")); + JPanel scalePane = getScalePane(); + scalePane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + JPanel scaleCheckPane = GUICoreUtils.createCheckboxAndDynamicPane(fitPaperSizeCheck, scalePane, true); // TableLayout double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p, p, p}; + double[] rowSize = {p, p, p, p, p, p, p}; double[] columnSize = {60, p}; Component[][] components = { {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Printer") + ":"), printerPane}, @@ -185,9 +209,8 @@ public class NativePrintSettingPane extends JPanel { {printAreaLabelPane, getPrintAreaPane()}, {getTopAlignLabelPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Paper") + ":"), paperSettingCheckPane}, {getTopAlignLabelPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout") + ":"), layoutSettingCheckPane}, - {getTopAlignLabelPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Margin") + ":"), pageMarginCheckPane} - // 此功能暂时不做,在界面上隐藏缩放选项 -// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Scale_EnlargeOrReduce") + ":"), fitPaperSizeCheck}, + {getTopAlignLabelPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Margin") + ":"), pageMarginCheckPane}, + {getTopAlignLabelPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_EnlargeOrReduce") + ":"), scaleCheckPane}, }; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 15); } @@ -197,6 +220,8 @@ public class NativePrintSettingPane extends JPanel { DocFlavor.INPUT_STREAM.AUTOSENSE, null); Set allPrinterName = new HashSet(); + allPrinterName.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_None")); + for (int i = 0, len = printServices.length; i < len; i++) { allPrinterName.add(printServices[i].getName()); } @@ -210,6 +235,7 @@ public class NativePrintSettingPane extends JPanel { Object[] tmpPaperSizeNameArray = ReportConstants.PaperSizeNameSizeArray[i]; predefinedPaperSizeComboBox.addItem(tmpPaperSizeNameArray[1]); } + predefinedPaperSizeComboBox.addItem(CUSTOM_PAPERSIZE); predefinedPaperSizeComboBox.setRenderer(new UIComboBoxRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -238,12 +264,41 @@ public class NativePrintSettingPane extends JPanel { } }); - JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); - panel.add(predefinedPaperSizeComboBox); - panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0)); + // 下拉框 + JPanel comboPanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + comboPanel.add(predefinedPaperSizeComboBox); + comboPanel.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0)); + + customPaperSizePane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_M_Pane(); + // 宽度设置 + JPanel customWidthPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + customWidthPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Designer_Width") + ":")); + customWidthFieldPane = new UnitFieldPane(Constants.UNIT_MM); + customWidthFieldPane.setUnitValue(DEFAULT_PAPERSIZE.getWidth()); + customWidthPane.add(customWidthFieldPane); + // 高度设置 + JPanel customHeightPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + customHeightPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Height") + ":")); + customHeightFieldPane = new UnitFieldPane(Constants.UNIT_MM); + customHeightFieldPane.setUnitValue(DEFAULT_PAPERSIZE.getHeight()); + customHeightPane.add(customHeightFieldPane); + + customPaperSizePane.add(customWidthPane); + customPaperSizePane.add(customHeightPane); + customPaperSizePane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.add(comboPanel, BorderLayout.NORTH); + panel.add(customPaperSizePane, BorderLayout.CENTER); + return panel; } + private void updateCustomPaperSizeArea() { + boolean isCustom = ComparatorUtils.equals(predefinedPaperSizeComboBox.getSelectedItem(), CUSTOM_PAPERSIZE); + customPaperSizePane.setVisible(isCustom); + } + private JPanel getLayoutSettingPane() { JPanel layoutSettingPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); layoutSettingPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); @@ -266,10 +321,12 @@ public class NativePrintSettingPane extends JPanel { allPageRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_All_Pages")); currentPageRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Current_Page")); customPageRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_HJS-Specified_Pages")); + doublePrintRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Double_Side_Print")); ButtonGroup group = new ButtonGroup(); group.add(allPageRadioButton); group.add(currentPageRadioButton); group.add(customPageRadioButton); + group.add(doublePrintRadioButton); allPageRadioButton.setSelected(true); specifiedAreaField = new UITextField(20) { @@ -284,14 +341,46 @@ public class NativePrintSettingPane extends JPanel { }; UILabel areaFieldTip = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_Area_Tip")); + doublePrintComboBox = new UIComboBox() { + @Override + public void setEnabled(boolean enabled) { + // 如果未选中"双面打印",此下拉框始终不可用 + if (enabled && !doublePrintRadioButton.isSelected()) { + return; + } + super.setEnabled(enabled); + } + }; + doublePrintComboBox.addItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_HF_Odd_Page")); + doublePrintComboBox.addItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_HF_Even_Page")); + // TableLayout double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p}; + double[] rowSize = {p, p, p, p}; double[] columnSize = {p, p, p}; Component[][] components = { {allPageRadioButton, null, null}, {currentPageRadioButton, null, null}, - {customPageRadioButton, specifiedAreaField, areaFieldTip} + {customPageRadioButton, specifiedAreaField, areaFieldTip}, + {doublePrintRadioButton, doublePrintComboBox, new JPanel()} + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 0); + } + + private JPanel getScalePane() { + scalePercentField = new UINumberField(5); + scalePercentField.setMaxIntegerLength(3); + scalePercentField.setMaxDecimalLength(0); + scalePercentField.setMaxValue(200); + + UILabel percent = new UILabel("%"); + + // TableLayout + double p = TableLayout.PREFERRED; + double[] rowSize = {p}; + double[] columnSize = {p, p}; + Component[][] components = { + {scalePercentField, percent} }; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 0); } @@ -312,14 +401,32 @@ public class NativePrintSettingPane extends JPanel { allPageRadioButton.setSelected(true); } else if (nativePrintAttr.getPageType().equals(NativePrintAttr.PageType.CURRENT_PAGE)) { currentPageRadioButton.setSelected(true); - } else { + } else if (nativePrintAttr.getPageType().equals(NativePrintAttr.PageType.SPECIFIED_PAGES)) { customPageRadioButton.setSelected(true); specifiedAreaField.setText(nativePrintAttr.getArea()); + } else { + doublePrintRadioButton.setSelected(true); + if (nativePrintAttr.getPageType().equals(NativePrintAttr.PageType.ODD_PAGES)) { + doublePrintComboBox.setSelectedIndex(ODD_INDEX); + } else { + doublePrintComboBox.setSelectedIndex(EVEN_INDEX); + } } specifiedAreaField.setEnabled(customPageRadioButton.isSelected()); + doublePrintComboBox.setEnabled(doublePrintRadioButton.isSelected()); inheritPagePaperSettingCheck.setSelected(nativePrintAttr.isInheritPagePaperSetting()); - predefinedPaperSizeComboBox.setSelectedItem(nativePrintAttr.getPaperSize()); + + PaperSize paperSize = nativePrintAttr.getPaperSize(); + predefinedPaperSizeComboBox.setSelectedItem(paperSize); + if (!ComparatorUtils.equals(predefinedPaperSizeComboBox.getSelectedItem(), paperSize)) { + // 自定义尺寸 + predefinedPaperSizeComboBox.setSelectedItem(CUSTOM_PAPERSIZE); + customWidthFieldPane.setUnitValue(paperSize.getWidth()); + customHeightFieldPane.setUnitValue(paperSize.getHeight()); + } + updateCustomPaperSizeArea(); + inheritPageLayoutSettingCheck.setSelected(nativePrintAttr.isInheritPageLayoutSetting()); if (nativePrintAttr.getOrientation() == ReportConstants.PORTRAIT) { portraitRadioButton.setSelected(true); @@ -329,6 +436,9 @@ public class NativePrintSettingPane extends JPanel { inheritPageMarginSettingCheck.setSelected(nativePrintAttr.isInheritPageMarginSetting()); pageMarginSettingPane.populate(nativePrintAttr.getMargin()); fitPaperSizeCheck.setSelected(nativePrintAttr.isFitPaperSize()); + scalePercentField.setValue(nativePrintAttr.getScalePercent()); + + checkEnabled(); } public void update(NativePrintAttr nativePrintAttr) { @@ -343,19 +453,32 @@ public class NativePrintSettingPane extends JPanel { nativePrintAttr.setPageType(NativePrintAttr.PageType.ALL_PAGES); } else if (currentPageRadioButton.isSelected()) { nativePrintAttr.setPageType(NativePrintAttr.PageType.CURRENT_PAGE); - } else { + } else if (customPageRadioButton.isSelected()) { nativePrintAttr.setPageType(NativePrintAttr.PageType.SPECIFIED_PAGES); nativePrintAttr.setArea(specifiedAreaField.getText()); + } else if (doublePrintComboBox.getSelectedIndex() == ODD_INDEX){ + nativePrintAttr.setPageType(NativePrintAttr.PageType.ODD_PAGES); + } else { + nativePrintAttr.setPageType(NativePrintAttr.PageType.EVEN_PAGES); } nativePrintAttr.setInheritPagePaperSetting(inheritPagePaperSettingCheck.isSelected()); - nativePrintAttr.setPaperSize((PaperSize) predefinedPaperSizeComboBox.getSelectedItem()); + + PaperSize newPaperSize; + if (ComparatorUtils.equals(predefinedPaperSizeComboBox.getSelectedItem(), CUSTOM_PAPERSIZE)) { + newPaperSize = new PaperSize(customWidthFieldPane.getUnitValue(), customHeightFieldPane.getUnitValue()); + } else { + newPaperSize = (PaperSize) predefinedPaperSizeComboBox.getSelectedItem(); + } + nativePrintAttr.setPaperSize(newPaperSize); + nativePrintAttr.setInheritPageLayoutSetting(inheritPageLayoutSettingCheck.isSelected()); nativePrintAttr.setOrientation(portraitRadioButton.isSelected() ? ReportConstants.PORTRAIT : ReportConstants.LANDSCAPE); nativePrintAttr.setInheritPageMarginSetting(inheritPageMarginSettingCheck.isSelected()); nativePrintAttr.setMargin(pageMarginSettingPane.updateBean()); nativePrintAttr.setFitPaperSize(fitPaperSizeCheck.isSelected()); + nativePrintAttr.setScalePercent((int)scalePercentField.getValue()); } // 刷新面板可用状态 diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java index 4dd9fa6b96..a61cd7a3c2 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java @@ -8,12 +8,10 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.utils.gui.GUICoreUtils; - import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.FlowLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -23,6 +21,7 @@ import java.awt.event.ItemListener; */ public class NoClientPrintSettingPane extends JPanel { private UICheckBox setMarginWhenPrintCheck; + private UICheckBox ieQuietPrintCheck; private UICheckBox inheritPageMarginSettingCheck; // 继承页面边距设置 private PageMarginSettingPane pageMarginSettingPane; private JPanel centerPane; @@ -35,15 +34,16 @@ public class NoClientPrintSettingPane extends JPanel { private void initComponents() { JPanel printPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - setMarginWhenPrintCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Set_Margin_When_Printing")); - setMarginWhenPrintCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); - UILabel tipLabel = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Use_Default_Print_Margin")); - JPanel northPane = GUICoreUtils.createFlowPane(new Component[] { - setMarginWhenPrintCheck, tipLabel}, FlowLayout.LEFT); - northPane.setBorder(BorderFactory.createEmptyBorder(8, 10, 10, 0)); + printPane.add(createNorthPane(), BorderLayout.NORTH); + + initCenterPane(); + printPane.add(centerPane, BorderLayout.CENTER); - printPane.add(northPane, BorderLayout.NORTH); + this.setLayout(new BorderLayout()); + this.add(printPane, BorderLayout.CENTER); + } + private void initCenterPane() { centerPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default_Settings")); inheritPageMarginSettingCheck = GUICoreUtils.createNoBorderCheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Inherit_Page_Margin_Setting")); @@ -61,11 +61,27 @@ public class NoClientPrintSettingPane extends JPanel { JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 15); centerPane.add(panel); + } - printPane.add(centerPane, BorderLayout.CENTER); + private JPanel createNorthPane() { + setMarginWhenPrintCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Set_Margin_When_Printing")); + setMarginWhenPrintCheck.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 20)); + UILabel tipLabel = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Use_Default_Print_Margin")); + ieQuietPrintCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_No_Print_Settings_In_IE")); + ieQuietPrintCheck.setBorder(BorderFactory.createEmptyBorder(0, 12, 10, 0)); - this.setLayout(new BorderLayout()); - this.add(printPane, BorderLayout.CENTER); + // TableLayout + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {180, p}; + Component[][] components = { + {setMarginWhenPrintCheck, tipLabel}, + {ieQuietPrintCheck, null} + }; + JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10); + northPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + + return northPane; } private void initListeners() { @@ -86,12 +102,14 @@ public class NoClientPrintSettingPane extends JPanel { public void populate(NoClientPrintAttr noClientPrintAttr) { setMarginWhenPrintCheck.setSelected(noClientPrintAttr.isSetMarginOnPrint()); + ieQuietPrintCheck.setSelected(noClientPrintAttr.isIeQuietPrint()); inheritPageMarginSettingCheck.setSelected(noClientPrintAttr.isInheritPageMarginSetting()); pageMarginSettingPane.populate(noClientPrintAttr.getMargin()); } public void update(NoClientPrintAttr noClientPrintAttr) { noClientPrintAttr.setSetMarginOnPrint(setMarginWhenPrintCheck.isSelected()); + noClientPrintAttr.setIeQuietPrint(ieQuietPrintCheck.isSelected()); noClientPrintAttr.setInheritPageMarginSetting(inheritPageMarginSettingCheck.isSelected()); noClientPrintAttr.setMargin(pageMarginSettingPane.updateBean()); } diff --git a/designer-realize/src/main/java/com/fr/design/write/submit/SubmitVisitorListPane.java b/designer-realize/src/main/java/com/fr/design/write/submit/SubmitVisitorListPane.java index 0875b1568c..6d5aac3022 100644 --- a/designer-realize/src/main/java/com/fr/design/write/submit/SubmitVisitorListPane.java +++ b/designer-realize/src/main/java/com/fr/design/write/submit/SubmitVisitorListPane.java @@ -137,7 +137,7 @@ public class SubmitVisitorListPane extends ObjectJControlPane { try { editing = (BuiltInSQLSubmiterProvider) editing.clone(); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } editing.setDBManipulation(dbManipulation); diff --git a/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java b/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java index a0d2db47e4..2b02478cc9 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java @@ -574,7 +574,6 @@ public class PolyDesigner extends ReportComponent