Browse Source

Merge branch 'feature/x' of https://code.fineres.com/scm/design/design into feature/x

# Conflicts:
#	designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
feature/x
kerry 3 years ago
parent
commit
3d91403aac
  1. 112
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  2. 2
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java
  3. 4
      designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java
  4. 200
      designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java
  5. 77
      designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java
  6. 95
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  7. 30
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  8. 13
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java
  9. 74
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java
  10. 59
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java
  11. 18
      designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java
  12. 9
      designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java
  13. 30
      designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java
  14. 165
      designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java
  15. 1
      designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java
  16. 6
      designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java
  17. 6
      designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java
  18. 4
      designer-realize/src/main/java/com/fr/design/sort/expressionpane/FormulaSortExpressionPane.java
  19. 144
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

112
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -1,12 +1,12 @@
package com.fr.design.data.datapane;
import com.fr.base.TableData;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.core.db.dialect.Dialect;
import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager;
@ -19,7 +19,7 @@ import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.icombobox.FilterableComboBoxModel;
import com.fr.design.gui.icombobox.SearchPreTaskTreeComboBox;
import com.fr.design.gui.icombobox.SearchFRTreeComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxEditor;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
@ -40,11 +40,6 @@ import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.util.Collections;
import java.util.concurrent.CancellationException;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
@ -58,21 +53,20 @@ import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.CancellationException;
/**
* @author zhou
@ -97,41 +91,12 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
/**
* 表名
*/
protected SearchPreTaskTreeComboBox tableNameComboBox;
private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(new NamedThreadFactory("ChoosePane"));
protected SearchFRTreeComboBox tableNameComboBox;
private SwingWorker populateWorker;
private SwingWorker<List<String>, Void> initWorker;
private PopupMenuListener popupMenuListener = new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>() {
@Override
public Void call() throws Exception {
calculateTableDataNames();
return null;
}
});
tableNameComboBox.setPreSearchTask(task);
SERVICE.submit(task);
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
// Do nothing
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
// Do nothing
}
};
private PopupMenuListener listener = new PopupMenuListener() {
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
@ -181,7 +146,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
schemaBox = new StringUIComboBox();
schemaBox.setEditor(new ComboBoxEditor());
tableNameComboBox = new SearchPreTaskTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false);
tableNameComboBox = new SearchFRTreeComboBox(this, new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer);
tableNameComboBox.setEditable(true);
tableNameComboBox.setRenderer(listCellRenderer);
registerDSChangeListener();
@ -198,7 +163,6 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
});
schemaBox.addPopupMenuListener(listener);
addFocusListener();
this.tableNameComboBox.addPopupMenuListener(popupMenuListener);
}
protected void addDSBoxListener() {
@ -355,7 +319,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
GUICoreUtils.setSelectedItemQuietly(tableNameComboBox, -1);
}
protected com.fr.data.impl.Connection getConnection() {
public Connection getConnection() {
String selectedDSName = this.getDSName();
if (StringUtils.isEmpty(selectedDSName)) {
return null; // peter:选中了当前的零长度的节点,直接返回.
@ -455,56 +419,6 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return "choosepane";
}
protected void calculateTableDataNames() {
JTree tree = tableNameComboBox.getTree();
if (tree == null) {
return;
}
DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) tree.getModel().getRoot();
rootTreeNode.removeAllChildren();
String selectedDSName = this.getDSName();
com.fr.data.impl.Connection selectedDatabase = this.getConnection();
if (selectedDatabase == null) {
return;
}
try {
String schema = StringUtils.isEmpty(this.schemaBox.getSelectedItem()) ? null : this.schemaBox.getSelectedItem();
TableProcedure[] sqlTableArray = DataCoreUtils.getTables(selectedDatabase, TableProcedure.TABLE, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace());
if (sqlTableArray.length > 0) {
ExpandMutableTreeNode tableTreeNode = new ExpandMutableTreeNode(selectedDSName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_Table"));
rootTreeNode.add(tableTreeNode);
for (int i = 0; i < sqlTableArray.length; i++) {
ExpandMutableTreeNode tableChildTreeNode = new ExpandMutableTreeNode(sqlTableArray[i]);
tableTreeNode.add(tableChildTreeNode);
}
}
TableProcedure[] sqlViewArray = DataCoreUtils.getTables(selectedDatabase, TableProcedure.VIEW, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace());
if (sqlViewArray.length > 0) {
ExpandMutableTreeNode viewTreeNode = new ExpandMutableTreeNode(selectedDSName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_View"));
rootTreeNode.add(viewTreeNode);
for (int i = 0; i < sqlViewArray.length; i++) {
ExpandMutableTreeNode viewChildTreeNode = new ExpandMutableTreeNode(sqlViewArray[i]);
viewTreeNode.add(viewChildTreeNode);
}
}
((DefaultTreeModel) tree.getModel()).reload();
// daniel 展开所有tree
TreeNode root = (TreeNode) tree.getModel().getRoot();
TreePath parent = new TreePath(root);
TreeNode node = (TreeNode) parent.getLastPathComponent();
for (Enumeration e = node.children(); e.hasMoreElements(); ) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
tree.expandPath(path);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE);
}
}
/**
* 创建选中的数据集数据
*
@ -558,10 +472,14 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return tableData;
}
protected String getDSName() {
public String getDSName() {
return this.dsNameComboBox.getSelectedItem();
}
public String getSchema() {
return this.schemaBox.getSelectedItem();
}
protected void failedToFindTable() {
// Do nothing
}

2
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java

@ -83,7 +83,7 @@ public class ChoosePaneSupportFormula extends ChoosePane {
*
* @return
*/
protected String getDSName() {
public String getDSName() {
String selectedDSName = null;
String item = Utils.objectToString(this.dsNameComboBox.getEditor().getItem());
// 没有选中的列表项 那么看看是不是手输值

4
designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java

@ -248,7 +248,7 @@ public class FRTreeComboBox extends UIComboBox {
private static TreePopup treePopup;
private static class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{
protected static class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{
private boolean isRollover = false;
public FRTreeComboBoxUI() {
@ -535,7 +535,7 @@ public class FRTreeComboBox extends UIComboBox {
public class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener {
private volatile boolean setting = false;
private FRTreeComboBox comboBox;
private Object item;
protected Object item;
public FrTreeSearchComboBoxEditor(FRTreeComboBox comboBox) {
super();

200
designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java

@ -0,0 +1,200 @@
package com.fr.design.gui.icombobox;
import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.impl.Connection;
import com.fr.design.DesignerEnvManager;
import com.fr.design.data.datapane.ChoosePane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.mainframe.DesignerContext;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import javax.swing.JOptionPane;
import javax.swing.JTree;
import javax.swing.SwingWorker;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.event.MouseEvent;
import java.util.Enumeration;
/**
* 实现模糊搜索的FRTreeComboBox
* FRTreeComboBox搜索后滚动到首个匹配节点
* SearchFRTreeComboBox显示所有匹配的节点
*
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2021/4/14
*/
public class SearchFRTreeComboBox extends FRTreeComboBox {
// 持有父容器,需要实时获取其他组件值
private final ChoosePane parent;
public SearchFRTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) {
super(tree, renderer);
this.parent = parent;
setUI(new SearchFRTreeComboBoxUI());
}
protected UIComboBoxEditor createEditor() {
return new SearchFRComboBoxEditor(this);
}
/**
* 执行模糊搜索
*/
private void searchExecute() {
UIComboBoxEditor searchEditor = (UIComboBoxEditor) this.getEditor();
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() {
processTableDataNames(
parent.getDSName(),
parent.getConnection(),
parent.getSchema(),
createFilter((String) searchEditor.getItem()));
return null;
}
@Override
protected void done() {
expandTree();
// 输入框获取焦点
searchEditor.getEditorComponent().requestFocus();
}
}.execute();
}
private TableNameFilter createFilter(String text) {
return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text);
}
/**
* 查询数据库表并构建节点目录
*
* @param databaseName 数据库名
* @param connection 数据连接
* @param schema 模式
* @param filter 模糊搜索过滤器
*/
private void processTableDataNames(String databaseName, Connection connection, String schema, TableNameFilter filter) {
if (tree == null) {
return;
}
DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) tree.getModel().getRoot();
rootTreeNode.removeAllChildren();
if (connection == null) {
return;
}
try {
schema = StringUtils.isEmpty(schema) ? null : schema;
TableProcedure[] sqlTableArray = DataCoreUtils.getTables(connection, TableProcedure.TABLE, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace());
if (ArrayUtils.isNotEmpty(sqlTableArray)) {
ExpandMutableTreeNode tableTreeNode = new ExpandMutableTreeNode(databaseName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_Table"));
rootTreeNode.add(tableTreeNode);
addArrayNode(tableTreeNode, sqlTableArray, filter);
}
TableProcedure[] sqlViewArray = DataCoreUtils.getTables(connection, TableProcedure.VIEW, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace());
if (ArrayUtils.isNotEmpty(sqlViewArray)) {
ExpandMutableTreeNode viewTreeNode = new ExpandMutableTreeNode(databaseName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_View"));
rootTreeNode.add(viewTreeNode);
addArrayNode(viewTreeNode, sqlViewArray, filter);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE);
}
}
private void addArrayNode(ExpandMutableTreeNode rootNode, TableProcedure[] sqlArray, TableNameFilter filter) {
if (sqlArray != null) {
for (TableProcedure procedure : sqlArray) {
if (filter.accept(procedure)) {
ExpandMutableTreeNode viewChildTreeNode = new ExpandMutableTreeNode(procedure);
rootNode.add(viewChildTreeNode);
}
}
}
}
/**
* 展开节点
*/
private void expandTree() {
((DefaultTreeModel) tree.getModel()).reload();
// daniel 展开所有tree
TreeNode root = (TreeNode) tree.getModel().getRoot();
TreePath parent = new TreePath(root);
TreeNode node = (TreeNode) parent.getLastPathComponent();
for (Enumeration e = node.children(); e.hasMoreElements(); ) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
tree.expandPath(path);
}
}
/**
* 重写输入框编辑器实现输入框模糊搜索逻辑
*/
private class SearchFRComboBoxEditor extends FrTreeSearchComboBoxEditor {
public SearchFRComboBoxEditor(FRTreeComboBox comboBox) {
super(comboBox);
}
@Override
protected void changeHandler() {
if (isSetting()) {
return;
}
setPopupVisible(true);
this.item = textField.getText();
searchExecute();
}
}
private static final TableNameFilter EMPTY_FILTER = new TableNameFilter(StringUtils.EMPTY) {
public boolean accept(TableProcedure procedure) {
return true;
}
};
/**
* 表名模糊搜索实现
*/
private static class TableNameFilter {
private final String searchFilter;
public TableNameFilter(String searchFilter) {
if (StringUtils.isNotEmpty(searchFilter)) {
searchFilter = searchFilter.toLowerCase().trim();
}
this.searchFilter = searchFilter;
}
// 字符串匹配
public boolean accept(TableProcedure procedure) {
return procedure.getName().toLowerCase().contains(searchFilter);
}
}
/**
* 重写FRTreeComboBoxUI实现点击下拉时触发模糊搜索
*/
private class SearchFRTreeComboBoxUI extends FRTreeComboBoxUI {
@Override
public void mouseClicked(MouseEvent e) {
searchExecute();
}
}
}

77
designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java

@ -1,77 +0,0 @@
package com.fr.design.gui.icombobox;
import com.fr.log.FineLoggerFactory;
import javax.swing.JTree;
import javax.swing.SwingWorker;
import javax.swing.tree.TreeCellRenderer;
import java.util.concurrent.FutureTask;
/**
* 模糊搜索前需执行完前置任务的TreeComboBox
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2021/4/14
*/
public class SearchPreTaskTreeComboBox extends FRTreeComboBox {
/**
* 模糊搜索前任务
*/
private FutureTask<Void> preSearchTask;
public SearchPreTaskTreeComboBox(JTree tree, TreeCellRenderer renderer, boolean editable) {
super(tree, renderer, editable);
}
public FutureTask<Void> getPreSearchTask() {
return preSearchTask;
}
public void setPreSearchTask(FutureTask<Void> preSearchTask) {
this.preSearchTask = preSearchTask;
}
protected UIComboBoxEditor createEditor() {
return new SearchPreTaskComboBoxEditor(this);
}
private class SearchPreTaskComboBoxEditor extends FrTreeSearchComboBoxEditor {
public SearchPreTaskComboBoxEditor(FRTreeComboBox comboBox) {
super(comboBox);
}
protected void changeHandler() {
if (isSetting()) {
return;
}
setPopupVisible(true);
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() {
FutureTask<Void> task = getPreSearchTask();
try {
// 确保模糊搜索前任务执行完成后,再进行模糊搜索
if (task != null) {
task.get();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (task != null) {
// 任务执行后置空,否则会被别的操作重复触发
setPreSearchTask(null);
}
return null;
}
@Override
protected void done() {
// 模糊搜索
search();
}
}.execute();
}
}
}

95
designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java

@ -13,6 +13,7 @@ import com.fr.design.formula.UIFormula;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField;
@ -20,6 +21,7 @@ import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.sort.celldscolumn.CellDSColumnSortPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement;
@ -47,14 +49,26 @@ public class DSColumnAdvancedPane extends BasicPane {
private UICheckBox verticalExtendableCheckBox;
private UICheckBox useMultiplyNumCheckBox;
private UISpinner multiNumSpinner;
private JPanel contentPane;
public DSColumnAdvancedPane() {
this(DSColumnPane.SETTING_ALL);
}
public DSColumnAdvancedPane(int setting) {
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initContentPane(setting);
initScrollPane();
}
private void initScrollPane() {
ScrollPane scrollPane = new ScrollPane(contentPane);
this.add(scrollPane);
}
private void initContentPane(int setting) {
contentPane = new JPanel();
contentPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
contentPane.setLayout(FRGUIPaneFactory.createBorderLayout());
sortPane = new SortPane();
sortPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order")));
@ -124,7 +138,7 @@ public class DSColumnAdvancedPane extends BasicPane {
TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED};
double[] columnSize = {TableLayout.FILL};
this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER);
contentPane.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER);
}
@Override
@ -137,7 +151,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return;
}
sortPane.populate(cellElement);
sortPane.populateBean(cellElement);
valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
@ -187,7 +201,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return;
}
sortPane.update(cellElement);
sortPane.updateBean(cellElement);
valuePane.update(cellElement);
formatAttrPane.update(cellElement);
@ -223,66 +237,25 @@ public class DSColumnAdvancedPane extends BasicPane {
}
}
private static class SortPane extends SortFormulaPane {
private CellElement cellElement;
private static class ScrollPane extends UIScrollPane {
ScrollPane(Component component) {
super(component);
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}
@Override
public void formulaAction() {
if (cellElement == null) {
return;
}
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
String[] displayNames = DesignTableDataManager.getSelectedColumnNames(
DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName());
showFormulaDialog(displayNames);
public Dimension getPreferredSize() {
return new Dimension(DSColumnPane.DEFAULT_DIMENSION.width - 20, DSColumnPane.DEFAULT_DIMENSION.height - 100);
}
}
void populate(CellElement cellElement) {
if (cellElement == null) {
return;
}
this.cellElement = cellElement;
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
DSColumn dSColumn = (DSColumn) value;
int sort = dSColumn.getOrder();
this.sortOrderComboBox.setSortOrder(new SortOrder(sort));
String sortFormula = dSColumn.getSortFormula();
sortFormulaTextField.setText(sortFormula);
private static class SortPane extends CellDSColumnSortPane {
SortPane() {
this.setLayout(new FlowLayout(FlowLayout.LEFT));
}
public void update(CellElement cellElement) {
if (cellElement == null) {
return;
}
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
DSColumn dSColumn = (DSColumn) (cellElement.getValue());
dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder());
//lance:sort formula
String sText = null;
if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) {
sText = new String(sortFormulaTextField.getText());
}
if (!(sText == null || sText.length() < 1)) {
dSColumn.setSortFormula(sText);
} else {
dSColumn.setSortFormula(null);
}
protected boolean needSortHeaderPane() {
return false;
}
}
@ -540,12 +513,12 @@ public class DSColumnAdvancedPane extends BasicPane {
public static class FormatAttrPane extends TextFormatPane {
protected void initLayout() {
JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0);
JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0);
settingPane.add(typeComboBox);
settingPane.add(textField);
settingPane.add(roundingBox);
addComponents(4, new JComponent[] { settingPane, previewLabel});
addComponents(4, new JComponent[]{settingPane, previewLabel});
}
@Override

30
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -6,6 +6,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseFormula;
import com.fr.base.DynamicUnitList;
import com.fr.base.Formula;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState;
@ -95,6 +96,7 @@ import com.fr.page.PageAttributeGetter;
import com.fr.page.ReportPageAttrProvider;
import com.fr.poly.creator.PolyElementCasePane;
import com.fr.report.ReportHelper;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.core.RichText;
@ -131,6 +133,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.lang.reflect.Constructor;
import java.util.Iterator;
import java.util.Set;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -1371,6 +1374,33 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
return cellNeedTOFormat;
}
public void traverseSelectedCellElements(TemplateCellElementVisitor visitor) {
Selection selection = getSelection();
if (!(selection instanceof CellSelection)) {
return;
}
CellSelection cs = (CellSelection) selection;
TemplateElementCase elementCase = getEditingElementCase();
int cellRectangleCount = cs.getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
Rectangle cellRectangle = cs.getCellRectangle(rect);
for (int j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < cellRectangle.width; i++) {
int column = i + cellRectangle.x;
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
visitor.visit(column, row, cellElement);
}
}
}
}
public interface TemplateCellElementVisitor {
void visit(int column, int row, TemplateCellElement cellElement);
}
private class ElementCaseEditingState implements EditingState {
protected Selection selection;

13
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java

@ -4,7 +4,6 @@ import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.expand.ExpandLeftFatherPane;
import com.fr.design.expand.ExpandUpFatherPane;
import com.fr.design.expand.SortExpandAttrPane;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox;
@ -39,7 +38,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private ExpandUpFatherPane rightFatherPane;
private UICheckBox horizontalExpandableCheckBox;
private UICheckBox verticalExpandableCheckBox;
private SortExpandAttrPane sortAfterExpand;
private JPanel layoutPane;
private JPanel basicPane;
private JPanel seniorPane;
@ -64,7 +62,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
rightFatherPane = new ExpandUpFatherPane();
horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"));
verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable"));
sortAfterExpand = new SortExpandAttrPane();
initAllNames();
return layoutPane();
}
@ -124,16 +121,12 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private JPanel seniorPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
UILabel expendSort = new UILabel(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT);
JPanel expendSortPane = new JPanel(new BorderLayout());
expendSortPane.add(expendSort, BorderLayout.NORTH);
horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{horizontalExpandableCheckBox, null},
new Component[]{verticalExpandableCheckBox, null},
new Component[]{expendSortPane, sortAfterExpand},
};
double[] rowSize = {p, p, p, p, p};
double[] columnSize = {p, f};
@ -174,8 +167,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
}
sortAfterExpand.populate(cellExpandAttr);
extraPane.populate(cellElement);
cellExpandSortPane.populateBean(cellElement);
}
@ -223,10 +214,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) {
sortAfterExpand.update(cellExpandAttr);
}
extraPane.update(cellElement);
cellExpandSortPane.updateBean(cellElement);
}

