472 changed files with 23011 additions and 5378 deletions
@ -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,37 @@ |
|||||||
|
package com.fr.design.data.tabledata.strategy; |
||||||
|
|
||||||
|
import com.fr.esd.core.strategy.config.StrategyConfig; |
||||||
|
import com.fr.esd.query.StrategicTableData; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author rinoux |
||||||
|
* @version 10.0 |
||||||
|
* Created by rinoux on 2021/3/19 |
||||||
|
*/ |
||||||
|
public abstract class StrategyConfigHandler<T extends StrategicTableData> { |
||||||
|
|
||||||
|
private final T tableData; |
||||||
|
|
||||||
|
public StrategyConfigHandler(T tableData) { |
||||||
|
this.tableData = tableData; |
||||||
|
} |
||||||
|
|
||||||
|
protected T getTableData() { |
||||||
|
return tableData; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查找配置 |
||||||
|
* |
||||||
|
* @return 缓存配置 |
||||||
|
*/ |
||||||
|
public abstract StrategyConfig find(); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 保存配置 |
||||||
|
* |
||||||
|
* @param config 缓存配置 |
||||||
|
*/ |
||||||
|
public abstract void save(T saved, StrategyConfig config); |
||||||
|
} |
@ -1,47 +0,0 @@ |
|||||||
package com.fr.design.data.tabledata.tabledatapane.db; |
|
||||||
|
|
||||||
import com.fr.data.impl.DBTableData; |
|
||||||
import com.fr.esd.event.DSMapping; |
|
||||||
import com.fr.esd.event.DsNameTarget; |
|
||||||
import com.fr.esd.event.StrategyEventsNotifier; |
|
||||||
import com.fr.esd.event.xml.XMLSavedHook; |
|
||||||
import com.fr.stable.StringUtils; |
|
||||||
|
|
||||||
public class DBTableDataSavedHook implements XMLSavedHook<DBTableData> { |
|
||||||
|
|
||||||
private static final long serialVersionUID = 4925391747683335372L; |
|
||||||
|
|
||||||
private final String tplPath; |
|
||||||
private String origName; |
|
||||||
|
|
||||||
private String origConnection; |
|
||||||
|
|
||||||
private String origQuery; |
|
||||||
|
|
||||||
public DBTableDataSavedHook(String tplPath, DBTableData origDBTableData) { |
|
||||||
this.tplPath = tplPath; |
|
||||||
this.origName = origDBTableData.getDsName(); |
|
||||||
this.origConnection = origDBTableData.getDatabase().toString(); |
|
||||||
this.origQuery = origDBTableData.getQuery(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void doAfterSaved(DBTableData saved) { |
|
||||||
String dsName = saved.getDsName(); |
|
||||||
String conn = saved.getDatabase().toString(); |
|
||||||
String query = saved.getQuery(); |
|
||||||
|
|
||||||
|
|
||||||
//检查数据集名称、数据链接和sql是否修改,如果修改需要触发缓存监听事件
|
|
||||||
if (!dsName.equals(origName) || !conn.equals(origConnection) || !query.equals(origQuery)) { |
|
||||||
if (StringUtils.isNotEmpty(tplPath) && StringUtils.isNotEmpty(origName)) { |
|
||||||
//新建数据集的origName为null,不用触发
|
|
||||||
StrategyEventsNotifier.modifyDataSet(new DSMapping(tplPath, new DsNameTarget(origName))); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
this.origName = dsName; |
|
||||||
this.origConnection = conn; |
|
||||||
this.origQuery = query; |
|
||||||
} |
|
||||||
} |
|
@ -1,70 +0,0 @@ |
|||||||
package com.fr.design.data.tabledata.tabledatapane.db; |
|
||||||
|
|
||||||
import com.fr.data.impl.DBTableData; |
|
||||||
import com.fr.esd.core.strategy.config.StrategyConfig; |
|
||||||
import com.fr.esd.event.DSMapping; |
|
||||||
import com.fr.esd.event.DsNameTarget; |
|
||||||
import com.fr.esd.event.StrategyEventsNotifier; |
|
||||||
import com.fr.log.FineLoggerFactory; |
|
||||||
import com.fr.stable.StringUtils; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author rinoux |
|
||||||
* @version 10.0 |
|
||||||
* Created by rinoux on 2021/3/19 |
|
||||||
*/ |
|
||||||
public class ServerStrategyConfigHandler implements StrategyConfigHandler { |
|
||||||
private final DBTableData tableData; |
|
||||||
|
|
||||||
private final String origName; |
|
||||||
|
|
||||||
private final String origConnection; |
|
||||||
|
|
||||||
private final String origQuery; |
|
||||||
|
|
||||||
public ServerStrategyConfigHandler(DBTableData tableData) { |
|
||||||
this.tableData = tableData; |
|
||||||
this.origName = tableData.getDsName(); |
|
||||||
this.origConnection = tableData.getDatabase().toString(); |
|
||||||
this.origQuery = tableData.getQuery(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public StrategyConfig find() { |
|
||||||
StrategyConfig strategyConfig = null; |
|
||||||
if (tableData != null) { |
|
||||||
try { |
|
||||||
strategyConfig = tableData.getStrategyConfig() == null ? null : tableData.getStrategyConfig().clone(); |
|
||||||
} catch (CloneNotSupportedException e) { |
|
||||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return strategyConfig; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void save(DBTableData saved, StrategyConfig strategyConfig) { |
|
||||||
String conn = saved.getDatabase().toString(); |
|
||||||
String query = saved.getQuery(); |
|
||||||
|
|
||||||
|
|
||||||
//检查数据链接和sql是否修改,如果修改需要触发缓存监听事件
|
|
||||||
if (!conn.equals(origConnection) || !query.equals(origQuery)) { |
|
||||||
if (StringUtils.isNotEmpty(origName)) { |
|
||||||
//新建数据集的origName为null,不用触发
|
|
||||||
StrategyEventsNotifier.modifyDataSet(DSMapping.ofServerDS(new DsNameTarget(origName))); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
//配置变动事件
|
|
||||||
try { |
|
||||||
final StrategyConfig orig = tableData.getStrategyConfig(); |
|
||||||
saved.setStrategyConfig(strategyConfig.clone()); |
|
||||||
StrategyEventsNotifier.compareAndFireConfigEvents(orig, strategyConfig, DSMapping.ofServerDS(new DsNameTarget(saved.getDsName()))); |
|
||||||
} catch (CloneNotSupportedException e) { |
|
||||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,16 +0,0 @@ |
|||||||
package com.fr.design.data.tabledata.tabledatapane.db; |
|
||||||
|
|
||||||
import com.fr.data.impl.DBTableData; |
|
||||||
import com.fr.esd.core.strategy.config.StrategyConfig; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author rinoux |
|
||||||
* @version 10.0 |
|
||||||
* Created by rinoux on 2021/3/19 |
|
||||||
*/ |
|
||||||
public interface StrategyConfigHandler { |
|
||||||
|
|
||||||
StrategyConfig find(); |
|
||||||
|
|
||||||
void save(DBTableData saved, StrategyConfig config); |
|
||||||
} |
|
@ -1,50 +0,0 @@ |
|||||||
package com.fr.design.data.tabledata.tabledatapane.db; |
|
||||||
|
|
||||||
import com.fr.base.TableData; |
|
||||||
import com.fr.data.impl.DBTableData; |
|
||||||
import com.fr.design.data.DesignerStrategyConfigUtils; |
|
||||||
import com.fr.design.file.HistoryTemplateListCache; |
|
||||||
import com.fr.esd.core.strategy.config.StrategyConfig; |
|
||||||
import com.fr.esd.query.StrategicTableData; |
|
||||||
import com.fr.workspace.WorkContext; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author rinoux |
|
||||||
* @version 10.0 |
|
||||||
* Created by rinoux on 2021/3/19 |
|
||||||
*/ |
|
||||||
public class TemplateStrategyConfigHandler implements StrategyConfigHandler { |
|
||||||
|
|
||||||
DBTableData tableData; |
|
||||||
|
|
||||||
public TemplateStrategyConfigHandler(DBTableData tableData) { |
|
||||||
this.tableData = tableData; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public StrategyConfig find() { |
|
||||||
StrategyConfig strategyConfig = null; |
|
||||||
if (tableData != null) { |
|
||||||
//设置保存数据集的事件检查钩子
|
|
||||||
String tplPath = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath(); |
|
||||||
|
|
||||||
//新建模版此时不存在,不需要注册钩子
|
|
||||||
if (tableData.getXmlSavedHook() == null && WorkContext.getWorkResource().exist(tplPath)) { |
|
||||||
tableData.setXmlSavedHook(new DBTableDataSavedHook(tplPath, tableData)); |
|
||||||
} |
|
||||||
|
|
||||||
//获取当前的缓存配置,没有就创建一份
|
|
||||||
String dsName = tableData.getDsName(); |
|
||||||
|
|
||||||
//这里为了之前兼容插件创建的配置,缓存配置不在DBTableData,而是从模版attr读取
|
|
||||||
strategyConfig = DesignerStrategyConfigUtils.getStrategyConfig(dsName); |
|
||||||
} |
|
||||||
|
|
||||||
return strategyConfig; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void save(DBTableData saved, StrategyConfig config) { |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -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,54 @@ |
|||||||
|
package com.fr.design.formula; |
||||||
|
|
||||||
|
import com.fr.parser.BinaryExpression; |
||||||
|
import com.fr.parser.DatasetFunctionCall; |
||||||
|
import com.fr.parser.FunctionCall; |
||||||
|
import com.fr.stable.script.Node; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Hoky |
||||||
|
* @date 2021/8/30 |
||||||
|
*/ |
||||||
|
public class UnsupportedFormulaScanner { |
||||||
|
public final static String[] UNSUPPORTED_FORMULAS = new String[]{"PROPORTION", "TOIMAGE", |
||||||
|
"WEBIMAGE", "SORT", "CROSSLAYERTOTAL", "CIRCULAR", "LAYERTOTAL", "MOM", "HIERARCHY", |
||||||
|
"FILENAME", "FILESIZE", "FILETYPE", "TREELAYER", "GETUSERDEPARTMENTS", "GETUSERJOBTITLES"}; |
||||||
|
|
||||||
|
private String unSupportFormula = ""; |
||||||
|
|
||||||
|
public boolean travelFormula(Node node) { |
||||||
|
if (node instanceof FunctionCall) { |
||||||
|
if (isUnsupportedFomula(((FunctionCall) node).getName())) { |
||||||
|
unSupportFormula = ((FunctionCall) node).getName(); |
||||||
|
return false; |
||||||
|
} else { |
||||||
|
for (Node argument : ((FunctionCall) node).getArguments()) { |
||||||
|
if (!travelFormula(argument)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} else if (node instanceof BinaryExpression) { |
||||||
|
for (Node array : ((BinaryExpression) node).getNodes()) { |
||||||
|
if (!travelFormula(array)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} else if (node instanceof DatasetFunctionCall) { |
||||||
|
DatasetFunctionCall datasetFunctionCall = (DatasetFunctionCall) node; |
||||||
|
unSupportFormula = datasetFunctionCall.getSourceName() + "." + datasetFunctionCall.getFnName() + "()"; |
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public String getUnSupportFormula() { |
||||||
|
return unSupportFormula; |
||||||
|
} |
||||||
|
|
||||||
|
private static boolean isUnsupportedFomula(String formula) { |
||||||
|
return Arrays.asList(UNSUPPORTED_FORMULAS).contains(formula.toUpperCase()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.stable.fun.mark.Mutable; |
||||||
|
|
||||||
|
|
||||||
|
public interface PcFitProvider extends Mutable { |
||||||
|
String XML_TAG = "PcFitProvider"; |
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
//设计器上看到的选项
|
||||||
|
String getContentDisplayValue(); |
||||||
|
|
||||||
|
//返回给前端的值
|
||||||
|
int getContentDisplayKey(); |
||||||
|
|
||||||
|
//设计器上的提示信息
|
||||||
|
String getContentDisplayTip(); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.design.fun.PcFitProvider; |
||||||
|
import com.fr.stable.fun.mark.API; |
||||||
|
|
||||||
|
|
||||||
|
@API(level = PcFitProvider.CURRENT_LEVEL) |
||||||
|
public abstract class AbstractPcFitProvider implements PcFitProvider { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String mark4Provider() { |
||||||
|
return getClass().getName(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.file.FILE; |
||||||
|
import com.fr.intelli.record.Focus; |
||||||
|
import com.fr.intelli.record.Original; |
||||||
|
import com.fr.record.analyzer.EnableMetrics; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by rinoux on 2016/12/16. |
||||||
|
*/ |
||||||
|
@EnableMetrics |
||||||
|
public class DesignerStartWithEmptyFile extends AbstractDesignerStartOpenFileProcessor { |
||||||
|
|
||||||
|
private static final DesignerStartWithEmptyFile INSTANCE = new DesignerStartWithEmptyFile(); |
||||||
|
|
||||||
|
private DesignerStartWithEmptyFile() { |
||||||
|
} |
||||||
|
|
||||||
|
public static DesignerStartWithEmptyFile getInstance() { |
||||||
|
return INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Focus(id = "com.fr.dzstartemptyfile", text = "Fine_Design_Start_Empty_File", source = Original.REPORT) |
||||||
|
public FILE fileToShow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -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,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,36 @@ |
|||||||
|
package com.fr.design.gui.ibutton; |
||||||
|
|
||||||
|
import com.fr.design.gui.ipoppane.PopupHider; |
||||||
|
import com.fr.design.style.color.ColorControlWindow; |
||||||
|
|
||||||
|
import javax.swing.Icon; |
||||||
|
|
||||||
|
|
||||||
|
public class UINoThemeColorButton extends UIColorButton{ |
||||||
|
|
||||||
|
public UINoThemeColorButton(Icon icon) { |
||||||
|
super(icon); |
||||||
|
} |
||||||
|
|
||||||
|
protected ColorControlWindow initColorControlWindow(){ |
||||||
|
return new NoThemeColorControlWindow(this); |
||||||
|
} |
||||||
|
|
||||||
|
private class NoThemeColorControlWindow extends ColorControlWindow{ |
||||||
|
|
||||||
|
|
||||||
|
public NoThemeColorControlWindow(PopupHider popupHider) { |
||||||
|
super(popupHider); |
||||||
|
} |
||||||
|
|
||||||
|
protected boolean supportThemeColor(){ |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
protected void colorChanged() { |
||||||
|
UINoThemeColorButton.this.setColor(this.getColor()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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,20 @@ |
|||||||
|
package com.fr.design.gui.style; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.general.act.BorderPacker; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/8/11 |
||||||
|
*/ |
||||||
|
public abstract class AbstractBorderPackerPane extends BasicPane { |
||||||
|
|
||||||
|
public abstract void populateBean(BorderPacker style); |
||||||
|
public abstract void updateBean(BorderPacker style); |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,99 @@ |
|||||||
|
package com.fr.design.gui.style; |
||||||
|
|
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.dialog.BasicScrollPane; |
||||||
|
import com.fr.design.gui.frpane.UIPercentDragPane; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.general.act.BackgroundPacker; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JComponent; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/8/11 |
||||||
|
*/ |
||||||
|
public abstract class AbstractTranslucentBackgroundSpecialPane<T extends BackgroundPacker> extends BasicPane { |
||||||
|
|
||||||
|
private final int uiLabelWidth; |
||||||
|
private final int uiSettingWidth; |
||||||
|
// 背景名称:如主题背景 或 标题背景
|
||||||
|
private final String backgroundName; |
||||||
|
// 背景
|
||||||
|
protected BackgroundSpecialPane backgroundPane = new LayoutBackgroundSpecialPane(); |
||||||
|
// 背景透明度
|
||||||
|
protected UIPercentDragPane opacityPane = new UIPercentDragPane(); |
||||||
|
|
||||||
|
public AbstractTranslucentBackgroundSpecialPane(int uiLabelWidth, int uiSettingWidth, String backgroundName) { |
||||||
|
this.uiLabelWidth = uiLabelWidth; |
||||||
|
this.uiSettingWidth = uiSettingWidth; |
||||||
|
this.backgroundName = backgroundName; |
||||||
|
this.initializePane(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initializePane() { |
||||||
|
setLayout(new BorderLayout(0, 0)); |
||||||
|
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; |
||||||
|
|
||||||
|
// 确保BackgroundSpecialPane高度变化时,Label依然保持与其顶部对齐
|
||||||
|
JPanel backgroundLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
backgroundLabelPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); |
||||||
|
backgroundLabelPane.add(new UILabel(backgroundName), BorderLayout.NORTH); |
||||||
|
|
||||||
|
JPanel backgroundComposedPane = TableLayoutHelper.createGapTableLayoutPane( |
||||||
|
new JComponent[][]{ |
||||||
|
{backgroundLabelPane, backgroundPane} |
||||||
|
}, |
||||||
|
new double[]{p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); |
||||||
|
|
||||||
|
JPanel opacityComposedPane = TableLayoutHelper.createGapTableLayoutPane( |
||||||
|
new JComponent[][]{ |
||||||
|
{new UILabel(""), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))}, |
||||||
|
{new UILabel(""), opacityPane} |
||||||
|
}, |
||||||
|
new double[]{p, p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); |
||||||
|
opacityComposedPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); |
||||||
|
opacityComposedPane.setVisible(false); |
||||||
|
|
||||||
|
backgroundPane.addChangeListener(new ChangeListener() { |
||||||
|
@Override |
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
Background background = backgroundPane.update(); |
||||||
|
opacityComposedPane.setVisible(background != null); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
add(backgroundComposedPane, BorderLayout.NORTH, 0); |
||||||
|
add(opacityComposedPane, BorderLayout.CENTER, 1); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public abstract void populateBean(T style); |
||||||
|
|
||||||
|
public abstract void updateBean(T style); |
||||||
|
|
||||||
|
protected static class LayoutBackgroundSpecialPane extends BackgroundSpecialPane { |
||||||
|
@Override |
||||||
|
protected GradientBackgroundQuickPane createGradientBackgroundQuickPane() { |
||||||
|
return new GradientBackgroundQuickPane(140); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
package com.fr.design.gui.style; |
||||||
|
|
||||||
|
import com.fr.general.act.BorderPacker; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/8/11 |
||||||
|
*/ |
||||||
|
public class ComponentBodyStylePane extends AbstractTranslucentBackgroundSpecialPane<BorderPacker> { |
||||||
|
|
||||||
|
public ComponentBodyStylePane(int uiLabelWidth) { |
||||||
|
this(uiLabelWidth, -1); |
||||||
|
} |
||||||
|
|
||||||
|
public ComponentBodyStylePane(int uiLabelWidth, int uiSettingWidth) { |
||||||
|
super(uiLabelWidth, uiSettingWidth, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(BorderPacker style) { |
||||||
|
this.backgroundPane.populateBean(style.getBackground()); |
||||||
|
if (this.opacityPane != null) { |
||||||
|
this.opacityPane.populateBean(style.getAlpha()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(BorderPacker style) { |
||||||
|
style.setBackground(backgroundPane.update()); |
||||||
|
style.setAlpha((float)opacityPane.updateBean()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,109 @@ |
|||||||
|
package com.fr.design.gui.style; |
||||||
|
|
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.general.act.BorderPacker; |
||||||
|
|
||||||
|
import javax.swing.JComponent; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/8/11 |
||||||
|
*/ |
||||||
|
public class ComponentIntegralStylePane extends AbstractBorderPackerPane { |
||||||
|
public static final String[] BORDER_STYLE = new String[]{ |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Common"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Shadow") |
||||||
|
}; |
||||||
|
|
||||||
|
//渲染风格:有无阴影
|
||||||
|
protected UIComboBox borderStyleCombo; |
||||||
|
// 含图片类型边框的边框配置面板(图片类型边框 + 阴影时存在默认的阴影颜色)
|
||||||
|
protected TranslucentBorderSpecialPane borderPane; |
||||||
|
//边框圆角或圆角裁剪
|
||||||
|
protected UISpinner cornerSpinner; |
||||||
|
|
||||||
|
private final int uiLabelWidth; |
||||||
|
private final int uiSettingWidth; |
||||||
|
private final boolean supportBorderImage; |
||||||
|
private final boolean supportCornerRadius; |
||||||
|
|
||||||
|
public ComponentIntegralStylePane(int uiLabelWidth, |
||||||
|
boolean supportBorderImage, boolean supportCornerRadius) { |
||||||
|
this(uiLabelWidth, -1, supportBorderImage, supportCornerRadius); |
||||||
|
} |
||||||
|
|
||||||
|
public ComponentIntegralStylePane(int uiLabelWidth, int uiSettingWidth) { |
||||||
|
this(uiLabelWidth, uiSettingWidth, true, true); |
||||||
|
} |
||||||
|
|
||||||
|
public ComponentIntegralStylePane( |
||||||
|
int uiLabelWidth, int uiSettingWidth, |
||||||
|
boolean supportBorderImage, boolean supportCornerRadius) { |
||||||
|
this.uiLabelWidth = uiLabelWidth; |
||||||
|
this.uiSettingWidth = uiSettingWidth; |
||||||
|
this.supportBorderImage = supportBorderImage; |
||||||
|
this.supportCornerRadius = supportCornerRadius; |
||||||
|
|
||||||
|
this.initializePane(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initializeComponents() { |
||||||
|
borderStyleCombo = new UIComboBox(BORDER_STYLE); |
||||||
|
borderPane = new TranslucentBorderSpecialPane(this.supportBorderImage); |
||||||
|
cornerSpinner = new UISpinner(0,1000,1,0); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initializePane() { |
||||||
|
setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
this.initializeComponents(); |
||||||
|
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double[] rowSize = supportCornerRadius ? new double[] {p, p, p} : new double[]{p, p}; |
||||||
|
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; |
||||||
|
|
||||||
|
JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ |
||||||
|
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, |
||||||
|
{this.borderPane, null}, |
||||||
|
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, |
||||||
|
}, |
||||||
|
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); |
||||||
|
|
||||||
|
this.add(content, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(BorderPacker style) { |
||||||
|
if (this.borderStyleCombo != null) { |
||||||
|
this.borderStyleCombo.setSelectedIndex(style.getBorderStyle()); |
||||||
|
} |
||||||
|
if (cornerSpinner != null) { |
||||||
|
this.cornerSpinner.setValue(style.getBorderRadius()); |
||||||
|
} |
||||||
|
if (this.borderPane != null) { |
||||||
|
this.borderPane.populateBean(style); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(BorderPacker style) { |
||||||
|
if (borderStyleCombo != null) { |
||||||
|
style.setBorderStyle(borderStyleCombo.getSelectedIndex()); |
||||||
|
} |
||||||
|
if (cornerSpinner != null) { |
||||||
|
style.setBorderRadius((int) cornerSpinner.getValue()); |
||||||
|
} |
||||||
|
if (borderPane != null) { |
||||||
|
borderPane.updateBean(style); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,348 @@ |
|||||||
|
package com.fr.design.gui.style; |
||||||
|
|
||||||
|
import com.fr.base.Utils; |
||||||
|
import com.fr.base.svg.IconUtils; |
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.formula.TinyFormulaPane; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.ibutton.UIColorButton; |
||||||
|
import com.fr.design.gui.ibutton.UIToggleButton; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.form.ui.LayoutBorderStyle; |
||||||
|
import com.fr.form.ui.WidgetTitle; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.general.act.BorderPacker; |
||||||
|
import com.fr.general.act.TitlePacker; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.Icon; |
||||||
|
import javax.swing.JComponent; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Font; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/8/11 |
||||||
|
*/ |
||||||
|
public class ComponentTitleStylePane extends AbstractBorderPackerPane { |
||||||
|
private static final Dimension BUTTON_SIZE = new Dimension(20, 20); |
||||||
|
public static final TitlePacker DEFAULT_TITLE_PACKER = new WidgetTitle(); |
||||||
|
|
||||||
|
// 标题可见
|
||||||
|
protected UICheckBox visibleCheckbox; |
||||||
|
//标题文字内容
|
||||||
|
protected TinyFormulaPane textContentPane; |
||||||
|
//标题字体格式
|
||||||
|
protected UIComboBox fontFamilyComboBox; |
||||||
|
//标题字体大小
|
||||||
|
protected UIComboBox fontSizeComboBox; |
||||||
|
//标题字体颜色
|
||||||
|
protected UIColorButton fontColorSelectPane; |
||||||
|
//标题字体特殊效果:粗体、斜体、下划线
|
||||||
|
private UIToggleButton fontBoldButton; |
||||||
|
private UIToggleButton fontItalicButton; |
||||||
|
private UIToggleButton fontUnderlineButton; |
||||||
|
// 标题图文混排
|
||||||
|
protected TextInsetImageBackgroundSpecialPane insetImagePane; |
||||||
|
//对齐方式
|
||||||
|
protected UIButtonGroup alignPane; |
||||||
|
//标题整体背景
|
||||||
|
protected TitleTranslucentBackgroundSpecialPane backgroundPane; |
||||||
|
|
||||||
|
// 是否支持用户编辑这些属性(不支持时: 设置面板总是不可见)
|
||||||
|
private boolean isSupportTitleVisible = true; |
||||||
|
private boolean isSupportTitleContent = true; |
||||||
|
private boolean isSupportTitleOtherSetting = true; |
||||||
|
|
||||||
|
// 用于控制各部分设置的可见性
|
||||||
|
private JPanel titleVisiblePane; |
||||||
|
private JPanel titleContentPane; |
||||||
|
private JPanel titleOtherSettingPane; |
||||||
|
|
||||||
|
private final int uiLabelWidth; |
||||||
|
private final int uiSettingWidth; |
||||||
|
|
||||||
|
public ComponentTitleStylePane(int uiLabelWidth) { |
||||||
|
this(uiLabelWidth, -1); |
||||||
|
} |
||||||
|
|
||||||
|
public ComponentTitleStylePane( |
||||||
|
int uiLabelWidth, int uiSettingWidth) { |
||||||
|
this.uiLabelWidth = uiLabelWidth; |
||||||
|
this.uiSettingWidth = uiSettingWidth; |
||||||
|
this.initializePane(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initializeComponents() { |
||||||
|
visibleCheckbox = new UICheckBox(); |
||||||
|
|
||||||
|
textContentPane = new TinyFormulaPane(); |
||||||
|
|
||||||
|
fontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); |
||||||
|
FRFont frFont = DEFAULT_TITLE_PACKER.getFrFont(); |
||||||
|
if (frFont != null) { |
||||||
|
String fontFamily = frFont.getFamily(); |
||||||
|
// 使用style中默认的字体初始化titleFontFamilyComboBox,保证UI和数据的一致性
|
||||||
|
this.fontFamilyComboBox.setSelectedItem(fontFamily); |
||||||
|
} |
||||||
|
fontFamilyComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family")); |
||||||
|
|
||||||
|
fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); |
||||||
|
fontSizeComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size")); |
||||||
|
|
||||||
|
fontColorSelectPane = new UIColorButton(); |
||||||
|
fontColorSelectPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground")); |
||||||
|
fontColorSelectPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground")); |
||||||
|
|
||||||
|
fontBoldButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); |
||||||
|
fontBoldButton.setPreferredSize(BUTTON_SIZE); |
||||||
|
fontBoldButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold")); |
||||||
|
fontBoldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold")); |
||||||
|
|
||||||
|
fontItalicButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); |
||||||
|
fontItalicButton.setPreferredSize(BUTTON_SIZE); |
||||||
|
fontItalicButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic")); |
||||||
|
fontItalicButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic")); |
||||||
|
|
||||||
|
fontUnderlineButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); |
||||||
|
fontUnderlineButton.setPreferredSize(BUTTON_SIZE); |
||||||
|
fontUnderlineButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline")); |
||||||
|
fontUnderlineButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline")); |
||||||
|
|
||||||
|
insetImagePane = new TextInsetImageBackgroundSpecialPane(); |
||||||
|
|
||||||
|
alignPane = new UIButtonGroup<>( |
||||||
|
new Icon[]{ |
||||||
|
IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), |
||||||
|
IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), |
||||||
|
IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png") |
||||||
|
}, |
||||||
|
new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT}); |
||||||
|
alignPane.setAllToolTips( |
||||||
|
new String[] { |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right") |
||||||
|
}); |
||||||
|
alignPane.setSelectedItem(DEFAULT_TITLE_PACKER.getPosition()); |
||||||
|
|
||||||
|
backgroundPane = new TitleTranslucentBackgroundSpecialPane(this.uiLabelWidth, this.uiSettingWidth); |
||||||
|
} |
||||||
|
|
||||||
|
private void initializePane() { |
||||||
|
this.setLayout(new BorderLayout(0, 0)); |
||||||
|
this.initializeComponents(); |
||||||
|
|
||||||
|
titleVisiblePane = this.createTitleVisiblePane(); |
||||||
|
titleContentPane = this.createTitleContentPane(); |
||||||
|
titleOtherSettingPane = this.createTitleOtherSettingPane(); |
||||||
|
|
||||||
|
if (isSupportTitleVisible) { |
||||||
|
titleVisiblePane.setVisible(true); |
||||||
|
} |
||||||
|
if (isSupportTitleVisible) { |
||||||
|
titleContentPane.setVisible(false); |
||||||
|
} |
||||||
|
if (isSupportTitleVisible) { |
||||||
|
titleOtherSettingPane.setVisible(false); |
||||||
|
} |
||||||
|
|
||||||
|
addComponents(titleVisiblePane, titleContentPane, titleOtherSettingPane); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createTitleVisiblePane() { |
||||||
|
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
|
||||||
|
visibleCheckbox.setSelected(false); |
||||||
|
|
||||||
|
container.add(visibleCheckbox, BorderLayout.WEST); |
||||||
|
container.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER); |
||||||
|
|
||||||
|
visibleCheckbox.addChangeListener(new ChangeListener() { |
||||||
|
@Override |
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
boolean visible = visibleCheckbox.isSelected(); |
||||||
|
if (titleContentPane != null) { |
||||||
|
titleContentPane.setVisible(visible && isSupportTitleContent); |
||||||
|
} |
||||||
|
if (titleOtherSettingPane != null) { |
||||||
|
titleOtherSettingPane.setVisible(visible && isSupportTitleOtherSetting); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
return container; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createTitleContentPane() { |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double[] rowSize = {p}; |
||||||
|
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; |
||||||
|
|
||||||
|
return TableLayoutHelper.createCommonTableLayoutPane( |
||||||
|
new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), textContentPane}}, |
||||||
|
rowSize, columnSize, IntervalConstants.INTERVAL_L1); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createTitleOtherSettingPane() { |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double[] rowSize = {p, p, p, p, p}; |
||||||
|
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; |
||||||
|
|
||||||
|
JComponent[][] components = new JComponent[][]{ |
||||||
|
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), fontFamilyComboBox}, |
||||||
|
{null, createTitleFontButtonPane()}, |
||||||
|
{insetImagePane, null}, |
||||||
|
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), alignPane}, |
||||||
|
{backgroundPane, null} |
||||||
|
}; |
||||||
|
|
||||||
|
return TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, IntervalConstants.INTERVAL_L1); |
||||||
|
} |
||||||
|
|
||||||
|
protected JPanel createTitleFontButtonPane(){ |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double[] rowSize = {p}; |
||||||
|
double[] columnSize = {f, p, p, p, p}; |
||||||
|
|
||||||
|
JPanel buttonPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] { |
||||||
|
{fontSizeComboBox, fontColorSelectPane, fontItalicButton, fontBoldButton, fontUnderlineButton}, |
||||||
|
}, rowSize, columnSize, IntervalConstants.INTERVAL_W0); |
||||||
|
|
||||||
|
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
containerPane.add(buttonPane, BorderLayout.NORTH); |
||||||
|
|
||||||
|
return containerPane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(BorderPacker style) { |
||||||
|
TitlePacker widgetTitle = style == null ? new WidgetTitle() : style.getTitle(); |
||||||
|
widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; |
||||||
|
boolean titleVisible = style != null && style.getType() != LayoutBorderStyle.STANDARD; |
||||||
|
visibleCheckbox.setSelected(isSupportTitleVisible && titleVisible); |
||||||
|
titleContentPane.setVisible(isSupportTitleContent && titleVisible); |
||||||
|
titleOtherSettingPane.setVisible(isSupportTitleOtherSetting && titleVisible); |
||||||
|
|
||||||
|
this.textContentPane.populateBean(widgetTitle.getTextObject().toString()); |
||||||
|
|
||||||
|
FRFont frFont = widgetTitle.getFrFont(); |
||||||
|
this.fontSizeComboBox.setSelectedItem(frFont.getSize()); |
||||||
|
this.fontFamilyComboBox.setSelectedItem(frFont.getFamily()); |
||||||
|
this.fontColorSelectPane.setColor(frFont.getForeground()); |
||||||
|
this.fontColorSelectPane.repaint(); |
||||||
|
fontBoldButton.setSelected(frFont.isBold()); |
||||||
|
fontItalicButton.setSelected(frFont.isItalic()); |
||||||
|
|
||||||
|
int line = frFont.getUnderline(); |
||||||
|
if (line == Constants.LINE_NONE) { |
||||||
|
fontUnderlineButton.setSelected(false); |
||||||
|
} else { |
||||||
|
fontUnderlineButton.setSelected(true); |
||||||
|
} |
||||||
|
|
||||||
|
alignPane.setSelectedItem(widgetTitle.getPosition()); |
||||||
|
insetImagePane.populateBean(widgetTitle); |
||||||
|
backgroundPane.populateBean(widgetTitle); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(BorderPacker style) { |
||||||
|
style.setType(visibleCheckbox != null && visibleCheckbox.isSelected() ? LayoutBorderStyle.TITLE : LayoutBorderStyle.STANDARD); |
||||||
|
TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); |
||||||
|
title.setTextObject(textContentPane.updateBean()); |
||||||
|
FRFont frFont = title.getFrFont(); |
||||||
|
frFont = frFont.applySize((Integer) fontSizeComboBox.getSelectedItem()); |
||||||
|
frFont = frFont.applyName(fontFamilyComboBox.getSelectedItem().toString()); |
||||||
|
frFont = frFont.applyForeground(fontColorSelectPane.getColor()); |
||||||
|
frFont = updateTitleFontItalicBold(frFont); |
||||||
|
int line = fontUnderlineButton.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE; |
||||||
|
frFont = frFont.applyUnderline(line); |
||||||
|
title.setFrFont(frFont); |
||||||
|
title.setPosition((Integer) alignPane.getSelectedItem()); |
||||||
|
insetImagePane.updateBean(title); |
||||||
|
backgroundPane.updateBean(title); |
||||||
|
style.setTitle(title); |
||||||
|
} |
||||||
|
|
||||||
|
private FRFont updateTitleFontItalicBold(FRFont frFont) { |
||||||
|
int italic_bold = frFont.getStyle(); |
||||||
|
boolean isItalic = italic_bold == Font.ITALIC || italic_bold == (Font.BOLD + Font.ITALIC); |
||||||
|
boolean isBold = italic_bold == Font.BOLD || italic_bold == (Font.BOLD + Font.ITALIC); |
||||||
|
if (fontItalicButton.isSelected() && !isItalic) { |
||||||
|
italic_bold += Font.ITALIC; |
||||||
|
} else if (!fontItalicButton.isSelected() && isItalic) { |
||||||
|
italic_bold -= Font.ITALIC; |
||||||
|
} |
||||||
|
frFont = frFont.applyStyle(italic_bold); |
||||||
|
if (fontBoldButton.isSelected() && !isBold) { |
||||||
|
italic_bold += Font.BOLD; |
||||||
|
} else if (!fontBoldButton.isSelected() && isBold) { |
||||||
|
italic_bold -= Font.BOLD; |
||||||
|
} |
||||||
|
frFont = frFont.applyStyle(italic_bold); |
||||||
|
return frFont; |
||||||
|
} |
||||||
|
|
||||||
|
private void addComponents(JComponent... components) { |
||||||
|
if (components == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
JPanel container = this; |
||||||
|
for (JComponent component: components) { |
||||||
|
if (component != null) { |
||||||
|
container.add(component, BorderLayout.NORTH); |
||||||
|
JPanel nextContainer = new JPanel(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
nextContainer.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); |
||||||
|
container.add(nextContainer, BorderLayout.CENTER); |
||||||
|
container = nextContainer; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void setSupportTitleVisible(boolean supporting) { |
||||||
|
isSupportTitleVisible = supporting; |
||||||
|
if (titleVisiblePane != null) { |
||||||
|
titleVisiblePane.setVisible(supporting); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void setSupportTitleContent(boolean supporting) { |
||||||
|
isSupportTitleContent = supporting; |
||||||
|
if (titleContentPane != null) { |
||||||
|
boolean titleVisible = visibleCheckbox.isSelected(); |
||||||
|
if (isSupportTitleContent) { |
||||||
|
titleContentPane.setVisible(titleVisible); |
||||||
|
} else { |
||||||
|
titleContentPane.setVisible(false); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void setSupportOtherSetting(boolean supporting) { |
||||||
|
isSupportTitleOtherSetting = supporting; |
||||||
|
if (titleOtherSettingPane != null) { |
||||||
|
boolean titleVisible = visibleCheckbox.isSelected(); |
||||||
|
if (isSupportTitleOtherSetting) { |
||||||
|
titleOtherSettingPane.setVisible(titleVisible); |
||||||
|
} else { |
||||||
|
titleOtherSettingPane.setVisible(false); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,138 @@ |
|||||||
|
package com.fr.design.gui.style; |
||||||
|
|
||||||
|
import com.fr.base.theme.FormTheme; |
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.event.GlobalNameListener; |
||||||
|
import com.fr.design.event.GlobalNameObserver; |
||||||
|
import com.fr.design.event.UIObserver; |
||||||
|
import com.fr.design.event.UIObserverListener; |
||||||
|
import com.fr.design.file.HistoryTemplateListCache; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
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.JTemplate; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/8/19 |
||||||
|
*/ |
||||||
|
public class FollowingThemePane extends BasicPane implements UIObserver { |
||||||
|
public static final int SETTING_LABEL_WIDTH = 60; |
||||||
|
|
||||||
|
public static final String[] FOLLOWING_THEME_STRING_ARRAYS = new String[]{ |
||||||
|
Toolkit.i18nText("Fine-Design_Style_Follow_Theme"), |
||||||
|
Toolkit.i18nText("Fine-Design_Style_Not_Follow_Theme"), |
||||||
|
}; |
||||||
|
|
||||||
|
private final UIButtonGroup<String> followingThemeButtonGroup; |
||||||
|
private final List<FollowingThemeActionChangeListener> changeListeners = new ArrayList<>(); |
||||||
|
private UIObserverListener uiObserverListener; |
||||||
|
|
||||||
|
private JPanel container; |
||||||
|
|
||||||
|
public FollowingThemePane(String name) { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||||
|
|
||||||
|
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); |
||||||
|
followingThemeButtonGroup.setSelectedIndex(1); |
||||||
|
followingThemeButtonGroup.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
for (FollowingThemeActionChangeListener changeListener : changeListeners) { |
||||||
|
changeListener.onFollowingTheme(isFollowingTheme()); |
||||||
|
} |
||||||
|
invalidate(); |
||||||
|
|
||||||
|
// 与主题相关的属性面板更新完毕后,再通知外层更新数据
|
||||||
|
if (uiObserverListener != null) { |
||||||
|
uiObserverListener.doChange(); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
UILabel followingThemeLabel = new UILabel(name); |
||||||
|
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
JPanel followingThemePane = |
||||||
|
TableLayoutHelper.createGapTableLayoutPane( new Component[][]{new Component[] { followingThemeLabel, followingThemeButtonGroup}}, |
||||||
|
new double[] { p }, new double[] { SETTING_LABEL_WIDTH, f }, 10, 0); |
||||||
|
followingThemePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||||
|
followingThemePane.setVisible(false); |
||||||
|
|
||||||
|
add(followingThemePane, BorderLayout.NORTH); |
||||||
|
container = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
add(container, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
public void addFollowThemePane(JPanel content, FollowingThemeActionChangeListener changeListener) { |
||||||
|
if (content != null) { |
||||||
|
container.add(content, BorderLayout.NORTH); |
||||||
|
changeListeners.add(changeListener); |
||||||
|
|
||||||
|
JPanel nextContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
container.add(nextContainer, BorderLayout.CENTER); |
||||||
|
container = nextContainer; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void registerChangeListener(UIObserverListener uiObserverListener) { |
||||||
|
this.uiObserverListener = uiObserverListener; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean shouldResponseChangeListener() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public interface FollowingThemeActionChangeListener { |
||||||
|
void onFollowingTheme(boolean following); |
||||||
|
} |
||||||
|
|
||||||
|
public TemplateTheme getUsingTheme() { |
||||||
|
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||||
|
if (template != null) { |
||||||
|
return template.getTemplateTheme(); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public void supportFollowingTheme(boolean supporting) { |
||||||
|
getComponent(0).setVisible(supporting); |
||||||
|
if (!supporting) { |
||||||
|
setFollowingTheme(false); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void setFollowingTheme(boolean following) { |
||||||
|
followingThemeButtonGroup.setSelectedIndex(following ? 0 : 1); |
||||||
|
for (FollowingThemeActionChangeListener changeListener : changeListeners) { |
||||||
|
changeListener.onFollowingTheme(isFollowingTheme()); |
||||||
|
} |
||||||
|
} |
||||||
|
public boolean isFollowingTheme() { |
||||||
|
return followingThemeButtonGroup.getSelectedIndex() == 0; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,102 @@ |
|||||||
|
package com.fr.design.gui.style; |
||||||
|
|
||||||
|
import com.fr.design.ExtraDesignClassManager; |
||||||
|
import com.fr.design.event.UIObserverListener; |
||||||
|
import com.fr.design.fun.BackgroundQuickUIProvider; |
||||||
|
import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.PatternBackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.TextureBackgroundQuickPane; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/8/19 |
||||||
|
*/ |
||||||
|
public class ReportBackgroundSpecialPane extends BackgroundPane { |
||||||
|
public ReportBackgroundSpecialPane(){ |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { |
||||||
|
NullBackgroundQuickPane nullBackgroundPane = new NullBackgroundQuickPane(); |
||||||
|
|
||||||
|
ColorBackgroundQuickPane colorBackgroundPane = new ColorBackgroundQuickPane(); |
||||||
|
colorBackgroundPane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
ImageBackgroundQuickPane imageBackgroundPane = new ImageBackgroundQuickPane(); |
||||||
|
imageBackgroundPane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
GradientBackgroundQuickPane gradientBackgroundPane = createGradientBackgroundQuickPane(); |
||||||
|
gradientBackgroundPane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
TextureBackgroundQuickPane textureBackgroundPane = new TextureBackgroundQuickPane(); |
||||||
|
textureBackgroundPane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
PatternBackgroundQuickPane patternBackgroundPane = new PatternBackgroundQuickPane(); |
||||||
|
patternBackgroundPane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<BackgroundQuickPane> kinds = new ArrayList<BackgroundQuickPane>(); |
||||||
|
|
||||||
|
kinds.add(nullBackgroundPane); |
||||||
|
kinds.add(colorBackgroundPane); |
||||||
|
kinds.add(imageBackgroundPane); |
||||||
|
kinds.add(gradientBackgroundPane); |
||||||
|
kinds.add(textureBackgroundPane); |
||||||
|
kinds.add(patternBackgroundPane); |
||||||
|
|
||||||
|
Set<BackgroundQuickUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING); |
||||||
|
for (BackgroundQuickUIProvider provider : providers) { |
||||||
|
BackgroundQuickPane newTypePane = provider.appearanceForBackground(); |
||||||
|
newTypePane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
kinds.add(newTypePane); |
||||||
|
} |
||||||
|
|
||||||
|
return kinds.toArray(new BackgroundQuickPane[kinds.size()]); |
||||||
|
} |
||||||
|
|
||||||
|
protected GradientBackgroundQuickPane createGradientBackgroundQuickPane() { |
||||||
|
// 使用默认的150宽度构建渐变条
|
||||||
|
return new GradientBackgroundQuickPane(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package com.fr.design.gui.style; |
||||||
|
|
||||||
|
import com.fr.general.act.TitlePacker; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/8/11 |
||||||
|
*/ |
||||||
|
public class TitleTranslucentBackgroundSpecialPane extends AbstractTranslucentBackgroundSpecialPane<TitlePacker> { |
||||||
|
|
||||||
|
public TitleTranslucentBackgroundSpecialPane(int uiLabelWidth, int uiSettingWidth) { |
||||||
|
super(uiLabelWidth, uiSettingWidth, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Background")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(TitlePacker style) { |
||||||
|
backgroundPane.populateBean(style.getBackground()); |
||||||
|
opacityPane.populateBean(style.getBackgroundOpacity()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(TitlePacker style) { |
||||||
|
style.setBackground(backgroundPane.update()); |
||||||
|
style.setBackgroundOpacity((float)opacityPane.updateBean()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,328 @@ |
|||||||
|
package com.fr.design.hyperlink.popup; |
||||||
|
|
||||||
|
import com.fr.base.BaseFormula; |
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.Parameter; |
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.formula.TinyFormulaPane; |
||||||
|
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.itableeditorpane.UITableEditAction; |
||||||
|
import com.fr.design.gui.itextfield.UITextField; |
||||||
|
import com.fr.design.gui.itree.filetree.ReportletPane; |
||||||
|
import com.fr.design.hyperlink.AbstractHyperLinkPane; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.module.DesignModuleFactory; |
||||||
|
import com.fr.design.parameter.ParameterReader; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.js.MobilePopupHyperlink; |
||||||
|
import com.fr.stable.CommonUtils; |
||||||
|
import com.fr.stable.FormulaProvider; |
||||||
|
import com.fr.stable.ParameterProvider; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public class ContentSettingPane extends AbstractHyperLinkPane<MobilePopupHyperlink> { |
||||||
|
private JPanel popupTargetPane; |
||||||
|
private UIRadioButton templatePopupButton; |
||||||
|
private UIRadioButton textPopupButton; |
||||||
|
private ButtonGroup popupTargetButtons; |
||||||
|
|
||||||
|
private JPanel templateContentPane; |
||||||
|
private UITextField templatePathTextField; |
||||||
|
private UICheckBox extendParametersCheckBox; |
||||||
|
|
||||||
|
private JPanel textSettingPanel; |
||||||
|
private TinyFormulaPane textContentPane; |
||||||
|
private CustomFontPane fontPane; |
||||||
|
|
||||||
|
public ContentSettingPane() { |
||||||
|
super(); |
||||||
|
this.initCompoennt(); |
||||||
|
} |
||||||
|
|
||||||
|
public void addTargetRadioActionListener(ActionListener listener) { |
||||||
|
templatePopupButton.addActionListener(listener); |
||||||
|
textPopupButton.addActionListener(listener); |
||||||
|
} |
||||||
|
|
||||||
|
public String getTargetType() { |
||||||
|
if (templatePopupButton.isSelected()) { |
||||||
|
return MobilePopupConstants.Target_Template; |
||||||
|
} else { |
||||||
|
return MobilePopupConstants.Target_Text; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void initCompoennt() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); |
||||||
|
this.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Content"))); |
||||||
|
|
||||||
|
popupTargetPane = this.createPopupTargetPane(); |
||||||
|
this.add(popupTargetPane, BorderLayout.NORTH); |
||||||
|
|
||||||
|
templateContentPane= this.createTemplateContentPane(); |
||||||
|
textSettingPanel = this.createTextSettingPane(); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createPopupTargetPane() { |
||||||
|
templatePopupButton = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Template")); |
||||||
|
templatePopupButton.addActionListener(radioActionListener); |
||||||
|
|
||||||
|
textPopupButton = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Text")); |
||||||
|
textPopupButton.addActionListener(radioActionListener); |
||||||
|
|
||||||
|
popupTargetButtons = new ButtonGroup(); |
||||||
|
popupTargetButtons.add(templatePopupButton); |
||||||
|
popupTargetButtons.add(textPopupButton); |
||||||
|
|
||||||
|
JPanel popupButtonsPanel = new JPanel(); |
||||||
|
popupButtonsPanel.setLayout( new FlowLayout(FlowLayout.LEFT, 10, 0)); |
||||||
|
popupButtonsPanel.add(templatePopupButton); |
||||||
|
popupButtonsPanel.add(textPopupButton); |
||||||
|
return MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Target"), popupButtonsPanel); |
||||||
|
} |
||||||
|
|
||||||
|
private ActionListener radioActionListener = new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if(templatePopupButton.isSelected()) { |
||||||
|
ContentSettingPane.this.add(templateContentPane); |
||||||
|
ContentSettingPane.this.remove(textSettingPanel); |
||||||
|
} else if (textPopupButton.isSelected()) { |
||||||
|
ContentSettingPane.this.add(textSettingPanel); |
||||||
|
ContentSettingPane.this.remove(templateContentPane); |
||||||
|
} |
||||||
|
ContentSettingPane.this.revalidate(); |
||||||
|
ContentSettingPane.this.repaint(); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
private JPanel createTemplateContentPane() { |
||||||
|
JPanel templateContentPane = new JPanel(); |
||||||
|
templateContentPane.setLayout(new BorderLayout(0,8)); |
||||||
|
|
||||||
|
templateContentPane.add(this.createTemplateSelectPanel(), BorderLayout.NORTH); |
||||||
|
|
||||||
|
parameterViewPane = this.createReportletParameterViewPane(); |
||||||
|
templateContentPane.add(parameterViewPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters")); |
||||||
|
templateContentPane.add(GUICoreUtils.createFlowPane(extendParametersCheckBox, FlowLayout.LEFT), BorderLayout.SOUTH); |
||||||
|
|
||||||
|
return templateContentPane; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createTemplateSelectPanel() { |
||||||
|
JPanel templatePanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
// 路径输入框
|
||||||
|
templatePathTextField = new UITextField(20); |
||||||
|
templatePanel.add(templatePathTextField, BorderLayout.CENTER); |
||||||
|
|
||||||
|
// 选择路径按钮
|
||||||
|
UIButton templateSelectButton = new UIButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Select")); |
||||||
|
templateSelectButton.setPreferredSize(new Dimension(templateSelectButton.getPreferredSize().width, 20)); |
||||||
|
templatePanel.add(templateSelectButton, BorderLayout.EAST); |
||||||
|
templateSelectButton.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
final ReportletPane reportletPane = new ReportletPane(); |
||||||
|
reportletPane.setSelectedReportletPath(templatePathTextField.getText()); |
||||||
|
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ContentSettingPane.this)); |
||||||
|
|
||||||
|
reportletDialog.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
templatePathTextField.setText(reportletPane.getSelectedReportletPath()); |
||||||
|
} |
||||||
|
}); |
||||||
|
reportletDialog.setVisible(true); |
||||||
|
} |
||||||
|
}); |
||||||
|
return MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Template"), templatePanel); |
||||||
|
} |
||||||
|
|
||||||
|
private ReportletParameterViewPane createReportletParameterViewPane() { |
||||||
|
ReportletParameterViewPane templateParameterViewPane = new ReportletParameterViewPane( |
||||||
|
new UITableEditAction[]{ |
||||||
|
new HyperlinkParametersAction() |
||||||
|
}, |
||||||
|
getChartParaType(), |
||||||
|
getValueEditorPane(), |
||||||
|
getValueEditorPane() |
||||||
|
); |
||||||
|
templateParameterViewPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Parameter"), null)); |
||||||
|
templateParameterViewPane.setPreferredSize(new Dimension(this.getWidth(), 200)); |
||||||
|
return templateParameterViewPane; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createTextSettingPane() { |
||||||
|
JPanel textSettingPanel = new JPanel(); |
||||||
|
textSettingPanel.setLayout(new BorderLayout(0,8)); |
||||||
|
|
||||||
|
textContentPane = new TinyFormulaPane(); |
||||||
|
textContentPane.getUITextField().setColumns(20); |
||||||
|
textSettingPanel.add( |
||||||
|
MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Text"), textContentPane), |
||||||
|
BorderLayout.CENTER); |
||||||
|
|
||||||
|
fontPane = new CustomFontPane(); |
||||||
|
textSettingPanel.add( |
||||||
|
MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Style"), fontPane), |
||||||
|
BorderLayout.SOUTH); |
||||||
|
return MobilePopupUIUtils.createTitleSplitLineContentPane("", textSettingPanel); |
||||||
|
} |
||||||
|
|
||||||
|
private String getReportletName() { |
||||||
|
String text = this.templatePathTextField.getText(); |
||||||
|
return StringUtils.isBlank(text) ? StringUtils.EMPTY : text.substring(1); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(MobilePopupHyperlink link) { |
||||||
|
this.populatePopupTargetBean(link.getPopupTarget()); |
||||||
|
this.populateTemplateContentBean(link); |
||||||
|
this.populateTextContentBean(link); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobilePopupHyperlink updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(MobilePopupHyperlink link) { |
||||||
|
this.updatePopupTargetBean(link); |
||||||
|
this.updateTemplateContentBean(link); |
||||||
|
this.updateTextContentBean(link); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String title4PopupWindow() { |
||||||
|
return StringUtils.EMPTY; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 自动添加模板参数的按钮操作 |
||||||
|
*/ |
||||||
|
private class HyperlinkParametersAction extends UITableEditAction { |
||||||
|
public HyperlinkParametersAction() { |
||||||
|
this.setName(Toolkit.i18nText("Fine-Design_Basic_Template_Parameter")); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
String tpl = getReportletName(); |
||||||
|
if (StringUtils.isBlank(tpl)) { |
||||||
|
JOptionPane.showMessageDialog( |
||||||
|
ContentSettingPane.this, |
||||||
|
Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Please_Select_Reportlet") + ".", |
||||||
|
Toolkit.i18nText("Fine-Design_Basic_Message"), |
||||||
|
JOptionPane.WARNING_MESSAGE); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//根据模板路径返回参数
|
||||||
|
//与当前模块、当前文件无关
|
||||||
|
Parameter[] parameters = new Parameter[0]; |
||||||
|
|
||||||
|
ParameterReader[] readers = DesignModuleFactory.getParameterReaders(); |
||||||
|
for (ParameterReader reader : readers) { |
||||||
|
Parameter[] ps = reader.readParameterFromPath(tpl); |
||||||
|
if (ps != null) { |
||||||
|
parameters = ps; |
||||||
|
} |
||||||
|
} |
||||||
|
parameterViewPane.populate(parameters); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void checkEnabled() { |
||||||
|
//do nothing
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void populatePopupTargetBean(String target) { |
||||||
|
if (StringUtils.equals(target, MobilePopupConstants.Target_Text)) { |
||||||
|
popupTargetButtons.setSelected(textPopupButton.getModel(), true); |
||||||
|
this.remove(templateContentPane); |
||||||
|
this.add(textSettingPanel, BorderLayout.CENTER); |
||||||
|
} else { |
||||||
|
popupTargetButtons.setSelected(templatePopupButton.getModel(), true); |
||||||
|
this.remove(textSettingPanel); |
||||||
|
this.add(templateContentPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void updatePopupTargetBean(MobilePopupHyperlink mobilePopupHyperlink) { |
||||||
|
if (templatePopupButton.isSelected()) { |
||||||
|
mobilePopupHyperlink.setPopupTarget(MobilePopupConstants.Target_Template); |
||||||
|
} else if (textPopupButton.isSelected()) { |
||||||
|
mobilePopupHyperlink.setPopupTarget(MobilePopupConstants.Target_Text); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void populateTemplateContentBean(MobilePopupHyperlink link) { |
||||||
|
// 模板路径
|
||||||
|
templatePathTextField.setText(link.getReportletPath()); |
||||||
|
|
||||||
|
// 参数面板
|
||||||
|
List<ParameterProvider> parameterList = this.parameterViewPane.update(); |
||||||
|
parameterList.clear(); |
||||||
|
ParameterProvider[] parameters =link.getParameters(); |
||||||
|
parameterViewPane.populate(parameters); |
||||||
|
|
||||||
|
// 继承参数
|
||||||
|
extendParametersCheckBox.setSelected(link.isExtendParameters()); |
||||||
|
} |
||||||
|
|
||||||
|
private void updateTemplateContentBean(MobilePopupHyperlink link) { |
||||||
|
link.setReportletPath(templatePathTextField.getText()); |
||||||
|
|
||||||
|
List<ParameterProvider> parameterList = this.parameterViewPane.update(); |
||||||
|
if (!parameterList.isEmpty()) { |
||||||
|
Parameter[] parameters = new Parameter[parameterList.size()]; |
||||||
|
parameterList.toArray(parameters); |
||||||
|
link.setParameters(parameters); |
||||||
|
} else { |
||||||
|
link.setParameters(null); |
||||||
|
} |
||||||
|
|
||||||
|
link.setExtendParameters(extendParametersCheckBox.isSelected()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void populateTextContentBean(MobilePopupHyperlink link) { |
||||||
|
Object text = link.getPopupText(); |
||||||
|
if (text instanceof FormulaProvider) { |
||||||
|
textContentPane.populateBean(((FormulaProvider) text).getContent()); |
||||||
|
} else { |
||||||
|
textContentPane.populateBean(text == null ? StringUtils.EMPTY : text.toString()); |
||||||
|
} |
||||||
|
fontPane.populateBean(link.getFRFont()); |
||||||
|
} |
||||||
|
private void updateTextContentBean(MobilePopupHyperlink link) { |
||||||
|
link.setPopupText(textContentPane.getUITextField().getText()); |
||||||
|
String text = textContentPane.updateBean(); |
||||||
|
if (CommonUtils.maybeFormula(text)) { |
||||||
|
link.setPopupText(BaseFormula.createFormulaBuilder().build(textContentPane.updateBean())); |
||||||
|
} else { |
||||||
|
link.setPopupText(text); |
||||||
|
} |
||||||
|
|
||||||
|
link.setFRFont(fontPane.updateBean()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,100 @@ |
|||||||
|
package com.fr.design.hyperlink.popup; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.constants.LayoutConstants; |
||||||
|
import com.fr.design.gui.ibutton.UIColorButton; |
||||||
|
import com.fr.design.gui.ibutton.UIToggleButton; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.util.Vector; |
||||||
|
|
||||||
|
public class CustomFontPane extends JPanel { |
||||||
|
private static final int MAX_FONT_SIZE = 100; |
||||||
|
private static final Dimension BUTTON_SIZE = new Dimension(20, 18); |
||||||
|
|
||||||
|
public static Vector<Integer> getFontSizes() { |
||||||
|
Vector<Integer> FONT_SIZES = new Vector<Integer>(); |
||||||
|
for (int i = 1; i < MAX_FONT_SIZE; i++) { |
||||||
|
FONT_SIZES.add(i); |
||||||
|
} |
||||||
|
return FONT_SIZES; |
||||||
|
} |
||||||
|
|
||||||
|
private UIComboBox fontSizeComboBox; |
||||||
|
private UIToggleButton bold; |
||||||
|
private UIToggleButton italic; |
||||||
|
private UIToggleButton underline; |
||||||
|
private UIColorButton colorSelectPane; |
||||||
|
|
||||||
|
public CustomFontPane() { |
||||||
|
this.initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponent() { |
||||||
|
|
||||||
|
fontSizeComboBox = new UIComboBox(getFontSizes()); |
||||||
|
fontSizeComboBox.setPreferredSize(new Dimension(60, 20)); |
||||||
|
fontSizeComboBox.setEditable(true); |
||||||
|
|
||||||
|
colorSelectPane = new UIColorButton(); |
||||||
|
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); |
||||||
|
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); |
||||||
|
underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); |
||||||
|
|
||||||
|
this.setButtonsTips(); |
||||||
|
this.setButtonsSize(BUTTON_SIZE); |
||||||
|
|
||||||
|
Component[] components_font = new Component[]{ |
||||||
|
fontSizeComboBox, colorSelectPane, bold, underline, italic |
||||||
|
}; |
||||||
|
|
||||||
|
JPanel buttonPane = new JPanel(new BorderLayout()); |
||||||
|
buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_SMALL)); |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout(0,0)); |
||||||
|
this.add(buttonPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private void setButtonsTips() { |
||||||
|
colorSelectPane.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Foreground")); |
||||||
|
italic.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Italic")); |
||||||
|
bold.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Bold")); |
||||||
|
underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline")); |
||||||
|
} |
||||||
|
|
||||||
|
private void setButtonsSize(Dimension size) { |
||||||
|
colorSelectPane.setPreferredSize(size); |
||||||
|
bold.setPreferredSize(size); |
||||||
|
italic.setPreferredSize(size); |
||||||
|
underline.setPreferredSize(size); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void populateBean(FRFont frFont) { |
||||||
|
fontSizeComboBox.setSelectedItem(frFont.getSize()); |
||||||
|
colorSelectPane.setColor(frFont.getForeground()); |
||||||
|
bold.setSelected(frFont.isBold()); |
||||||
|
italic.setSelected(frFont.isItalic()); |
||||||
|
underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE); |
||||||
|
} |
||||||
|
|
||||||
|
public FRFont updateBean() { |
||||||
|
int style = Font.PLAIN; |
||||||
|
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN; |
||||||
|
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN; |
||||||
|
return FRFont.getInstance( |
||||||
|
FRFont.DEFAULT_FONTNAME, |
||||||
|
style, |
||||||
|
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()), |
||||||
|
colorSelectPane.getColor(), |
||||||
|
underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.fr.design.hyperlink.popup; |
||||||
|
|
||||||
|
import com.fr.stable.Constants; |
||||||
|
|
||||||
|
public interface MobilePopupConstants { |
||||||
|
int[] BORDER_LINE_STYLE_ARRAY = new int[]{ |
||||||
|
Constants.LINE_NONE, |
||||||
|
Constants.LINE_THIN, |
||||||
|
Constants.LINE_MEDIUM, |
||||||
|
Constants.LINE_THICK, |
||||||
|
}; |
||||||
|
|
||||||
|
String Target_Template= "template"; |
||||||
|
String Target_Text = "text"; |
||||||
|
String Regular_Custom = "custom"; |
||||||
|
String Regular_Auto_Height = "auto_height"; |
||||||
|
|
||||||
|
double Popup_Center_Default_Width = 95; |
||||||
|
double Popup_Center_Default_Height = 95; |
||||||
|
double Popup_Follow_Default_Width = 40; |
||||||
|
double Popup_Follow_Default_Height = 10; |
||||||
|
} |
@ -0,0 +1,81 @@ |
|||||||
|
package com.fr.design.hyperlink.popup; |
||||||
|
|
||||||
|
import com.fr.design.beans.FurtherBasicBeanPane; |
||||||
|
import com.fr.design.gui.icontainer.UIScrollPane; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.js.MobilePopupHyperlink; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
public class MobilePopupPane extends FurtherBasicBeanPane<MobilePopupHyperlink> { |
||||||
|
private ContentSettingPane contentSettingPane; |
||||||
|
private StyleSettingPane styleSettingPane; |
||||||
|
|
||||||
|
public MobilePopupPane() { |
||||||
|
this.initComponents(); |
||||||
|
this.setDefaultBean(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initComponents() { |
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||||
|
|
||||||
|
JPanel scrollContent = new JPanel(); |
||||||
|
scrollContent.setLayout(new BorderLayout(10, 10)); |
||||||
|
contentSettingPane = new ContentSettingPane(); |
||||||
|
scrollContent.add(contentSettingPane, BorderLayout.NORTH); |
||||||
|
styleSettingPane = new StyleSettingPane(); |
||||||
|
scrollContent.add(styleSettingPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
contentSettingPane.addTargetRadioActionListener(radioActionListener); |
||||||
|
|
||||||
|
UIScrollPane scrollPane= new UIScrollPane(scrollContent); |
||||||
|
scrollPane.setBorder(BorderFactory.createEmptyBorder()); |
||||||
|
|
||||||
|
JComponent scrollComponent = new JLayer<UIScrollPane>(scrollPane, new WheelScrollLayerUI()); |
||||||
|
|
||||||
|
this.add(scrollComponent, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private void setDefaultBean() { |
||||||
|
this.populateBean(new MobilePopupHyperlink()); |
||||||
|
} |
||||||
|
private ActionListener radioActionListener = new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
styleSettingPane.resetPane(contentSettingPane.getTargetType()); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(MobilePopupHyperlink mobilePopupHyperlink) { |
||||||
|
contentSettingPane.populateBean(mobilePopupHyperlink); |
||||||
|
styleSettingPane.populateBean(mobilePopupHyperlink); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobilePopupHyperlink updateBean() { |
||||||
|
MobilePopupHyperlink mobilePopupHyperlink = new MobilePopupHyperlink(); |
||||||
|
contentSettingPane.updateBean(mobilePopupHyperlink); |
||||||
|
styleSettingPane.updateBean(mobilePopupHyperlink); |
||||||
|
return mobilePopupHyperlink; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean accept(Object ob) { |
||||||
|
return ob instanceof MobilePopupHyperlink; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void reset() { |
||||||
|
this.setDefaultBean(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,157 @@ |
|||||||
|
package com.fr.design.hyperlink.popup; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.gui.ibutton.UIRadioButton; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.VerticalFlowLayout; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
public class MobilePopupRegularPane extends BasicPane { |
||||||
|
private String label; |
||||||
|
|
||||||
|
private JPanel radiosPane; |
||||||
|
private UIRadioButton customRadio; |
||||||
|
private UIRadioButton autoRadio; |
||||||
|
private ButtonGroup radioButtons; |
||||||
|
|
||||||
|
private JPanel spinnerGroupPane; |
||||||
|
private UISpinner widthSpinner; |
||||||
|
private JPanel widthSpinnerPane; |
||||||
|
private UISpinner heightSpinner; |
||||||
|
private JPanel heightSpinnerPane; |
||||||
|
|
||||||
|
|
||||||
|
public MobilePopupRegularPane(String label) { |
||||||
|
this.label = label; |
||||||
|
this.initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponent() { |
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.add(this.createRadioButtonGroupPane(), BorderLayout.NORTH); |
||||||
|
spinnerGroupPane = this.createSpinnerPane(); |
||||||
|
this.add(spinnerGroupPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createRadioButtonGroupPane() { |
||||||
|
radiosPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5)); |
||||||
|
|
||||||
|
customRadio = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Custom")); |
||||||
|
customRadio.addActionListener(radioActionListener); |
||||||
|
autoRadio = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Height_Adaptive")); |
||||||
|
autoRadio.addActionListener(radioActionListener); |
||||||
|
|
||||||
|
radioButtons = new ButtonGroup(); |
||||||
|
radioButtons.add(customRadio); |
||||||
|
radioButtons.add(autoRadio); |
||||||
|
|
||||||
|
radiosPane.add(customRadio); |
||||||
|
radiosPane.add(autoRadio); |
||||||
|
|
||||||
|
return MobilePopupUIUtils.createLeftTileRightContentPanel(this.label, radiosPane); |
||||||
|
} |
||||||
|
|
||||||
|
private ActionListener radioActionListener = new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
resetSpinnerGroupPane(customRadio.isSelected()); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
private JPanel createSpinnerPane() { |
||||||
|
JPanel spinnerPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 5)); |
||||||
|
spinnerPane.setBorder(BorderFactory.createEmptyBorder(0, MobilePopupUIUtils.Left_Title_width, 0, 0)); |
||||||
|
widthSpinner = new UISpinner(0, 100, 1, 95); |
||||||
|
widthSpinnerPane = this.createSpinnerLabelPane(widthSpinner, Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Width")); |
||||||
|
heightSpinner = new UISpinner(0, 100, 1, 95); |
||||||
|
heightSpinnerPane = this.createSpinnerLabelPane(heightSpinner, Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Height")); |
||||||
|
|
||||||
|
spinnerPane.add(widthSpinnerPane); |
||||||
|
spinnerPane.add(heightSpinnerPane); |
||||||
|
|
||||||
|
return spinnerPane; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createSpinnerLabelPane(UISpinner spinner, String labelText) { |
||||||
|
JPanel spinnerLabelPane = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 5)); |
||||||
|
|
||||||
|
JPanel spinnerPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 2,0)); |
||||||
|
Dimension dimension = new Dimension(60, 20); |
||||||
|
spinner.setPreferredSize(dimension); |
||||||
|
UILabel percent = new UILabel("%"); |
||||||
|
spinnerPane.add(spinner); |
||||||
|
spinnerPane.add(percent); |
||||||
|
|
||||||
|
UILabel label = new UILabel(labelText); |
||||||
|
label.setPreferredSize(dimension); |
||||||
|
label.setHorizontalAlignment(SwingConstants.CENTER); |
||||||
|
|
||||||
|
spinnerLabelPane.add(spinnerPane); |
||||||
|
spinnerLabelPane.add(label); |
||||||
|
|
||||||
|
return spinnerLabelPane; |
||||||
|
} |
||||||
|
|
||||||
|
private void resetSpinnerGroupPane(boolean showHeightSpinnerPane) { |
||||||
|
spinnerGroupPane.removeAll(); |
||||||
|
spinnerGroupPane.add(widthSpinnerPane); |
||||||
|
if(showHeightSpinnerPane) { |
||||||
|
spinnerGroupPane.add(heightSpinnerPane); |
||||||
|
} |
||||||
|
spinnerGroupPane.revalidate(); |
||||||
|
spinnerGroupPane.repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return StringUtils.EMPTY; |
||||||
|
} |
||||||
|
|
||||||
|
public void setRegularType(String regularType) { |
||||||
|
if (StringUtils.equals(regularType, MobilePopupConstants.Regular_Auto_Height)) { |
||||||
|
radioButtons.setSelected(autoRadio.getModel(), true); |
||||||
|
} else { |
||||||
|
radioButtons.setSelected(customRadio.getModel(), true); |
||||||
|
} |
||||||
|
resetSpinnerGroupPane(customRadio.isSelected()); |
||||||
|
} |
||||||
|
|
||||||
|
public String getRegularType() { |
||||||
|
if (autoRadio.isSelected()) { |
||||||
|
return MobilePopupConstants.Regular_Auto_Height; |
||||||
|
} else { |
||||||
|
return MobilePopupConstants.Regular_Custom; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void setWidthSpinnerValue(double width) { |
||||||
|
widthSpinner.setValue(width); |
||||||
|
} |
||||||
|
|
||||||
|
public double getWidthSpinnerValue() { |
||||||
|
return widthSpinner.getValue(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setHeightSpinnerValue(double height) { |
||||||
|
heightSpinner.setValue(height); |
||||||
|
} |
||||||
|
|
||||||
|
public double getHeightSpinnerValue() { |
||||||
|
return heightSpinner.getValue(); |
||||||
|
} |
||||||
|
|
||||||
|
public void resetPane(String regularType, double width, double height) { |
||||||
|
this.setRegularType(regularType); |
||||||
|
this.setWidthSpinnerValue(width); |
||||||
|
this.setHeightSpinnerValue(height); |
||||||
|
resetSpinnerGroupPane(StringUtils.equals(regularType, MobilePopupConstants.Regular_Custom)); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.fr.design.hyperlink.popup; |
||||||
|
|
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.mainframe.widget.UITitleSplitLine; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
public class MobilePopupUIUtils { |
||||||
|
static public int Line_Height = 20; |
||||||
|
static public int SplitLineWidth = 520; |
||||||
|
static public int Left_Title_width = 80; |
||||||
|
|
||||||
|
static public JPanel createLeftTileRightContentPanel(String title, JComponent contentPanel) { |
||||||
|
JPanel jp = new JPanel(); |
||||||
|
jp.setBorder(BorderFactory.createEmptyBorder(0,0,0, 30)); |
||||||
|
jp.setLayout(new BorderLayout(10,0)); |
||||||
|
UILabel titleLabel = new UILabel(title + ":"); |
||||||
|
titleLabel.setPreferredSize(new Dimension(MobilePopupUIUtils.Left_Title_width, Line_Height)); |
||||||
|
titleLabel.setHorizontalAlignment(SwingConstants.RIGHT); |
||||||
|
jp.add(titleLabel, BorderLayout.WEST); |
||||||
|
jp.add(contentPanel, BorderLayout.CENTER); |
||||||
|
return jp; |
||||||
|
} |
||||||
|
|
||||||
|
static public JPanel createTitleSplitLineContentPane(String title, JComponent contentPanel) { |
||||||
|
JPanel jp = new JPanel(); |
||||||
|
jp.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); |
||||||
|
jp.setLayout(new BorderLayout(0, 10)); |
||||||
|
UITitleSplitLine titleLine = new UITitleSplitLine(title, SplitLineWidth); |
||||||
|
titleLine.setPreferredSize(new Dimension(SplitLineWidth, Line_Height)); |
||||||
|
jp.add(titleLine, BorderLayout.NORTH); |
||||||
|
jp.add(contentPanel, BorderLayout.CENTER); |
||||||
|
return jp; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,205 @@ |
|||||||
|
package com.fr.design.hyperlink.popup; |
||||||
|
|
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.gui.frpane.UINumberDragPane; |
||||||
|
import com.fr.design.gui.icombobox.LineComboBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.VerticalFlowLayout; |
||||||
|
import com.fr.design.style.color.NewColorSelectBox; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.js.MobilePopupHyperlink; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
public class StyleSettingPane extends BasicBeanPane<MobilePopupHyperlink> { |
||||||
|
private double maxNumber = 100; |
||||||
|
private double maxBorderRadius = 24; |
||||||
|
|
||||||
|
JPanel typePane; |
||||||
|
UILabel popupTypeLabel; |
||||||
|
|
||||||
|
JPanel stylePane; |
||||||
|
LineComboBox borderType; |
||||||
|
NewColorSelectBox borderColor; |
||||||
|
UISpinner borderRadiusSpinner; |
||||||
|
|
||||||
|
NewColorSelectBox bgColor; |
||||||
|
//透明度
|
||||||
|
UINumberDragPane numberDragPane; |
||||||
|
|
||||||
|
MobilePopupRegularPane mobileRegularPane; |
||||||
|
MobilePopupRegularPane padRegularPane; |
||||||
|
|
||||||
|
public StyleSettingPane() { |
||||||
|
this.initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponent() { |
||||||
|
this.setLayout(new BorderLayout(0, 10)); |
||||||
|
this.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Style"))); |
||||||
|
|
||||||
|
typePane = this.createTypePane(); |
||||||
|
this.add(typePane, BorderLayout.NORTH); |
||||||
|
stylePane = this.createStylePane(); |
||||||
|
this.add(stylePane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createTypePane() { |
||||||
|
JPanel typePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
popupTypeLabel = new UILabel(""); |
||||||
|
typePane.add(popupTypeLabel, BorderLayout.CENTER); |
||||||
|
return MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Type"), typePane); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createStylePane() { |
||||||
|
JPanel stylePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
stylePane.add(this.createBorderSettingPane(), BorderLayout.NORTH); |
||||||
|
stylePane.add(this.createBackgroundSettingPane(), BorderLayout.CENTER); |
||||||
|
stylePane.add(this.createPopupSizePane(), BorderLayout.SOUTH); |
||||||
|
return stylePane; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createBorderSettingPane() { |
||||||
|
JPanel borderPane = new JPanel(); |
||||||
|
VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 10); |
||||||
|
layout.setAlignLeft(true); |
||||||
|
borderPane.setLayout(layout); |
||||||
|
|
||||||
|
borderType = new LineComboBox(MobilePopupConstants.BORDER_LINE_STYLE_ARRAY); |
||||||
|
borderType.setPreferredSize(new Dimension(115, 20)); |
||||||
|
borderPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Line"), borderType)); |
||||||
|
borderColor = new NewColorSelectBox(100); |
||||||
|
borderPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Colors"), borderColor)); |
||||||
|
borderRadiusSpinner = new UISpinner(0, maxBorderRadius, 1, 20); |
||||||
|
borderRadiusSpinner.setPreferredSize(new Dimension(120, 20)); |
||||||
|
borderPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Radius"), borderRadiusSpinner)); |
||||||
|
return MobilePopupUIUtils.createTitleSplitLineContentPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Border"), borderPane); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createBackgroundSettingPane() { |
||||||
|
JPanel bgPane = new JPanel(); |
||||||
|
VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 10); |
||||||
|
layout.setAlignLeft(true); |
||||||
|
bgPane.setLayout(layout); |
||||||
|
|
||||||
|
JPanel colorPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0,0)); |
||||||
|
bgColor = new NewColorSelectBox(100); |
||||||
|
colorPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Colors"), bgColor)); |
||||||
|
bgPane.add(colorPane); |
||||||
|
|
||||||
|
JPanel transparencyPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
this.numberDragPane = new UINumberDragPane(0,100); |
||||||
|
this.numberDragPane.setPreferredSize(new Dimension(140, 20)); |
||||||
|
transparencyPane.add(numberDragPane, BorderLayout.CENTER); |
||||||
|
transparencyPane.add(new UILabel(" %"), BorderLayout.EAST); |
||||||
|
bgPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Opacity"), transparencyPane)); |
||||||
|
return MobilePopupUIUtils.createTitleSplitLineContentPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Background"), bgPane); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createPopupSizePane() { |
||||||
|
JPanel sizePane = new JPanel(new BorderLayout()); |
||||||
|
|
||||||
|
mobileRegularPane = new MobilePopupRegularPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Mobile_Rules")); |
||||||
|
padRegularPane = new MobilePopupRegularPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Pad_Rules")); |
||||||
|
|
||||||
|
sizePane.add(mobileRegularPane, BorderLayout.NORTH); |
||||||
|
sizePane.add(padRegularPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
return MobilePopupUIUtils.createTitleSplitLineContentPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Size"), sizePane); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return StringUtils.EMPTY; |
||||||
|
} |
||||||
|
|
||||||
|
public void resetPane(String popupTargetType) { |
||||||
|
if (StringUtils.equals(popupTargetType, MobilePopupConstants.Target_Template)) { |
||||||
|
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Center")); |
||||||
|
mobileRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Center_Default_Width, MobilePopupConstants.Popup_Center_Default_Height); |
||||||
|
padRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Center_Default_Width, MobilePopupConstants.Popup_Center_Default_Height); |
||||||
|
} else { |
||||||
|
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Follow")); |
||||||
|
mobileRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Follow_Default_Width, MobilePopupConstants.Popup_Follow_Default_Height); |
||||||
|
padRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Follow_Default_Width, MobilePopupConstants.Popup_Follow_Default_Height); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(MobilePopupHyperlink link) { |
||||||
|
this.populateTypeBean(link); |
||||||
|
this.populateBorderSettingBean(link); |
||||||
|
this.populateBackgroundSettingBean(link); |
||||||
|
this.populatePopupSizeBean(link); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobilePopupHyperlink updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(MobilePopupHyperlink link) { |
||||||
|
this.updateBorderSettingBean(link); |
||||||
|
this.updateBackgroundSettingBean(link); |
||||||
|
this.updatePopupSizeBean(link); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void populateTypeBean(MobilePopupHyperlink link) { |
||||||
|
if (StringUtils.equals(link.getPopupTarget(), MobilePopupConstants.Target_Text)) { |
||||||
|
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Follow")); |
||||||
|
} else { |
||||||
|
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Center")); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void populateBorderSettingBean(MobilePopupHyperlink link) { |
||||||
|
borderType.setSelectedLineStyle(link.getBorderType()); |
||||||
|
borderColor.setSelectObject(link.getBorderColor()); |
||||||
|
borderRadiusSpinner.setValue(link.getBorderRadius()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void updateBorderSettingBean(MobilePopupHyperlink link) { |
||||||
|
link.setBorderType(borderType.getSelectedLineStyle()); |
||||||
|
link.setBorderColor(borderColor.getSelectObject()); |
||||||
|
link.setBorderRadius(borderRadiusSpinner.getValue()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void populateBackgroundSettingBean(MobilePopupHyperlink link) { |
||||||
|
bgColor.setSelectObject(link.getBgColor()); |
||||||
|
numberDragPane.populateBean(link.getBgOpacity() * maxNumber); |
||||||
|
} |
||||||
|
|
||||||
|
private void updateBackgroundSettingBean(MobilePopupHyperlink link) { |
||||||
|
link.setBgColor(bgColor.getSelectObject()); |
||||||
|
link.setBgOpacity((float)(numberDragPane.updateBean() / maxNumber)); |
||||||
|
} |
||||||
|
|
||||||
|
private void populatePopupSizeBean(MobilePopupHyperlink link) { |
||||||
|
mobileRegularPane.setRegularType(link.getMobileRegularType()); |
||||||
|
mobileRegularPane.setWidthSpinnerValue(link.getMobileWidth()); |
||||||
|
mobileRegularPane.setHeightSpinnerValue(link.getMobileHeight()); |
||||||
|
padRegularPane.setRegularType(link.getPadRegularType()); |
||||||
|
padRegularPane.setWidthSpinnerValue(link.getPadWidth()); |
||||||
|
padRegularPane.setHeightSpinnerValue(link.getPadHeight()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void updatePopupSizeBean(MobilePopupHyperlink link) { |
||||||
|
link.setMobileRegularType(mobileRegularPane.getRegularType()); |
||||||
|
link.setMobileWidth(mobileRegularPane.getWidthSpinnerValue()); |
||||||
|
link.setMobileHeight(mobileRegularPane.getHeightSpinnerValue()); |
||||||
|
link.setPadRegularType(padRegularPane.getRegularType()); |
||||||
|
link.setPadWidth(padRegularPane.getWidthSpinnerValue()); |
||||||
|
link.setPadHeight(padRegularPane.getHeightSpinnerValue()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
package com.fr.design.hyperlink.popup; |
||||||
|
|
||||||
|
import com.fr.design.gui.icontainer.UIScrollPane; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.plaf.LayerUI; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.MouseWheelEvent; |
||||||
|
|
||||||
|
class WheelScrollLayerUI extends LayerUI<UIScrollPane> { |
||||||
|
@Override |
||||||
|
public void installUI(JComponent c) { |
||||||
|
super.installUI(c); |
||||||
|
if (c instanceof JLayer) { |
||||||
|
((JLayer) c).setLayerEventMask(AWTEvent.MOUSE_WHEEL_EVENT_MASK); |
||||||
|
} |
||||||
|
} |
||||||
|
@Override |
||||||
|
public void uninstallUI(JComponent c) { |
||||||
|
if (c instanceof JLayer) { |
||||||
|
((JLayer) c).setLayerEventMask(0); |
||||||
|
} |
||||||
|
super.uninstallUI(c); |
||||||
|
} |
||||||
|
@Override |
||||||
|
protected void processMouseWheelEvent(MouseWheelEvent e, JLayer<? extends UIScrollPane> l) { |
||||||
|
Component c = e.getComponent(); |
||||||
|
int dir = e.getWheelRotation(); |
||||||
|
JScrollPane main = l.getView(); |
||||||
|
if (c instanceof JScrollPane && !c.equals(main)) { |
||||||
|
JScrollPane child = (JScrollPane) c; |
||||||
|
BoundedRangeModel m = child.getVerticalScrollBar().getModel(); |
||||||
|
int extent = m.getExtent(); |
||||||
|
int minimum = m.getMinimum(); |
||||||
|
int maximum = m.getMaximum(); |
||||||
|
int value = m.getValue(); |
||||||
|
if (value + extent >= maximum && dir > 0 || value <= minimum && dir < 0) { |
||||||
|
main.dispatchEvent(SwingUtilities.convertMouseEvent(c, e, main)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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,86 @@ |
|||||||
|
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) { |
||||||
|
if (fileName.length() <= prefix.length()) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
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,35 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.provider.combo; |
||||||
|
|
||||||
|
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.design.mainframe.mobile.ui.combo.SimpleComboPane; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.form.ui.mobile.combo.SimpleComboStyle; |
||||||
|
|
||||||
|
public class SimpleComboCheckBoxStyleProvider extends AbstractMobileWidgetStyleProvider { |
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyle> classForMobileStyle() { |
||||||
|
return SimpleComboStyle.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() { |
||||||
|
return SimpleComboPane.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String xTypeForWidget() { |
||||||
|
return "tagcombocheckbox"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String displayName() { |
||||||
|
return Toolkit.i18nText("Fine-Plugin-SimpleCombo_SimpleComboStyle"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.provider.combo; |
||||||
|
|
||||||
|
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.design.mainframe.mobile.ui.combo.SimpleComboPane; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.form.ui.mobile.combo.SimpleComboStyle; |
||||||
|
|
||||||
|
public class SimpleComboStyleProvider extends AbstractMobileWidgetStyleProvider{ |
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyle> classForMobileStyle() { |
||||||
|
return SimpleComboStyle.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() { |
||||||
|
return SimpleComboPane.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String xTypeForWidget() { |
||||||
|
return "combo"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String displayName() { |
||||||
|
return Toolkit.i18nText("Fine-Plugin-SimpleCombo_SimpleComboStyle"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.provider.date; |
||||||
|
|
||||||
|
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.design.mainframe.mobile.ui.date.NavigationCustomDefinePane; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.form.ui.mobile.date.NavigationMobileStyle; |
||||||
|
|
||||||
|
public class NavigationStyleProvider extends AbstractMobileWidgetStyleProvider { |
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyle> classForMobileStyle() { |
||||||
|
return NavigationMobileStyle.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() { |
||||||
|
return NavigationCustomDefinePane.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String xTypeForWidget() { |
||||||
|
return "datetime"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String displayName() { |
||||||
|
return Toolkit.i18nText("Fine-Plugin-Date_Navigation_Calendar"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.provider.date; |
||||||
|
|
||||||
|
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.design.mainframe.mobile.ui.date.SimpleDateCustomDefinePane; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.form.ui.mobile.date.SimpleDateMobileStyle; |
||||||
|
|
||||||
|
public class SimpleDateStyleProvider extends AbstractMobileWidgetStyleProvider { |
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyle> classForMobileStyle() { |
||||||
|
return SimpleDateMobileStyle.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() { |
||||||
|
return SimpleDateCustomDefinePane.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String xTypeForWidget() { |
||||||
|
return "datetime"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String displayName() { |
||||||
|
return Toolkit.i18nText("Fine-Plugin-SimpleDate_Style"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.provider.date; |
||||||
|
|
||||||
|
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.design.mainframe.mobile.ui.date.SimpleCustomDefinePane; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.form.ui.mobile.date.SimpleMobileStyle; |
||||||
|
|
||||||
|
public class SimpleStyleProvider extends AbstractMobileWidgetStyleProvider { |
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyle> classForMobileStyle() { |
||||||
|
return SimpleMobileStyle.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() { |
||||||
|
return SimpleCustomDefinePane.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String xTypeForWidget() { |
||||||
|
return "datetime"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String displayName() { |
||||||
|
return Toolkit.i18nText("Fine-Plugin-Date_Simple_Calendar"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.provider.radiogroup; |
||||||
|
|
||||||
|
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.design.mainframe.mobile.ui.radiogroup.CapsuleCustomDefinePane; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.form.ui.mobile.radiogroup.CapsuleMobileStyle; |
||||||
|
|
||||||
|
public class CapsuleRadioGroupStyleProvider extends AbstractMobileWidgetStyleProvider { |
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyle> classForMobileStyle() { |
||||||
|
return CapsuleMobileStyle.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() { |
||||||
|
return CapsuleCustomDefinePane.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String xTypeForWidget() { |
||||||
|
return "radiogroup"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String displayName() { |
||||||
|
return Toolkit.i18nText("Fine-Plugin-RadioGroup_Capsule_Button"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.provider.radiogroup; |
||||||
|
|
||||||
|
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.design.mainframe.mobile.ui.radiogroup.ImageCustomDefinePane; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.form.ui.mobile.radiogroup.ImageMobileStyle; |
||||||
|
|
||||||
|
public class ImageRadioGroupStyleProvider extends AbstractMobileWidgetStyleProvider { |
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyle> classForMobileStyle() { |
||||||
|
return ImageMobileStyle.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() { |
||||||
|
return ImageCustomDefinePane.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String xTypeForWidget() { |
||||||
|
return "radiogroup"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String displayName() { |
||||||
|
return Toolkit.i18nText("Fine-Plugin-RadioGroup_Graphic_Button"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue