Browse Source

依赖FineKit

master
richie 5 years ago
parent
commit
d0e5bac556
  1. 18
      src/main/java/com/fr/plugin/file/download/oss/OssFile2Image.java
  2. 8
      src/main/java/com/fr/plugin/file/submit/oss/OssHyperlink4Download.java
  3. 6
      src/main/java/com/fr/plugin/file/submit/oss/OssHyperlinkJavaScriptHandler.java
  4. 6
      src/main/java/com/fr/plugin/file/submit/oss/OssJavaScriptActionBridge.java
  5. 4
      src/main/java/com/fr/plugin/file/submit/oss/OssSubmitUIBridge.java
  6. 6
      src/main/java/com/fr/plugin/file/submit/oss/OssURLAliasProvider.java
  7. 26
      src/main/java/com/fr/plugin/file/submit/oss/conf/FileSubmitOssServerConfig.java
  8. 16
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssDownloadHttpHandler.java
  9. 29
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTarget.java
  10. 6
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTargetConfig.java
  11. 36
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssUpload.java
  12. 38
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssUploadHttpHandler.java
  13. 26
      src/main/java/com/fr/plugin/file/submit/oss/fun/OssVariableValue.java
  14. 4
      src/main/java/com/fr/plugin/file/submit/oss/job/OssSubmitJob.java
  15. 73
      src/main/java/com/fr/plugin/file/submit/oss/script/OssDownloadHyperlink.java
  16. 15
      src/main/java/com/fr/plugin/file/submit/oss/script/OssSubmitJavaScript.java
  17. 8
      src/main/java/com/fr/plugin/file/submit/oss/ui/Editors.java
  18. 29
      src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlink4DownloadPane.java
  19. 3
      src/main/java/com/fr/plugin/file/submit/oss/ui/OssPathConfigPane.java
  20. 6
      src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitJavaScriptPane.java
  21. 47
      src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitPathTableModel.java
  22. 4
      src/main/java/com/fr/plugin/file/submit/oss/ui/tools/RewriteAction.java

18
src/main/java/com/fr/plugin/file/download/oss/OssFile2Image.java

@ -2,12 +2,12 @@ package com.fr.plugin.file.download.oss;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.OSSObject;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.util.IOKit;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.oss.universal.config.OssUniversalConfig;
import com.fr.script.AbstractFunction;
import com.fr.stable.ArrayUtils;
import com.fanruan.api.util.ArrayKit;
import com.fr.stable.Primitive;
import javax.imageio.ImageIO;
@ -21,22 +21,22 @@ public class OssFile2Image extends AbstractFunction {
@Override
public Object run(Object[] args) {
int len = ArrayUtils.getLength(args);
int len = ArrayKit.getLength(args);
if (len < 2) {
return Primitive.ERROR_VALUE;
}
String key = GeneralUtils.objectToString(args[0]);
String bucket = GeneralUtils.objectToString(args[1]);
String key = GeneralKit.objectToString(args[0]);
String bucket = GeneralKit.objectToString(args[1]);
OSSClient ossClient = new OSSClient(
OssUniversalConfig.getInstance().getEndPoint(),
OssUniversalConfig.getInstance().getAccessKeyId(),
OssUniversalConfig.getInstance().getRealAccessKeySecret());
OSSObject object = ossClient.getObject(bucket, key);
byte[] bytes = IOUtils.inputStream2Bytes(object.getObjectContent());
byte[] bytes = IOKit.inputStream2Bytes(object.getObjectContent());
try {
return ImageIO.read(new ByteArrayInputStream(bytes));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
LogKit.error(e.getMessage(), e);
return Primitive.ERROR_VALUE;
}
}

8
src/main/java/com/fr/plugin/file/submit/oss/OssHyperlink4Download.java

@ -3,10 +3,10 @@ package com.fr.plugin.file.submit.oss;
import com.fr.design.fun.impl.AbstractHyperlinkProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.i18n.Toolkit;
import com.fanruan.api.design.DesignKit;
import com.fr.plugin.file.submit.oss.script.OssDownloadHyperlink;
import com.fr.plugin.file.submit.oss.ui.OssHyperlink4DownloadPane;
import com.fr.stable.AssistUtils;
import com.fanruan.api.util.AssistKit;
public class OssHyperlink4Download extends AbstractHyperlinkProvider {
@ -14,7 +14,7 @@ public class OssHyperlink4Download extends AbstractHyperlinkProvider {
public OssHyperlink4Download() {
nameableCreator = new NameObjectCreator(
Toolkit.i18nText("Plugin-File_Download_Oss"),
DesignKit.i18nText("Plugin-File_Download_Oss"),
OssDownloadHyperlink.class,
OssHyperlink4DownloadPane.class);
}
@ -27,7 +27,7 @@ public class OssHyperlink4Download extends AbstractHyperlinkProvider {
@Override
public boolean equals(Object o) {
return o instanceof OssHyperlink4Download
&& AssistUtils.equals(((OssHyperlink4Download) o).nameableCreator, nameableCreator);
&& AssistKit.equals(((OssHyperlink4Download) o).nameableCreator, nameableCreator);
}

6
src/main/java/com/fr/plugin/file/submit/oss/OssHyperlinkJavaScriptHandler.java

@ -1,13 +1,15 @@
package com.fr.plugin.file.submit.oss;
import com.fr.base.TemplateUtils;
import com.fanruan.api.util.RenderKit;
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler;
import java.util.Collections;
public class OssHyperlinkJavaScriptHandler extends AbstractJavaScriptFileHandler {
@Override
public String[] pathsForFiles() {
try {
String text = TemplateUtils.render("${fineServletURL}");
String text = RenderKit.renderParameter4Tpl("${fineServletURL}", Collections.EMPTY_MAP);
System.out.println(text);
} catch (Exception e) {
e.printStackTrace();

6
src/main/java/com/fr/plugin/file/submit/oss/OssJavaScriptActionBridge.java

@ -2,7 +2,7 @@ package com.fr.plugin.file.submit.oss;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.fun.impl.AbstractJavaScriptActionProvider;
import com.fr.design.mainframe.DesignerContext;
import com.fanruan.api.design.DesignKit;
import com.fr.js.JavaScript;
import com.fr.plugin.file.submit.oss.ui.OssSubmitJavaScriptPane;
@ -12,8 +12,8 @@ public class OssJavaScriptActionBridge extends AbstractJavaScriptActionProvider
public FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane() {
return new OssSubmitJavaScriptPane();
}
@Override
public boolean isSupportType() {
return DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook();
return DesignKit.getDesignerFrame().getSelectedJTemplate().isJWorkBook();
}
}

4
src/main/java/com/fr/plugin/file/submit/oss/OssSubmitUIBridge.java

@ -2,7 +2,7 @@ package com.fr.plugin.file.submit.oss;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.impl.AbstractSubmitProvider;
import com.fr.design.i18n.Toolkit;
import com.fanruan.api.design.DesignKit;
import com.fr.plugin.file.submit.oss.fun.OssConstants;
import com.fr.plugin.file.submit.oss.ui.OssPathConfigPane;
@ -14,7 +14,7 @@ public class OssSubmitUIBridge extends AbstractSubmitProvider {
@Override
public String dataForSubmit() {
return Toolkit.i18nText("Plugin-File_Submit_Oss");
return DesignKit.i18nText("Plugin-File_Submit_Oss");
}
@Override

6
src/main/java/com/fr/plugin/file/submit/oss/OssURLAliasProvider.java

@ -1,15 +1,15 @@
package com.fr.plugin.file.submit.oss;
import com.fr.decision.webservice.url.alias.URLAlias;
import com.fr.decision.webservice.url.alias.URLAliasFactory;
import com.fanruan.api.net.URLAliasKit;
import com.fr.decision.webservice.url.provider.AbstractURLAliasProvider;
public class OssURLAliasProvider extends AbstractURLAliasProvider {
@Override
public URLAlias[] registerAlias() {
return new URLAlias[]{
URLAliasFactory.createPluginAlias("/oss/download", "/oss/download", true),
URLAliasFactory.createPluginAlias("/oss/upload", "/oss/upload", true)
URLAliasKit.createPluginAlias("/oss/download", "/oss/download", true),
URLAliasKit.createPluginAlias("/oss/upload", "/oss/upload", true)
};
}
}

26
src/main/java/com/fr/plugin/file/submit/oss/conf/FileSubmitOssServerConfig.java

@ -1,53 +1,47 @@
package com.fr.plugin.file.submit.oss.conf;
import com.fr.config.ConfigContext;
import com.fr.config.DefaultConfiguration;
import com.fanruan.api.conf.BaseConfiguration;
import com.fr.config.Identifier;
import com.fr.config.Status;
import com.fr.config.Visualization;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.config.holder.impl.ColConf;
import com.fr.config.holder.impl.ObjConf;
import com.fanruan.api.conf.HolderKit;
import com.fanruan.api.conf.impl.ColConf;
import com.fr.intelli.record.Focus;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.collections4.CollectionUtils;
import com.fanruan.api.util.StringKit;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* OSS文件上传下载所使用的OSS配置
*/
@Visualization(category = "Plugin-Oss_Settings")
@EnableMetrics
public class FileSubmitOssServerConfig extends DefaultConfiguration {
public class FileSubmitOssServerConfig extends BaseConfiguration {
private static volatile FileSubmitOssServerConfig instance = null;
public static FileSubmitOssServerConfig getInstance() {
if (instance == null) {
instance = ConfigContext.getConfigInstance(FileSubmitOssServerConfig.class);
instance = BaseConfiguration.getConfigInstance(FileSubmitOssServerConfig.class);
}
return instance;
}
// 地域节点配置信息
@Identifier(value = "endPoint", name = "EndPoint", description = "Plugin-Oss_End_Point", status = Status.SHOW)
private Conf<String> endPoint = Holders.simple(StringUtils.EMPTY);
private Conf<String> endPoint = HolderKit.simple(StringKit.EMPTY);
@Identifier(value = "accessKeyId", name = "AccessKeyId", description = "Plugin-Oss_AccessKeyId", status = Status.SHOW)
private Conf<String> accessKeyId = Holders.simple(StringUtils.EMPTY);
private Conf<String> accessKeyId = HolderKit.simple(StringKit.EMPTY);
@Identifier(value = "accessKeySecret", name = "AccessKeySecret", description = "Plugin-Oss_AccessKeySecret", status = Status.SHOW)
private Conf<String> accessKeySecret = Holders.simple(StringUtils.EMPTY);
private Conf<String> accessKeySecret = HolderKit.simple(StringKit.EMPTY);
@Identifier(value = "buckets", name = "Buckets", description = "Plugin-Oss_Buckets", status = Status.SHOW)
private ColConf<Collection<String>> buckets = Holders.collection(new ArrayList<String>(), String.class);
private ColConf<Collection<String>> buckets = HolderKit.collection(new ArrayList<String>(), String.class);
public String getEndPoint() {
return endPoint.get();

16
src/main/java/com/fr/plugin/file/submit/oss/fun/OssDownloadHttpHandler.java

@ -3,12 +3,11 @@ package com.fr.plugin.file.submit.oss.fun;
import com.aliyun.oss.HttpMethod;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.GeneratePresignedUrlRequest;
import com.fr.data.NetworkHelper;
import com.fanruan.api.net.NetworkKit;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.plugin.oss.universal.config.OssUniversalConfig;
import com.fr.stable.StableUtils;
import com.fanruan.api.util.GeneralKit;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -18,6 +17,7 @@ import java.util.Calendar;
import java.util.Date;
public class OssDownloadHttpHandler extends BaseHttpHandler {
@Override
public RequestMethod getMethod() {
return RequestMethod.POST;
@ -35,10 +35,10 @@ public class OssDownloadHttpHandler extends BaseHttpHandler {
@Override
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
String bucket = NetworkHelper.getHTTPRequestParameter(req, "bucket");
String directory = NetworkHelper.getHTTPRequestParameter(req, "directory");
String fileName = NetworkHelper.getHTTPRequestParameter(req, "fileName");
PrintWriter writer = WebUtils.createPrintWriter(res);
String bucket = NetworkKit.getHTTPRequestParameter(req, "bucket");
String directory = NetworkKit.getHTTPRequestParameter(req, "directory");
String fileName = NetworkKit.getHTTPRequestParameter(req, "fileName");
PrintWriter writer = NetworkKit.createPrintWriter(res);
writer.write(createDownloadUrl(bucket, directory, fileName));
writer.flush();
writer.close();
@ -54,7 +54,7 @@ public class OssDownloadHttpHandler extends BaseHttpHandler {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 1);
Date expiration = calendar.getTime();
String key = StableUtils.pathJoin(directory, fileName);
String key = GeneralKit.pathJoin(directory, fileName);
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, key, HttpMethod.GET);
// 设置过期时间。
request.setExpiration(expiration);

29
src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTarget.java

@ -1,8 +1,8 @@
package com.fr.plugin.file.submit.oss.fun;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import com.fanruan.api.xml.XmlKit;
import com.fanruan.api.util.AssistKit;
import com.fanruan.api.util.StringKit;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader;
@ -64,39 +64,40 @@ public class OssSubmitTarget implements XMLable {
if ("Bucket".equals(tagName)) {
this.bucket = reader.getElementValue();
} else if ("Directory".equals(tagName)) {
this.directory = (OssVariableValue) GeneralXMLTools.readXMLable(reader);
this.directory = (OssVariableValue) XmlKit.readXMLable(reader);
} else if ("Name".equals(tagName)) {
this.name = (OssVariableValue) GeneralXMLTools.readXMLable(reader);
this.name = (OssVariableValue) XmlKit.readXMLable(reader);
} else if ("File".equals(tagName)) {
this.file = (OssVariableValue) GeneralXMLTools.readXMLable(reader);
this.file = (OssVariableValue) XmlKit.readXMLable(reader);
}
}
}
public void writeXML(final XMLPrintWriter writer) {
if (StringUtils.isNotEmpty(bucket)) {
if (StringKit.isNotEmpty(bucket)) {
writer.startTAG("Bucket").textNode(bucket).end();
}
if (directory != null) {
GeneralXMLTools.writeXMLable(writer, directory, "Directory");
XmlKit.writeXMLable(writer, directory, "Directory");
}
if (name != null) {
GeneralXMLTools.writeXMLable(writer, name, "Name");
XmlKit.writeXMLable(writer, name, "Name");
}
if (file != null) {
GeneralXMLTools.writeXMLable(writer, file, "File");
XmlKit.writeXMLable(writer, file, "File");
}
}
@Override
public boolean equals(final Object o) {
return o instanceof OssSubmitTarget
&& AssistUtils.equals(((OssSubmitTarget) o).bucket, bucket)
&& AssistUtils.equals(((OssSubmitTarget) o).directory, directory)
&& AssistUtils.equals(((OssSubmitTarget) o).name, name)
&& AssistUtils.equals(((OssSubmitTarget) o).file, file);
&& AssistKit.equals(((OssSubmitTarget) o).bucket, bucket)
&& AssistKit.equals(((OssSubmitTarget) o).directory, directory)
&& AssistKit.equals(((OssSubmitTarget) o).name, name)
&& AssistKit.equals(((OssSubmitTarget) o).file, file);
}
@Override
public Object clone() throws CloneNotSupportedException {
OssSubmitTarget cloned = (OssSubmitTarget) super.clone();
cloned.bucket = bucket;

6
src/main/java/com/fr/plugin/file/submit/oss/fun/OssSubmitTargetConfig.java

@ -1,6 +1,6 @@
package com.fr.plugin.file.submit.oss.fun;
import com.fr.general.xml.GeneralXMLTools;
import com.fanruan.api.xml.XmlKit;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLable;
@ -40,7 +40,7 @@ public class OssSubmitTargetConfig implements XMLable {
if (xmLableReader.isChildNode()) {
String tagName = xmLableReader.getTagName();
if (OssSubmitTarget.XML_TAG.equals(tagName)) {
OssSubmitTarget target = (OssSubmitTarget)GeneralXMLTools.readXMLable(xmLableReader);
OssSubmitTarget target = (OssSubmitTarget)XmlKit.readXMLable(xmLableReader);
targets.add(target);
}
}
@ -52,7 +52,7 @@ public class OssSubmitTargetConfig implements XMLable {
@Override
public void writeXML(XMLPrintWriter writer) {
for (OssSubmitTarget target : targets) {
GeneralXMLTools.writeXMLable(writer, target, OssSubmitTarget.XML_TAG);
XmlKit.writeXMLable(writer, target, OssSubmitTarget.XML_TAG);
}
}

36
src/main/java/com/fr/plugin/file/submit/oss/fun/OssUpload.java

@ -3,34 +3,36 @@ package com.fr.plugin.file.submit.oss.fun;
import com.aliyun.oss.OSSClient;
import com.fr.cache.Attachment;
import com.fr.general.FArray;
import com.fr.general.GeneralUtils;
import com.fr.locale.InterProviderFactory;
import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.i18n.I18nKit;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fanruan.api.util.StringKit;
import com.fr.stable.xml.FRFile;
import java.io.ByteArrayInputStream;
public class OssUpload {
public static void upload(Calculator calculator, OSSClient ossClient, OssSubmitTargetConfig submitTargetConfig) throws Exception {
public static void upload(Calculator calculator, OSSClient ossClient, OssSubmitTargetConfig submitTargetConfig)
throws Exception {
OssSubmitTarget[] submitTargets = submitTargetConfig.getSubmitTargets();
for (OssSubmitTarget target : submitTargets) {
OssVariableValue fileObject = target.getFile();
String filePath = GeneralUtils.objectToString(fileObject);
String filePath = GeneralKit.objectToString(fileObject);
Object file = calculator.evalValue(filePath);
uploadFile(ossClient, target.getBucket(), file,
target.getDirectory() == null ? null : target.getDirectory().getResult(calculator),
target.getName() == null ? null : target.getName().getResult(calculator));
}
}
private static void uploadFile( OSSClient ossClient, String bucket, Object file, String directory, String newFileName) {
private static void uploadFile(OSSClient ossClient, String bucket, Object file, String directory,
String newFileName) {
if (file instanceof FRFile) {
uploadSingleFile(ossClient, bucket, directory, combineName(((FRFile) file).getFileName(), newFileName), ((FRFile) file).getBytes());
uploadSingleFile(ossClient, bucket, directory, combineName(((FRFile) file).getFileName(), newFileName),
((FRFile) file).getBytes());
} else if (file instanceof FArray && ((FArray) file).length() != 0) {
FArray array = (FArray) file;
for (int i = 0; i < array.length(); i++) {
@ -40,28 +42,28 @@ public class OssUpload {
uploadFile(ossClient, bucket, element, directory, newFileName);
}
} else {
uploadSingleFile(ossClient, bucket, directory, combineName(((Attachment) element).getFilename(), newFileName), ((Attachment) element).getBytes());
uploadSingleFile(ossClient, bucket, directory,
combineName(((Attachment) element).getFilename(), newFileName),
((Attachment) element).getBytes());
}
}
}
}
private static void uploadSingleFile(OSSClient ossClient, String bucket, String directory, String newFileName, byte[] bytes) {
private static void uploadSingleFile(OSSClient ossClient, String bucket, String directory, String newFileName,
byte[] bytes) {
if (ArrayUtils.isEmpty(bytes)) {
throw new RuntimeException(InterProviderFactory.getProvider().getLocText("Plugin-File_Submit_Oss_Failed", newFileName));
throw new RuntimeException(I18nKit.getLocText("Plugin-File_Submit_Oss_Failed", newFileName));
}
ossClient.putObject(bucket, directory + "/" + newFileName, new ByteArrayInputStream(bytes));
}
/*
* 这里的逻辑是
* 1如果没有设置文件名就用上传的文件的名字
* 2如果设置了文件名且带有文件后缀就用设置的文件名
* 3其他情况都用原文件名
/**
* 这里的逻辑是 1如果没有设置文件名就用上传的文件的名字 2如果设置了文件名且带有文件后缀就用设置的文件名 3其他情况都用原文件名
*/
private static String combineName(String fileName, String myFileName) {
String realFileName;
if (StringUtils.isBlank(fileName)) {
if (StringKit.isBlank(fileName)) {
fileName = "unnamed.png";
}
if (StringUtils.isNotEmpty(myFileName)) {

38
src/main/java/com/fr/plugin/file/submit/oss/fun/OssUploadHttpHandler.java

@ -1,15 +1,15 @@
package com.fr.plugin.file.submit.oss.fun;
import com.aliyun.oss.OSSClient;
import com.fr.base.ParameterMapNameSpace;
import com.fr.data.NetworkHelper;
import com.fr.stable.script.NameSpace;
import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.net.NetworkKit;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.json.JSON;
import com.fanruan.api.xml.XmlKit;
import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.json.JSONKit;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.file.submit.oss.script.OssSubmitJavaScript;
import com.fr.plugin.oss.universal.config.OssUniversalConfig;
import com.fr.script.Calculator;
@ -18,7 +18,7 @@ import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.web.core.ReportSessionIDInfor;
import com.fr.web.core.SessionPoolManager;
import com.fr.web.session.SessionIDInfo;
import com.fr.web.utils.WebUtils;
import com.fanruan.api.session.SessionKit;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -42,23 +42,23 @@ public class OssUploadHttpHandler extends BaseHttpHandler {
@Override
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
final String httpRequestEncodeParameter = NetworkHelper.getHTTPRequestEncodeParameter(req, "xmlconf", true);
final String httpRequestEncodeParameter = NetworkKit.getHTTPRequestEncodeParameter(req, "xmlconf", true);
if (httpRequestEncodeParameter != null) {
String sessionID = NetworkHelper.getHTTPRequestParameter(req, "sessionID");
String sessionID = NetworkKit.getHTTPRequestParameter(req, "sessionID");
final ReportSessionIDInfor reportSessionIDInfor = SessionPoolManager.getSessionIDInfor(sessionID, ReportSessionIDInfor.class);
if (reportSessionIDInfor == null) {
return;
}
final OssSubmitJavaScript javaScript = (OssSubmitJavaScript) GeneralXMLTools.readStringAsXMLable(httpRequestEncodeParameter);
final OssSubmitJavaScript javaScript = (OssSubmitJavaScript) XmlKit.readStringAsXMLable(httpRequestEncodeParameter);
if (javaScript == null) {
return;
}
final Calculator calculator = Calculator.createCalculator();
final ParameterMapNameSpace create = ParameterMapNameSpace.create(WebUtils.parameters4SessionIDInfor(req));
final NameSpace create = ParameterKit.createParameterMapNameSpace(SessionKit.parameters4SessionIDInfor(req));
calculator.pushNameSpace(create);
this.initCalAttrAndNS(calculator, reportSessionIDInfor, req);
boolean b = true;
final JSONObject jsonObject = JSONObject.create();
final JSONObject jsonObject = JSONKit.create();
OSSClient ossClient = new OSSClient(
OssUniversalConfig.getInstance().getEndPoint(),
OssUniversalConfig.getInstance().getAccessKeyId(),
@ -66,16 +66,16 @@ public class OssUploadHttpHandler extends BaseHttpHandler {
try {
this.process(ossClient, javaScript, calculator);
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
LogKit.error(ex.getMessage(), ex);
b = false;
jsonObject.put("errorMsg", ex.getMessage());
} finally {
ossClient.shutdown();
}
calculator.removeNameSpace(create);
final PrintWriter printWriter = WebUtils.createPrintWriter(res);
final JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY);
final JSONObject jsonObject2 = JSONFactory.createJSON(JSON.OBJECT);
final PrintWriter printWriter = NetworkKit.createPrintWriter(res);
final JSONArray jsonArray = JSONKit.createJSONArray();
final JSONObject jsonObject2 = JSONKit.create();
jsonObject.put("success", b);
jsonObject2.put("oss_submit_info", jsonObject);
jsonArray.put(jsonObject2);
@ -90,10 +90,10 @@ public class OssUploadHttpHandler extends BaseHttpHandler {
}
private void initCalAttrAndNS(final Calculator calculator, final ReportSessionIDInfor reportSessionIDInfor, final HttpServletRequest httpServletRequest) {
calculator.setAttribute(Calculator.SHEET_NUMBER_KEY, WebUtils.getHTTPRequestParameter(httpServletRequest, "sheetNum"));
calculator.setAttribute(Calculator.SHEET_NUMBER_KEY, NetworkKit.getHTTPRequestParameter(httpServletRequest, "sheetNum"));
reportSessionIDInfor.setUpAttribute4dbCommit(calculator);
calculator.pushNameSpace(ParameterMapNameSpace.create(reportSessionIDInfor.getParameterMap4Execute()));
final ColumnRow value = ColumnRow.valueOf(WebUtils.getHTTPRequestParameter(httpServletRequest, "location"));
calculator.pushNameSpace(ParameterKit.createParameterMapNameSpace(reportSessionIDInfor.getParameterMap4Execute()));
final ColumnRow value = ColumnRow.valueOf(NetworkKit.getHTTPRequestParameter(httpServletRequest, "location"));
if (value != ColumnRow.ERROR) {
calculator.setAttribute(ColumnRow.CURRENT_CR_KEY, value);
}

26
src/main/java/com/fr/plugin/file/submit/oss/fun/OssVariableValue.java

@ -1,10 +1,10 @@
package com.fr.plugin.file.submit.oss.fun;
import com.fr.base.BaseFormula;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
import com.fr.stable.StringUtils;
import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.cal.FormulaKit;
import com.fanruan.api.util.StringKit;
import com.fr.stable.UtilEvalError;
import com.fr.stable.script.CalculatorProvider;
import com.fr.stable.xml.XMLPrintWriter;
@ -28,8 +28,8 @@ public class OssVariableValue implements XMLable {
type = Type.FORMULA;
this.value = value;
} else {
String content = GeneralUtils.objectToString(value);
if (CommonUtils.canBeFormula(content)) {
String content = GeneralKit.objectToString(value);
if (FormulaKit.canBeFormula(content)) {
type = Type.FORMULA;
this.value = BaseFormula.createFormulaBuilder().build(content);
} else {
@ -51,7 +51,7 @@ public class OssVariableValue implements XMLable {
if (type == Type.FORMULA) {
return ((BaseFormula)value).getPureContent();
} else {
return GeneralUtils.objectToString(value);
return GeneralKit.objectToString(value);
}
}
@ -61,10 +61,10 @@ public class OssVariableValue implements XMLable {
try {
result = ((BaseFormula) value).evalValue(cal);
} catch (UtilEvalError u) {
FineLoggerFactory.getLogger().error(u.getMessage(), u);
LogKit.error(u.getMessage(), u);
}
}
return GeneralUtils.objectToString(result);
return GeneralKit.objectToString(result);
}
@Override
@ -74,9 +74,9 @@ public class OssVariableValue implements XMLable {
if ("Attr".equals(tagName)) {
type = Type.parse(reader.getAttrAsInt("type", 0));
if (type == Type.FORMULA) {
value = BaseFormula.createFormulaBuilder().build(reader.getAttrAsString("value", StringUtils.EMPTY));
value = BaseFormula.createFormulaBuilder().build(reader.getAttrAsString("value", StringKit.EMPTY));
} else {
value = reader.getAttrAsString("value", StringUtils.EMPTY);
value = reader.getAttrAsString("value", StringKit.EMPTY);
}
}
}
@ -88,7 +88,7 @@ public class OssVariableValue implements XMLable {
if (value instanceof BaseFormula) {
writer.attr("type", Type.FORMULA.getIndex()).attr("value", ((BaseFormula) value).getPureContent());
} else {
writer.attr("type", Type.PLAIN.getIndex()).attr("value", GeneralUtils.objectToString(value));
writer.attr("type", Type.PLAIN.getIndex()).attr("value", GeneralKit.objectToString(value));
}
writer.end();
}
@ -99,7 +99,7 @@ public class OssVariableValue implements XMLable {
}
public String toString() {
return value == null ? StringUtils.EMPTY : GeneralUtils.objectToString(value);
return value == null ? StringKit.EMPTY : GeneralKit.objectToString(value);
}

4
src/main/java/com/fr/plugin/file/submit/oss/job/OssSubmitJob.java

@ -2,7 +2,7 @@ package com.fr.plugin.file.submit.oss.job;
import com.aliyun.oss.OSSClient;
import com.fr.data.AbstractSubmitTask;
import com.fr.general.xml.GeneralXMLTools;
import com.fanruan.api.xml.XmlKit;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.file.submit.oss.fun.OssConstants;
@ -114,7 +114,7 @@ public class OssSubmitJob extends AbstractSubmitTask {
@Override
public void writeXML(XMLPrintWriter writer) {
if (submitTargetConfig != null) {
GeneralXMLTools.writeXMLable(writer, submitTargetConfig, OssSubmitTargetConfig.XML_TAG);
XmlKit.writeXMLable(writer, submitTargetConfig, OssSubmitTargetConfig.XML_TAG);
}
}
}

73
src/main/java/com/fr/plugin/file/submit/oss/script/OssDownloadHyperlink.java

@ -1,35 +1,29 @@
package com.fr.plugin.file.submit.oss.script;
import com.fr.base.BaseFormula;
import com.fr.base.Parameter;
import com.fr.base.ParameterMapNameSpace;
import com.fr.stable.ParameterProvider;
import com.fanruan.api.cal.ParameterKit;
import com.fr.base.ResultFormula;
import com.fr.general.GeneralUtils;
import com.fr.general.xml.GeneralXMLTools;
import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.xml.XmlKit;
import com.fr.js.Hyperlink;
import com.fr.json.JSONException;
import com.fanruan.api.err.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.json.JSONKit;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.AssistUtils;
import com.fr.stable.ColumnRow;
import com.fr.stable.FormulaProvider;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.script.CalculatorProvider;
import com.fr.stable.script.ExTool;
import com.fr.stable.script.NameSpace;
import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.AssistKit;
import com.fanruan.api.util.StringKit;
import com.fr.stable.web.Repository;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.web.session.SessionIDInfo;
import com.fanruan.api.session.SessionKit;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class OssDownloadHyperlink extends Hyperlink {
@ -68,8 +62,8 @@ public class OssDownloadHyperlink extends Hyperlink {
return;
}
ParameterProvider[] providers = getParameters();
if (ArrayUtils.isEmpty(providers)) {
providers = ArrayUtils.add(providers, new Parameter(parameterName, variableValue.getValue()));
if (ArrayKit.isEmpty(providers)) {
providers = ArrayKit.add(providers, ParameterKit.newParameter(parameterName, variableValue.getValue()));
} else {
Map<String, ParameterProvider> map = new HashMap<String, ParameterProvider>();
for (ParameterProvider provider : providers) {
@ -78,7 +72,7 @@ public class OssDownloadHyperlink extends Hyperlink {
if (map.containsKey(parameterName)) {
map.get(parameterName).setValue(variableValue.getValue());
} else {
providers = ArrayUtils.add(providers, new Parameter(parameterName, variableValue.getValue()));
providers = ArrayKit.add(providers, ParameterKit.newParameter(parameterName, variableValue.getValue()));
}
}
setParameters(providers);
@ -86,8 +80,8 @@ public class OssDownloadHyperlink extends Hyperlink {
@Override
protected String actionJS(Repository repository) {
JSONObject data = JSONObject.create();
protected String actionJS(Repository repository) throws JSONException{
JSONObject data = JSONKit.create();
try {
data.put("bucket", bucket);
if (directory != null) {
@ -97,16 +91,17 @@ public class OssDownloadHyperlink extends Hyperlink {
data.put("fileName", getResultValue(repository, "fileName", fileName));
}
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
LogKit.error(e.getMessage(), e);
}
return "FR.doHyperlinkByOssDownload(" + data.toString() + ");";
}
@NotNull
private String getResultValue(Repository repository, String parameterName, OssVariableValue variableValue){
Object result = null;
ParameterProvider[] providers = getParameters();
for (ParameterProvider provider : providers) {
if (AssistUtils.equals(parameterName, provider.getName())) {
if (AssistKit.equals(parameterName, provider.getName())) {
Object value = provider.getValue();
if (value instanceof BaseFormula) {
result = ((BaseFormula) value).getResult();
@ -123,22 +118,22 @@ public class OssDownloadHyperlink extends Hyperlink {
Calculator calculator = newCalculator(repository);
result = variableValue.getResult(calculator);
}
return GeneralUtils.objectToString(result);
return GeneralKit.objectToString(result);
}
private Calculator newCalculator(Repository repository) {
Calculator calculator = Calculator.createCalculator();
if (repository != null) {
calculator.pushNameSpace(ParameterMapNameSpace.create(repository.getReportParameterMap()));
calculator.pushNameSpace(SessionIDInfo.asNameSpace(repository.getSessionID()));
calculator.pushNameSpace(ParameterKit.createParameterMapNameSpace(repository.getReportParameterMap()));
calculator.pushNameSpace(SessionKit.asNameSpace(repository.getSessionID()));
}
if (!paraMap.isEmpty()) {
calculator.pushNameSpace(ParameterMapNameSpace.create(this.paraMap));
calculator.pushNameSpace(ParameterKit.createParameterMapNameSpace(new HashMap(this.paraMap)));
}
return calculator;
}
@Override
public void readXML(final XMLableReader reader) {
super.readXML(reader);
if (reader.isChildNode()) {
@ -146,24 +141,24 @@ public class OssDownloadHyperlink extends Hyperlink {
if ("Bucket".equals(tagName)) {
this.bucket = reader.getElementValue();
} else if ("Directory".equals(tagName)) {
this.setDirectory((OssVariableValue)GeneralXMLTools.readXMLable(reader));
this.setDirectory((OssVariableValue)XmlKit.readXMLable(reader));
} else if ("FileName".equals(tagName)) {
this.setFileName((OssVariableValue) GeneralXMLTools.readXMLable(reader));
this.setFileName((OssVariableValue) XmlKit.readXMLable(reader));
}
}
}
@Override
public void writeXML(final XMLPrintWriter writer) {
writer.startTAG("JavaScript").attr("class", this.getClass().getName());
super.writeXML(writer);
if (StringUtils.isNotEmpty(bucket)) {
if (StringKit.isNotEmpty(bucket)) {
writer.startTAG("Bucket").textNode(bucket).end();
}
if (directory != null) {
GeneralXMLTools.writeXMLable(writer, directory, "Directory");
XmlKit.writeXMLable(writer, directory, "Directory");
}
if (fileName != null) {
GeneralXMLTools.writeXMLable(writer, fileName, "FileName");
XmlKit.writeXMLable(writer, fileName, "FileName");
}
writer.end();
}
@ -171,9 +166,9 @@ public class OssDownloadHyperlink extends Hyperlink {
@Override
public boolean equals(Object o) {
return o instanceof OssDownloadHyperlink
&& AssistUtils.equals(((OssDownloadHyperlink) o).bucket, bucket)
&& AssistUtils.equals(((OssDownloadHyperlink) o).directory, directory)
&& AssistUtils.equals(((OssDownloadHyperlink) o).fileName, fileName);
&& AssistKit.equals(((OssDownloadHyperlink) o).bucket, bucket)
&& AssistKit.equals(((OssDownloadHyperlink) o).directory, directory)
&& AssistKit.equals(((OssDownloadHyperlink) o).fileName, fileName);
}
@Override

15
src/main/java/com/fr/plugin/file/submit/oss/script/OssSubmitJavaScript.java

@ -1,11 +1,10 @@
package com.fr.plugin.file.submit.oss.script;
import com.fr.general.xml.GeneralXMLTools;
import com.fanruan.api.xml.XmlKit;
import com.fr.js.AbstractJavaScript;
import com.fr.json.JSONObject;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTargetConfig;
import com.fr.stable.AssistUtils;
import com.fr.stable.CommonCodeUtils;
import com.fanruan.api.util.AssistKit;
import com.fanruan.api.util.CodeKit;
import com.fr.stable.web.Repository;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
@ -24,11 +23,11 @@ public class OssSubmitJavaScript extends AbstractJavaScript {
@Override
protected String actionJS(Repository repository) {
return "var fm = new FR.OssForm();fm.ossCommit({xmlconf:" + quote(GeneralXMLTools.writeXMLableAsString(this)) + "},this)";
return "var fm = new FR.OssForm();fm.ossCommit({xmlconf:" + quote(XmlKit.writeXMLableAsString(this)) + "},this)";
}
private String quote(String string) {
return "\"" + CommonCodeUtils.javascriptEncode(string) + "\"" ;
return "\"" + CodeKit.javascriptEncode(string) + "\"" ;
}
@Override
@ -48,7 +47,7 @@ public class OssSubmitJavaScript extends AbstractJavaScript {
public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer);
if (submitTargetConfig != null) {
GeneralXMLTools.writeXMLable(writer, submitTargetConfig, OssSubmitTargetConfig.XML_TAG);
XmlKit.writeXMLable(writer, submitTargetConfig, OssSubmitTargetConfig.XML_TAG);
}
}
@ -56,7 +55,7 @@ public class OssSubmitJavaScript extends AbstractJavaScript {
public boolean equals(Object o) {
return o instanceof OssSubmitJavaScript
&& super.equals(o)
&& AssistUtils.equals(((OssSubmitJavaScript) o).submitTargetConfig, submitTargetConfig);
&& AssistKit.equals(((OssSubmitJavaScript) o).submitTargetConfig, submitTargetConfig);
}
@Override

8
src/main/java/com/fr/plugin/file/submit/oss/ui/Editors.java

@ -1,16 +1,16 @@
package com.fr.plugin.file.submit.oss.ui;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fanruan.api.design.ui.editor.ValueEditors;
import com.fr.design.editor.editor.Editor;
import com.fr.design.editor.editor.FormulaEditor;
import com.fr.design.editor.editor.TextEditor;
import com.fanruan.api.design.ui.editor.TextEditor;
import com.fr.design.i18n.Toolkit;
public class Editors {
public static ValueEditorPane createValueEditorPane() {
return ValueEditorPaneFactory.createValueEditorPane(new Editor[]{
return ValueEditors.createValueEditorPane(new Editor[]{
new TextEditor(),
new FormulaEditor(Toolkit.i18nText("Plugin-File_Submit_Oss_Editor_Formula")),
});

29
src/main/java/com/fr/plugin/file/submit/oss/ui/OssHyperlink4DownloadPane.java

@ -1,13 +1,12 @@
package com.fr.plugin.file.submit.oss.ui;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.GeneralUtils;
import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fanruan.api.design.ui.component.UIComboBox;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.ui.layout.TableLayoutKit;
import com.fanruan.api.util.GeneralKit;
import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
import com.fr.plugin.file.submit.oss.script.OssDownloadHyperlink;
import com.fr.plugin.oss.universal.config.OssUniversalConfig;
@ -30,15 +29,15 @@ public class OssHyperlink4DownloadPane extends BasicBeanPane<OssDownloadHyperlin
this.bucketComboBox = new UIComboBox(OssUniversalConfig.getInstance().getArrayBuckets());
this.directoryValuePane = Editors.createValueEditorPane();
this.fileNameValuePane = Editors.createValueEditorPane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double p = TableLayoutKit.PREFERRED;
double f = TableLayoutKit.FILL;
double[] rowSize = {p, p, p};
double[] columnSize = {p, f};
JPanel centerPane = TableLayoutHelper.createTableLayoutPane(
JPanel centerPane = TableLayoutKit.createTableLayoutPane(
new Component[][] {
{new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_Bucket_Name") + ":"), bucketComboBox},
{new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_Directory") + ":"), directoryValuePane},
{new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_File_Name") + ":"), fileNameValuePane}
{new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_Bucket_Name") + ":"), bucketComboBox},
{new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_Directory") + ":"), directoryValuePane},
{new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_File_Name") + ":"), fileNameValuePane}
}, rowSize, columnSize);
this.add(centerPane, BorderLayout.CENTER);
}
@ -56,7 +55,7 @@ public class OssHyperlink4DownloadPane extends BasicBeanPane<OssDownloadHyperlin
@Override
public OssDownloadHyperlink updateBean() {
OssDownloadHyperlink hyperlink = new OssDownloadHyperlink();
hyperlink.setBucket(GeneralUtils.objectToString(bucketComboBox.getSelectedItem()));
hyperlink.setBucket(GeneralKit.objectToString(bucketComboBox.getSelectedItem()));
hyperlink.setDirectory(new OssVariableValue(directoryValuePane.update()));
hyperlink.setFileName(new OssVariableValue(fileNameValuePane.update()));
return hyperlink;
@ -64,6 +63,6 @@ public class OssHyperlink4DownloadPane extends BasicBeanPane<OssDownloadHyperlin
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-File_Download_Hyperlink");
return DesignKit.i18nText("Plugin-File_Download_Hyperlink");
}
}

3
src/main/java/com/fr/plugin/file/submit/oss/ui/OssPathConfigPane.java

@ -1,11 +1,12 @@
package com.fr.plugin.file.submit.oss.ui;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fanruan.api.design.ui.component.table.UITableEditorPane;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTargetConfig;
import com.fr.plugin.file.submit.oss.job.OssSubmitJob;
import javax.swing.*;
import java.awt.*;

6
src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitJavaScriptPane.java

@ -1,8 +1,8 @@
package com.fr.plugin.file.submit.oss.ui;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.i18n.Toolkit;
import com.fanruan.api.design.ui.component.table.UITableEditorPane;
import com.fanruan.api.design.DesignKit;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTargetConfig;
import com.fr.plugin.file.submit.oss.script.OssSubmitJavaScript;
@ -59,6 +59,6 @@ public class OssSubmitJavaScriptPane extends FurtherBasicBeanPane<OssSubmitJavaS
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Plugin-File_Submit_Oss");
return DesignKit.i18nText("Plugin-File_Submit_Oss");
}
}

47
src/main/java/com/fr/plugin/file/submit/oss/ui/OssSubmitPathTableModel.java

@ -1,16 +1,16 @@
package com.fr.plugin.file.submit.oss.ui;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils;
import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fanruan.api.util.StringKit;
import com.fanruan.api.design.ui.component.UIComboBox;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.ui.component.table.action.UITableEditAction;
import com.fanruan.api.design.ui.component.table.model.UITableModelAdapter;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.util.GeneralKit;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget;
import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
import com.fr.plugin.oss.universal.config.OssUniversalConfig;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.CellEditorListener;
@ -24,10 +24,10 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
public OssSubmitPathTableModel() {
super(new String[]{
com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_Bucket_Name"),
com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_Directory"),
com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_File"),
com.fr.design.i18n.Toolkit.i18nText("Plugin-File_Submit_Oss_File_Name")});
DesignKit.i18nText("Plugin-File_Submit_Oss_Bucket_Name"),
DesignKit.i18nText("Plugin-File_Submit_Oss_Directory"),
DesignKit.i18nText("Plugin-File_Submit_Oss_File"),
DesignKit.i18nText("Plugin-File_Submit_Oss_File_Name")});
this.setColumnClass(new Class[]{BucketEditor.class, DirectoryEditor.class, FileSelectEditor.class, FileNameEditor.class});
@ -43,7 +43,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
this.setDefaultEditor(FileNameEditor.class, new FileNameEditor());
this.setDefaultRenderer(FileNameEditor.class, new CurrentValueRenderer());
}
@Override
public Object getValueAt(final int row, final int column) {
final OssSubmitTarget target = this.getList().get(row);
switch (column) {
@ -64,17 +64,16 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
}
}
}
@Override
public boolean isCellEditable(final int row, final int column) {
return true;
}
@Override
public UITableEditAction[] createAction() {
return new UITableEditAction[]{
new AddPathAction(),
new UITableModelAdapter.DeleteAction(),
new UITableModelAdapter.MoveUpAction(),
new UITableModelAdapter.MoveDownAction()};
};
}
private void addPath() {
@ -100,7 +99,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
return;
}
OssSubmitTarget submitTarget = getList().get(table.getSelectedRow());
submitTarget.setBucket(GeneralUtils.objectToString(getCellEditorValue()));
submitTarget.setBucket(GeneralKit.objectToString(getCellEditorValue()));
fireTableDataChanged();
}
});
@ -142,7 +141,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
@Override
public Component getTableCellEditorComponent(final JTable table, final Object o, final boolean b, final int n, final int n2) {
this.textField.populate((o == null) ? StringUtils.EMPTY : o);
this.textField.populate((o == null) ? StringKit.EMPTY : o);
return this.textField;
}
@ -176,7 +175,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
@Override
public Component getTableCellEditorComponent(final JTable table, final Object o, final boolean b, final int n, final int n2) {
this.textField.populate((o == null) ? StringUtils.EMPTY : o);
this.textField.populate((o == null) ? StringKit.EMPTY : o);
return this.textField;
}
@ -210,7 +209,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
@Override
public Component getTableCellEditorComponent(final JTable table, final Object o, final boolean b, final int n, final int n2) {
this.textField.populate((o == null) ? StringUtils.EMPTY : o);
this.textField.populate((o == null) ? StringKit.EMPTY : o);
return this.textField;
}
@ -222,7 +221,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
private class SimpleRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
this.setText(GeneralUtils.objectToString(value));
this.setText(GeneralKit.objectToString(value));
return this;
}
}
@ -237,7 +236,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
}
public CurrentValueRenderer(ValueEditorPane valueEditorPane) {
disableLabel = new UILabel(Toolkit.i18nText("Plugin-File_Submit_Oss_Disable"));
disableLabel = new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_Disable"));
disableLabel.setForeground(Color.pink);
disableLabel.setHorizontalAlignment(SwingConstants.CENTER);
@ -247,7 +246,7 @@ public class OssSubmitPathTableModel extends UITableModelAdapter<OssSubmitTarget
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (table.isCellEditable(row, column)) {
if (value == null) {
editor.populate(StringUtils.EMPTY);
editor.populate(StringKit.EMPTY);
} else {
if (value instanceof OssVariableValue) {
editor.populate(((OssVariableValue) value).getValue());

4
src/main/java/com/fr/plugin/file/submit/oss/ui/tools/RewriteAction.java

@ -1,8 +1,6 @@
package com.fr.plugin.file.submit.oss.ui.tools;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.mainframe.DesignerContext;
import com.fanruan.api.design.ui.action.UpdateAction;
import java.awt.event.ActionEvent;

Loading…
Cancel
Save