74
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java

@ -1,22 +1,23 @@
package com.fr.design.mainframe.cell.settingpane;
import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.design.actions.utils.ReportActionUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.style.BorderPane;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.cell.settingpane.style.StylePane;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.design.style.BorderUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import javax.swing.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.BorderLayout;
/**
* @author zhou
@ -71,29 +72,56 @@ public class CellStylePane extends AbstractCellAttrPane {
@Override
public void updateBeans() {
Object[] selectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane);
// 因为存在框选多个单元格的情况,跟随主题切换到自定义的行为似乎不太适合由updateBeans完成,它更像是个工具栏上的Action.
// 但它又会触发updateBeans...
boolean isSwitchToCustomStyleAction = stylePane.isFollowingThemeSettingChanged() && !stylePane.isFollowingTheme();
if (isSwitchToCustomStyleAction) {
switchCellStylesToCustom();
return;
}
updateCellStylesByPaneSettings();
}
private void switchCellStylesToCustom() {
TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
int cellRectangleCount = cs.getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
Rectangle cellRectangle = cs.getCellRectangle(rect);
for (int j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < cellRectangle.width; i++) {
int column = i + cellRectangle.x;
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
if (cellElement == null) {
cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
elementCase.addCellElement(cellElement);
}
Style style = stylePane.updateBean();
cellElement.setStyle(style);
elementCasePane.traverseSelectedCellElements(new ElementCasePane.TemplateCellElementVisitor() {
@Override
public void visit(int column, int row, TemplateCellElement cellElement) {
if (cellElement == null) {
cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
elementCase.addCellElement(cellElement);
}
Style style = cellElement.getStyle();
if (style instanceof NameStyle) {
style = ((NameStyle) style).getRealStyle();
}
if (style == null) {
style = Style.DEFAULT_STYLE;
}
cellElement.setStyle(style);
}
}
});
}
private void updateCellStylesByPaneSettings() {
Object[] oldSelectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane);
TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
elementCasePane.traverseSelectedCellElements(new ElementCasePane.TemplateCellElementVisitor() {
@Override
public void visit(int column, int row, TemplateCellElement cellElement) {
if (cellElement == null) {
cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
elementCase.addCellElement(cellElement);
}
Style style = stylePane.updateBean();
cellElement.setStyle(style);
}
});
// border必须特别处理
CellBorderStyle cellBorderStyle = stylePane.updateBorderStyle();
if (cellBorderStyle != null) {
BorderUtils.update(elementCasePane, selectionCellBorderObjects, cellBorderStyle);
CellBorderStyle newCellBorderStyle = stylePane.updateBorderStyle();
if (newCellBorderStyle != null) {
BorderUtils.update(elementCasePane, oldSelectionCellBorderObjects, newCellBorderStyle);
}
}

59
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java

@ -51,6 +51,7 @@ public class StylePane extends BasicPane implements UIObserver {
private final List<UIObserverListener> observerListeners = new ArrayList<>();
private Style backupStyleFromPopulating = Style.DEFAULT_STYLE;
private boolean isFollowingThemeSettingChanged = false;
public StylePane() {
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
@ -77,6 +78,7 @@ public class StylePane extends BasicPane implements UIObserver {
followingThemeButtonGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
isFollowingThemeSettingChanged = true;
AttributeChangeUtils.changeComposedUI(StylePane.this, false, new AttributeChangeUtils.UIChangeAction() {
@Override
public void changeComposedUI() {
@ -85,6 +87,7 @@ public class StylePane extends BasicPane implements UIObserver {
}
});
fireStateChanged();
isFollowingThemeSettingChanged = false;
}
});
@ -103,25 +106,33 @@ public class StylePane extends BasicPane implements UIObserver {
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]);
if (!isFollowingTheme) {
// 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致
NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle();
if (lastSelectedNameStyle != null) {
Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle();
try {
lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone();
if (lastSelectedRealStyle != null) {
customStylePane.populateBean(lastSelectedRealStyle);
customStylePane.dealWithBorder();
}
} catch (CloneNotSupportedException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
}
syncCustomStylePaneBySelectedNameStyle();
} else {
// 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格
nameStyleListPane.reset();
}
}
private void syncCustomStylePaneBySelectedNameStyle() {
NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle();
if (lastSelectedNameStyle != null) {
Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle();
try {
lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone();
if (lastSelectedRealStyle != null) {
customStylePane.populateBean(lastSelectedRealStyle);
customStylePane.dealWithBorder();
}
} catch (CloneNotSupportedException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
}
}
public boolean isFollowingThemeSettingChanged() {
return isFollowingThemeSettingChanged;
}
protected JPanel createTabbedContentPane() {
JPanel contentPane = new JPanel(cardLayout) {
@Override
@ -161,14 +172,22 @@ public class StylePane extends BasicPane implements UIObserver {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style");
}
public void setSelectedIndex(int index) {
public boolean isFollowingTheme() {
return getSelectedIndex() == 0;
}
public void setFollowingTheme(boolean followingTheme) {
setSelectedIndex(followingTheme ? 0 : 1);
}
private void setSelectedIndex(int index) {
if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) {
followingThemeButtonGroup.setSelectedIndex(index);
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]);
}
}
public int getSelectedIndex() {
private int getSelectedIndex() {
return followingThemeButtonGroup.getSelectedIndex();
}
@ -185,11 +204,11 @@ public class StylePane extends BasicPane implements UIObserver {
}
public void setSelctedByName(String id) {
setSelectedIndex(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id)? 1 : 0);
setFollowingTheme(!ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id));
}
public CellBorderStyle updateBorderStyle() {
if (getSelectedIndex() == 0) {
if (isFollowingTheme()) {
return nameStyleListPane.updateBorderStyle();
} else if (customStylePane.isBorderPaneSelected()) {
return customStylePane.updateBorderStyle();
@ -199,7 +218,7 @@ public class StylePane extends BasicPane implements UIObserver {
public Style updateBean() {
Style finalStyle = null;
if (getSelectedIndex() == 0) {
if (isFollowingTheme()) {
finalStyle = nameStyleListPane.updateNameStyle();
}
if (finalStyle == null) {
@ -215,7 +234,7 @@ public class StylePane extends BasicPane implements UIObserver {
if (style instanceof NameStyle) {
NameStyle nameStyle = (NameStyle) style;
setSelectedIndex(0);
setFollowingTheme(true);
nameStyleListPane.populateNameStyle(nameStyle);
Style realStyle = nameStyle.getRealStyle();
try {
@ -225,7 +244,7 @@ public class StylePane extends BasicPane implements UIObserver {
e.printStackTrace();
}
} else {
setSelectedIndex(1);
setFollowingTheme(false);
customStylePane.populateBean(style);
}
//单元格配置界面是单例 所以直接在populate的时候把跟随主题的按钮组设置不可见

18
designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java

@ -15,22 +15,24 @@ public class CellDSColumnSortGroupPane extends AbstractSortGroupPane {
super(sortGroupPaneWidth, sortGroupPaneRightWidth);
}
public void populateDsColumn( DSColumn dsColumn){
public void populateDsColumn(DSColumn dsColumn) {
this.dsColumn = dsColumn;
}
@Override
protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) {
CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane( sortItemPaneWidth, sortItemPaneRightWidth);
CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane(sortItemPaneWidth, sortItemPaneRightWidth);
java.util.Map<String, TableDataWrapper> tableDataWrapperMap =
DesignTableDataManager.getAllEditingDataSet(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget());
TableDataWrapper tableDataWrapper = tableDataWrapperMap.get(dsColumn.getDSName());
java.util.List<String> columnNameList = tableDataWrapper.calculateColumnNameList();
String[] columnNames = new String[columnNameList.size()];
columnNameList.toArray(columnNames);
cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems();
for (String columnName : columnNames) {
cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName);
if (tableDataWrapper != null) {
java.util.List<String> columnNameList = tableDataWrapper.calculateColumnNameList();
String[] columnNames = new String[columnNameList.size()];
columnNameList.toArray(columnNames);
cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems();
for (String columnName : columnNames) {
cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName);
}
}
cellDSColumnSortItemPane.populateBean(sortExpression);
return cellDSColumnSortItemPane;

9
designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java

@ -18,6 +18,8 @@ import java.util.List;
public abstract class AbstractSortGroupPane extends JPanel implements ComponentChangeObserver {
private static final int SECOND_SORT_LENGTH_REDUCTION = 13;
protected int sortGroupPaneWidth;
protected int sortGroupPaneRightWidth;
List<SortExpression> sortExpressions;
@ -95,8 +97,8 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC
int sortItemPaneWidth = sortGroupPaneWidth;
int sortItemPaneRightWidth = sortGroupPaneRightWidth;
if (!mainSort) {
sortItemPaneWidth -= 12;
sortItemPaneRightWidth -= 12;
sortItemPaneWidth -= SECOND_SORT_LENGTH_REDUCTION;
sortItemPaneRightWidth -= SECOND_SORT_LENGTH_REDUCTION;
}
if (sortExpression == null) {
sortExpression = new CellSortExpression(selfSortArea);
@ -131,12 +133,13 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC
AddSortItemBar(AbstractSortGroupPane sortGroupPane) {
init();
this.sortGroupPane = sortGroupPane;
this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
}
void init() {
uiButton = new UIButton(Toolkit.i18nText("Fine-Design_Sort_Add_Second_Sort"),
IconUtils.readIcon("/com/fr/design/images/sort/add.png"));
uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, 20));
uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, AbstractSortPane.PANE_COMPONENT_HEIGHT));
this.add(uiButton);
uiButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

30
designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java

@ -34,13 +34,19 @@ public abstract class AbstractSortPane extends JPanel {
private void initComponents() {
initSortGroupPane();
sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5);
this.add(sortHeaderPane);
if (needSortHeaderPane()) {
sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5);
this.add(sortHeaderPane);
}
}
protected abstract void initSortGroupPane();
protected boolean needSortHeaderPane() {
return true;
}
protected abstract CellSortAttr getCellSortAttr(TemplateCellElement cellElement);
public void populateBean(TemplateCellElement cellElement) {
@ -55,11 +61,13 @@ public abstract class AbstractSortPane extends JPanel {
sortExpressions.add(new CellSortExpression(selfSortArea));
}
sortGroupPane.populateBean(sortExpressions, selfSortArea);
SortHeader sortHeader = null;
if (cellSortAttr != null) {
sortHeader = cellSortAttr.getSortHeader();
if (needSortHeaderPane()) {
SortHeader sortHeader = null;
if (cellSortAttr != null) {
sortHeader = cellSortAttr.getSortHeader();
}
sortHeaderPane.populateBean(sortHeader, defaultHeaderArea);
}
sortHeaderPane.populateBean(sortHeader, defaultHeaderArea);
refresh();
}
@ -76,13 +84,15 @@ public abstract class AbstractSortPane extends JPanel {
public void updateBean(TemplateCellElement cellElement) {
List<SortExpression> sortExpressions = sortGroupPane.updateBean();
SortHeader sortHeader = sortHeaderPane.updateBean();
CellSortAttr cellSortAttr = getCellSortAttr(cellElement);
cellSortAttr.setSortExpressions(sortExpressions);
if (sortHeader != null) {
sortHeader.setSortArea(selfSortArea);
if (needSortHeaderPane()) {
SortHeader sortHeader = sortHeaderPane.updateBean();
if (sortHeader != null) {
sortHeader.setSortArea(selfSortArea);
}
cellSortAttr.setSortHeader(sortHeader);
}
cellSortAttr.setSortHeader(sortHeader);
}
protected void refresh() {

165
designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java

@ -1,5 +1,7 @@
package com.fr.design.sort.common;
import com.fr.base.Style;
import com.fr.base.background.ColorBackground;
import com.fr.base.svg.IconUtils;
import com.fr.design.designer.TargetComponent;
import com.fr.design.event.UIObserver;
@ -10,9 +12,18 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.selection.SelectionEvent;
import com.fr.design.selection.SelectionListener;
import com.fr.design.ui.util.UIUtil;
import com.fr.general.Background;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.log.FineLoggerFactory;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.core.sort.common.CellSortable;
import com.fr.report.core.sort.header.SortHeader;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow;
import com.fr.stable.EssentialUtils;
import com.fr.stable.StringUtils;
@ -21,6 +32,12 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class SortColumnRowPane extends JPanel implements UIObserver {
int paneWidth;
@ -75,7 +92,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
void initSelectButton() {
selectButton = new UIButton(IconUtils.readIcon("/com/fr/design/images/buttonicon/select.png"));
selectButton.addActionListener(new SelectActionListener(this));
selectButton.addMouseListener(new SelectActionListener(this));
this.add(selectButton);
}
@ -90,7 +107,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
refresh();
}
public void setColumnRow(ColumnRow columnRow){
public void setColumnRow(ColumnRow columnRow) {
populateBean(columnRow);
uiObserverListener.doChange();
}
@ -112,59 +129,145 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
return true;
}
class SelectActionListener implements ActionListener {
class SelectActionListener extends MouseAdapter {
SortColumnRowPane columnRowPane;
Map<ColumnRow, Style> disableHeaderCellsStyleMap = new HashMap<>();
java.util.List<TemplateCellElement> tempHeaderCells = new ArrayList<>();
SelectActionListener(SortColumnRowPane columnRowPane) {
this.columnRowPane = columnRowPane;
}
@Override
public void actionPerformed(ActionEvent e) {
public void mouseClicked(MouseEvent e) {
ElementCasePane elementCasePane = getCurrentElementCase();
if (elementCasePane == null || isAlreadyAddListener) {
return;
}
oldSelection = (CellSelection) elementCasePane.getSelection();
elementCasePane.getGrid().setNotShowingTableSelectPane(false);
elementCasePane.setEditable(false);
elementCasePane.repaint(10);
prepareSelectHeader(elementCasePane);
gridSelectionChangeListener = new SelectionListener() {
@Override
public void selectionChanged(SelectionEvent e) {
Selection selection = elementCasePane.getSelection();
if (selection instanceof CellSelection) {
CellSelection cellselection = (CellSelection) selection;
ColumnRow cr = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow());
elementCasePane.setOldSelecton(oldSelection);
columnRowPane.setColumnRow(cr);
}
elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener);
isAlreadyAddListener = false;
elementCasePane.getGrid().setNotShowingTableSelectPane(true);
elementCasePane.setEditable(true);
elementCasePane.repaint();
completeSelectHeader(elementCasePane);
}
};
elementCasePane.addSelectionChangeListener(gridSelectionChangeListener);
isAlreadyAddListener = true;
}
}
private ElementCasePane getCurrentElementCase() {
try {
TargetComponent targetComponent
= HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane();
if (targetComponent instanceof ElementCasePane) {
return (ElementCasePane) targetComponent;
private void prepareSelectHeader(ElementCasePane elementCasePane) {
ashDisableHeaderCellsStyle(elementCasePane.getEditingElementCase());
oldSelection = (CellSelection) elementCasePane.getSelection();
elementCasePane.getGrid().setNotShowingTableSelectPane(false);
elementCasePane.setEditable(false);
elementCasePane.repaint(10);
}
private void completeSelectHeader(ElementCasePane elementCasePane) {
Selection selection = elementCasePane.getSelection();
if (selection instanceof CellSelection) {
CellSelection cellselection = (CellSelection) selection;
ColumnRow columnRow = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow());
elementCasePane.setOldSelecton(oldSelection);
oldSelection.getQuickEditor(elementCasePane);
if (!disableHeaderCellsStyleMap.keySet().contains(columnRow)) {
columnRowPane.setColumnRow(columnRow);
}
restoreDisableHeaderCellsStyle(elementCasePane.getEditingElementCase());
}
elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener);
isAlreadyAddListener = false;
elementCasePane.getGrid().setNotShowingTableSelectPane(true);
elementCasePane.setEditable(true);
elementCasePane.repaint();
}
private void ashDisableHeaderCellsStyle(TemplateElementCase elementCase) {
disableHeaderCellsStyleMap = new HashMap<>();
tempHeaderCells = new ArrayList<>();
Map<ColumnRow, TemplateCellElement> disableHeaderCellsMap = getDisableHeaderCellsMap(elementCase);
for (ColumnRow headerColumnRow : disableHeaderCellsMap.keySet()) {
TemplateCellElement headerCell = disableHeaderCellsMap.get(headerColumnRow);
if (headerCell == null) {
headerCell = new DefaultTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
elementCase.addCellElement(headerCell);
tempHeaderCells.add(headerCell);
}
Style style = headerCell.getStyle();
disableHeaderCellsStyleMap.put(headerColumnRow, style);
style = style.deriveBackground(ColorBackground.getInstance(Color.gray));
headerCell.setStyle(style);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return null;
private void restoreDisableHeaderCellsStyle(TemplateElementCase elementCase) {
try {
for (ColumnRow headerColumnRow : disableHeaderCellsStyleMap.keySet()) {
TemplateCellElement headerTemplateCellElement
= elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
headerTemplateCellElement.setStyle(disableHeaderCellsStyleMap.get(headerColumnRow));
}
for (TemplateCellElement templateCellElement : tempHeaderCells) {
elementCase.removeCellElement(templateCellElement);
}
disableHeaderCellsStyleMap = new HashMap<>();
tempHeaderCells = new ArrayList<>();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
}
private Map<ColumnRow, TemplateCellElement> getDisableHeaderCellsMap(TemplateElementCase elementCase) {
Map<ColumnRow, TemplateCellElement> headerCellsMap = new HashMap<>();
Iterator iterator = elementCase.cellIterator();
while (iterator.hasNext()) {
TemplateCellElement templateCellElement = (TemplateCellElement) iterator.next();
CellExpandAttr cellExpandAttr = templateCellElement.getCellExpandAttr();
if (cellExpandAttr != null) {
handleDisableHeaderCell(elementCase, cellExpandAttr, headerCellsMap);
}
Object value = templateCellElement.getValue();
if (value instanceof DSColumn) {
handleDisableHeaderCell(elementCase, (DSColumn) value, headerCellsMap);
}
}
return headerCellsMap;
}
private void handleDisableHeaderCell(TemplateElementCase elementCase, CellSortable cellSortable, Map<ColumnRow, TemplateCellElement> headerCellsMap) {
if (cellSortable.getCellSortAttr() != null) {
SortHeader sortHeader = cellSortable.getCellSortAttr().getSortHeader();
if (sortHeader != null) {
String headerArea = sortHeader.getHeaderArea();
if (headerArea != null) {
ColumnRow headerColumnRow = ColumnRow.valueOf(headerArea);
ColumnRow columnRow = columnRowPane.updateBean();
if (!headerColumnRow.equals(columnRow)) {
TemplateCellElement headerCell
= elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
headerCellsMap.put(headerColumnRow, headerCell);
}
}
}
}
}
private ElementCasePane getCurrentElementCase() {
try {
TargetComponent targetComponent
= HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane();
if (targetComponent instanceof ElementCasePane) {
return (ElementCasePane) targetComponent;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return null;
}
}
protected void refresh() {
validate();
repaint();

1
designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java

@ -31,6 +31,7 @@ public class SortUIExpandablePane extends JPanel {
initComponents();
wrapPane.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
wrapPane.setBackground(Color.WHITE);
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5));
}

6
designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java

@ -1,6 +1,5 @@
package com.fr.design.sort.expressionpane;
import com.fr.base.BaseUtils;
import com.fr.base.svg.IconUtils;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
@ -29,11 +28,10 @@ public class CustomSequencePane extends JPanel {
protected void initComponents(int width) {
textField = new UITextField();
textField.setEditable(false);
textField.setPreferredSize(new Dimension(width - 20, 20));
textField.setPreferredSize(new Dimension(width - 20, AbstractSortPane.PANE_COMPONENT_HEIGHT));
Icon icon = IconUtils.readIcon("/com/fr/design/images/control/refresh.png");
button = new UIButton(icon);
button.setBackground(Color.RED);
button.setPreferredSize(new Dimension(24, 20));
button.setOpaque(false);
button.setCursor(new Cursor(Cursor.HAND_CURSOR));
button.addActionListener(new ActionListener() {
@ -48,7 +46,7 @@ public class CustomSequencePane extends JPanel {
}, new Dimension(700, 400)).setVisible(true);
}
});
button.setPreferredSize(new Dimension(24, AbstractSortPane.PANE_COMPONENT_HEIGHT));
button.setPreferredSize(new Dimension(20, AbstractSortPane.PANE_COMPONENT_HEIGHT));
this.add(textField);
this.add(button);

6
designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java

@ -13,10 +13,8 @@ public class CustomSequenceSortExpressionPane extends SortExpressionPane<CustomS
CustomSequencePane customSequencePane;
public CustomSequenceSortExpressionPane(int width, int rightWidth) {
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
customSequencePane = new CustomSequencePane(rightWidth);
customSequencePane.setPreferredSize(new Dimension(width, AbstractSortPane.PANE_COMPONENT_HEIGHT));
customSequencePane.setBorder(BorderFactory.createEmptyBorder(0,0,0,3));
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0));
customSequencePane = new CustomSequencePane(rightWidth + 5);
this.add(customSequencePane);
}

4
designer-realize/src/main/java/com/fr/design/sort/expressionpane/FormulaSortExpressionPane.java

@ -12,9 +12,9 @@ public class FormulaSortExpressionPane extends SortExpressionPane<FormulaSortExp
TinyFormulaPane tinyFormulaPane;
public FormulaSortExpressionPane(int width) {
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 1));
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0));
tinyFormulaPane = new TinyFormulaPane();
tinyFormulaPane.setPreferredSize(new Dimension(width, AbstractSortPane.PANE_COMPONENT_HEIGHT));
tinyFormulaPane.setPreferredSize(new Dimension(width + 5, AbstractSortPane.PANE_COMPONENT_HEIGHT));
this.add(tinyFormulaPane);
}

144
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -316,10 +316,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
class DSColumnAdvancedEditorPane extends AbstractDSCellEditorPane {
/*pane begin*/
/**
* 排列顺序
*/
private ResultSetSortConfigPane sortPane;
/**
* 结果集筛选
*/
@ -377,7 +373,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
@Override
public void update() {
if (cellElement != null) {
sortPane.update(cellElement);
valuePane.update(cellElement);
formatAttrPane.update(cellElement);
filterPane.update(cellElement);
@ -393,7 +388,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void populate() {
if (cellElement != null) {
this.removeAttributeChangeListener();
sortPane.populate(cellElement);
valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
filterPane.populate(cellElement);
@ -500,10 +494,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
protected JPanel createContentPane() {
JPanel contentPane = new JPanel(new BorderLayout());
this.setLayout(FRGUIPaneFactory.createBorderLayout());
//结果集排序
sortPane = new ResultSetSortConfigPane();
//结果筛选
filterPane = new ResultSetFilterConfigPane();
@ -538,7 +528,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
multiNumPane.add(multiPane);
Component[][] components = new Component[][]{
{sortPane},
{filterPane},
{valuePane},
{formatAttrPane},
@ -552,9 +541,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
JPanel advancePropertyPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
contentPane.add(advancePropertyPane, BorderLayout.NORTH);
UIExpandablePane sortUIExpandablePane =
new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"),
new UIExpandablePane(Toolkit.i18nText("Fine-Design_Sort_Data_Column_Sort"),
223, 24, cellDSColumnSortPane = new CellDSColumnSortPane());
contentPane.add(sortUIExpandablePane, BorderLayout.CENTER);
return contentPane;
}
@ -569,136 +557,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
}
}
/**
* 单元格元素>数据集>高级设置>结果排序设置面板
*
* @see com.fr.design.expand.SortExpandAttrPane
* @see DSColumnAdvancedPane.SortPane
*/
public class ResultSetSortConfigPane extends JPanel {
private static final String DEFAULT_VALUE = "=";
private JPanel contentPane;
private UIButtonGroup sortTypePane;
private JFormulaField formulaField;
private CardLayout cardLayout;
private JPanel centerPane;
public ResultSetSortConfigPane() {
this.setLayout(new BorderLayout());
Icon[] iconArray = {
IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"),
IOUtils.readIcon("/com/fr/design/images/expand/asc.png"),
IOUtils.readIcon("/com/fr/design/images/expand/des.png")
};
String[] nameArray = {Toolkit.i18nText("Fine-Design_Report_Sort_Original"), Toolkit.i18nText("Fine-Design_Report_Sort_Ascending"), Toolkit.i18nText("Fine-Design_Report_Sort_Descending")};
sortTypePane = new UIButtonGroup(iconArray);
sortTypePane.setAllToolTips(nameArray);
sortTypePane.setGlobalName(Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"));
cardLayout = new CardLayout();
centerPane = new JPanel(cardLayout);
formulaField = new JFormulaField(DEFAULT_VALUE);
centerPane.add(new JPanel(), "none");
centerPane.add(formulaField, "content");
UILabel sortLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order"));
sortLabel.setPreferredSize(LABEL_DIMENSION);
sortTypePane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
boolean noContent = sortTypePane.getSelectedIndex() == 0;
cardLayout.show(centerPane, noContent ? "none" : "content");
if (noContent) {
centerPane.setPreferredSize(new Dimension(0, 0));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0);
} else {
centerPane.setPreferredSize(new Dimension(165, 20));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP);
}
}
});
Component[][] components = new Component[][]{
new Component[]{sortLabel, sortTypePane},
new Component[]{null, centerPane}
};
double[] rowSize = {P, P}, columnSize = {P, F};
contentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
this.add(contentPane, BorderLayout.CENTER);
}
/**
* 刷新面板信息
*
* @param cellElement 单元格
*/
public void populate(TemplateCellElement cellElement) {
if (cellElement != null) {
Object value = cellElement.getValue();
if (value instanceof DSColumn) {
this.formulaField.populateElement(cellElement);
DSColumn dSColumn = (DSColumn) value;
int sort = dSColumn.getOrder();
this.sortTypePane.setSelectedIndex(sort);
boolean noContent = sortTypePane.getSelectedIndex() == 0;
cardLayout.show(centerPane, noContent ? "none" : "content");
if (noContent) {
centerPane.setPreferredSize(new Dimension(0, 0));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0);
} else {
centerPane.setPreferredSize(new Dimension(156, 20));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP);
}
String sortFormula = dSColumn.getSortFormula();
if (sortFormula != null && sortFormula.length() >= 1) {
this.formulaField.populate(sortFormula);
} else {
this.formulaField.populate(DEFAULT_VALUE);
}
}
}
}
/**
* 保存面板配置信息
*
* @param cellElement 单元格
*/
public void update(CellElement cellElement) {
if (cellElement != null) {
Object value = cellElement.getValue();
if (value instanceof DSColumn) {
DSColumn dSColumn = (DSColumn) value;
dSColumn.setOrder(this.sortTypePane.getSelectedIndex());
dSColumn.setSortFormula(this.formulaField.getFormulaText());
}
}
}
/**
* 添加事件监听器
*
* @param formulaChangeListener 公式输入框改动事件监听器
* @param changeListener 排序类型下拉框改动事件监听器
*/
public void addListener(UIObserverListener formulaChangeListener, ChangeListener changeListener) {
formulaField.addListener(formulaChangeListener);
sortTypePane.addChangeListener(changeListener);
}
/**
* 去除事件监听器
*
* @param changeListener 排序类型下拉框改动事件监听器
*/
public void removeListener(ChangeListener changeListener) {
formulaField.removeListener();
sortTypePane.removeChangeListener(changeListener);
}
}
/**
* 单元格元素>数据集>高级设置>结果集筛选设置面板
*

Loading…
Cancel
Save