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