Browse Source

111

pull/1/head
richie 6 years ago
parent
commit
ec6bbab3a8
  1. 6
      plugin.xml
  2. 33
      src/main/java/com/fr/plugin/file/submit/oss/OssTemplateReload.java
  3. 18
      src/main/java/com/fr/plugin/file/submit/oss/ui/tools/RewriteAction.java
  4. 124
      src/main/java/com/fr/plugin/file/submit/oss/ui/tools/RewritePane.java
  5. 17
      src/main/java/com/fr/plugin/file/submit/oss/ui/tools/RewriteWorker.java

6
plugin.xml

@ -2,11 +2,14 @@
<id>com.fr.plugin.file.submit.oss</id> <id>com.fr.plugin.file.submit.oss</id>
<name><![CDATA[文件上传下载(OSS)]]></name> <name><![CDATA[文件上传下载(OSS)]]></name>
<active>yes</active> <active>yes</active>
<version>1.0</version> <version>1.1</version>
<env-version>10.0</env-version> <env-version>10.0</env-version>
<jartime>2018-11-02</jartime> <jartime>2018-11-02</jartime>
<vendor>author</vendor> <vendor>author</vendor>
<description><![CDATA[文件上传至阿里云的OSS中。]]></description> <description><![CDATA[文件上传至阿里云的OSS中。]]></description>
<dependence>
<item type="plugin" key="com.fr.plugin.customsubmmit.v10"/>
</dependence>
<change-notes><![CDATA[ <change-notes><![CDATA[
[2018-10-31]初始化插件。<br/> [2018-10-31]初始化插件。<br/>
]]></change-notes> ]]></change-notes>
@ -24,6 +27,7 @@
<SubmitProvider class="com.fr.plugin.file.submit.oss.OssSubmitUIBridge"/> <SubmitProvider class="com.fr.plugin.file.submit.oss.OssSubmitUIBridge"/>
<JavaScriptActionProvider class="com.fr.plugin.file.submit.oss.OssJavaScriptActionBridge"/> <JavaScriptActionProvider class="com.fr.plugin.file.submit.oss.OssJavaScriptActionBridge"/>
<HyperlinkProvider class="com.fr.plugin.file.submit.oss.OssHyperlink4Download"/> <HyperlinkProvider class="com.fr.plugin.file.submit.oss.OssHyperlink4Download"/>
<MenuHandler class="com.fr.plugin.file.submit.oss.OssTemplateReload"/>
</extra-designer> </extra-designer>
<function-recorder class="com.fr.plugin.file.submit.oss.job.OssSubmitJob"/> <function-recorder class="com.fr.plugin.file.submit.oss.job.OssSubmitJob"/>
</plugin> </plugin>

33
src/main/java/com/fr/plugin/file/submit/oss/OssTemplateReload.java

@ -0,0 +1,33 @@
package com.fr.plugin.file.submit.oss;
import com.fr.design.fun.MenuHandler;
import com.fr.design.fun.impl.AbstractMenuHandler;
import com.fr.design.menu.ShortCut;
import com.fr.plugin.file.submit.oss.ui.tools.RewriteAction;
public class OssTemplateReload extends AbstractMenuHandler {
@Override
public int insertPosition(int total) {
return 0;
}
@Override
public boolean insertSeparatorBefore() {
return false;
}
@Override
public boolean insertSeparatorAfter() {
return false;
}
@Override
public String category() {
return MenuHandler.HELP;
}
@Override
public ShortCut shortcut() {
return new RewriteAction();
}
}

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

@ -0,0 +1,18 @@
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 java.awt.event.ActionEvent;
public class RewriteAction extends UpdateAction {
@Override
public void actionPerformed(ActionEvent e) {
RewritePane rewritePane = new RewritePane();
BasicDialog dialog = rewritePane.showWindow(DesignerContext.getDesignerFrame());
dialog.setVisible(true);
}
}

124
src/main/java/com/fr/plugin/file/submit/oss/ui/tools/RewritePane.java

