vito
9 years ago
8 changed files with 180 additions and 63 deletions
@ -1,67 +1,92 @@
|
||||
package com.fr.design.report; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.BoxLayout; |
||||
import javax.swing.*; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.fun.AbstractExportPane; |
||||
import com.fr.design.fun.ExportAttrTabProvider; |
||||
import com.fr.design.gui.frpane.UITabbedPane; |
||||
import com.fr.general.Inter; |
||||
import com.fr.io.attr.ImageExportAttr; |
||||
import com.fr.io.attr.ReportExportAttr; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
|
||||
public class ReportExportAttrPane extends BasicPane { |
||||
private ExcelExportPane excelExportPane; |
||||
private PDFExportPane pdfExportPane; |
||||
private WordExportPane wordExportPane; |
||||
|
||||
public ReportExportAttrPane() { |
||||
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||||
excelExportPane = new ExcelExportPane(); |
||||
this.add(excelExportPane); |
||||
pdfExportPane = new PDFExportPane(); |
||||
this.add(pdfExportPane); |
||||
wordExportPane = new WordExportPane(); |
||||
this.add(wordExportPane); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("ReportD-Excel_Export"); |
||||
} |
||||
|
||||
public void populate(ReportExportAttr reportExportAttr) { |
||||
if (reportExportAttr == null) { |
||||
reportExportAttr = new ReportExportAttr(); |
||||
} |
||||
|
||||
if (this.excelExportPane != null) { |
||||
this.excelExportPane.populate(reportExportAttr.getExcelExportAttr()); |
||||
} |
||||
|
||||
if (this.pdfExportPane != null) { |
||||
this.pdfExportPane.populate(reportExportAttr.getPDFExportAttr()); |
||||
} |
||||
|
||||
if (this.wordExportPane != null) { |
||||
this.wordExportPane.populate(reportExportAttr.getWordExportAttr()); |
||||
} |
||||
} |
||||
|
||||
public ReportExportAttr update() { |
||||
|
||||
ReportExportAttr reportExportAttr = new ReportExportAttr(); |
||||
if (this.excelExportPane != null) { |
||||
reportExportAttr.setExcelExportAttr(this.excelExportPane.update()); |
||||
} |
||||
|
||||
if (this.pdfExportPane != null) { |
||||
reportExportAttr.setPDFExportAttr(this.pdfExportPane.update()); |
||||
} |
||||
|
||||
if (this.wordExportPane != null) { |
||||
reportExportAttr.setWordExportAttr(this.wordExportPane.update()); |
||||
} |
||||
|
||||
return reportExportAttr; |
||||
} |
||||
private ExcelExportPane excelExportPane; |
||||
private PDFExportPane pdfExportPane; |
||||
private WordExportPane wordExportPane; |
||||
Map<String, AbstractExportPane> paneMap; |
||||
|
||||
public ReportExportAttrPane() { |
||||
UITabbedPane uiTabbedPane = new UITabbedPane(); |
||||
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||||
excelExportPane = new ExcelExportPane(); |
||||
uiTabbedPane.addTab("Excel", excelExportPane); |
||||
pdfExportPane = new PDFExportPane(); |
||||
uiTabbedPane.addTab("PDF", pdfExportPane); |
||||
wordExportPane = new WordExportPane(); |
||||
uiTabbedPane.addTab("Word", wordExportPane); |
||||
ExportAttrTabProvider[] providers = ExtraDesignClassManager.getInstance().getExportAttrTabProviders(); |
||||
paneMap = new HashMap<String, AbstractExportPane>(); |
||||
for (ExportAttrTabProvider provider : providers) { |
||||
uiTabbedPane.addTab(provider.title(), provider.toSwingComponent()); |
||||
paneMap.put(provider.tag(), provider.toExportPane()); |
||||
} |
||||
this.add(uiTabbedPane); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("ReportD-Excel_Export"); |
||||
} |
||||
|
||||
public void populate(ReportExportAttr reportExportAttr) { |
||||
if (reportExportAttr == null) { |
||||
reportExportAttr = new ReportExportAttr(); |
||||
} |
||||
|
||||
if (this.excelExportPane != null) { |
||||
this.excelExportPane.populate(reportExportAttr.getExcelExportAttr()); |
||||
} |
||||
|
||||
if (this.pdfExportPane != null) { |
||||
this.pdfExportPane.populate(reportExportAttr.getPDFExportAttr()); |
||||
} |
||||
|
||||
if (this.wordExportPane != null) { |
||||
this.wordExportPane.populate(reportExportAttr.getWordExportAttr()); |
||||
} |
||||
|
||||
AbstractExportPane exportPane = paneMap.get("Image"); |
||||
if(exportPane != null){ |
||||
exportPane.populate(reportExportAttr.getImageExportAttr()); |
||||
} |
||||
} |
||||
|
||||
public ReportExportAttr update() { |
||||
|
||||
ReportExportAttr reportExportAttr = new ReportExportAttr(); |
||||
if (this.excelExportPane != null) { |
||||
reportExportAttr.setExcelExportAttr(this.excelExportPane.update()); |
||||
} |
||||
|
||||
if (this.pdfExportPane != null) { |
||||
reportExportAttr.setPDFExportAttr(this.pdfExportPane.update()); |
||||
} |
||||
|
||||
if (this.wordExportPane != null) { |
||||
reportExportAttr.setWordExportAttr(this.wordExportPane.update()); |
||||
} |
||||
|
||||
AbstractExportPane exportPane = paneMap.get("Image"); |
||||
if(exportPane != null){ |
||||
reportExportAttr.setImageExportAttr(exportPane.update(ImageExportAttr.class)); |
||||
} |
||||
return reportExportAttr; |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
|
||||
/** |
||||
* Created by vito on 16/5/5. |
||||
*/ |
||||
public abstract class AbstractExportPane extends BasicPane { |
||||
|
||||
public abstract void populate(Object t); |
||||
|
||||
public abstract Object update(); |
||||
|
||||
// public <T> void populate(Object object,Class<? extends T> clazz){
|
||||
// if(object.getClass().isAssignableFrom(clazz)){
|
||||
// this.populate(clazz.cast(object));
|
||||
// }
|
||||
// }
|
||||
|
||||
public <T> T update(Class<? extends T> clazz){ |
||||
Object object = this.update(); |
||||
if(object == null){ |
||||
return null; |
||||
} |
||||
if(object.getClass().isAssignableFrom(clazz)){ |
||||
return clazz.cast(object); |
||||
} |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.stable.fun.Level; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* Created by vito on 16/5/5. |
||||
*/ |
||||
public interface ExportAttrTabProvider extends Level{ |
||||
String XML_TAG = "ExportAttrTabProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
JComponent toSwingComponent(); |
||||
|
||||
AbstractExportPane toExportPane(); |
||||
|
||||
String title(); |
||||
|
||||
String tag(); |
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.ExportAttrTabProvider; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
|
||||
/** |
||||
* Created by vito on 16/5/5. |
||||
*/ |
||||
public abstract class AbstractExportAttrTabProvider extends AbstractProvider implements ExportAttrTabProvider { |
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String mark4Provider() { |
||||
return this.getClass().getName(); |
||||
} |
||||
} |
Loading…
Reference in new issue