diff --git a/designer-base/src/com/fr/design/gui/UILookAndFeel.java b/designer-base/src/com/fr/design/gui/UILookAndFeel.java index f4fd5d4c45..ed93237f3c 100644 --- a/designer-base/src/com/fr/design/gui/UILookAndFeel.java +++ b/designer-base/src/com/fr/design/gui/UILookAndFeel.java @@ -1,6 +1,10 @@ package com.fr.design.gui; -import com.fr.design.gui.borders.*; +import com.fr.design.gui.borders.UIFrameBorder; +import com.fr.design.gui.borders.UIInternalFrameBorder; +import com.fr.design.gui.borders.UITableHeaderBorder; +import com.fr.design.gui.borders.UITableHeaderRolloverBorder; +import com.fr.design.gui.borders.UITextFieldBorder; import com.fr.design.gui.frpane.UIBasicOptionPaneUI; import com.fr.design.gui.ibutton.UIBasicButtonUI; import com.fr.design.gui.ibutton.UIButtonBorder; @@ -28,14 +32,15 @@ import com.fr.design.gui.itree.UITreeUI; import com.fr.general.FRLogger; import com.fr.general.IOUtils; -import javax.swing.*; +import javax.swing.ImageIcon; +import javax.swing.UIDefaults; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.plaf.BorderUIResource; import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.basic.BasicBorders; import javax.swing.plaf.metal.MetalLookAndFeel; -import java.awt.*; +import java.awt.Insets; import java.net.URL; /** @@ -84,7 +89,7 @@ public class UILookAndFeel extends MetalLookAndFeel { "MenuUI", UIBasicMenuUI.class.getName(), "MenuItemUI", UIBasicMenuItemUI.class.getName(), "RadioButtonMenuItemUI", UIRadioButtonMenuItemUI.class.getName(), - "OptionPaneUI",UIBasicOptionPaneUI.class.getName(), + "OptionPaneUI", UIBasicOptionPaneUI.class.getName(), }); } @@ -158,8 +163,8 @@ public class UILookAndFeel extends MetalLookAndFeel { table.put("FileChooser.listViewIcon", loadIcon("FileListIcon.png", this)); table.put("FileChooser.newFolderIcon", loadIcon("NewFolderIcon.png", this)); table.put("FileChooser.upFolderIcon", loadIcon("ParentDirectoryIcon.png", this)); - table.put("OptionPane.errorIcon", loadIcon("ErrorIcon.png", this)); - table.put("OptionPane.informationIcon", loadIcon("InformationIcon.png", this)); + table.put("OptionPane.errorIcon", loadIcon("Information_Icon_Error_32x32.png", this)); + table.put("OptionPane.informationIcon", loadIcon("Information_Icon_OK_32x32.png", this)); table.put("OptionPane.warningIcon", loadIcon("WarningIcon.png", this)); table.put("OptionPane.questionIcon", loadIcon("QuestionIcon.png", this)); table.put("ScrollPane.border", new UIScrollPaneBorder()); @@ -187,7 +192,7 @@ public class UILookAndFeel extends MetalLookAndFeel { if (url == null) { // Another try url = IOUtils.getResource( - "com/fr/design/images/lookandfeel/" + fileName, UILookAndFeel.class); + "com/fr/design/images/lookandfeel/" + fileName, UILookAndFeel.class); if (url == null) { FRLogger.getLogger().error("Icon directory could not be resolved."); diff --git a/designer-base/src/com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png b/designer-base/src/com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png new file mode 100644 index 0000000000..8c8831e6dd Binary files /dev/null and b/designer-base/src/com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png differ diff --git a/designer-base/src/com/fr/design/images/lookandfeel/Information_Icon_OK_32x32.png b/designer-base/src/com/fr/design/images/lookandfeel/Information_Icon_OK_32x32.png new file mode 100644 index 0000000000..480c829ed2 Binary files /dev/null and b/designer-base/src/com/fr/design/images/lookandfeel/Information_Icon_OK_32x32.png differ diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 1a03ab749f..f548e6920b 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -29,7 +29,11 @@ import com.fr.file.CacheManager; import com.fr.file.ConnectionConfig; import com.fr.file.TableDataConfig; import com.fr.file.filetree.FileNode; -import com.fr.general.*; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.general.Inter; +import com.fr.general.LogRecordTime; +import com.fr.general.LogUtils; import com.fr.general.http.HttpClient; import com.fr.io.utils.ResourceIOUtils; import com.fr.json.JSONArray; @@ -53,7 +57,8 @@ import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLableReader; import com.fr.web.ResourceConstants; -import javax.swing.*; +import javax.swing.JOptionPane; +import javax.swing.UIManager; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; @@ -61,14 +66,12 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import java.awt.*; +import java.awt.Component; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -84,12 +87,14 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Timer; import java.util.TimerTask; import java.util.logging.Level; import java.util.regex.Pattern; +/** + * @author null + */ public class RemoteEnv extends AbstractEnv { private static final int TIME_OUT = 30 * 1000; private static final int PLAIN_SOCKET_PORT = 80; @@ -110,7 +115,7 @@ public class RemoteEnv extends AbstractEnv { private int licNotSupport = 0; private boolean isRoot = false; private Timer logTimer = null; - private static ThreadLocal threadLocal = new ThreadLocal(); + private static ThreadLocal threadLocal = new ThreadLocal<>(); private boolean isReadTimeOut = false; private String buildFilePath; @@ -140,6 +145,7 @@ public class RemoteEnv extends AbstractEnv { /** * 当前设计环境的用户名,用于远程设计 */ + @Override public String getUser() { return user; } @@ -153,7 +159,11 @@ public class RemoteEnv extends AbstractEnv { return password; } - // 修复密码中包含特殊字符,无法登录的问题 + /** + * 修复密码中包含特殊字符,无法登录的问题 + * + * @return + */ private String getEncodedPassword() { try { return URLEncoder.encode(password, "UTF-8"); @@ -213,7 +223,7 @@ public class RemoteEnv extends AbstractEnv { /** * 根据nameValuePairs,也就是参数对,生成PostMethod */ - private HttpClient createHttpMethod(HashMap para, boolean isSignIn) throws EnvException, UnsupportedEncodingException { + private HttpClient createHttpMethod(HashMap para, boolean isSignIn) throws EnvException { String methodPath = this.path; if (!isSignIn) { methodPath = methodPath + "?id=" + createUserID(); @@ -230,14 +240,14 @@ public class RemoteEnv extends AbstractEnv { } - /* - * Read the response body. - * 拿出InputStream中所有的Byte,转换成ByteArrayInputStream的形式返回 - * - * 这样做的目的是确保method.releaseConnection - * - * TODO 但如果不做method.releaseConnection,有多大危害呢?不确定... - */ + /* + * Read the response body. + * 拿出InputStream中所有的Byte,转换成ByteArrayInputStream的形式返回 + * + * 这样做的目的是确保method.releaseConnection + * + * TODO 但如果不做method.releaseConnection,有多大危害呢?不确定... + */ /** * execute method之后,取返回的inputstream @@ -273,7 +283,6 @@ public class RemoteEnv extends AbstractEnv { } else if (ComparatorUtils.equals(message, RemoteDeziConstants.FILE_LOCKED)) { JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Remote_File_is_Locked")); return null; - } else if (message.startsWith(RemoteDeziConstants.RUNTIME_ERROR_PREFIX)) { } return new ByteArrayInputStream(bytes); } finally { @@ -360,6 +369,7 @@ public class RemoteEnv extends AbstractEnv { * @return 链接是否成功 * @throws Exception 异常 */ + @Override public boolean testServerConnectionWithOutShowMessagePane() throws Exception { return testConnection(false, true, DesignerContext.getDesignerFrame()); } @@ -379,7 +389,7 @@ public class RemoteEnv extends AbstractEnv { private boolean testConnection(boolean needMessage, boolean isRegisteServer, Component parentComponent) throws Exception { extraChangeEnvPara(); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "test_server_connection"); para.put("user", user); @@ -394,7 +404,11 @@ public class RemoteEnv extends AbstractEnv { String res = stream2String(execute4InputStream(client)); if (res == null) { if (needMessage) { - JOptionPane.showMessageDialog(parentComponent, Inter.getLocText("Datasource-Connection_failed")); + JOptionPane.showMessageDialog( + parentComponent, + Inter.getLocText("Datasource-Connection_failed"), + UIManager.getString("OptionPane.messageDialogTitle", parentComponent.getLocale()), + JOptionPane.ERROR_MESSAGE); } return false; } else if (ComparatorUtils.equals(res, "true")) { @@ -404,22 +418,33 @@ public class RemoteEnv extends AbstractEnv { } return true; } else if (ComparatorUtils.equals(res, "invalid username or password.")) { - JOptionPane.showMessageDialog(parentComponent, - Inter.getLocText(new String[]{"Datasource-Connection_failed", "Registration-User_Name", "Password", "Error"}, new String[]{",", "", "", "!"}) - , Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog( + parentComponent, + Inter.getLocText(new String[]{"Datasource-Connection_failed", "Registration-User_Name", "Password", "Error"}, new String[]{",", "", "", "!"}), + Inter.getLocText("FR-Server-All_Error"), + JOptionPane.ERROR_MESSAGE); return false; } else if (res.contains("RegistEditionException")) { if (needMessage) { - JOptionPane.showMessageDialog(parentComponent, Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); + JOptionPane.showMessageDialog( + parentComponent, + Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"}), + UIManager.getString("OptionPane.messageDialogTitle", parentComponent.getLocale()), + JOptionPane.ERROR_MESSAGE + ); } else { - FRLogger.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); + FRContext.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); } return false; } else if (ComparatorUtils.equals(res, "war not support remote design.")) { if (needMessage) { - JOptionPane.showMessageDialog(parentComponent, Inter.getLocText(new String[]{"Datasource-Connection_failed", "NS-war-remote"}, new String[]{",", "!"})); + JOptionPane.showMessageDialog( + parentComponent, + Inter.getLocText(new String[]{"Datasource-Connection_failed", "NS-war-remote"}, new String[]{",", "!"}), + UIManager.getString("OptionPane.messageDialogTitle", parentComponent.getLocale()), + JOptionPane.ERROR_MESSAGE); } else { - FRLogger.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "NS-war-remote"}, new String[]{",", "!"})); + FRContext.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "NS-war-remote"}, new String[]{",", "!"})); } return false; } else { @@ -447,17 +472,17 @@ public class RemoteEnv extends AbstractEnv { try { SignIn.signIn(this); } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage()); } } /** * 心跳访问,用来更新当前用户的访问时间 * - * @throws Exception + * @throws Exception e */ public void heartBeatConnection() throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "heart_beat"); para.put("user", user); @@ -474,7 +499,7 @@ public class RemoteEnv extends AbstractEnv { // DesignerFrameFileDealerPane.getInstance().refresh(); // } // } catch (Exception e) { -// FRLogger.getLogger().error(e.getMessage()); +// FRContext.getLogger().error(e.getMessage()); // } } @@ -483,6 +508,7 @@ public class RemoteEnv extends AbstractEnv { * * @return 描述环境名字的字符串 */ + @Override public String getEnvDescription() { return Inter.getLocText("Env-Remote_Server"); } @@ -490,6 +516,7 @@ public class RemoteEnv extends AbstractEnv { /** * 登录,返回userID */ + @Override public void signIn() throws Exception { if (clock != null && clock.connected) { return; @@ -500,7 +527,7 @@ public class RemoteEnv extends AbstractEnv { } clearUserID(); startLogTimer(); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "r_sign_in"); para.put("user", user); @@ -521,6 +548,7 @@ public class RemoteEnv extends AbstractEnv { } timer = new Timer(); timer.schedule(new TimerTask() { + @Override public void run() { try { RemoteEnv.this.setThreadLocal("HEART_BEAT"); @@ -540,19 +568,20 @@ public class RemoteEnv extends AbstractEnv { logTimer = new Timer(); logTimer.schedule(new TimerTask() { + @Override public void run() { try { RemoteEnv.this.setThreadLocal("LOG_MESSAGE"); FRContext.getCurrentEnv().printLogMessage(); } catch (Exception e) { - FRLogger.getLogger().info(e.getMessage()); + FRContext.getLogger().info(e.getMessage()); } } }, 10000, 10000); } private void stopLogTimer() { - if(logTimer != null) { + if (logTimer != null) { logTimer.cancel(); logTimer = null; } @@ -562,8 +591,9 @@ public class RemoteEnv extends AbstractEnv { * 根据userID sign out * * @return 成功签出返回true - * @throws Exception + * @throws Exception e */ + @Override public boolean signOut() throws Exception { if (userID == null) { return true; @@ -574,7 +604,7 @@ public class RemoteEnv extends AbstractEnv { // richer:把轮训使用的定时器也去掉 timer.cancel(); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "r_sign_out"); para.put("id", userID); @@ -591,7 +621,7 @@ public class RemoteEnv extends AbstractEnv { try { resJSON = stream2String(execute4InputStream(client)); } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage()); } if (resJSON == null) { @@ -638,7 +668,7 @@ public class RemoteEnv extends AbstractEnv { } JSONArray ja = new JSONArray(filePathes); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", cmd); para.put("pathes", ja.toString()); @@ -660,7 +690,7 @@ public class RemoteEnv extends AbstractEnv { * * @param filePathes 文件路径 * @return 成功解锁返回true - * @throws Exception + * @throws Exception e */ public boolean releaseLock(String[] filePathes) throws Exception { return doLockOperation(filePathes, "design_release_lock"); @@ -678,7 +708,7 @@ public class RemoteEnv extends AbstractEnv { return false; } - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_report_exist"); para.put("report_path", reportPath); @@ -693,11 +723,11 @@ public class RemoteEnv extends AbstractEnv { * 解锁当前模板,用于远程设计。当远程设计某张模板 时,在解锁之前改模板处于锁定状态 * * @param tplPath 路径 - * @throws Exception + * @throws Exception e */ @Override public void unlockTemplate(String tplPath) throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_close_report"); para.put(RemoteDeziConstants.TEMPLATE_PATH, tplPath); @@ -746,8 +776,9 @@ public class RemoteEnv extends AbstractEnv { /** * 刷新数出流,并提交 * - * @throws IOException + * @throws IOException e */ + @Override public void flush() throws IOException { super.flush(); post2Server(); @@ -757,10 +788,9 @@ public class RemoteEnv extends AbstractEnv { * 将指定字节写入输入流数组 * * @param b 写入的字节 - * @throws IOException */ @Override - public void write(int b) throws IOException { + public void write(int b) { out.write(b); } @@ -781,7 +811,7 @@ public class RemoteEnv extends AbstractEnv { // 把database写成xml文件到out DavXMLUtils.writeXMLFileDatabaseConnection(database, out); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_test_con"); @@ -802,7 +832,7 @@ public class RemoteEnv extends AbstractEnv { ByteArrayOutputStream out = new ByteArrayOutputStream(); DavXMLUtils.writeXMLFileDatabaseConnection(database, out); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_get_schema"); InputStream input = postBytes2ServerB(out.toByteArray(), para); @@ -819,7 +849,7 @@ public class RemoteEnv extends AbstractEnv { public TableProcedure[] getTableProcedure(com.fr.data.impl.Connection database, String type, String schema) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); DavXMLUtils.writeXMLFileDatabaseConnection(database, out); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_get_tables"); para.put("__type__", type); @@ -831,6 +861,7 @@ public class RemoteEnv extends AbstractEnv { return DavXMLUtils.readXMLSQLTables(input); } + @Override public List getProcedures(com.fr.data.impl.Connection datasource, String[] schemas, boolean isOracle, boolean isOracleSysSpace) throws Exception { HashMap schemaTableProcedureMap = new HashMap(); List sqlTableObjs = new ArrayList(); @@ -863,11 +894,11 @@ public class RemoteEnv extends AbstractEnv { * * @param folderPath 文件名 * @return 成功创建返回true - * @throws Exception + * @throws Exception e */ @Override public boolean createFolder(String folderPath) throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_create_folder"); para.put("folder_path", folderPath); @@ -887,10 +918,11 @@ public class RemoteEnv extends AbstractEnv { * * @param filePath :目标文件相对路径 * @return 成功新建返回true - * @throws Exception + * @throws Exception e */ + @Override public boolean createFile(String filePath) throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_create_file"); para.put("file_path", filePath); @@ -905,8 +937,9 @@ public class RemoteEnv extends AbstractEnv { return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); } + @Override public boolean renameFile(String newPath, String oldPath) throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_rename_file"); para.put("newPath", newPath); @@ -927,7 +960,7 @@ public class RemoteEnv extends AbstractEnv { * * @param filePath :目标文件相对路径 * @return 文件是否存在 - * @throws Exception + * @throws Exception e */ @Override public boolean fileExists(String filePath) throws Exception { @@ -935,7 +968,7 @@ public class RemoteEnv extends AbstractEnv { return false; } - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_file_exists"); para.put("file_path", filePath); @@ -955,14 +988,15 @@ public class RemoteEnv extends AbstractEnv { * * @param filePath 文件路径 * @return 文件被锁住了,返回true - * @throws Exception + * @throws Exception e */ + @Override public boolean fileLocked(String filePath) throws Exception { if (filePath == null) { return false; } - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_file_locked"); para.put("file_path", filePath); @@ -983,6 +1017,7 @@ public class RemoteEnv extends AbstractEnv { * * @param env 用户环境 */ + @Override public void registerUserEnv(UserBaseEnv env) { } @@ -990,6 +1025,7 @@ public class RemoteEnv extends AbstractEnv { * 用于检测用户环境 * ,启动定时器 */ + @Override public void startUserCheckTimer() { } @@ -1006,12 +1042,13 @@ public class RemoteEnv extends AbstractEnv { * @param filePath 文件地址 * @return 删除成功返回true */ + @Override public boolean deleteFile(String filePath) { if (filePath == null) { return false; } try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "delete_file"); para.put("file_path", filePath); @@ -1025,7 +1062,7 @@ public class RemoteEnv extends AbstractEnv { return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage()); } return false; } @@ -1036,10 +1073,10 @@ public class RemoteEnv extends AbstractEnv { * @param key 键值 * @param value 值 * @return 如果写入成功,返回true - * @throws Exception + * @throws Exception e */ public boolean writePrivilegeMap(String key, String value) throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "write_privilege_map"); para.put("current_user", this.user); @@ -1047,7 +1084,8 @@ public class RemoteEnv extends AbstractEnv { para.put("key", key); para.put("value", value); - HttpClient client = createHttpMethod(para); //jim :加上user,远程设计点击预览时传递用户角色信息 + //jim :加上user,远程设计点击预览时传递用户角色信息 + HttpClient client = createHttpMethod(para); InputStream input = execute4InputStream(client); if (input == null) { @@ -1060,11 +1098,12 @@ public class RemoteEnv extends AbstractEnv { /** * DataSource中去除当前角色没有权限访问的数据源 */ + @Override public void removeNoPrivilegeConnection() { TableDataConfig dm = TableDataConfig.getInstance(); try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fs_remote_design"); para.put("cmd", "env_get_role"); para.put("currentUsername", this.getUser()); @@ -1073,7 +1112,7 @@ public class RemoteEnv extends AbstractEnv { HttpClient client = createHttpMethod(para); InputStream input = execute4InputStream(client); JSONArray ja = new JSONArray(stream2String(input)); - ArrayList toBeRemoveTDName = new ArrayList(); + ArrayList toBeRemoveTDName = new ArrayList<>(); for (int i = 0; i < ja.length(); i++) { String toBeRemoveConnName = (String) ((JSONObject) ja.get(i)).get("name"); ConnectionConfig.getInstance().removeConnection(toBeRemoveConnName); @@ -1098,7 +1137,7 @@ public class RemoteEnv extends AbstractEnv { * * @param rootFilePath 指定目录 * @return WEB-INF目录下指定路径的文件夹与文件 - * @throws Exception + * @throws Exception e */ @Override public FileNode[] listFile(String rootFilePath) throws Exception { @@ -1110,7 +1149,7 @@ public class RemoteEnv extends AbstractEnv { * * @param rootFilePath 指定目录 * @return WEB-INF上层目录下指定路径的文件夹与文件 - * @throws Exception + * @throws Exception e */ @Override public FileNode[] listReportPathFile(String rootFilePath) throws Exception { @@ -1120,7 +1159,7 @@ public class RemoteEnv extends AbstractEnv { private FileNode[] listFile(String rootFilePath, boolean isWebReport) throws Exception { FileNode[] fileNodes; - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fs_remote_design"); para.put("cmd", "design_list_file"); para.put("file_path", rootFilePath); @@ -1137,7 +1176,7 @@ public class RemoteEnv extends AbstractEnv { // 远程环境下左侧目录树暂不需要打开xlsx,xls文件 fileNodes = DavXMLUtils.readXMLFileNodes(input); - ArrayList al = new ArrayList(); + ArrayList al = new ArrayList<>(); for (int i = 0; i < fileNodes.length; i++) { al.add(fileNodes[i]); } @@ -1156,9 +1195,9 @@ public class RemoteEnv extends AbstractEnv { * * @param rootFilePath 指定目录 * @return 列出目标目录下所有cpt文件或文件夹 - * @throws Exception */ - public FileNode[] listCpt(String rootFilePath) throws Exception { + @Override + public FileNode[] listCpt(String rootFilePath) { return listCpt(rootFilePath, false); } @@ -1168,10 +1207,11 @@ public class RemoteEnv extends AbstractEnv { * @param rootFilePath 指定目录 * @param recurse 是否递归查找其子目录 * @return 列出目标目录下所有cpt文件或文件夹 - * @throws Exception + * @throws Exception e */ + @Override public FileNode[] listCpt(String rootFilePath, boolean recurse) { - List fileNodeList = new ArrayList(); + List fileNodeList = new ArrayList<>(); try { listAll(rootFilePath, fileNodeList, new String[]{"cpt"}, recurse); } catch (Exception e) { @@ -1211,13 +1251,14 @@ public class RemoteEnv extends AbstractEnv { * @return 数据集的参数 * @throws Exception 获取参数失败则抛出此异常 */ + @Override public Parameter[] getTableDataParameters(TableData tableData) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); -// 把tableData写成xml文件到out + //把tableData写成xml文件到out DavXMLUtils.writeXMLFileTableData(tableData, out); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_td_pars"); InputStream input = postBytes2ServerB(out.toByteArray(), para); @@ -1236,12 +1277,13 @@ public class RemoteEnv extends AbstractEnv { * @return 返回存储过程中的所有参数组成的数组 * @throws Exception 如果获取参数失败则抛出此异常 */ + @Override public Parameter[] getStoreProcedureParameters(StoreProcedure storeProcedure) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); // 把tableData写成xml文件到out DavXMLUtils.writeXMLFileStoreProcedureAndSource(storeProcedure, out); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_sp_pars"); InputStream input = postBytes2ServerB(out.toByteArray(), para); @@ -1266,6 +1308,7 @@ public class RemoteEnv extends AbstractEnv { * @return 实际的二维数据集 * @throws Exception 如果生成数据失败则抛出此异常 */ + @Override public EmbeddedTableData previewTableData(TableDataSource dataSource, Object tableData, java.util.Map parameterMap, int rowCount) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -1275,7 +1318,7 @@ public class RemoteEnv extends AbstractEnv { // 把parameterMap转成JSON格式的字符串 JSONObject jo = new JSONObject(parameterMap); String jsonParameter = jo.toString(); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_preview_td"); para.put("pars", jsonParameter); @@ -1301,6 +1344,7 @@ public class RemoteEnv extends AbstractEnv { * @return 实际的二位数据条 * @throws Exception 异常 */ + @Override public Object previewTableData(Object tableData, java.util.Map parameterMap, int start, int end, String[] cols, int[] colIdx) throws Exception { return previewTableData(tableData, parameterMap, -1); } @@ -1329,6 +1373,7 @@ public class RemoteEnv extends AbstractEnv { * The method will be invoked when read data from XML file.
* May override the method to read the data that you saved. */ + @Override public void readXML(XMLableReader reader) { if (reader.isChildNode()) { String tmpVal; @@ -1353,6 +1398,7 @@ public class RemoteEnv extends AbstractEnv { * * @param writer the PrintWriter. */ + @Override public void writeXML(XMLPrintWriter writer) { writer.startTAG("DIR").attr("path", this.path).attr("user", this.user).attr("password", this.password).end(); } @@ -1431,7 +1477,7 @@ public class RemoteEnv extends AbstractEnv { if (StringUtils.isBlank(remoteVersion) || ComparatorUtils.compare(remoteVersion, ProductConstants.DESIGNER_VERSION) < 0) { String infor = Inter.getLocText("FR-Server_Version_Tip"); String moreInfo = Inter.getLocText("FR-Server_Version_Tip_MoreInfo"); - FRLogger.getLogger().log(Level.WARNING, infor); + FRContext.getLogger().log(Level.WARNING, infor); new InformationWarnPane(infor, moreInfo, Inter.getLocText("FR-Designer_Tooltips")).show(); return; } @@ -1454,8 +1500,10 @@ public class RemoteEnv extends AbstractEnv { Pattern pattern = Pattern.compile("[/:]+"); String[] strs = pattern.split(remoteEnv.path); - String shost = strs[1];//host,如:192.168.100.195 - int sport = Integer.parseInt(strs[2]);//端口,如:8080 + //host,如:192.168.100.195 + String shost = strs[1]; + //端口,如:8080 + int sport = Integer.parseInt(strs[2]); Socket socket = new Socket(shost, sport); //OOBBINLINE:是否支持发送一个字节的TCP紧急数据,false表示服务器不用处理这个数据 @@ -1470,7 +1518,7 @@ public class RemoteEnv extends AbstractEnv { * * @param resourceName 配置文件的名字,如datasource.xml * @return 输入流 - * @throws Exception + * @throws Exception e */ @Override public InputStream readResource(String resourceName) throws Exception { @@ -1484,13 +1532,14 @@ public class RemoteEnv extends AbstractEnv { * @param path 制定路径,是基于报表目录下resource文件夹路径 * @return 读到的文件 */ + @Override public String[] readPathSvgFiles(String path) { String cataloguePath = StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getPath(), SvgProvider.SERVER, path); ArrayList fileArray = new ArrayList<>(); try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_read_svgfile"); para.put("resourcePath", path); @@ -1525,10 +1574,11 @@ public class RemoteEnv extends AbstractEnv { * @return 是否写入成功 * @throws Exception 异常 */ + @Override public boolean writeSvgFile(SvgProvider svgFile) throws Exception { testServerConnection(); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "svgrelate"); para.put("cmd", "design_save_svg"); para.put("filePath", svgFile.getFilePath()); @@ -1581,7 +1631,7 @@ public class RemoteEnv extends AbstractEnv { public boolean writeResource(XMLFileManagerProvider mgr) throws Exception { testServerConnection(); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_save_resource"); para.put("resource", mgr.fileName()); @@ -1616,9 +1666,10 @@ public class RemoteEnv extends AbstractEnv { * @param prefix 当前Env下得工程分类,如reportlets,lib等 * @return InputStream 输入流 */ + @Override public InputStream readBean(String beanPath, String prefix) throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fs_remote_design"); para.put("cmd", "design_open"); para.put(RemoteDeziConstants.PREFXI, prefix); @@ -1637,9 +1688,9 @@ public class RemoteEnv extends AbstractEnv { * @param prefix 当前Env下得工程分类,如reportlets,lib等 * @return OutputStream 输出流 */ - public OutputStream writeBean(String beanPath, String prefix) - throws Exception { - HashMap para = new HashMap(); + @Override + public OutputStream writeBean(String beanPath, String prefix) { + HashMap para = new HashMap<>(); para.put("op", "fs_remote_design"); para.put("cmd", "design_save_report"); para.put(RemoteDeziConstants.PREFXI, prefix); @@ -1657,7 +1708,7 @@ public class RemoteEnv extends AbstractEnv { */ @Override public String[] getColumns(String selectedName, String schema, String tableName) throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_columns"); para.put("dsName", selectedName); @@ -1688,7 +1739,7 @@ public class RemoteEnv extends AbstractEnv { @Override public String getProcedureText(String connectionName, String databaseName) throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_get_procedure_text"); para.put("procedure_name", databaseName); @@ -1705,7 +1756,7 @@ public class RemoteEnv extends AbstractEnv { @Override public StoreProcedureParameter[] getStoreProcedureDeclarationParameters(String connectionName, String databaseName, String parameterDefaultValue) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_get_sp_parameters"); para.put("__name__", databaseName); @@ -1722,9 +1773,10 @@ public class RemoteEnv extends AbstractEnv { /** * 获取datasource.xml文件的修改表 */ + @Override public ModifiedTable getDataSourceModifiedTables(String type) { try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "get_datasource_modified_tables"); para.put("type", type); @@ -1749,6 +1801,7 @@ public class RemoteEnv extends AbstractEnv { * @param type 操作类型,是数据连接还是服务器数据集 * @return 写入成功返回true */ + @Override public boolean writeDataSourceModifiedTables(ModifiedTable modifiedTable, String type) { ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -1756,7 +1809,7 @@ public class RemoteEnv extends AbstractEnv { // 把tableData写成xml文件到out DavXMLUtils.writeXMLModifiedTables(modifiedTable, out); try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "update_modifytable_to_server"); para.put("type", type); @@ -1776,7 +1829,7 @@ public class RemoteEnv extends AbstractEnv { public String[] getProcedureColumns(StoreProcedure storeProcedure, java.util.Map parameterMap) throws Exception { String[] columns; - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "list_sp"); HttpClient client = createHttpMethod(para); @@ -1790,17 +1843,15 @@ public class RemoteEnv extends AbstractEnv { columns = DavXMLUtils.readXMLSPColumns(input); return columns; } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage()); } return new String[0]; } - ; - public String[] getProcedureColumns(String name) throws Exception { String[] columns; - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "list_sp_columns_name"); para.put("name", name); @@ -1813,7 +1864,7 @@ public class RemoteEnv extends AbstractEnv { columns = DavXMLUtils.readXMLSPColumns(input); return columns; } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage()); } return new String[0]; @@ -1824,9 +1875,10 @@ public class RemoteEnv extends AbstractEnv { * * @throws Exception */ + @Override public void printLogMessage() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "get_log_message"); @@ -1840,6 +1892,7 @@ public class RemoteEnv extends AbstractEnv { } } + @Override public String getUserID() { return userID; } @@ -1867,7 +1920,7 @@ public class RemoteEnv extends AbstractEnv { String jsonParameter = jo.toString(); try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "list_sp"); para.put("pars", jsonParameter); @@ -1891,12 +1944,13 @@ public class RemoteEnv extends AbstractEnv { } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage()); } return new ProcedureDataModel[0]; } + @Override public String getAppName() { return "WebReport"; } @@ -1908,10 +1962,11 @@ public class RemoteEnv extends AbstractEnv { * @return 是返回true * @throws Exception */ + @Override public boolean isOracle(Connection database) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); DavXMLUtils.writeXMLFileDatabaseConnection(database, out); - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_get_isOracle"); InputStream input = postBytes2ServerB(out.toByteArray(), para); @@ -1921,6 +1976,7 @@ public class RemoteEnv extends AbstractEnv { return DavXMLUtils.readXMLBoolean(input); } + @Override public String[] getSupportedTypes() { return FILE_TYPE; } @@ -1930,6 +1986,7 @@ public class RemoteEnv extends AbstractEnv { * * @return 不支持返回false */ + @Override public boolean isSupportLocalFileOperate() { return false; } @@ -1940,10 +1997,11 @@ public class RemoteEnv extends AbstractEnv { * @param path 路径 * @return 有权限则返回true */ + @Override public boolean hasFileFolderAllow(String path) { HttpClient client = null; try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fs_remote_design"); para.put("cmd", "design_filefolder_allow"); para.put("current_uid", this.createUserID()); @@ -1957,7 +2015,7 @@ public class RemoteEnv extends AbstractEnv { } return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage()); return false; } @@ -1968,6 +2026,7 @@ public class RemoteEnv extends AbstractEnv { * * @return 是则返回true */ + @Override public boolean isRoot() { return isRoot; } @@ -1984,7 +2043,7 @@ public class RemoteEnv extends AbstractEnv { @Override public String getDesignerVersion() throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_get_designer_version"); para.put("user", user); @@ -1994,11 +2053,12 @@ public class RemoteEnv extends AbstractEnv { try { return stream2String(execute4InputStream(client)); } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage()); } return null; } + @Override public InputStream getDataSourceInputStream(String filePath) throws Exception { return readBean(filePath, "datasource"); } @@ -2008,7 +2068,7 @@ public class RemoteEnv extends AbstractEnv { public ArrayList getAllRole4Privilege(boolean isFS) { ArrayList allRoleList = new ArrayList(); try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "get_all_role"); para.put("isFS", String.valueOf(isFS)); @@ -2040,6 +2100,7 @@ public class RemoteEnv extends AbstractEnv { /** * 获取当前env的build文件路径 */ + @Override public String getBuildFilePath() { return StringUtils.isEmpty(buildFilePath) ? ResourceConstants.BUILD_PATH : buildFilePath; } @@ -2047,6 +2108,7 @@ public class RemoteEnv extends AbstractEnv { /** * 设置当前env的build文件路径 */ + @Override public void setBuildFilePath(String buildFilePath) { this.buildFilePath = buildFilePath; } @@ -2057,8 +2119,9 @@ public class RemoteEnv extends AbstractEnv { * @param sourceText 源代码 * @return 编译信息,有可能是成功信息,也有可能是出错或者警告信息 */ + @Override public JavaCompileInfo compilerSourceCode(String sourceText) throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_compile_source_code"); InputStream in = postBytes2ServerB(sourceText.getBytes(EncodeConstants.ENCODING_UTF_8), para); @@ -2073,37 +2136,39 @@ public class RemoteEnv extends AbstractEnv { info.parseJSON(jo); return info; } - - + @Override public String pluginServiceAction(String serviceID, String req) throws Exception { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_get_plugin_service_data"); para.put("serviceID", serviceID); para.put("req", req); - HttpClient client = createHttpMethod(para); //jim :加上user,远程设计点击预览时传递用户角色信息 + //jim :加上user,远程设计点击预览时传递用户角色信息 + HttpClient client = createHttpMethod(para); InputStream inputStream = execute4InputStream(client); return IOUtils.inputStream2String(inputStream); } /** * 远程不启动,使用虚拟服务 - * @param serviceID + * + * @param serviceID serviceID */ @Override - public void pluginServiceStart(String serviceID){ + public void pluginServiceStart(String serviceID) { } + @Override - public String[] loadREUFile() throws Exception { + public String[] loadREUFile() { ResourceIOUtils.delete(StableUtils.pathJoin( CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath(), ShareConstants.DIR_SHARE_CACHE)); String zipFilePath = null; try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_read_reufile"); para.put("current_uid", this.createUserID()); @@ -2149,7 +2214,7 @@ public class RemoteEnv extends AbstractEnv { String shareXMLName = StableUtils.pathJoin(tempFile.getAbsolutePath(), ShareConstants.NAME_XML_MODULE); String helpXMLName = StableUtils.pathJoin(tempFile.getAbsolutePath(), ShareConstants.NAME_XML_HELP); try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_install_reufile"); para.put("current_uid", this.createUserID()); @@ -2176,7 +2241,7 @@ public class RemoteEnv extends AbstractEnv { return true; } try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_remove_reufile"); para.put("current_uid", this.createUserID()); @@ -2194,7 +2259,7 @@ public class RemoteEnv extends AbstractEnv { @Override public String getSharePath() { try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "fr_remote_design"); para.put("cmd", "design_get_share_path"); para.put("current_uid", this.createUserID()); @@ -2208,32 +2273,33 @@ public class RemoteEnv extends AbstractEnv { } } + @Override public void doWhenServerShutDown() { } - + @Override public boolean isLocalEnv() { - + return false; } - + @Override public boolean hasPluginServiceStarted(String key) { return true; } - + @Override public JSONArray getPluginStatus() { - + try { - HashMap para = new HashMap(); + HashMap para = new HashMap<>(); para.put("op", "plugin"); para.put("cmd", "get_status"); para.put("current_uid", this.createUserID()); para.put("currentUsername", this.getUser()); - + HttpClient client = createHttpMethod(para); InputStream input = execute4InputStream(client); return new JSONArray(stream2String(input)); diff --git a/designer-base/src/com/fr/env/RemoteEnvPane.java b/designer-base/src/com/fr/env/RemoteEnvPane.java index 05469ec42b..12fb4d2b40 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane.java @@ -26,6 +26,7 @@ import javax.swing.JTextPane; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; +import javax.swing.UIManager; import javax.swing.border.EmptyBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -478,7 +479,12 @@ public class RemoteEnvPane extends BasicBeanPane { connect = env.testConnectionWithOutRegisteServer(this); } } catch (Exception e) { - JOptionPane.showMessageDialog(this, Inter.getLocText("Datasource-Connection_failed")); + JOptionPane.showMessageDialog( + this, + Inter.getLocText("Datasource-Connection_failed"), + UIManager.getString("OptionPane.messageDialogTitle", this.getLocale()), + JOptionPane.ERROR_MESSAGE + ); FRContext.getLogger().error(e.getMessage(), e); } if (connect) {