@ -0,0 +1,124 @@
package com.fr.plugin.file.submit.oss.ui.tools;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.data.SubmitJob;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.file.filetree.FileNode;
import com.fr.io.TemplateWorkBookIO;
import com.fr.main.impl.WorkBook;
import com.fr.plugin.customsubmmit.core.PathConfig;
import com.fr.plugin.customsubmmit.core.ServerPathColumnConfig;
import com.fr.plugin.customsubmmit.report.ServerPathSubmiterJob;
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.fun.OssVariableValue;
import com.fr.plugin.file.submit.oss.job.OssSubmitJob;
import com.fr.report.report.Report;
import com.fr.report.worksheet.WorkSheet;
import com.fr.report.write.ReportWriteAttr;
import com.fr.report.write.SubmitVisitor;
import com.fr.report.write.WClassSubmiter;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
public class RewritePane extends BasicPane {
public RewritePane() {
initComponents();
}
private void initComponents() {
setLayout(new BorderLayout());
UIButton button = new UIButton("Start");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
rewrite();
}
});
add(button, BorderLayout.NORTH);
}
private void rewrite() {
new SwingWorker<Void, Integer>() {
@Override
protected Void doInBackground() {
FileNode[] fileNodes = FRContext.getFileNodes().list(ProjectConstants.REPORTLETS_NAME, FileExtension.CPT, true);
int len = fileNodes.length;
for (int i = 0; i < len; i++) {
FileNode fileNode = fileNodes[i];
try {
WorkBook workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(fileNode.getEnvPath().substring(10));
int count = workBook.getReportCount();
for (int n = 0; n < count; n++) {
Report report = workBook.getReport(n);
if (report instanceof WorkSheet) {
ReportWriteAttr reportWriteAttr = ((WorkSheet) report).getAttributeTarget(ReportWriteAttr.XML_TAG);
if (reportWriteAttr != null) {
int submitJobCount = reportWriteAttr.getSubmitVisitorCount();
for (int sn = 0; sn < submitJobCount; sn++) {
SubmitVisitor submitVisitor = reportWriteAttr.getSubmitVisitor(sn);
if (submitVisitor instanceof WClassSubmiter) {
SubmitJob job = ((WClassSubmiter) submitVisitor).getSubmitJob();
if (job instanceof ServerPathSubmiterJob) {
((WClassSubmiter) submitVisitor).setSubmitJob(convert2OssJob((ServerPathSubmiterJob) job));
}
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
publish(i);
}
return null;
}
@Override
protected void process(List<Integer> chunks) {
System.out.println("已经到第" + chunks.get(chunks.size() - 1) + "个模板");
}
}.execute();
}
private OssSubmitJob convert2OssJob(ServerPathSubmiterJob job) {
OssSubmitJob ossSubmitJob = new OssSubmitJob();
OssSubmitTargetConfig targetConfig = new OssSubmitTargetConfig();
ossSubmitJob.setSubmitTargetConfig(targetConfig);
PathConfig pathConfig = job.getPathConfig();
if (pathConfig != null) {
for (ServerPathColumnConfig config : pathConfig.getColumnConfigList()) {
OssSubmitTarget target = new OssSubmitTarget();
targetConfig.addSubmitTarget(target);
target.setBucket("fanruan-crm");
target.setDirectory(new OssVariableValue(config.getPath()));
target.setFile(new OssVariableValue(config.getCellConfig().toString()));
target.setName(new OssVariableValue(config.getName()));
}
}
return ossSubmitJob;
}
@Override
protected String title4PopupWindow() {
return "Transform";
}
}

17
src/main/java/com/fr/plugin/file/submit/oss/ui/tools/RewriteWorker.java

@ -0,0 +1,17 @@
package com.fr.plugin.file.submit.oss.ui.tools;
import javax.swing.*;
import java.util.List;
public class RewriteWorker extends SwingWorker<Void, Void> {
@Override
protected Void doInBackground() throws Exception {
return null;
}
@Override
protected void process(List<Void> chunks) {
super.process(chunks);
}
}
Loading…
Cancel
Save