richie
6 years ago
5 changed files with 197 additions and 1 deletions
@ -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(); |
||||
} |
||||
} |
@ -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); |
||||
|
||||
} |
||||
} |
@ -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"; |
||||
} |
||||
} |
@ -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…
Reference in new issue