@ -0,0 +1,24 @@
|
||||
package com.fr.design.base.clipboard; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class ClipboardHelper { |
||||
public static String formatExcelString(List<List<Object>> table) { |
||||
StringBuffer stringBuffer = new StringBuffer(); |
||||
|
||||
for (int row = 0; row < table.size(); row++) { |
||||
List<Object> rowValue = table.get(row); |
||||
for (int col = 0; col < rowValue.size(); col++) { |
||||
Object cell = rowValue.get(col); |
||||
stringBuffer.append(cell); |
||||
if (col != rowValue.size() - 1) { |
||||
stringBuffer.append("\t"); |
||||
} |
||||
} |
||||
if (row != table.size() - 1) { |
||||
stringBuffer.append("\n"); |
||||
} |
||||
} |
||||
return stringBuffer.toString(); |
||||
} |
||||
} |
@ -0,0 +1,311 @@
|
||||
package com.fr.design.data.datapane.preview; |
||||
|
||||
import com.fr.design.base.clipboard.ClipboardHelper; |
||||
import com.fr.design.gui.itable.SortableJTable; |
||||
import com.fr.design.gui.itable.TableSorter; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.os.OperatingSystem; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.table.DefaultTableCellRenderer; |
||||
import javax.swing.table.JTableHeader; |
||||
import javax.swing.table.TableCellRenderer; |
||||
import javax.swing.table.TableColumnModel; |
||||
import java.awt.*; |
||||
import java.awt.datatransfer.Clipboard; |
||||
import java.awt.datatransfer.StringSelection; |
||||
import java.awt.datatransfer.Transferable; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.Comparator; |
||||
|
||||
public class CopyableJTable extends SortableJTable { |
||||
|
||||
//区域选中用到的定位数据
|
||||
public int startRow = -1; |
||||
public int startCol = -1; |
||||
public int endRow = -1; |
||||
public int endCol = -1; |
||||
//单元格不连续多选用到的定位数据
|
||||
java.util.List<Point> pointList = new ArrayList<>(); |
||||
//shift键是否被按下
|
||||
public boolean isShiftDown = false; |
||||
//control\command键是否被按下
|
||||
public boolean isControlDown = false; |
||||
//是否可以复制
|
||||
public boolean isCopy = true; |
||||
int ctrlKeyCode = 17; |
||||
int cKeyCode = 67; |
||||
int shiftKeyCode = 16; |
||||
int commandKeyCode = 157; |
||||
//选中单元格的背景色
|
||||
Color selectBackGround = new Color(54, 133, 242, 63); |
||||
Color headerBackGround = new Color(229, 229, 229); |
||||
boolean mouseDrag = false; |
||||
boolean headerSelect = false; |
||||
|
||||
|
||||
class CopyableTableHeaderCellRenderer implements TableCellRenderer { |
||||
TableCellRenderer tableCellRenderer; |
||||
|
||||
CopyableTableHeaderCellRenderer(TableCellRenderer tableCellRenderer) { |
||||
this.tableCellRenderer = tableCellRenderer; |
||||
} |
||||
|
||||
@Override |
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
||||
JComponent comp = (JComponent) this.tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); |
||||
if (isChoose(row, column)) { |
||||
comp.setBackground(selectBackGround); |
||||
} else { |
||||
comp.setBackground(headerBackGround); |
||||
} |
||||
return comp; |
||||
} |
||||
} |
||||
|
||||
|
||||
public CopyableJTable(TableSorter tableModel) { |
||||
super(tableModel); |
||||
initListener(); |
||||
this.getTableHeader().setDefaultRenderer(new CopyableTableHeaderCellRenderer(this.getTableHeader().getDefaultRenderer())); |
||||
} |
||||
|
||||
private void initListener() { |
||||
CopyableJTable self = this; |
||||
this.getTableHeader().addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseEntered(MouseEvent e) { |
||||
if (mouseDrag) { |
||||
headerSelect = true; |
||||
int column = getColumn(e); |
||||
self.updateEndPoint(-1, column); |
||||
self.getTableHeader().repaint(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void mouseExited(MouseEvent e) { |
||||
if (mouseDrag) { |
||||
headerSelect = false; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
headerSelect = true; |
||||
int column = getColumn(e); |
||||
if (column != -1) { |
||||
self.clearPoint(); |
||||
self.addPoint(-1, column); |
||||
self.updateStartPoint(-1, column); |
||||
self.updateEndPoint(-1, column); |
||||
self.refreshTable(); |
||||
} |
||||
} |
||||
|
||||
private int getColumn(MouseEvent e) { |
||||
JTableHeader h = (JTableHeader) e.getSource(); |
||||
TableColumnModel columnModel = h.getColumnModel(); |
||||
int viewColumn = columnModel.getColumnIndexAtX(e.getX()); |
||||
return viewColumn; |
||||
} |
||||
}); |
||||
this.getTableHeader().addMouseMotionListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseMoved(MouseEvent e) { |
||||
mouseDrag = false; |
||||
} |
||||
|
||||
@Override |
||||
public void mouseDragged(MouseEvent e) { |
||||
self.clearPoint(); |
||||
self.updateStartPoint(-1, -1); |
||||
self.updateEndPoint(-1, -1); |
||||
self.refreshTable(); |
||||
} |
||||
|
||||
}); |
||||
|
||||
|
||||
this.addMouseMotionListener(new java.awt.event.MouseAdapter() { |
||||
@Override |
||||
public void mouseDragged(MouseEvent evt) { |
||||
mouseDrag = true; |
||||
int row = self.rowAtPoint(evt.getPoint()); |
||||
int col = self.columnAtPoint(evt.getPoint()); |
||||
if (self.updateEndPoint(row, col)) { |
||||
self.refreshTable(); |
||||
} |
||||
} |
||||
|
||||
public void mouseMoved(MouseEvent e) { |
||||
mouseDrag = false; |
||||
} |
||||
}); |
||||
this.addMouseListener(new MouseAdapter() { |
||||
public void mousePressed(MouseEvent e) { |
||||
headerSelect = false; |
||||
int row = self.rowAtPoint(e.getPoint()); |
||||
int col = self.columnAtPoint(e.getPoint()); |
||||
if (!self.isControlDown) { |
||||
self.clearPoint(); |
||||
} |
||||
if (self.isShiftDown) { |
||||
self.clearPoint(); |
||||
} else { |
||||
self.updateStartPoint(row, col); |
||||
} |
||||
self.addPoint(row, col); |
||||
self.updateEndPoint(row, col); |
||||
|
||||
self.refreshTable(); |
||||
} |
||||
|
||||
}); |
||||
this.addKeyListener(new KeyAdapter() { |
||||
@Override |
||||
public void keyPressed(KeyEvent e) { |
||||
if (isControlKey(e)) { |
||||
isControlDown = true; |
||||
} else if (e.getKeyCode() == shiftKeyCode) { |
||||
isShiftDown = true; |
||||
} else if (e.getKeyCode() == cKeyCode) { |
||||
if (isControlDown && isCopy) { |
||||
self.copy(); |
||||
isCopy = false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void keyReleased(KeyEvent e) { |
||||
if (isControlKey(e)) { |
||||
isControlDown = false; |
||||
isCopy = true; |
||||
} else if (e.getKeyCode() == shiftKeyCode) { |
||||
isShiftDown = false; |
||||
} |
||||
} |
||||
|
||||
private boolean isControlKey(KeyEvent e) { |
||||
if (e.getKeyCode() == ctrlKeyCode) { |
||||
return true; |
||||
} |
||||
if (e.getKeyCode() == commandKeyCode && OperatingSystem.isMacos()) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { |
||||
Component comp = super.prepareRenderer(renderer, row, column); |
||||
if (isChoose(row, column)) { |
||||
comp.setBackground(selectBackGround); |
||||
} else { |
||||
comp.setBackground(this.getBackground()); |
||||
} |
||||
return comp; |
||||
} |
||||
|
||||
|
||||
private boolean updateEndPoint(int row, int col) { |
||||
if (headerSelect && row != -1) |
||||
return false; |
||||
if (endRow != row || endCol != col) { |
||||
endRow = row; |
||||
endCol = col; |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
private boolean updateStartPoint(int row, int col) { |
||||
if (startRow != row || startCol != col) { |
||||
startRow = row; |
||||
startCol = col; |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
private void addPoint(int row, int col) { |
||||
pointList.add(new Point(row, col)); |
||||
} |
||||
|
||||
private void clearPoint() { |
||||
pointList = new ArrayList<>(); |
||||
} |
||||
|
||||
private void copy() { |
||||
FineLoggerFactory.getLogger().info("copy cell value"); |
||||
java.util.List<java.util.List<Object>> table = new ArrayList<>(); |
||||
if ((startRow != endRow || startCol != endCol) && Math.min(startCol, endCol) > -1) { |
||||
for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) { |
||||
table.add(new ArrayList<>()); |
||||
for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) { |
||||
Object text = this.getTableValue(i, j); |
||||
table.get(table.size() - 1).add(text); |
||||
} |
||||
} |
||||
} else if (pointList.size() > 0) { |
||||
Collections.sort(pointList, Comparator.comparing(Point::getX).thenComparing(Point::getY)); |
||||
int startRow = pointList.get(0).x; |
||||
int currentRow = startRow; |
||||
table.add(new ArrayList<>()); |
||||
for (Point point : pointList) { |
||||
while (currentRow < point.x) { |
||||
table.add(new ArrayList<>()); |
||||
currentRow++; |
||||
} |
||||
Object text = this.getTableValue(point.x, point.y); |
||||
table.get(table.size() - 1).add(text); |
||||
} |
||||
} |
||||
|
||||
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); |
||||
Transferable tText = new StringSelection(ClipboardHelper.formatExcelString(table)); |
||||
clip.setContents(tText, null); |
||||
} |
||||
|
||||
private Object getTableValue(int row, int col) { |
||||
Object value = null; |
||||
if (col > -1) { |
||||
if (row > -1) { |
||||
value = this.getValueAt(row, col); |
||||
} else if (row == -1) { |
||||
col = columnModel.getColumn(col).getModelIndex(); |
||||
value = this.getModel().getColumnName(col); |
||||
} |
||||
} |
||||
return value; |
||||
} |
||||
|
||||
private void refreshTable() { |
||||
this.repaint(); |
||||
this.getTableHeader().repaint(); |
||||
} |
||||
|
||||
private boolean isChoose(int row, int col) { |
||||
if (row >= Math.min(startRow, endRow) && row <= Math.max(startRow, endRow)) { |
||||
if (col >= Math.min(startCol, endCol) && col <= Math.max(startCol, endCol)) { |
||||
return true; |
||||
} |
||||
} |
||||
for (Point point : pointList) { |
||||
if (point.x == row && point.y == col) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,251 @@
|
||||
package com.fr.design.dialog; |
||||
|
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.design.dialog.link.MessageWithLink; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.icontainer.UIScrollPane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextarea.UITextArea; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.utils.DesignUtils; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Dialog; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.Frame; |
||||
import java.awt.Point; |
||||
import java.awt.Window; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.io.PrintWriter; |
||||
import java.io.StringWriter; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JComponent; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingUtilities; |
||||
|
||||
/** |
||||
* 带链接的错误详情弹窗 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/2 |
||||
*/ |
||||
public class UIDetailErrorLinkDialog extends UIDialog { |
||||
|
||||
private static final Color LINK_COLOR = new Color(51, 152, 253); |
||||
private static final int GAP_5 = 5; |
||||
private static final int GAP_10 = 10; |
||||
private static final String TAG_A_START = "<a>"; |
||||
private static final String TAG_A_END = "</a>"; |
||||
private static final double SCALE = 1.2; |
||||
|
||||
private final Dimension dimension = new Dimension(300, 180); |
||||
|
||||
public static Builder newBuilder() { |
||||
return new Builder(); |
||||
} |
||||
|
||||
private UIDetailErrorLinkDialog(Frame parent, Builder builder) { |
||||
super(parent); |
||||
init(builder); |
||||
} |
||||
|
||||
private UIDetailErrorLinkDialog(Dialog parent, Builder builder) { |
||||
super(parent); |
||||
init(builder); |
||||
} |
||||
|
||||
private void init(Builder builder) { |
||||
this.setTitle(builder.title); |
||||
// 顶部 图标和提示
|
||||
UILabel errorIcon = new UILabel(IOUtils.readIcon("com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png")); |
||||
UILabel errorInfo= new UILabel(builder.reason); |
||||
JPanel topPane = new JPanel(new FlowLayout(FlowLayout.LEFT, GAP_10, GAP_5)); |
||||
topPane.add(errorIcon); |
||||
topPane.add(errorInfo); |
||||
|
||||
// 中部 详细内容
|
||||
JPanel contentPane = new JPanel(new BorderLayout()); |
||||
contentPane.setBorder(BorderFactory.createEmptyBorder(0, GAP_5,0,0)); |
||||
UILabel errorCodeLabel = new UILabel(Toolkit.i18nText("Fine_Design_Basic_Error_Code", builder.errorCode)); |
||||
UILabel link = new UILabel(Toolkit.i18nText("Fine_Design_Basic_Show_Error_Stack")); |
||||
link.setForeground(LINK_COLOR); |
||||
link.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mousePressed(MouseEvent e) { |
||||
StringWriter stackTraceWriter = new StringWriter(); |
||||
builder.throwable.printStackTrace(new PrintWriter(stackTraceWriter)); |
||||
StackPane stackPane = new StackPane(stackTraceWriter.toString()); |
||||
BasicDialog dialog = stackPane.showLargeWindow(UIDetailErrorLinkDialog.this, null); |
||||
dialog.setVisible(true); |
||||
} |
||||
}); |
||||
contentPane.add(errorCodeLabel, BorderLayout.NORTH); |
||||
contentPane.add(createComponent(builder), BorderLayout.CENTER); |
||||
contentPane.add(link, BorderLayout.SOUTH); |
||||
|
||||
// 确定 + 取消
|
||||
JPanel actionPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, GAP_10, GAP_10)); |
||||
actionPane.add(createButton(Toolkit.i18nText("Fine-Design_Report_OK"))); |
||||
actionPane.add(createButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"))); |
||||
this.getContentPane().add(topPane, BorderLayout.NORTH); |
||||
this.getContentPane().add(contentPane, BorderLayout.CENTER); |
||||
this.getContentPane().add(actionPane, BorderLayout.SOUTH); |
||||
this.setSize(dimension); |
||||
this.setResizable(false); |
||||
this.setModal(true); |
||||
GUICoreUtils.centerWindow(this); |
||||
} |
||||
|
||||
private UIButton createButton(String content) { |
||||
UIButton button = new UIButton(content); |
||||
button.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
UIDetailErrorLinkDialog.this.dispose(); |
||||
} |
||||
}); |
||||
return button; |
||||
} |
||||
|
||||
private JComponent createComponent(Builder builder) { |
||||
JPanel panel = new JPanel(new BorderLayout()); |
||||
boolean existDetailReason = StringUtils.isNotEmpty(builder.detailReason); |
||||
int maxWidth = dimension.width; |
||||
if (existDetailReason) { |
||||
String message = Toolkit.i18nText("Fine_Design_Basic_Detail_Error_Info", builder.detailReason); |
||||
UILabel label = new UILabel(message); |
||||
maxWidth = Math.max(maxWidth, GraphHelper.getWidth(message, label.getFont())); |
||||
panel.add(label, BorderLayout.NORTH); |
||||
} |
||||
String solution = existDetailReason ? builder.solution : Toolkit.i18nText("Fine_Design_Basic_Detail_Error_Info", builder.solution); |
||||
if (builder.solution.contains(TAG_A_START)) { |
||||
String[] solutionP1 = solution.split(TAG_A_START); |
||||
String[] solutionP2 = solutionP1[1].split(TAG_A_END); |
||||
MessageWithLink messageWithLink; |
||||
if (solutionP2.length == 2) { |
||||
messageWithLink = new MessageWithLink(solutionP1[0], solutionP2[0], builder.link, solutionP2[1]); |
||||
} else { |
||||
messageWithLink = new MessageWithLink(solutionP1[0], solutionP2[0], builder.link); |
||||
} |
||||
|
||||
panel.add(messageWithLink, BorderLayout.CENTER); |
||||
} else { |
||||
UILabel solutionLabel = new UILabel(solution); |
||||
panel.add(solutionLabel, BorderLayout.CENTER); |
||||
} |
||||
dimension.width = getMaxDimensionWidth(maxWidth, solution); |
||||
return panel; |
||||
|
||||
} |
||||
|
||||
private int getMaxDimensionWidth(int width, String solution) { |
||||
int maxWidth = GraphHelper.getWidth(solution, DesignUtils.getDefaultGUIFont()); |
||||
if (maxWidth >= width) { |
||||
maxWidth = (int) (SCALE * maxWidth); |
||||
} else { |
||||
maxWidth = width; |
||||
} |
||||
return maxWidth; |
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
// do nothing
|
||||
} |
||||
|
||||
class StackPane extends BasicPane { |
||||
|
||||
public StackPane(String stack) { |
||||
setLayout(new BorderLayout()); |
||||
UITextArea textArea = new UITextArea(); |
||||
textArea.setEditable(false); |
||||
textArea.setText(stack); |
||||
UIScrollPane scrollPane = new UIScrollPane(textArea); |
||||
add(scrollPane); |
||||
// 滚动条默认在顶部
|
||||
SwingUtilities.invokeLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
scrollPane.getViewport().setViewPosition(new Point(0, 0)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine_Design_Basic_Error_Stack"); |
||||
} |
||||
} |
||||
|
||||
public static class Builder { |
||||
private Window window; |
||||
private String title; |
||||
private String reason; |
||||
private String errorCode; |
||||
private String detailReason; |
||||
private String solution; |
||||
private String link; |
||||
private Throwable throwable; |
||||
|
||||
private Builder() { |
||||
|
||||
} |
||||
|
||||
public Builder setTitle(String title) { |
||||
this.title = title; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setReason(String reason) { |
||||
this.reason = reason; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setErrorCode(String errorCode) { |
||||
this.errorCode = errorCode; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setSolution(String solution) { |
||||
this.solution = solution; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setDetailReason(String detailReason) { |
||||
this.detailReason = detailReason; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setThrowable(Throwable throwable) { |
||||
this.throwable = throwable; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setWindow(Window window) { |
||||
this.window = window; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setLink(String link) { |
||||
this.link = link; |
||||
return this; |
||||
} |
||||
|
||||
public UIDetailErrorLinkDialog build() { |
||||
if (this.window instanceof Frame) { |
||||
return new UIDetailErrorLinkDialog((Frame) window, this); |
||||
} else { |
||||
return new UIDetailErrorLinkDialog((Dialog) window, this); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.fr.design.env; |
||||
|
||||
/** |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/24 |
||||
*/ |
||||
public class DesignerWorkspaceInfoContext { |
||||
|
||||
private static DesignerWorkspaceInfo workspaceInfo; |
||||
|
||||
public static DesignerWorkspaceInfo getWorkspaceInfo() { |
||||
return workspaceInfo; |
||||
} |
||||
|
||||
public static void setWorkspaceInfo(DesignerWorkspaceInfo workspaceInfo) { |
||||
DesignerWorkspaceInfoContext.workspaceInfo = workspaceInfo; |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.fr.design.gui.chart; |
||||
|
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
|
||||
import java.util.EventListener; |
||||
|
||||
/** |
||||
* @author shine |
||||
* @version 10.0 |
||||
* Created by shine on 2021/5/26 |
||||
*/ |
||||
public interface ChartEditPaneActionListener extends EventListener { |
||||
|
||||
void attributeChange(ChartCollection chartCollection); |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.fr.design.gui.chart; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2021-08-02 |
||||
*/ |
||||
public class ChartXMLTag { |
||||
|
||||
public static final String CHART_TYPE_UI_PROVIDER = "ChartTypeUIProvider"; |
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.fr.design.gui.ibutton; |
||||
|
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
public class UIHead { |
||||
private String text = StringUtils.EMPTY; |
||||
private Icon icon = null; |
||||
private boolean enable = true; |
||||
private int index = 0; |
||||
|
||||
public UIHead(String text, int index) { |
||||
this.text = text; |
||||
this.index = index; |
||||
} |
||||
|
||||
public UIHead(String text, int index, boolean enable) { |
||||
this(text, index); |
||||
this.enable = enable; |
||||
} |
||||
|
||||
public UIHead(Icon icon, int index) { |
||||
this.icon = icon; |
||||
this.index = index; |
||||
} |
||||
|
||||
public UIHead(Icon icon, int index, boolean enable) { |
||||
this(icon, index); |
||||
this.enable = enable; |
||||
} |
||||
|
||||
public UIHead(String text, Icon icon, int index) { |
||||
this.text = text; |
||||
this.icon = icon; |
||||
this.index = index; |
||||
} |
||||
|
||||
public UIHead(String text, Icon icon, int index, boolean enable) { |
||||
this(text, icon, index); |
||||
this.enable = enable; |
||||
} |
||||
|
||||
public boolean isOnlyText() { |
||||
return StringUtils.isNotEmpty(text) && icon == null; |
||||
} |
||||
|
||||
public String getText() { |
||||
return text; |
||||
} |
||||
|
||||
public Icon getIcon() { |
||||
return icon; |
||||
} |
||||
|
||||
public boolean isEnable() { |
||||
return enable; |
||||
} |
||||
|
||||
public int getIndex() { |
||||
return index; |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
package com.fr.design.gui.ifilechooser; |
||||
|
||||
import java.awt.*; |
||||
import java.io.File; |
||||
|
||||
public interface FileChooserProvider { |
||||
File[] getSelectedFiles(); |
||||
|
||||
File getSelectedFile(); |
||||
|
||||
int showDialog(Component parent); |
||||
} |
@ -0,0 +1,5 @@
|
||||
package com.fr.design.gui.ifilechooser; |
||||
|
||||
public enum FileSelectionMode { |
||||
FILE, MULTIPLE_FILE, DIR |
||||
} |
@ -0,0 +1,235 @@
|
||||
package com.fr.design.gui.ifilechooser; |
||||
|
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.sun.javafx.application.PlatformImpl; |
||||
import javafx.application.Platform; |
||||
import javafx.scene.Scene; |
||||
import javafx.scene.control.Label; |
||||
import javafx.scene.layout.Background; |
||||
import javafx.scene.layout.BackgroundFill; |
||||
import javafx.scene.paint.Color; |
||||
import javafx.stage.DirectoryChooser; |
||||
import javafx.stage.FileChooser; |
||||
import javafx.stage.Modality; |
||||
import javafx.stage.Stage; |
||||
import javafx.stage.StageStyle; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.io.File; |
||||
import java.util.List; |
||||
import java.util.concurrent.CountDownLatch; |
||||
|
||||
public class JavaFxNativeFileChooser implements FileChooserProvider { |
||||
private static boolean showDialogState = false; |
||||
private File[] selectedFiles = new File[0]; |
||||
private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE; |
||||
private String title = Toolkit.i18nText("Fine-Design_Basic_Open"); |
||||
private FileChooser.ExtensionFilter[] filters; |
||||
private File currentDirectory; |
||||
|
||||
@Override |
||||
public File[] getSelectedFiles() { |
||||
return selectedFiles; |
||||
} |
||||
|
||||
@Override |
||||
public File getSelectedFile() { |
||||
if (selectedFiles.length > 0) { |
||||
return selectedFiles[0]; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static boolean isShowDialogState() { |
||||
return showDialogState; |
||||
} |
||||
|
||||
public static void setShowDialogState(boolean showDialogState) { |
||||
JavaFxNativeFileChooser.showDialogState = showDialogState; |
||||
} |
||||
|
||||
@Override |
||||
public int showDialog(Component parent) { |
||||
setShowDialogState(true); |
||||
final CountDownLatch latch = new CountDownLatch(1); |
||||
PlatformImpl.startup(() -> { |
||||
}); |
||||
Platform.setImplicitExit(false); |
||||
Platform.runLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
Component fileChooserParent = parent; |
||||
if (fileChooserParent == null) { |
||||
fileChooserParent = DesignerContext.getDesignerFrame(); |
||||
} |
||||
Stage stage = showCoverStage(fileChooserParent); |
||||
try { |
||||
if (fileSelectionMode == FileSelectionMode.FILE || fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { |
||||
FileChooser fileChooser = new FileChooser(); |
||||
fileChooser.setTitle(title); |
||||
fileChooser.getExtensionFilters().addAll(filters); |
||||
fileChooser.setInitialDirectory(currentDirectory); |
||||
if (fileSelectionMode == FileSelectionMode.FILE) { |
||||
File file = fileChooser.showOpenDialog(stage); |
||||
if (file != null) { |
||||
selectedFiles = new File[]{file}; |
||||
} |
||||
} else if (fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { |
||||
List<File> fileList = fileChooser.showOpenMultipleDialog(stage); |
||||
if (fileList != null) { |
||||
selectedFiles = new File[fileList.size()]; |
||||
fileList.toArray(selectedFiles); |
||||
} |
||||
} |
||||
} else if (fileSelectionMode == FileSelectionMode.DIR) { |
||||
DirectoryChooser directoryChooser = new DirectoryChooser(); |
||||
directoryChooser.setTitle(title); |
||||
directoryChooser.setInitialDirectory(currentDirectory); |
||||
File folder = directoryChooser.showDialog(stage); |
||||
if (folder != null) { |
||||
selectedFiles = new File[]{folder}; |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
||||
} finally { |
||||
latch.countDown(); |
||||
closeCoverStage(stage); |
||||
} |
||||
} |
||||
|
||||
private void closeCoverStage(Stage stage) { |
||||
if (stage != null) { |
||||
stage.close(); |
||||
closeCoverStage((Stage) stage.getOwner()); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
private Stage showCoverStage(Component component) { |
||||
try { |
||||
if (component == null) |
||||
return null; |
||||
Stage parentStage = showCoverStage(component.getParent()); |
||||
if (component instanceof JDialog || component instanceof JFrame) { |
||||
return createStage(component.getX(), component.getY(), component.getWidth(), component.getHeight(), parentStage); |
||||
} else { |
||||
return parentStage; |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
private Stage createStage(double x, double y, double w, double h, Stage parentStage) { |
||||
try { |
||||
Stage stage = new Stage(); |
||||
stage.setX(x); |
||||
stage.setY(y); |
||||
stage.setWidth(w); |
||||
stage.setHeight(h); |
||||
stage.setOpacity(0.2); |
||||
stage.setResizable(false); |
||||
stage.initStyle(StageStyle.UNDECORATED); |
||||
|
||||
Label label = new Label(); |
||||
label.setBackground( |
||||
new Background(new BackgroundFill(Color.color(0.78, 0.78, 0.80, 0.5), null, null))); |
||||
stage.setScene(new Scene(label)); |
||||
|
||||
|
||||
if (parentStage != null) { |
||||
stage.initOwner(parentStage); |
||||
stage.initModality(Modality.WINDOW_MODAL); |
||||
} |
||||
stage.show(); |
||||
return stage; |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
||||
return null; |
||||
} |
||||
} |
||||
}); |
||||
|
||||
try { |
||||
latch.await(); |
||||
} catch (InterruptedException ignore) { |
||||
} |
||||
return selectedFiles.length > 0 ? JFileChooser.APPROVE_OPTION : JFileChooser.CANCEL_OPTION; |
||||
} |
||||
|
||||
public void setSelectionMode(FileSelectionMode fileSelectionMode) { |
||||
this.fileSelectionMode = fileSelectionMode; |
||||
} |
||||
|
||||
public void setCurrentDirectory(File currentDirectory) { |
||||
this.currentDirectory = currentDirectory; |
||||
} |
||||
|
||||
|
||||
public static class Builder { |
||||
private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE; |
||||
private String title = Toolkit.i18nText("Fine-Design_Basic_Open"); |
||||
private FileChooser.ExtensionFilter[] filters = new FileChooser.ExtensionFilter[0]; |
||||
private File currentDirectory; |
||||
|
||||
public Builder fileSelectionMode(FileSelectionMode fileSelectionMode) { |
||||
this.fileSelectionMode = fileSelectionMode; |
||||
return this; |
||||
} |
||||
|
||||
public Builder title(String title) { |
||||
this.title = title; |
||||
return this; |
||||
} |
||||
|
||||
public Builder filters(FileChooser.ExtensionFilter[] filters) { |
||||
this.filters = filters; |
||||
return this; |
||||
} |
||||
|
||||
public Builder filter(String des, String... extensions) { |
||||
if (extensions != null) { |
||||
this.filters = new FileChooser.ExtensionFilter[]{new FileChooser.ExtensionFilter(des, extensions)}; |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
|
||||
public Builder currentDirectory(File currentDirectory) { |
||||
if (currentDirectory != null) { |
||||
if (!currentDirectory.isDirectory()) { |
||||
currentDirectory = currentDirectory.getParentFile(); |
||||
} |
||||
if (currentDirectory != null && currentDirectory.isDirectory()) { |
||||
this.currentDirectory = currentDirectory; |
||||
} |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
public Builder currentDirectory(String path) { |
||||
if (path != null) { |
||||
return currentDirectory(new File(path)); |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
public JavaFxNativeFileChooser build() { |
||||
return new JavaFxNativeFileChooser(this); |
||||
} |
||||
} |
||||
|
||||
private JavaFxNativeFileChooser(Builder builder) { |
||||
this.fileSelectionMode = builder.fileSelectionMode; |
||||
this.title = builder.title; |
||||
this.filters = builder.filters; |
||||
this.currentDirectory = builder.currentDirectory; |
||||
} |
||||
} |
@ -0,0 +1,454 @@
|
||||
package com.fr.design.javascript; |
||||
|
||||
import com.fr.base.BaseFormula; |
||||
import com.fr.base.Parameter; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.editor.editor.FormulaEditor; |
||||
import com.fr.design.gui.frpane.ReportletParameterViewPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.gui.itree.filetree.TemplateFileTree; |
||||
import com.fr.design.hyperlink.AbstractHyperLinkPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.scrollruler.ModLineBorder; |
||||
import com.fr.file.filetree.IOFileNodeFilter; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.js.ExportJavaScript; |
||||
import com.fr.stable.ParameterProvider; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.AbstractButton; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.ButtonGroup; |
||||
import javax.swing.DefaultComboBoxModel; |
||||
import javax.swing.JList; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.SwingUtilities; |
||||
import javax.swing.event.TableModelEvent; |
||||
import javax.swing.event.TableModelListener; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.CardLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.HashSet; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript> { |
||||
|
||||
private ExportRadioGroup templateRadioGroup; |
||||
private UIRadioButton currentTemplateRadio; |
||||
private UIRadioButton otherTemplateRadio; |
||||
private UITextField reportPathTextField; |
||||
private UIButton browserButton; |
||||
private UIComboBox exportTypeComboBox; |
||||
private ExportRadioGroup fileNameRadioGroup; |
||||
private UIRadioButton defaultNameRadio; |
||||
private UIRadioButton customNameRadio; |
||||
private FormulaEditor fileNameFormulaEditor; |
||||
private UICheckBox extendParametersCheckBox; |
||||
private ReportletParameterViewPane parameterViewPane; |
||||
|
||||
private static final double p = TableLayout.PREFERRED; |
||||
private static final Map<String, String> EXPORT_TYPES_MAP = new HashMap<>(); |
||||
private static final String CURRENT_TEMPLATE = "current"; |
||||
private static final String DEFAULT_FILENAME = "default"; |
||||
|
||||
|
||||
static { |
||||
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF")); |
||||
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_PAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Page")); |
||||
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SIMPLE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Simple")); |
||||
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SHEET, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Sheet")); |
||||
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_WORD, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Word")); |
||||
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_IMAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Image")); |
||||
} |
||||
|
||||
public ExportJavaScriptPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting"))); |
||||
|
||||
//导出模板+导出方式+导出文件名
|
||||
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
|
||||
//导出模板
|
||||
JPanel chooseTemplatePane = initChooseTemplatePane(); |
||||
northPane.add(chooseTemplatePane, BorderLayout.NORTH); |
||||
|
||||
//导出方式
|
||||
JPanel exportTypePane = initExportTypePane(); |
||||
northPane.add(exportTypePane, BorderLayout.CENTER); |
||||
|
||||
//导出文件名
|
||||
JPanel fileNamePane = initFileNamePane(); |
||||
northPane.add(fileNamePane, BorderLayout.SOUTH); |
||||
|
||||
//参数
|
||||
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
JPanel paramsPane = initParamsPane(); |
||||
centerPane.add(paramsPane); |
||||
|
||||
this.add(northPane, BorderLayout.NORTH); |
||||
this.add(centerPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
private JPanel initParamsPane() { |
||||
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters")); |
||||
extendParametersCheckBox.setSelected(true); |
||||
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); |
||||
parameterViewPane.setVisible(false); |
||||
parameterViewPane.addTableEditorListener(new TableModelListener() { |
||||
public void tableChanged(TableModelEvent e) { |
||||
List<ParameterProvider> list = parameterViewPane.update(); |
||||
HashSet<String> tempSet = new HashSet<>(); |
||||
for (int i = 0; i < list.size(); i++) { |
||||
if (StringUtils.isEmpty(list.get(i).getName())) { |
||||
continue; |
||||
} |
||||
if (tempSet.contains(list.get(i).toString())) { |
||||
list.remove(i); |
||||
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!"); |
||||
return; |
||||
} |
||||
tempSet.add(list.get(i).toString()); |
||||
} |
||||
} |
||||
}); |
||||
extendParametersCheckBox.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
parameterViewPane.setVisible(e.getStateChange() == ItemEvent.DESELECTED); |
||||
} |
||||
}); |
||||
JPanel paramsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
paramsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Parameters"))); |
||||
paramsPane.add(extendParametersCheckBox, BorderLayout.NORTH); |
||||
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
dynamicPaneWrapper.add(parameterViewPane); |
||||
paramsPane.add(dynamicPaneWrapper, BorderLayout.CENTER); |
||||
return paramsPane; |
||||
} |
||||
|
||||
private JPanel initFileNamePane() { |
||||
UILabel nameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename") + ":"); |
||||
fileNameRadioGroup = new ExportRadioGroup(); |
||||
defaultNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default")); |
||||
defaultNameRadio.setSelected(true); |
||||
customNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Custom")); |
||||
addRadioToGroup(fileNameRadioGroup, defaultNameRadio, customNameRadio); |
||||
fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula")); |
||||
fileNameFormulaEditor.setEnabled(false); |
||||
fileNameRadioGroup.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
if (defaultNameRadio.isSelected()) { |
||||
fileNameFormulaEditor.setEnabled(false); |
||||
} else { |
||||
fileNameFormulaEditor.setEnabled(true); |
||||
} |
||||
} |
||||
}); |
||||
Component[][] components = new Component[][]{{nameLabel, defaultNameRadio, customNameRadio, fileNameFormulaEditor}}; |
||||
JPanel fileNameRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p, p}); |
||||
|
||||
JPanel fileNameTipPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
UILabel fileNameTipLabel = new UILabel("<html><body style=\"color:red\">" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + "</html>"); |
||||
fileNameTipPane.add(fileNameTipLabel); |
||||
|
||||
JPanel fileNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
fileNamePane.add(fileNameRadioPane, BorderLayout.NORTH); |
||||
fileNamePane.add(fileNameTipPane, BorderLayout.CENTER); |
||||
fileNameTipPane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2)); |
||||
fileNamePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2)); |
||||
return fileNamePane; |
||||
} |
||||
|
||||
private JPanel initExportTypePane() { |
||||
UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":"); |
||||
exportTypeComboBox = new UIComboBox(new DefaultComboBoxModel<String>()); |
||||
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) exportTypeComboBox.getModel(); |
||||
String[] allExportTypes = new String[]{ExportJavaScript.EXPORT_PDF, ExportJavaScript.EXPORT_EXCEL_PAGE, ExportJavaScript.EXPORT_EXCEL_SIMPLE, ExportJavaScript.EXPORT_EXCEL_SHEET, ExportJavaScript.EXPORT_WORD, ExportJavaScript.EXPORT_IMAGE}; |
||||
for (int i = 0; i < allExportTypes.length; i++) { |
||||
comboBoxModel.addElement(allExportTypes[i]); |
||||
} |
||||
this.exportTypeComboBox.setRenderer(new UIComboBoxRenderer() { |
||||
|
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
if (value instanceof String) { |
||||
this.setText(EXPORT_TYPES_MAP.get(value)); |
||||
} |
||||
return this; |
||||
} |
||||
}); |
||||
Component[][] components = new Component[][]{{typeLabel, exportTypeComboBox}}; |
||||
|
||||
JPanel exportTypePane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p}); |
||||
exportTypePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2)); |
||||
return exportTypePane; |
||||
} |
||||
|
||||
private JPanel initChooseTemplatePane() { |
||||
UILabel templateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template") + ":"); |
||||
templateRadioGroup = new ExportRadioGroup(); |
||||
currentTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")); |
||||
currentTemplateRadio.setSelected(true); |
||||
otherTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other")); |
||||
addRadioToGroup(templateRadioGroup, currentTemplateRadio, otherTemplateRadio); |
||||
templateRadioGroup.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
if (currentTemplateRadio.isSelected()) { |
||||
browserButton.setEnabled(false); |
||||
} else { |
||||
browserButton.setEnabled(true); |
||||
} |
||||
} |
||||
}); |
||||
Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}}; |
||||
JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p}); |
||||
|
||||
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
// 路径输入框
|
||||
reportPathTextField = new UITextField(20); |
||||
reportPathTextField.setEnabled(false); |
||||
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER); |
||||
|
||||
// 选择路径按钮
|
||||
browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select")); |
||||
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20)); |
||||
browserButton.setEnabled(false); |
||||
reportletNamePane.add(browserButton, BorderLayout.EAST); |
||||
browserButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent evt) { |
||||
final ReportletPane reportletPane = new ReportletPane(); |
||||
reportletPane.setSelectedReportletPath(reportPathTextField.getText()); |
||||
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this)); |
||||
|
||||
reportletDialog.addDialogActionListener(new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
reportPathTextField.setText(reportletPane.getSelectedReportletPath()); |
||||
} |
||||
}); |
||||
reportletDialog.setVisible(true); |
||||
} |
||||
}); |
||||
|
||||
JPanel chooseTemplatePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
chooseTemplatePane.add(reportletRadioPane, BorderLayout.NORTH); |
||||
chooseTemplatePane.add(reportletNamePane, BorderLayout.CENTER); |
||||
chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0,2,5,2)); |
||||
|
||||
return chooseTemplatePane; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(ExportJavaScript ob) { |
||||
if (ob == null) { |
||||
ob = new ExportJavaScript(); |
||||
} |
||||
this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1); |
||||
if (ob.isCurrentTemplate()) { |
||||
this.browserButton.setEnabled(false); |
||||
} else { |
||||
this.browserButton.setEnabled(true); |
||||
this.reportPathTextField.setText(ob.getTemplatePath()); |
||||
} |
||||
this.exportTypeComboBox.setSelectedItem(ob.getExportType()); |
||||
this.fileNameRadioGroup.selectIndexButton(ob.isDefaultFileName() ? 0 : 1); |
||||
if (ob.isDefaultFileName()) { |
||||
this.fileNameFormulaEditor.setEnabled(false); |
||||
} else { |
||||
this.fileNameFormulaEditor.setEnabled(true); |
||||
this.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(ob.getFileName())); |
||||
} |
||||
if (ob.isExtendParameters()) { |
||||
this.extendParametersCheckBox.setSelected(true); |
||||
} else { |
||||
this.extendParametersCheckBox.setSelected(false); |
||||
List<ParameterProvider> parameterList = this.parameterViewPane.update(); |
||||
parameterList.clear(); |
||||
ParameterProvider[] parameters = ob.getParameters(); |
||||
this.parameterViewPane.populate(parameters); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public ExportJavaScript updateBean() { |
||||
ExportJavaScript exportJavaScript = new ExportJavaScript(); |
||||
updateBean(exportJavaScript); |
||||
return exportJavaScript; |
||||
} |
||||
|
||||
@Override |
||||
public void updateBean(ExportJavaScript exportJavaScript) { |
||||
exportJavaScript.setCurrentTemplate(this.currentTemplateRadio.isSelected()); |
||||
exportJavaScript.setTemplatePath(getTemplatePath()); |
||||
exportJavaScript.setExportType(GeneralUtils.objectToString(this.exportTypeComboBox.getSelectedItem())); |
||||
exportJavaScript.setDefaultFileName(this.defaultNameRadio.isSelected()); |
||||
exportJavaScript.setFileName(getFileName()); |
||||
exportJavaScript.setExtendParameters(this.extendParametersCheckBox.isSelected()); |
||||
if (extendParametersCheckBox.isSelected()) { |
||||
exportJavaScript.setParameters(null); |
||||
} else { |
||||
List<ParameterProvider> parameterList = this.parameterViewPane.update(); |
||||
if (!parameterList.isEmpty()) { |
||||
Parameter[] parameters = new Parameter[parameterList.size()]; |
||||
parameterList.toArray(parameters); |
||||
exportJavaScript.setParameters(parameters); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private String getTemplatePath() { |
||||
return currentTemplateRadio.isSelected() ? CURRENT_TEMPLATE : reportPathTextField.getText(); |
||||
} |
||||
|
||||
private String getFileName() { |
||||
return defaultNameRadio.isSelected() ? DEFAULT_FILENAME : fileNameFormulaEditor.getUITextField().getText(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public boolean accept(Object ob) { |
||||
return ob instanceof ExportJavaScript; |
||||
} |
||||
|
||||
@Override |
||||
public void reset() { |
||||
populateBean(null); |
||||
} |
||||
|
||||
@Override |
||||
public java.lang.String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event"); |
||||
} |
||||
|
||||
private void addRadioToGroup(ButtonGroup buttonGroup, UIRadioButton... radios) { |
||||
for (UIRadioButton radio : radios) { |
||||
buttonGroup.add(radio); |
||||
} |
||||
} |
||||
|
||||
class ExportRadioGroup extends ButtonGroup { |
||||
private List<UIRadioButton> radioButtons = new ArrayList<>(); |
||||
|
||||
@Override |
||||
public void add(AbstractButton button) { |
||||
super.add(button); |
||||
|
||||
UIRadioButton radioButton = (UIRadioButton) button; |
||||
radioButtons.add(radioButton); |
||||
} |
||||
|
||||
public void selectIndexButton(int index) { |
||||
if (index < 0 || index > radioButtons.size() - 1) { |
||||
return; |
||||
} |
||||
|
||||
UIRadioButton button = radioButtons.get(index); |
||||
button.setSelected(true); |
||||
} |
||||
|
||||
public void addActionListener(ActionListener actionListener) { |
||||
for (UIRadioButton radioButton : radioButtons) { |
||||
radioButton.addActionListener(actionListener); |
||||
} |
||||
} |
||||
} |
||||
|
||||
class ReportletPane extends BasicPane { |
||||
private TemplateFileTree templateReportletTree; |
||||
private JScrollPane t_panel; |
||||
|
||||
private JPanel cardPane; |
||||
|
||||
public ReportletPane() { |
||||
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); |
||||
|
||||
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
this.add(centerPane, BorderLayout.CENTER); |
||||
|
||||
cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||
centerPane.add(cardPane, BorderLayout.CENTER); |
||||
cardPane.setLayout(new CardLayout()); |
||||
templateReportletTree = new TemplateFileTree(); |
||||
IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt"}); |
||||
templateReportletTree.setFileNodeFilter(filter); |
||||
cardPane.add(t_panel = new JScrollPane(templateReportletTree), "TEMPLATE"); |
||||
|
||||
this.refreshEnv(); |
||||
} |
||||
|
||||
/** |
||||
* 检查是否符合规范 |
||||
* |
||||
* @throws Exception 抛错 |
||||
*/ |
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
String path = this.getSelectedReportletPath(); |
||||
if (path == null) { |
||||
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Function_The_Selected_File_Cannot_Be_Null")); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 刷新Env |
||||
*/ |
||||
public void refreshEnv() { |
||||
this.templateReportletTree.refreshEnv(); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event"); |
||||
} |
||||
|
||||
/* |
||||
* 返回选中的Reportlet的路径 |
||||
*/ |
||||
public String getSelectedReportletPath() { |
||||
if (t_panel.isVisible()) { |
||||
return templateReportletTree.getSelectedTemplatePath(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/* |
||||
* 选中某Reportlet |
||||
*/ |
||||
public void setSelectedReportletPath(String reportletPath) { |
||||
if (reportletPath == null) { |
||||
return; |
||||
} |
||||
templateReportletTree.setSelectedTemplatePath(reportletPath); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,278 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.design.DesignState; |
||||
import com.fr.design.base.mode.DesignModeContext; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.design.file.MutilTempalteTabPane; |
||||
import com.fr.design.file.NewTemplatePane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.imenu.UIMenuHighLight; |
||||
import com.fr.design.gui.itoolbar.UILargeToolbar; |
||||
import com.fr.design.gui.itoolbar.UIToolbar; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; |
||||
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
import javax.swing.JComponent; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.border.MatteBorder; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.Insets; |
||||
import java.util.ArrayList; |
||||
|
||||
/** |
||||
* @author shine |
||||
* @version 10.0 |
||||
* Created by shine on 2021/4/6 |
||||
*/ |
||||
public class CenterRegionContainerPane extends JPanel { |
||||
|
||||
private static volatile CenterRegionContainerPane THIS; |
||||
|
||||
private static final int LEFT_ALIGN_GAP = -5; |
||||
|
||||
private DesktopCardPane centerTemplateCardPane; |
||||
|
||||
private JPanel toolbarPane;//撤销重做 等工具栏 + 模板tab标签 + maybe have cpt 字体
|
||||
|
||||
private JComponent toolbarComponent;//cpt 字体 等工具栏
|
||||
|
||||
private JPanel eastPane;//=largeToolbar+eastCenterPane
|
||||
private UILargeToolbar largeToolbar;//预览
|
||||
|
||||
private JPanel eastCenterPane;//=combineUp + templateTabPane
|
||||
|
||||
private UIToolbar combineUp;//撤销重做 等工具栏
|
||||
|
||||
private JPanel templateTabPane;//新建模板 + 模板tab标签
|
||||
private NewTemplatePane newWorkBookPane;//新建模板button
|
||||
|
||||
|
||||
public static CenterRegionContainerPane getInstance() { |
||||
if (THIS == null) { |
||||
synchronized (CenterRegionContainerPane.class) { |
||||
if (THIS == null) { |
||||
THIS = new CenterRegionContainerPane(); |
||||
} |
||||
} |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
public CenterRegionContainerPane() { |
||||
|
||||
toolbarPane = new JPanel() { |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
|
||||
Dimension dim = super.getPreferredSize(); |
||||
// dim.height = TOOLBAR_HEIGHT;
|
||||
return dim; |
||||
} |
||||
}; |
||||
toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
eastPane.add(largeToolbar = getToolBarMenuDock().createLargeToolbar(), BorderLayout.WEST); |
||||
eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
combineUpTooBar(); |
||||
eastCenterPane.add(combineUp, BorderLayout.NORTH); |
||||
templateTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
templateTabPane.add(newWorkBookPane = getToolBarMenuDock().getNewTemplatePane(), BorderLayout.WEST); |
||||
templateTabPane.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER); |
||||
eastCenterPane.add(templateTabPane, BorderLayout.CENTER); |
||||
|
||||
eastPane.add(eastCenterPane, BorderLayout.CENTER); |
||||
toolbarPane.add(eastPane, BorderLayout.NORTH); |
||||
toolbarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(centerTemplateCardPane = new DesktopCardPane(), BorderLayout.CENTER); |
||||
this.add(toolbarPane, BorderLayout.NORTH); |
||||
|
||||
} |
||||
|
||||
private ToolBarMenuDock getToolBarMenuDock() { |
||||
return DesignerContext.getDesignerFrame().getToolBarMenuDock(); |
||||
} |
||||
|
||||
/** |
||||
* 创建上工具栏 |
||||
*/ |
||||
private void combineUpTooBar() { |
||||
combineUp = new UIToolbar(FlowLayout.LEFT); |
||||
combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); |
||||
combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2)); |
||||
setUpUpToolBar(null); |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* 重置上工具栏 |
||||
*/ |
||||
private void resetCombineUpTooBar(JComponent[] toolbar4Form, ToolBarMenuDockPlus plus) { |
||||
combineUp.removeAll(); |
||||
setUpUpToolBar(toolbar4Form); |
||||
plus.insertToCombineUpToolbar(combineUp); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 填充上工具栏的中的工具 |
||||
* |
||||
* @param toolbar4Form 目标组件 |
||||
*/ |
||||
private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) { |
||||
UIButton[] fixButtons = getToolBarMenuDock().createUp(); |
||||
for (UIButton fixButton : fixButtons) { |
||||
combineUp.add(fixButton); |
||||
} |
||||
if (!DesignModeContext.isAuthorityEditing()) { |
||||
combineUp.addSeparator(new Dimension(2, 16)); |
||||
if (toolbar4Form != null) { |
||||
for (JComponent jComponent : toolbar4Form) { |
||||
combineUp.add(jComponent); |
||||
} |
||||
} |
||||
//添加检测按钮
|
||||
addCheckButton(); |
||||
} |
||||
//添加分享按钮
|
||||
addShareButton(); |
||||
//添加插件中的按钮
|
||||
addExtraButtons(); |
||||
} |
||||
|
||||
|
||||
private void addExtraButtons() { |
||||
|
||||
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||
if (jt == null) { |
||||
return; |
||||
} |
||||
|
||||
|
||||
UIButton[] extraButtons = jt.createExtraButtons(); |
||||
for (UIButton extraButton : extraButtons) { |
||||
combineUp.add(extraButton); |
||||
} |
||||
if (extraButtons.length > 0) { |
||||
combineUp.addSeparator(new Dimension(2, 16)); |
||||
} |
||||
} |
||||
|
||||
private void addCheckButton() { |
||||
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||
if (jt == null) { |
||||
return; |
||||
} |
||||
combineUp.addSeparator(new Dimension(2, 16)); |
||||
UIButton[] checkButtons = jt.createCheckButton(); |
||||
for (UIButton checkButton : checkButtons) { |
||||
combineUp.add(checkButton); |
||||
} |
||||
} |
||||
|
||||
private void addShareButton() { |
||||
|
||||
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||
if (jt == null) { |
||||
return; |
||||
} |
||||
|
||||
combineUp.addSeparator(new Dimension(2, 16)); |
||||
UIButton[] shareButtons = jt.createShareButton(); |
||||
for (UIButton shareButton : shareButtons) { |
||||
combineUp.add(shareButton); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 检查 |
||||
* |
||||
* @param flag 组件是否可见 |
||||
* @param al 组件名称 |
||||
*/ |
||||
protected void checkCombineUp(boolean flag, ArrayList<String> al) { |
||||
//Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的
|
||||
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||
if (jTemplate != null) { |
||||
// 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return
|
||||
if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) { |
||||
return; |
||||
} |
||||
combineUp.checkComponentsByNames(flag, al); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 重置相关的工具条. |
||||
* |
||||
* @param plus 工具条中相关信息 |
||||
*/ |
||||
protected void resetToolkitByPlus(ToolBarMenuDockPlus plus, ToolBarMenuDock ad) { |
||||
|
||||
resetCombineUpTooBar(ad.resetUpToolBar(plus), plus); |
||||
|
||||
if (toolbarComponent != null) { |
||||
toolbarPane.remove(toolbarComponent); |
||||
} |
||||
|
||||
// 颜色,字体那些按钮的工具栏
|
||||
toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); |
||||
|
||||
if (plus.hasToolBarPane()) { |
||||
this.add(toolbarPane, BorderLayout.NORTH); |
||||
} else { |
||||
this.remove(toolbarPane); |
||||
} |
||||
|
||||
resetByDesignMode(); |
||||
} |
||||
|
||||
private void resetByDesignMode() { |
||||
if (DesignModeContext.isDuchampMode()) { |
||||
eastPane.remove(largeToolbar); |
||||
eastCenterPane.remove(templateTabPane); |
||||
centerTemplateCardPane.refresh(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); |
||||
} else { |
||||
eastPane.add(largeToolbar, BorderLayout.WEST); |
||||
eastCenterPane.add(templateTabPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
} |
||||
|
||||
JComponent getToolbarComponent() { |
||||
|
||||
return this.toolbarComponent; |
||||
} |
||||
|
||||
/** |
||||
* 判断是否在权限编辑状态,若是在权限编辑状态,则需要有虚线框和关闭突变 |
||||
*/ |
||||
protected void needToAddAuhtorityPaint() { |
||||
newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); |
||||
|
||||
} |
||||
|
||||
|
||||
protected DesktopCardPane getCenterTemplateCardPane() { |
||||
|
||||
return centerTemplateCardPane; |
||||
} |
||||
|
||||
protected void refreshUIToolBar() { |
||||
if (toolbarComponent instanceof UIToolbar) { |
||||
((UIToolbar ) toolbarComponent).refreshUIToolBar(); |
||||
} |
||||
combineUp.refreshUIToolBar(); |
||||
getToolBarMenuDock().updateEnable(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,83 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.design.file.TemplateTreePane; |
||||
import com.fr.design.gui.itree.filetree.TemplateFileTree; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author shine |
||||
* @version 10.0 |
||||
* Created by shine on 2021/5/7 |
||||
*/ |
||||
public class JTemplateNameHelper { |
||||
|
||||
private static final int PREFIX_NUM = 3000; |
||||
|
||||
private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复
|
||||
|
||||
public static String newTemplateNameByIndex(String prefix) { |
||||
// 用于获取左侧模板的文件名,如左侧已包含"WorkBook1.cpt, WorkBook12.cpt, WorkBook177.cpt"
|
||||
// 那么新建的文件名将被命名为"WorkBook178.cpt",即取最大数+1
|
||||
TemplateFileTree tt = TemplateTreePane.getInstance().getTemplateFileTree(); |
||||
DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot(); |
||||
String[] str = new String[gen.getChildCount()]; |
||||
|
||||
List<Integer> reportNum = new ArrayList<>(); |
||||
for (int j = 0; j < gen.getChildCount(); j++) { |
||||
str[j] = gen.getChildAt(j).toString(); |
||||
//返回文件名中的index(算法中没有再匹配文件后缀了,因为DefaultMutableTreeNode中已经匹配过了)
|
||||
Integer index = getFileNameIndex(prefix, str[j]); |
||||
if (index != null) { |
||||
reportNum.add(index); |
||||
} |
||||
} |
||||
Collections.sort(reportNum); |
||||
int idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1) + 1 : 1; |
||||
|
||||
idx = idx + currentIndex; |
||||
currentIndex++; |
||||
return prefix + idx; |
||||
} |
||||
|
||||
/** |
||||
* @return java.lang.Integer WorkBook11.cpt则返回11,如果没有找到index返回null |
||||
* @Description 返回文件名中的index |
||||
* @param: prefix 前缀 |
||||
* @param: fileName 文件名称全名 |
||||
* @Author Henry.Wang |
||||
* @Date 2021/4/9 11:13 |
||||
**/ |
||||
private static Integer getFileNameIndex(String prefix, String fileName) { |
||||
char[] chars = new char[fileName.length()]; |
||||
int i = 0; |
||||
for (; i < fileName.length(); i++) { |
||||
char c = fileName.charAt(i); |
||||
//匹配前缀
|
||||
if (i < prefix.length()) { |
||||
if (c != prefix.charAt(i)) { |
||||
return null; |
||||
} |
||||
} else { |
||||
if (c == '.') { |
||||
break; |
||||
} else { |
||||
//匹配0~9
|
||||
if (c < 48 || c > 57) { |
||||
return null; |
||||
} |
||||
chars[i - prefix.length()] = c; |
||||
} |
||||
} |
||||
} |
||||
String s = new String(chars).substring(0, i - prefix.length()); |
||||
if (StringUtils.isBlank(s)) { |
||||
return null; |
||||
} |
||||
return Integer.valueOf(s); |
||||
} |
||||
} |
@ -0,0 +1,144 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.design.DesignState; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.fun.TitlePlaceProcessor; |
||||
import com.fr.design.gui.imenu.UIMenuHighLight; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.loghandler.LogMessageBar; |
||||
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; |
||||
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; |
||||
import com.fr.design.menu.MenuManager; |
||||
import com.fr.design.os.impl.SupportOSImpl; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.injectable.PluginModule; |
||||
import com.fr.plugin.manage.PluginFilter; |
||||
import com.fr.plugin.observer.PluginEvent; |
||||
import com.fr.plugin.observer.PluginEventListener; |
||||
import com.fr.stable.os.support.OSBasedAction; |
||||
import com.fr.stable.os.support.OSSupportCenter; |
||||
|
||||
import javax.swing.JMenuBar; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingUtilities; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.FlowLayout; |
||||
|
||||
/** |
||||
* @author shine |
||||
* @version 10.0 |
||||
* Created by shine on 2021/4/6 |
||||
*/ |
||||
public class NorthRegionContainerPane extends JPanel { |
||||
|
||||
private static volatile NorthRegionContainerPane THIS; |
||||
|
||||
private JMenuBar menuBar; |
||||
|
||||
public static NorthRegionContainerPane getInstance() { |
||||
if (THIS == null) { |
||||
synchronized (NorthRegionContainerPane.class) { |
||||
if (THIS == null) { |
||||
THIS = new NorthRegionContainerPane(); |
||||
} |
||||
} |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
public NorthRegionContainerPane() { |
||||
|
||||
ToolBarMenuDock ad = DesignerContext.getDesignerFrame().getToolBarMenuDock(); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(new UIMenuHighLight(), BorderLayout.SOUTH); |
||||
this.add(initNorthEastPane(ad), BorderLayout.EAST); |
||||
} |
||||
|
||||
/** |
||||
* @param ad 菜单栏 |
||||
* @return panel |
||||
*/ |
||||
protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { |
||||
//hugh: private修改为protected方便oem的时候修改右上的组件构成
|
||||
//顶部日志+登陆按钮
|
||||
final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
//优先级为-1,保证最后全面刷新一次
|
||||
GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { |
||||
|
||||
@Override |
||||
public void on(PluginEvent event) { |
||||
|
||||
refreshNorthEastPane(northEastPane, ad); |
||||
SwingUtilities.invokeLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
if (DesignerContext.getDesignerFrame() == null) { |
||||
return; |
||||
} |
||||
DesignerContext.getDesignerFrame().refresh(); |
||||
DesignerContext.getDesignerFrame().repaint(); |
||||
} |
||||
}); |
||||
} |
||||
}, new PluginFilter() { |
||||
|
||||
@Override |
||||
public boolean accept(PluginContext context) { |
||||
|
||||
return context.contain(PluginModule.ExtraDesign); |
||||
} |
||||
}); |
||||
refreshNorthEastPane(northEastPane, ad); |
||||
return northEastPane; |
||||
} |
||||
|
||||
private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) { |
||||
|
||||
northEastPane.removeAll(); |
||||
northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); |
||||
northEastPane.add(LogMessageBar.getInstance()); |
||||
TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); |
||||
if (processor != null) { |
||||
final Component[] bbsLoginPane = {null}; |
||||
OSSupportCenter.buildAction(new OSBasedAction() { |
||||
@Override |
||||
public void execute(Object... objects) { |
||||
bbsLoginPane[0] = ad.createBBSLoginPane(); |
||||
} |
||||
}, SupportOSImpl.USERINFOPANE); |
||||
processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); |
||||
} |
||||
northEastPane.add(ad.createAlphaFinePane()); |
||||
if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { |
||||
ad.createAlphaFinePane().setVisible(false); |
||||
} |
||||
northEastPane.add(ad.createNotificationCenterPane()); |
||||
|
||||
OSSupportCenter.buildAction(new OSBasedAction() { |
||||
@Override |
||||
public void execute(Object... objects) { |
||||
northEastPane.add(ad.createBBSLoginPane()); |
||||
} |
||||
}, SupportOSImpl.USERINFOPANE); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 重置相关的工具条. |
||||
* |
||||
* @param plus 工具条中相关信息 |
||||
*/ |
||||
void resetToolkitByPlus(ToolBarMenuDockPlus plus, ToolBarMenuDock ad) { |
||||
DesignState designState = new DesignState(plus); |
||||
MenuManager.getInstance().setMenus4Designer(designState); |
||||
if (menuBar == null) { |
||||
this.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); |
||||
} else { |
||||
ad.resetJMenuBar(menuBar, plus); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.env; |
||||
|
||||
import com.fr.general.locale.LocaleCenter; |
||||
import com.fr.general.locale.LocaleMark; |
||||
import com.fr.locale.InterProviderFactory; |
||||
import com.fr.stable.StringUtils; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 错误提示中的跳转链接管理 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/9 |
||||
*/ |
||||
public class HelpLink { |
||||
|
||||
public static String getLink(String solution) { |
||||
Map<String, String> map = new HashMap<>(); |
||||
LocaleMark<String> linkMark = LocaleCenter.getMark(RemoteDesignLocaleMark.class); |
||||
String link = linkMark.getValue(); |
||||
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), StringUtils.EMPTY); |
||||
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Cert_Error_Solution"), link); |
||||
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Connection_Unknown_Error_Solution"), link); |
||||
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_NetWork_Connection_Error_Solution"), link); |
||||
return map.get(solution); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.env; |
||||
|
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.locale.LocaleMark; |
||||
import java.util.HashMap; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/9 |
||||
*/ |
||||
public class RemoteDesignLocaleMark implements LocaleMark<String> { |
||||
|
||||
private Map<Locale, String> map = new HashMap<>(); |
||||
private static final String REMOTE_DESIGN_CN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.zh_CN", "https://help.fanruan.com/finereport/doc-view-3925.html"); |
||||
private static final String REMOTE_DESIGN_EN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.en_US", "https://help.fanruan.com/finereport-en/doc-view-3862.html"); |
||||
|
||||
|
||||
public RemoteDesignLocaleMark() { |
||||
map.put(Locale.CHINA, REMOTE_DESIGN_CN); |
||||
map.put(Locale.KOREA, REMOTE_DESIGN_EN); |
||||
map.put(Locale.JAPAN, REMOTE_DESIGN_EN); |
||||
map.put(Locale.US, REMOTE_DESIGN_EN); |
||||
map.put(Locale.TAIWAN, REMOTE_DESIGN_CN); |
||||
} |
||||
|
||||
@Override |
||||
public String getValue() { |
||||
String result = map.get(GeneralContext.getLocale()); |
||||
return result == null ? REMOTE_DESIGN_CN : result; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.fr.env.handler; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/5 |
||||
*/ |
||||
public interface Handler<T, R> { |
||||
|
||||
/** |
||||
* @param t |
||||
* @return 是否需要继续处理 |
||||
*/ |
||||
R handle(T t); |
||||
|
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.fr.env.handler; |
||||
|
||||
/** |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/11 |
||||
*/ |
||||
public class RefWrapper { |
||||
|
||||
private final Throwable throwable; |
||||
|
||||
private final String link; |
||||
|
||||
|
||||
public RefWrapper(Throwable throwable, String link) { |
||||
this.throwable = throwable; |
||||
this.link = link; |
||||
} |
||||
|
||||
public Throwable getThrowable() { |
||||
return throwable; |
||||
} |
||||
|
||||
public String getLink() { |
||||
return link; |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.env.handler; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/5 |
||||
*/ |
||||
public class ResultWrapper { |
||||
|
||||
private final boolean next; |
||||
|
||||
private final Throwable throwable; |
||||
|
||||
public ResultWrapper(Throwable throwable) { |
||||
this(true, throwable); |
||||
} |
||||
|
||||
public ResultWrapper(boolean next, Throwable e) { |
||||
this.next = next; |
||||
this.throwable = e; |
||||
} |
||||
|
||||
public boolean isNext() { |
||||
return next; |
||||
} |
||||
|
||||
public Throwable getThrowable() { |
||||
return throwable; |
||||
} |
||||
} |
@ -0,0 +1,97 @@
|
||||
package com.fr.env.handler; |
||||
|
||||
import com.fr.base.exception.ExceptionDescriptor; |
||||
import com.fr.design.EnvChangeEntrance; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.env.DesignerWorkspaceInfo; |
||||
import com.fr.design.env.DesignerWorkspaceType; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.env.RemoteWorkspaceURL; |
||||
import com.fr.env.handler.impl.CancelHandler; |
||||
import com.fr.env.handler.impl.CommonHandler; |
||||
import com.fr.env.handler.impl.ExecutionHandler; |
||||
import com.fr.env.handler.impl.UnexpectedHandler; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.StringUtils; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import javax.swing.UIManager; |
||||
|
||||
|
||||
import static javax.swing.JOptionPane.ERROR_MESSAGE; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/5 |
||||
*/ |
||||
public class WorkspaceExceptionHandler { |
||||
|
||||
private static final WorkspaceExceptionHandler INSTANCE = new WorkspaceExceptionHandler(); |
||||
|
||||
public static WorkspaceExceptionHandler getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
private final List<Handler<RefWrapper, ResultWrapper>> testList = new ArrayList<>(); |
||||
|
||||
private final List<Handler<RefWrapper, ResultWrapper>> switchList = new ArrayList<>(); |
||||
|
||||
private WorkspaceExceptionHandler() { |
||||
// 要保证顺序
|
||||
testList.add(new CancelHandler()); |
||||
testList.add(new ExecutionHandler()); |
||||
testList.add(new UnexpectedHandler()); |
||||
testList.add(new CommonHandler(false)); |
||||
|
||||
switchList.add(new CancelHandler()); |
||||
switchList.add(new ExecutionHandler()); |
||||
switchList.add(new UnexpectedHandler()); |
||||
switchList.add(new CommonHandler(true)); |
||||
} |
||||
|
||||
public void handle(Throwable e, List<Handler<RefWrapper, ResultWrapper>> list, DesignerWorkspaceInfo workspaceInfo) { |
||||
Throwable throwable = e; |
||||
ResultWrapper wrapper; |
||||
String link = workspaceInfo.getConnection().getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH; |
||||
for (Handler<RefWrapper, ResultWrapper> handler : list) { |
||||
wrapper = handler.handle(new RefWrapper(throwable, link)); |
||||
throwable = wrapper.getThrowable(); |
||||
if (!wrapper.isNext()) { |
||||
break; |
||||
} |
||||
} |
||||
FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable); |
||||
} |
||||
|
||||
public void handleInSwitch(Throwable e, DesignerWorkspaceInfo workspaceInfo) { |
||||
if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
if (e instanceof ExceptionDescriptor) { |
||||
new CommonHandler(true).handle(new RefWrapper(e, StringUtils.EMPTY)); |
||||
} else { |
||||
FineJOptionPane.showMessageDialog(EnvChangeEntrance.getInstance().getDialog(), |
||||
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), |
||||
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
||||
ERROR_MESSAGE, |
||||
UIManager.getIcon("OptionPane.errorIcon")); |
||||
} |
||||
return; |
||||
} |
||||
handle(e, switchList, workspaceInfo); |
||||
} |
||||
|
||||
public void handleInStart(Throwable e, DesignerWorkspaceInfo workspaceInfo) { |
||||
if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
new CommonHandler(false).handle(new RefWrapper(e, StringUtils.EMPTY)); |
||||
return; |
||||
} |
||||
handle(e, testList, workspaceInfo); |
||||
} |
||||
|
||||
public void handleInTest(Throwable e, DesignerWorkspaceInfo workspaceInfo) { |
||||
handle(e, testList, workspaceInfo); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.fr.env.handler.impl; |
||||
|
||||
import com.fr.env.handler.Handler; |
||||
import com.fr.env.handler.RefWrapper; |
||||
import com.fr.env.handler.ResultWrapper; |
||||
import java.util.concurrent.CancellationException; |
||||
|
||||
/** |
||||
* 取消测试连接时的处理器 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/5 |
||||
*/ |
||||
public class CancelHandler implements Handler<RefWrapper, ResultWrapper> { |
||||
|
||||
@Override |
||||
public ResultWrapper handle(RefWrapper wrapper) { |
||||
Throwable e = wrapper.getThrowable(); |
||||
return new ResultWrapper(!(e instanceof CancellationException), e); |
||||
} |
||||
} |
@ -0,0 +1,52 @@
|
||||
package com.fr.env.handler.impl; |
||||
|
||||
import com.fr.base.exception.ExceptionDescriptor; |
||||
import com.fr.design.EnvChangeEntrance; |
||||
import com.fr.design.dialog.UIDetailErrorLinkDialog; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.env.HelpLink; |
||||
import com.fr.env.handler.Handler; |
||||
import com.fr.env.handler.RefWrapper; |
||||
import com.fr.env.handler.ResultWrapper; |
||||
import com.fr.stable.StringUtils; |
||||
import javax.swing.SwingUtilities; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/5 |
||||
*/ |
||||
public class CommonHandler implements Handler<RefWrapper, ResultWrapper> { |
||||
|
||||
private final boolean onSwitch; |
||||
|
||||
public CommonHandler(boolean onSwitch) { |
||||
this.onSwitch = onSwitch; |
||||
} |
||||
|
||||
@Override |
||||
public ResultWrapper handle(RefWrapper wrapper) { |
||||
Throwable e = wrapper.getThrowable(); |
||||
if (e instanceof ExceptionDescriptor) { |
||||
ExceptionDescriptor exceptionDescriptor = (ExceptionDescriptor) e; |
||||
SwingUtilities.invokeLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
String link = HelpLink.getLink(exceptionDescriptor.solution()); |
||||
UIDetailErrorLinkDialog detailErrorLinkDialog = UIDetailErrorLinkDialog.newBuilder(). |
||||
setWindow(onSwitch ? DesignerContext.getDesignerFrame() : EnvChangeEntrance.getInstance().getDialog()). |
||||
setErrorCode(exceptionDescriptor.errorCode()). |
||||
setReason(exceptionDescriptor.reason()). |
||||
setSolution(exceptionDescriptor.solution()). |
||||
setDetailReason(exceptionDescriptor.detailReason()). |
||||
setTitle(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")). |
||||
setLink(StringUtils.isEmpty(link) ? wrapper.getLink() : link). |
||||
setThrowable(e).build(); |
||||
detailErrorLinkDialog.setVisible(true); |
||||
} |
||||
}); |
||||
} |
||||
return new ResultWrapper(e); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.env.handler.impl; |
||||
|
||||
import com.fr.env.handler.Handler; |
||||
import com.fr.env.handler.RefWrapper; |
||||
import com.fr.env.handler.ResultWrapper; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/5 |
||||
*/ |
||||
public class ExecutionHandler implements Handler<RefWrapper, ResultWrapper> { |
||||
|
||||
@Override |
||||
public ResultWrapper handle(RefWrapper wrapper) { |
||||
Throwable e = wrapper.getThrowable(); |
||||
if (e instanceof ExecutionException) { |
||||
return new ResultWrapper(e.getCause()); |
||||
} |
||||
return new ResultWrapper(e); |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.fr.env.handler.impl; |
||||
|
||||
import com.fr.base.exception.ExceptionDescriptor; |
||||
import com.fr.env.handler.Handler; |
||||
import com.fr.env.handler.RefWrapper; |
||||
import com.fr.env.handler.ResultWrapper; |
||||
import com.fr.workspace.engine.convert.ExceptionConverter; |
||||
|
||||
/** |
||||
* 出现预料之外的情况异常处理器 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/8/5 |
||||
*/ |
||||
public class UnexpectedHandler implements Handler<RefWrapper, ResultWrapper> { |
||||
|
||||
@Override |
||||
public ResultWrapper handle(RefWrapper wrapper) { |
||||
Throwable e = wrapper.getThrowable(); |
||||
if (!(e instanceof ExceptionDescriptor)) { |
||||
return new ResultWrapper(ExceptionConverter.getInstance().convert(e)) ; |
||||
} |
||||
return new ResultWrapper(e); |
||||
} |
||||
} |
After Width: | Height: | Size: 401 B |
After Width: | Height: | Size: 131 B |
After Width: | Height: | Size: 133 B |
After Width: | Height: | Size: 133 B |
After Width: | Height: | Size: 271 B |
After Width: | Height: | Size: 132 B |
After Width: | Height: | Size: 130 B |
After Width: | Height: | Size: 126 B |
After Width: | Height: | Size: 137 B |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 249 B |
@ -0,0 +1 @@
|
||||
report-engine-key=fine-report-engine-10.0.jar |
@ -0,0 +1,23 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import junit.framework.TestCase; |
||||
|
||||
/** |
||||
* @author shine |
||||
* @version 10.0 |
||||
* Created by shine on 2021/5/8 |
||||
*/ |
||||
public class JTemplateNameHelperTest extends TestCase { |
||||
|
||||
public void testNewTemplateNameByIndex() { |
||||
|
||||
String name = JTemplateNameHelper.newTemplateNameByIndex("TEST"); |
||||
|
||||
assertEquals("TEST1", name); |
||||
|
||||
String name1 = JTemplateNameHelper.newTemplateNameByIndex("TEST"); |
||||
|
||||
assertEquals("TEST2", name1); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.design.chart.fun.impl; |
||||
|
||||
import com.fr.chart.charttypes.ChartTypeManager; |
||||
import com.fr.chartx.attr.ChartProvider; |
||||
import com.fr.design.ChartTypeInterfaceManager; |
||||
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; |
||||
|
||||
/** |
||||
* @author shine |
||||
* @version 10.0 |
||||
* Created by shine on 2020/7/8 |
||||
*/ |
||||
public class DefaultChartTypePane<T extends ChartProvider> extends AbstractChartTypePane<T> { |
||||
|
||||
@Override |
||||
protected String[] getTypeIconPath() { |
||||
return ChartTypeInterfaceManager.getInstance().getDemoImagePath(this.getPlotID()); |
||||
} |
||||
|
||||
@Override |
||||
protected String[] getTypeTipName() { |
||||
return ChartTypeInterfaceManager.getInstance().getSubName(this.getPlotID()); |
||||
} |
||||
|
||||
public ChartProvider getDefaultChart() { |
||||
return ChartTypeManager.getInstance().getChartTypes(this.getPlotID())[0]; |
||||
} |
||||
|
||||
public String title4PopupWindow() { |
||||
return ChartTypeInterfaceManager.getInstance().getName(this.getPlotID()); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(T ob) { |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.design.chart.fun.impl; |
||||
|
||||
import com.fr.design.ChartTypeInterfaceManager; |
||||
|
||||
/** |
||||
* @author shine |
||||
* @version 10.0 |
||||
* Created by shine on 2021/6/25 |
||||
*/ |
||||
public class InvisibleChartTypePane extends DefaultChartTypePane { |
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE; |
||||
} |
||||
} |