diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index 17afec471..621e303b1 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -6,24 +6,19 @@ import com.fr.base.StoreProcedureParameter; import com.fr.base.TableData; import com.fr.data.TableDataSource; import com.fr.data.core.DataCoreXmlUtils; +import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedureConstants; +import com.fr.design.data.tabledata.wrapper.*; import com.fr.design.DesignModelAdapter; -import com.fr.design.data.datapane.preview.PreviewTablePane; -import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper; -import com.fr.design.data.tabledata.wrapper.StoreProcedureDataWrapper; -import com.fr.design.data.tabledata.wrapper.StoreProcedureNameWrapper; -import com.fr.design.data.tabledata.wrapper.TableDataFactory; -import com.fr.design.data.tabledata.wrapper.TableDataWrapper; -import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; -import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.parameter.ParameterInputPane; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.file.DatasourceManager; import com.fr.file.DatasourceManagerProvider; import com.fr.general.ComparatorUtils; @@ -39,16 +34,8 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.io.ByteArrayOutputStream; import java.text.Collator; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Timer; -import java.util.TimerTask; /** * 设计器管理操作数据集的类: @@ -364,20 +351,7 @@ public abstract class DesignTableDataManager { * @throws Exception 异常 */ public static EmbeddedTableData previewTableDataNeedInputParameters(TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception { - return previewTableData(null, tabledata, rowCount, true, needLoadingBar); - } - - /** - * 预览需要参数的数据集 - * - * @param tabledata 数据集 - * @param rowCount 需要预览的行数 - * @param needLoadingBar 是否需要加载进度条 - * @return 数据集 - * @throws Exception 异常 - */ - public static EmbeddedTableData previewTableDataNeedInputParameters(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception { - return previewTableData(tableDataSource, tabledata, rowCount, true, needLoadingBar); + return previewTableData(tabledata, rowCount, true, needLoadingBar); } /** @@ -390,20 +364,7 @@ public abstract class DesignTableDataManager { * @throws Exception 异常 */ public static EmbeddedTableData previewTableDataNotNeedInputParameters(TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception { - return previewTableData(null, tabledata, rowCount, false, needLoadingBar); - } - - /** - * 预览不需要参数的数据集 - * - * @param tabledata 数据集 - * @param rowCount 需要预览的行数 - * @param needLoadingBar 是否需要加载进度条 - * @return 数据集 - * @throws Exception 异常 - */ - public static EmbeddedTableData previewTableDataNotNeedInputParameters(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception { - return previewTableData(tableDataSource, tabledata, rowCount, false, needLoadingBar); + return previewTableData(tabledata, rowCount, false, needLoadingBar); } /** @@ -415,7 +376,7 @@ public abstract class DesignTableDataManager { * 而获取数据集的字段名字时,则没必要 * @return */ - private static EmbeddedTableData previewTableData(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception { + private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception { final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); Env currentEnv = FRContext.getCurrentEnv(); ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata); @@ -445,7 +406,7 @@ public abstract class DesignTableDataManager { parameter.setValue(parameterMap.get(parameter.getName())); } } - return currentEnv.previewTableData(tableDataSource, tabledata, parameterMap, rowCount); + return currentEnv.previewTableData(tabledata, parameterMap, rowCount); } catch (TableDataException e) { throw new TableDataException(e.getMessage(), e); } finally { diff --git a/designer_base/src/com/fr/design/designer/TargetComponent.java b/designer_base/src/com/fr/design/designer/TargetComponent.java index 4eedfa012..ef5369b65 100644 --- a/designer_base/src/com/fr/design/designer/TargetComponent.java +++ b/designer_base/src/com/fr/design/designer/TargetComponent.java @@ -1,16 +1,16 @@ package com.fr.design.designer; -import javax.swing.*; - +import com.fr.design.DesignState; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; +import com.fr.design.mainframe.AuthorityEditPane; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; -import com.fr.design.DesignState; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.stable.StringUtils; -import com.fr.design.mainframe.*; + +import javax.swing.*; /** * 模板设计界面 @@ -31,7 +31,7 @@ public abstract class TargetComponent extends JComponent { public abstract void stopEditing(); - public final T getTarget() { + public T getTarget() { return target; } diff --git a/designer_base/src/com/fr/env/RemoteEnv.java b/designer_base/src/com/fr/env/RemoteEnv.java index 72a20cf93..2188b322b 100644 --- a/designer_base/src/com/fr/env/RemoteEnv.java +++ b/designer_base/src/com/fr/env/RemoteEnv.java @@ -1,16 +1,7 @@ package com.fr.env; -import com.fr.base.AbstractEnv; -import com.fr.base.EnvException; -import com.fr.base.FRContext; -import com.fr.base.FRCoreContext; -import com.fr.base.ModifiedTable; -import com.fr.base.Parameter; -import com.fr.base.StoreProcedureParameter; -import com.fr.base.TableData; -import com.fr.base.Utils; +import com.fr.base.*; import com.fr.base.remote.RemoteDeziConstants; -import com.fr.data.TableDataSource; import com.fr.data.core.DataCoreUtils; import com.fr.data.core.db.TableProcedure; import com.fr.data.impl.Connection; @@ -26,34 +17,17 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; -import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.file.CacheManager; import com.fr.file.DatasourceManager; import com.fr.file.DatasourceManagerProvider; import com.fr.file.filetree.FileNode; -import com.fr.general.ComparatorUtils; -import com.fr.general.FRLogger; -import com.fr.general.IOUtils; -import com.fr.general.Inter; -import com.fr.general.LogRecordTime; -import com.fr.general.VT4FR; +import com.fr.general.*; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginLicense; -import com.fr.plugin.PluginLicenseManager; -import com.fr.plugin.PluginLoader; import com.fr.share.ShareConstants; -import com.fr.stable.ArrayUtils; -import com.fr.stable.EncodeConstants; -import com.fr.stable.JavaCompileInfo; -import com.fr.stable.LicUtils; -import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; -import com.fr.stable.StringUtils; -import com.fr.stable.SvgProvider; +import com.fr.stable.*; import com.fr.stable.file.XMLFileManagerProvider; import com.fr.stable.project.ProjectConstants; import com.fr.stable.xml.XMLPrintWriter; @@ -62,38 +36,17 @@ import com.fr.stable.xml.XMLableReader; import com.fr.web.ResourceConstants; import javax.swing.*; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; +import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import java.awt.*; -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; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; +import java.io.*; import java.net.HttpURLConnection; import java.net.NoRouteToHostException; import java.net.Socket; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; +import java.util.*; import java.util.List; -import java.util.Map; import java.util.Timer; -import java.util.TimerTask; import java.util.logging.Level; import java.util.regex.Pattern; @@ -159,15 +112,6 @@ public class RemoteEnv extends AbstractEnv { return password; } - // 修复密码中包含特殊字符,无法登录的问题 - private String getEncodedPassword() { - try { - return URLEncoder.encode(password, "UTF-8"); - } catch (UnsupportedEncodingException e) { - return password; - } - } - public void setPassword(String password) { this.password = password; clearUserID(); @@ -231,12 +175,8 @@ public class RemoteEnv extends AbstractEnv { * 根据nameValuePairs,也就是参数对,生成PostMethod,不同之处在于,参数拼在path后面,不是method.addParameters */ private HttpClient createHttpMethod2(HashMap para) throws EnvException { - StringBuilder sb = new StringBuilder(path); - - sb.append('?'); - sb.append("id=").append(createUserID()); - - return new HttpClient(sb.toString(), para, true); + String methodPath = path + '?' + "id=" + createUserID(); + return new HttpClient(methodPath, para, true); } @@ -393,7 +333,7 @@ public class RemoteEnv extends AbstractEnv { para.put("op", "fr_remote_design"); para.put("cmd", "test_server_connection"); para.put("user", user); - para.put("password", getEncodedPassword()); + para.put("password", password); if (path.startsWith("https") && (!DesignerEnvManager.getEnvManager().isHttps())) { return false; @@ -418,7 +358,7 @@ public class RemoteEnv extends AbstractEnv { 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.indexOf("RegistEditionException") != -1) { + } else if (res.contains("RegistEditionException")) { if (needMessage) { JOptionPane.showMessageDialog(parentComponent, Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); } else { @@ -439,7 +379,6 @@ public class RemoteEnv extends AbstractEnv { private void extraChangeEnvPara() { //在env连接之前, 加载一下不依赖env的插件. 看看需不需要改变参数. - PluginLoader.init(); DesignerEnvProcessor envProcessor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG); if (envProcessor != null) { this.path = envProcessor.changeEnvPathBeforeConnect(user, password, path); @@ -472,9 +411,8 @@ public class RemoteEnv extends AbstractEnv { para.put("op", "fr_remote_design"); para.put("cmd", "heart_beat"); para.put("user", user); - para.put("userid", userID); - HttpClient client = createHttpMethod(para, true); + HttpClient client = createHttpMethod(para); execute4InputStream(client); //这做法不好, 30秒刷一次, 刷新的时候会重新构建树, 构建完会把子节点都收缩起来, 效果太差. @@ -516,7 +454,7 @@ public class RemoteEnv extends AbstractEnv { para.put("op", "fr_remote_design"); para.put("cmd", "r_sign_in"); para.put("user", user); - para.put("password", getEncodedPassword()); + para.put("password", password); simulaRPC(para, true); @@ -609,7 +547,7 @@ public class RemoteEnv extends AbstractEnv { if (resJSON == null) { return false; } - if (resJSON.indexOf("RegistEditionException") != -1) { + if (resJSON.contains("RegistEditionException")) { JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Lic_does_not_Support_Remote")); return false; } @@ -1264,11 +1202,6 @@ public class RemoteEnv extends AbstractEnv { return DavXMLUtils.readXMLParameters(input); } - @Override - public EmbeddedTableData previewTableData(Object tableData, Map parameterMap, int rowCount) throws Exception { - return previewTableData(null, tableData, parameterMap, rowCount); - } - /** * 根据指定的参数生成一个实际可预览的数据集 * @@ -1278,7 +1211,7 @@ public class RemoteEnv extends AbstractEnv { * @return 实际的二维数据集 * @throws Exception 如果生成数据失败则抛出此异常 */ - public EmbeddedTableData previewTableData(TableDataSource dataSource, Object tableData, java.util.Map parameterMap, int rowCount) throws Exception { + public EmbeddedTableData previewTableData(Object tableData, java.util.Map parameterMap, int rowCount) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); // 把tableData写成xml文件到out @@ -1317,11 +1250,6 @@ public class RemoteEnv extends AbstractEnv { return previewTableData(tableData, parameterMap, -1); } - @Override - public Object previewTableData(TableDataSource dataSource, Object tableData, Map parameterMap, int start, int end, String[] cols, int[] colIdx) throws Exception { - return previewTableData(dataSource, tableData, parameterMap, -1); - } - /** * nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的 * @@ -1448,17 +1376,13 @@ public class RemoteEnv extends AbstractEnv { return; } SignIn.signIn(remoteEnv); - resetLicenseBytes(); + FRCoreContext.resetBytes(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); } catch (Exception em) { FRContext.getLogger().error(em.getMessage(), em); } } - private void resetLicenseBytes() { - FRCoreContext.retryLicLock(); - } - /** * 停止连接 */ @@ -1858,8 +1782,7 @@ public class RemoteEnv extends AbstractEnv { } LogRecordTime[] records = DavXMLUtils.readXMLLogRecords(input); for (LogRecordTime logRecordTime : records) { - DesignerLogHandler.getInstance().printRemoteLog(logRecordTime); - + //TODO } } @@ -2011,7 +1934,7 @@ public class RemoteEnv extends AbstractEnv { para.put("op", "fr_remote_design"); para.put("cmd", "design_get_designer_version"); para.put("user", user); - para.put("password", getEncodedPassword()); + para.put("password", password); HttpClient client = createHttpMethod(para, true); try { @@ -2058,7 +1981,8 @@ public class RemoteEnv extends AbstractEnv { public void setLicName(String licName) { //do nth } - + + /** * 获取当前env的build文件路径 */ @@ -2094,74 +2018,8 @@ public class RemoteEnv extends AbstractEnv { info.parseJSON(jo); return info; } - - /** - * 将文件拷贝到插件目录 - * - * @param dir 要拷贝的文件 - * @param plugin 插件 - */ - public void copyFilesToPluginAndLibFolder(File dir, Plugin plugin) throws Exception { - - } - - /** - * 将文件添加到指定目录或者删除指定目录的文件 - * - * @param file 解压插件的临时目录 - * @param plugin 当前处理的插件 - */ - public void movePluginEmbFile(File file, Plugin plugin) throws Exception { - - } - - /** - * 将文件从插件目录删除 - * - * @param plugin 要删除插件 - * @return 同上 - */ - public String[] deleteFileFromPluginAndLibFolder(Plugin plugin) { - return new String[0]; - } - - /** - * 保存插件的配置文件 - * - * @param plugin 插件 - */ - public void writePlugin(Plugin plugin) throws Exception { - - } - - - /** - * 获取插件的配置目录 - * - * @param plugin - */ - public String getPluginFilePath(Plugin plugin) { - - return StringUtils.EMPTY; - } - - public void readPluginLicenses() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - HashMap para = new HashMap(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_plugin_licenses"); - - InputStream inputStream = postBytes2ServerB(out.toByteArray(), para); - String pluginsLicensesStr = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); - if (StringUtils.isNotBlank(pluginsLicensesStr) && pluginsLicensesStr.startsWith("[")) { - JSONArray jsonArray = new JSONArray(pluginsLicensesStr); - for (int i = 0; i < jsonArray.length(); i++) { - PluginLicense pluginLicense = new PluginLicense(); - pluginLicense.parseJSON(jsonArray.getJSONObject(i)); - PluginLicenseManager.getInstance().addRemotePluginLicense(pluginLicense); - } - } - } + + @Override public String pluginServiceAction(String serviceID, String req) throws Exception { @@ -2182,12 +2040,6 @@ public class RemoteEnv extends AbstractEnv { @Override public void pluginServiceStart(String serviceID){ } - - @Override - public void checkAndRegisterLic(FileNode node, Plugin plugin) throws Exception { - - } - @Override public File[] loadREUFile() throws Exception { File target = new File(CacheManager.getProviderInstance().getCacheDirectory(), @@ -2303,9 +2155,34 @@ public class RemoteEnv extends AbstractEnv { return StringUtils.EMPTY; } } - + @Override - public void doWhenServerShutDown() { + public boolean isLocalEnv() { + + return false; + } + + @Override + public boolean hasPluginServiceStarted(String key) { + return true; + } + + @Override + public JSONArray getPluginStatus() { + + try { + 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)); + } catch (Exception e) { + return JSONArray.create(); + } } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 0a4aa9894..0d7f93c08 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -12,7 +12,11 @@ import com.fr.design.designer.beans.actions.FormDeleteAction; import com.fr.design.designer.beans.actions.PasteAction; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.*; +import com.fr.design.designer.creator.XComponent; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWAbsoluteBodyLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; @@ -499,6 +503,24 @@ public class JForm extends JTemplate implements BaseJForm { } + @Override + public void setTarget(Form form) { + if (this.formDesign == null) { + super.setTarget(form); + return; + } + this.formDesign.setTarget(form); + } + + @Override + public Form getTarget() { + if (this.formDesign == null) { + return super.getTarget(); + } + + return this.formDesign.getTarget(); + } + @Override protected FormModelAdapter createDesignModel() { return new FormModelAdapter(this);