xiqiu
3 years ago
132 changed files with 3559 additions and 2752 deletions
@ -0,0 +1,7 @@
|
||||
package com.fr.design.event; |
||||
|
||||
import java.awt.*; |
||||
|
||||
public interface ComponentChangeListener { |
||||
void initListener(Container changedComponent); |
||||
} |
@ -0,0 +1,6 @@
|
||||
package com.fr.design.event; |
||||
|
||||
|
||||
public interface ComponentChangeObserver { |
||||
void registerChangeListener(ComponentChangeListener uiChangeableListener); |
||||
} |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -1,4 +1,4 @@
|
||||
package com.fr.design.fit; |
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.unit.LEN_UNIT; |
@ -1,4 +1,4 @@
|
||||
package com.fr.design.fit; |
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; |
||||
import com.fr.stable.unit.UNIT; |
@ -0,0 +1,27 @@
|
||||
package com.fr.design.mainframe.loghandler; |
||||
|
||||
import com.fr.third.apache.log4j.spi.LoggingEvent; |
||||
import com.fr.third.apache.logging.log4j.Level; |
||||
import com.fr.third.apache.logging.log4j.core.LogEvent; |
||||
import com.fr.third.apache.logging.log4j.core.impl.Log4jLogEvent; |
||||
import com.fr.third.apache.logging.log4j.message.SimpleMessage; |
||||
|
||||
/** |
||||
* 兼容log4j1和2之间logEvent之间的转换 |
||||
* |
||||
* @author hades |
||||
* @version 11.0 |
||||
* Created by hades on 2021/12/9 |
||||
*/ |
||||
public class LogEventConverter { |
||||
|
||||
public static LogEvent convert(LoggingEvent loggingEvent) { |
||||
SimpleMessage message = new SimpleMessage(loggingEvent.getRenderedMessage()); |
||||
return Log4jLogEvent.newBuilder(). |
||||
setMessage(message). |
||||
setLevel(Level.getLevel(loggingEvent.getLevel().toString())). |
||||
build(); |
||||
} |
||||
|
||||
|
||||
} |
After Width: | Height: | Size: 141 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 175 B |
After Width: | Height: | Size: 166 B |
After Width: | Height: | Size: 3.3 KiB |
@ -1,115 +0,0 @@
|
||||
package com.fr.design.actions; |
||||
|
||||
|
||||
import com.fr.base.iofile.attr.MobileOnlyTemplateAttrMark; |
||||
import com.fr.design.designer.creator.XLayoutContainer; |
||||
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; |
||||
import com.fr.design.designer.creator.XWFitLayout; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.fit.NewJForm; |
||||
import com.fr.design.fit.common.AdaptiveSwitchUtil; |
||||
import com.fr.design.fit.common.TemplateTool; |
||||
import com.fr.design.form.mobile.FormMobileAttrPane; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.FormArea; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.JForm; |
||||
import com.fr.design.mainframe.WidgetPropertyPane; |
||||
import com.fr.file.FILE; |
||||
import com.fr.form.main.Form; |
||||
import com.fr.form.main.mobile.FormMobileAttr; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* Created by fanglei on 2016/11/14. |
||||
*/ |
||||
@EnableMetrics |
||||
public class NewFormMobileAttrAction extends FormMobileAttrAction { |
||||
|
||||
public NewFormMobileAttrAction(JForm jf) { |
||||
super(jf); |
||||
} |
||||
|
||||
/** |
||||
* 执行动作 |
||||
* |
||||
* @return 是否执行成功 |
||||
*/ |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
final JForm jf = getEditingComponent(); |
||||
if (jf == null) { |
||||
return; |
||||
} |
||||
final Form formTpl = jf.getTarget(); |
||||
FormMobileAttr mobileAttr = formTpl.getFormMobileAttr(); |
||||
|
||||
final FormMobileAttrPane mobileAttrPane = new FormMobileAttrPane(); |
||||
mobileAttrPane.populateBean(mobileAttr); |
||||
|
||||
final boolean oldMobileOnly = mobileAttr.isMobileOnly(); |
||||
final boolean oldAdaptive = mobileAttr.isAdaptivePropertyAutoMatch(); |
||||
BasicDialog dialog = mobileAttrPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
FormMobileAttr formMobileAttr = mobileAttrPane.updateBean(); |
||||
if (formMobileAttr.isMobileOnly() && jf.getTarget().getAttrMark(MobileOnlyTemplateAttrMark.XML_TAG) == null) { |
||||
// 如果是老模板,选择手机专属之后需要另存为
|
||||
FILE editingFILE = jf.getEditingFILE(); |
||||
if (editingFILE != null && editingFILE.exists()) { |
||||
String fileName = editingFILE.getName().substring(0, editingFILE.getName().length() - jf.suffix().length()) + "_mobile"; |
||||
if (!jf.saveAsTemplate(true, fileName)) { |
||||
return; |
||||
} |
||||
} |
||||
// 放到后面。如果提前 return 了,则仍然处于未设置状态,不要添加
|
||||
jf.getTarget().addAttrMark(new MobileOnlyTemplateAttrMark()); |
||||
} |
||||
// 设置移动端属性并刷新界面
|
||||
formTpl.setFormMobileAttr(formMobileAttr); // 会调整 body 的自适应布局,放到最后
|
||||
boolean changeSize = (!oldMobileOnly && formMobileAttr.isMobileOnly()) || (oldMobileOnly && !formMobileAttr.isMobileOnly()); |
||||
if (changeSize) { |
||||
((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified(); |
||||
} |
||||
//改变布局为自适应布局,只在移动端属性设置保存后改变一次
|
||||
boolean changeLayout = !oldAdaptive && formMobileAttr.isAdaptivePropertyAutoMatch(); |
||||
if (changeLayout) { |
||||
jf.getFormDesign().getSelectionModel().setSelectedCreator(jf.getFormDesign().getRootComponent()); |
||||
doChangeBodyLayout(); |
||||
WidgetPropertyPane.getInstance().refreshDockingView(); |
||||
} |
||||
jf.fireTargetModified(); |
||||
FILE editingFILE = jf.getEditingFILE(); |
||||
if(editingFILE != null && editingFILE.exists()){ |
||||
JForm jForm = getEditingComponent(); |
||||
TemplateTool.saveForm(jForm); |
||||
if (jForm instanceof NewJForm) { |
||||
AdaptiveSwitchUtil.switch2OldUI(); |
||||
} |
||||
}else { |
||||
AdaptiveSwitchUtil.switch2OldUIMode(); |
||||
NewJForm mobileJForm = new NewJForm(jf.getTarget(), jf.getEditingFILE()); |
||||
//设置临时的id,和新建的模板区分
|
||||
mobileJForm.getTarget().setTemplateID(StringUtils.EMPTY); |
||||
TemplateTool.resetTabPaneEditingTemplate(mobileJForm); |
||||
TemplateTool.activeAndResizeTemplate(mobileJForm); |
||||
} |
||||
} |
||||
}); |
||||
dialog.setVisible(true); |
||||
} |
||||
|
||||
private void doChangeBodyLayout(){ |
||||
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||
XLayoutContainer rootLayout = formDesigner.getRootComponent(); |
||||
if (rootLayout.getComponentCount() == 1 && rootLayout.getXCreator(0).acceptType(XWAbsoluteBodyLayout.class)) { |
||||
rootLayout = (XWAbsoluteBodyLayout) rootLayout.getXCreator(0); |
||||
} |
||||
((XWFitLayout)formDesigner.getRootComponent()).switch2FitBodyLayout(rootLayout); |
||||
} |
||||
} |
||||
|
@ -1,70 +0,0 @@
|
||||
package com.fr.design.fit.grid; |
||||
|
||||
import com.fr.base.DynamicUnitList; |
||||
import com.fr.design.fit.DesignerUIModeConfig; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.grid.GridHeader; |
||||
import com.fr.grid.AbstractGridHeaderMouseHandler; |
||||
import com.fr.report.elementcase.ElementCase; |
||||
import com.fr.report.elementcase.TemplateElementCase; |
||||
|
||||
import java.awt.event.MouseEvent; |
||||
|
||||
public abstract class GridHeaderWithBoundMouseHandler extends AbstractGridHeaderMouseHandler{ |
||||
protected static final int FUZZY_EDGE = 10; |
||||
private int limit; |
||||
|
||||
public GridHeaderWithBoundMouseHandler(GridHeader gHeader, int limit) { |
||||
super(gHeader); |
||||
this.limit = limit; |
||||
} |
||||
|
||||
public void setLimit(int limit) { |
||||
this.limit = limit; |
||||
} |
||||
|
||||
public int getLimit() { |
||||
return limit; |
||||
} |
||||
|
||||
public int getDragIndex(MouseEvent evt) { |
||||
ElementCase report = this.getEditingElementCase(); |
||||
DynamicUnitList sizeList = getSizeList(report); |
||||
|
||||
int scrollValue = getScrollValue(this.getElementCasePane()); |
||||
int scrollExtent = getScrollExtent(this.getElementCasePane()); |
||||
int endValue = scrollValue + scrollExtent + 1; |
||||
|
||||
int beginValue = getBeginValue(this.getElementCasePane()); |
||||
|
||||
double tmpSize1 = 0; |
||||
double tmpSize2; |
||||
double tmpIncreaseSize = 0; |
||||
|
||||
int resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); |
||||
|
||||
for (int index = beginValue; index < endValue; index++) { |
||||
if (index == 0) { |
||||
index = scrollValue; |
||||
} |
||||
|
||||
tmpSize1 += tmpIncreaseSize; |
||||
tmpIncreaseSize = sizeList.get(index).toPixD(resolution); |
||||
tmpSize2 = tmpSize1 + Math.max(1, tmpIncreaseSize); |
||||
if (isOnSeparatorLineIncludeZero(evt, tmpSize2, tmpIncreaseSize) || isOnNormalSeparatorLine(evt, tmpSize2)) { |
||||
return index; |
||||
} |
||||
} |
||||
return -1; |
||||
} |
||||
|
||||
|
||||
public ElementCasePane getElementCasePane() { |
||||
return this.gHeader.getElementCasePane(); |
||||
} |
||||
|
||||
public TemplateElementCase getEditingElementCase() { |
||||
return this.getElementCasePane().getEditingElementCase(); |
||||
} |
||||
|
||||
} |
@ -1,194 +0,0 @@
|
||||
package com.fr.design.fit.grid; |
||||
|
||||
import com.fr.base.DynamicUnitList; |
||||
import com.fr.design.fit.DesignerUIModeConfig; |
||||
import com.fr.design.gui.imenu.UIPopupMenu; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.grid.GridColumn; |
||||
import com.fr.grid.GridHeader; |
||||
import com.fr.grid.GridUtils; |
||||
import com.fr.grid.selection.CellSelection; |
||||
import com.fr.grid.selection.Selection; |
||||
import com.fr.report.ReportHelper; |
||||
import com.fr.report.elementcase.ElementCase; |
||||
import com.fr.stable.ColumnRow; |
||||
import com.fr.stable.unit.FU; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
import java.awt.Dimension; |
||||
import java.awt.Point; |
||||
import java.awt.Rectangle; |
||||
import java.awt.Toolkit; |
||||
import java.awt.event.MouseEvent; |
||||
|
||||
/** |
||||
* peter:处理对GridColumn的Mouse事件. |
||||
*/ |
||||
public class GridLimitColumnMouseHandler extends GridHeaderWithBoundMouseHandler { |
||||
|
||||
|
||||
public GridLimitColumnMouseHandler(GridColumn gridColumn, int limit) { |
||||
super(gridColumn, limit); |
||||
this.resolution = gridColumn.getResolution(); |
||||
} |
||||
|
||||
@Override |
||||
protected void resetSelectionByRightButton(ColumnRow selectedCellPoint, Selection cs, ElementCasePane ePane) { |
||||
int[] selectedColumns = cs.getSelectedColumns(); |
||||
if (selectedColumns.length == 0 |
||||
|| selectedCellPoint.getColumn() < selectedColumns[0] |
||||
|| selectedCellPoint.getColumn() > selectedColumns[selectedColumns.length - 1]) { |
||||
resetGridSelectionBySelect(selectedCellPoint.getColumn(), ePane); |
||||
} |
||||
} |
||||
|
||||
|
||||
protected int doChooseFrom() { |
||||
return CellSelection.CHOOSE_COLUMN; |
||||
} |
||||
|
||||
@Override |
||||
protected Rectangle resetSelectedBoundsByShift(Rectangle editRectangle, ColumnRow selectedCellPoint, ElementCasePane reportPane) { |
||||
int tempOldSelectedCellX = editRectangle.x;// editRectangle.x;
|
||||
|
||||
// adjust them to got the correct selected bounds.
|
||||
if (selectedCellPoint.getColumn() >= editRectangle.x) { |
||||
selectedCellPoint = ColumnRow.valueOf(selectedCellPoint.getColumn() + 1, selectedCellPoint.getRow()); |
||||
} else { |
||||
tempOldSelectedCellX++; |
||||
} |
||||
|
||||
int lastRow = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getRow(); |
||||
return new Rectangle(Math.min(tempOldSelectedCellX, selectedCellPoint.getColumn()), 0, Math.max(editRectangle.width, Math.abs(tempOldSelectedCellX |
||||
- selectedCellPoint.getColumn())), lastRow); |
||||
} |
||||
|
||||
@Override |
||||
protected int[] getGridSelectionIndices(CellSelection cs) { |
||||
return cs.getSelectedColumns(); |
||||
} |
||||
|
||||
@Override |
||||
protected int getScrollValue(ElementCasePane casePane) { |
||||
return casePane.getGrid().getHorizontalValue(); |
||||
} |
||||
|
||||
@Override |
||||
protected int getScrollExtent(ElementCasePane casePane) { |
||||
return casePane.getGrid().getHorizontalExtent(); |
||||
} |
||||
|
||||
@Override |
||||
protected int getBeginValue(ElementCasePane casePane) { |
||||
return casePane.getGrid().getHorizontalBeginValue(); |
||||
} |
||||
|
||||
@Override |
||||
protected int getColumnOrRowByGridHeader(ColumnRow selectedCellPoint) { |
||||
return selectedCellPoint.getColumn(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Checks whether is on zero separator line. |
||||
*/ |
||||
@Override |
||||
protected boolean isOnSeparatorLineIncludeZero(MouseEvent evt, double tmpWidth2, double tmpIncreaseWidth) { |
||||
return tmpIncreaseWidth <= 1 && (evt.getX() >= tmpWidth2 + 2 && (evt.getX() <= tmpWidth2 + SEPARATOR_GAP)); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean between(MouseEvent evt, double from, double to) { |
||||
return evt.getX() > from && evt.getX() <= to; |
||||
} |
||||
|
||||
/** |
||||
* Checks whether is on normal separator line. |
||||
*/ |
||||
@Override |
||||
protected boolean isOnNormalSeparatorLine(MouseEvent evt, double tmpWidth2) { |
||||
return (evt.getX() >= tmpWidth2 - 2) && (evt.getX() <= tmpWidth2 + 2); |
||||
} |
||||
|
||||
@Override |
||||
protected int evtOffset(MouseEvent evt, int offset) { |
||||
return evt.getX() - offset; |
||||
} |
||||
|
||||
@Override |
||||
protected DynamicUnitList getSizeList(ElementCase elementCase) { |
||||
return ReportHelper.getColumnWidthList(elementCase); |
||||
} |
||||
|
||||
@Override |
||||
protected String methodName() { |
||||
return "setColumnWidth"; |
||||
} |
||||
|
||||
@Override |
||||
protected String getSelectedHeaderTooltip(int selectedColumnCount) { |
||||
return selectedColumnCount + "C"; |
||||
} |
||||
|
||||
@Override |
||||
protected Point getTipLocationByMouseEvent(MouseEvent evt, GridHeader gHeader, Dimension tipPreferredSize) { |
||||
Point convertPoint = new Point(evt.getX(), 0); |
||||
SwingUtilities.convertPointToScreen(convertPoint, gHeader); |
||||
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
||||
convertPoint.x = Math.max(0, Math.min(convertPoint.x - tipPreferredSize.width / 2, screenSize.width - tipPreferredSize.width)); |
||||
convertPoint.y = convertPoint.y - tipPreferredSize.height - 2; |
||||
|
||||
return convertPoint; |
||||
} |
||||
|
||||
@Override |
||||
protected void resetGridSelectionBySelect(int column, ElementCasePane ePane) { |
||||
int lastRow = GridUtils.getAdjustLastColumnRowOfReportPane(ePane).getRow(); |
||||
CellSelection cellSelection = new CellSelection(column, 0, 1, lastRow); |
||||
cellSelection.setSelectedType(CellSelection.CHOOSE_COLUMN); |
||||
ePane.setSelection(cellSelection); |
||||
} |
||||
|
||||
@Override |
||||
protected String nameOfMoveCursorGIF() { |
||||
return "cursor_hmove"; |
||||
} |
||||
|
||||
@Override |
||||
protected String nameOfSelectCursorGIF() { |
||||
return "cursor_hselect"; |
||||
} |
||||
|
||||
@Override |
||||
protected String nameOfSplitCursorGIF() { |
||||
return "cursor_hsplit"; |
||||
} |
||||
|
||||
@Override |
||||
protected UIPopupMenu createPopupMenu(ElementCasePane reportPane, |
||||
MouseEvent evt, int columnIndex) { |
||||
return ElementCasePaneUtil.createColumnPopupMenu(reportPane, evt, columnIndex); |
||||
} |
||||
|
||||
@Override |
||||
protected void resetGridSelectionByDrag(CellSelection gridSelection, ElementCasePane reportPane, |
||||
int startMultiSelectIndex, int endMultiSelectIndex) { |
||||
int lastRow = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getRow(); |
||||
gridSelection.setLastRectangleBounds(Math.min(endMultiSelectIndex, startMultiSelectIndex), 0, Math.abs(startMultiSelectIndex - endMultiSelectIndex) + 1, lastRow); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseReleased(MouseEvent e) { |
||||
super.mouseReleased(e); |
||||
int resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); |
||||
int dragIndex = getDragIndex(e); |
||||
if (Math.abs(e.getX() - getLimit()) < FUZZY_EDGE && dragIndex >= 0) { |
||||
UNIT oldValue = this.getEditingElementCase().getColumnWidth(dragIndex); |
||||
this.getEditingElementCase().setColumnWidth(dragIndex, FU.valueOfPix(oldValue.toPixI(resolution) + getLimit() - e.getX(), resolution)); |
||||
} |
||||
this.getElementCasePane().repaint(); |
||||
} |
||||
|
||||
} |
@ -1,190 +0,0 @@
|
||||
package com.fr.design.fit.grid; |
||||
|
||||
import com.fr.base.DynamicUnitList; |
||||
import com.fr.design.fit.DesignerUIModeConfig; |
||||
import com.fr.design.gui.imenu.UIPopupMenu; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.grid.GridHeader; |
||||
import com.fr.grid.GridRow; |
||||
import com.fr.grid.GridUtils; |
||||
import com.fr.grid.selection.CellSelection; |
||||
import com.fr.grid.selection.Selection; |
||||
import com.fr.report.ReportHelper; |
||||
import com.fr.report.elementcase.ElementCase; |
||||
import com.fr.stable.ColumnRow; |
||||
import com.fr.stable.unit.FU; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
import java.awt.Dimension; |
||||
import java.awt.Point; |
||||
import java.awt.Rectangle; |
||||
import java.awt.event.MouseEvent; |
||||
|
||||
/** |
||||
* peter:处理对GridRow的Mouse事件. |
||||
*/ |
||||
public class GridLimitRowMouseHandler extends GridHeaderWithBoundMouseHandler { |
||||
|
||||
public GridLimitRowMouseHandler(GridRow gridRow, int limit) { |
||||
super(gridRow, limit); |
||||
} |
||||
|
||||
@Override |
||||
protected void resetSelectionByRightButton(ColumnRow selectedCellPoint, Selection cs, ElementCasePane ePane) { |
||||
int[] selectedRows = cs.getSelectedRows(); |
||||
if (selectedRows.length == 0 |
||||
|| selectedCellPoint.getRow() < selectedRows[0] |
||||
|| selectedCellPoint.getRow() > selectedRows[selectedRows.length - 1]) { |
||||
resetGridSelectionBySelect(selectedCellPoint.getRow(), ePane); |
||||
} |
||||
} |
||||
|
||||
|
||||
protected int doChooseFrom() { |
||||
return CellSelection.CHOOSE_ROW; |
||||
} |
||||
|
||||
@Override |
||||
protected int getScrollValue(ElementCasePane casePane) { |
||||
return casePane.getGrid().getVerticalValue(); |
||||
} |
||||
|
||||
@Override |
||||
protected int getScrollExtent(ElementCasePane casePane) { |
||||
return casePane.getGrid().getVerticalExtent(); |
||||
} |
||||
|
||||
@Override |
||||
protected int getBeginValue(ElementCasePane casePane) { |
||||
return casePane.getGrid().getVerticalBeginValue(); |
||||
} |
||||
|
||||
@Override |
||||
protected Rectangle resetSelectedBoundsByShift(Rectangle editRectangle, ColumnRow selectedCellPoint, ElementCasePane reportPane) { |
||||
int tempOldSelectedCellY = editRectangle.y;// editRectangle.x;
|
||||
|
||||
// ajust them to got the correct selected bounds.
|
||||
if (selectedCellPoint.getRow() >= editRectangle.y) { |
||||
selectedCellPoint = ColumnRow.valueOf(selectedCellPoint.getColumn(), selectedCellPoint.getRow() + 1); |
||||
} else { |
||||
tempOldSelectedCellY++; |
||||
} |
||||
|
||||
int lastColumn = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getColumn(); |
||||
return new Rectangle(0, Math.min(tempOldSelectedCellY, selectedCellPoint.getRow()), |
||||
lastColumn, Math.max(editRectangle.height, Math.abs(tempOldSelectedCellY - selectedCellPoint.getRow()))); |
||||
} |
||||
|
||||
@Override |
||||
protected int[] getGridSelectionIndices(CellSelection cs) { |
||||
return cs.getSelectedRows(); |
||||
} |
||||
|
||||
@Override |
||||
protected int getColumnOrRowByGridHeader(ColumnRow selectedCellPoint) { |
||||
return selectedCellPoint.getRow(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected void resetGridSelectionBySelect(int row, ElementCasePane ePane) { |
||||
int lastColumn = GridUtils.getAdjustLastColumnRowOfReportPane(ePane).getColumn(); |
||||
CellSelection cellSelection = new CellSelection(0, row, lastColumn, 1); |
||||
cellSelection.setSelectedType(CellSelection.CHOOSE_ROW); |
||||
ePane.setSelection(cellSelection); |
||||
} |
||||
|
||||
/** |
||||
* Checks whether is on zero separator line. |
||||
*/ |
||||
@Override |
||||
protected boolean isOnSeparatorLineIncludeZero(MouseEvent evt, double tmpHeight2, double tmpIncreaseHeight) { |
||||
return tmpIncreaseHeight <= 1 && (evt.getY() >= tmpHeight2 + 2 && evt.getY() <= tmpHeight2 + SEPARATOR_GAP); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean between(MouseEvent evt, double from, double to) { |
||||
return evt.getY() > from && evt.getY() <= to; |
||||
} |
||||
|
||||
@Override |
||||
protected DynamicUnitList getSizeList(ElementCase elementCase) { |
||||
return ReportHelper.getRowHeightList(elementCase); |
||||
} |
||||
|
||||
@Override |
||||
protected String methodName() { |
||||
return "setRowHeight"; |
||||
} |
||||
|
||||
/** |
||||
* Checks whether is on normal separator line. |
||||
*/ |
||||
@Override |
||||
protected boolean isOnNormalSeparatorLine(MouseEvent evt, double tmpHeight2) { |
||||
return (evt.getY() >= tmpHeight2 - 2) && (evt.getY() <= tmpHeight2 + 2); |
||||
} |
||||
|
||||
@Override |
||||
protected int evtOffset(MouseEvent evt, int offset) { |
||||
return evt.getY() - offset; |
||||
} |
||||
|
||||
@Override |
||||
protected String getSelectedHeaderTooltip(int rowSelectedCount) { |
||||
return rowSelectedCount + "R"; |
||||
} |
||||
|
||||
@Override |
||||
protected Point getTipLocationByMouseEvent(MouseEvent evt, GridHeader gHeader, Dimension tipPreferredSize) { |
||||
Point convertPoint = new Point(0, evt.getY()); |
||||
SwingUtilities.convertPointToScreen(convertPoint, gHeader); |
||||
|
||||
convertPoint.x = convertPoint.x + gHeader.getSize().width + 2; |
||||
convertPoint.y = convertPoint.y - tipPreferredSize.height / 2; |
||||
|
||||
return convertPoint; |
||||
} |
||||
|
||||
@Override |
||||
protected String nameOfMoveCursorGIF() { |
||||
return "cursor_vmove"; |
||||
} |
||||
|
||||
@Override |
||||
protected String nameOfSelectCursorGIF() { |
||||
return "cursor_vselect"; |
||||
} |
||||
|
||||
@Override |
||||
protected String nameOfSplitCursorGIF() { |
||||
return "cursor_vsplit"; |
||||
} |
||||
|
||||
@Override |
||||
protected UIPopupMenu createPopupMenu(ElementCasePane reportPane, |
||||
MouseEvent evt, int rowIndex) { |
||||
return ElementCasePaneUtil.createRowPopupMenu(reportPane, evt, rowIndex); |
||||
} |
||||
|
||||
@Override |
||||
protected void resetGridSelectionByDrag(CellSelection gridSelection, ElementCasePane reportPane, |
||||
int startMultiSelectIndex, int endMultiSelectIndex) { |
||||
int lastColumn = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getColumn(); |
||||
gridSelection.setLastRectangleBounds(0, Math.min(endMultiSelectIndex, startMultiSelectIndex), lastColumn, Math.abs(startMultiSelectIndex - endMultiSelectIndex) + 1); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void mouseReleased(MouseEvent e) { |
||||
super.mouseReleased(e); |
||||
int resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); |
||||
int dragIndex = getDragIndex(e); |
||||
if (Math.abs(e.getY() - getLimit()) < FUZZY_EDGE && dragIndex >= 0) { |
||||
UNIT oldValue = this.getEditingElementCase().getRowHeight(dragIndex); |
||||
this.getEditingElementCase().setRowHeight(dragIndex, FU.valueOfPix(oldValue.toPixI(resolution) + getLimit() - e.getY(), resolution)); |
||||
} |
||||
this.getElementCasePane().repaint(); |
||||
} |
||||
} |
@ -1,201 +0,0 @@
|
||||
package com.fr.design.fit.grid; |
||||
|
||||
import com.fr.design.designer.creator.XElementCase; |
||||
import com.fr.design.fit.AdaptiveCellElementPainter; |
||||
import com.fr.design.fit.DesignerUIModeConfig; |
||||
import com.fr.design.fit.common.FormDesignerUtil; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.grid.CellElementPainter; |
||||
import com.fr.grid.Grid; |
||||
import com.fr.grid.GridColumn; |
||||
import com.fr.grid.GridRow; |
||||
import com.fr.grid.GridUI; |
||||
import com.fr.report.elementcase.TemplateElementCase; |
||||
import com.fr.report.worksheet.FormElementCase; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.GraphDrawHelper; |
||||
|
||||
import javax.swing.JComponent; |
||||
import java.awt.Color; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Insets; |
||||
import java.awt.Rectangle; |
||||
import java.awt.event.MouseListener; |
||||
import java.awt.event.MouseMotionListener; |
||||
import java.awt.event.MouseWheelListener; |
||||
|
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-14 |
||||
*/ |
||||
public class NewFormDesignerGridUI extends GridUI { |
||||
private GridLimitColumnMouseHandler gridColumnMouseHandler; |
||||
private GridLimitRowMouseHandler gridRowMouseHandler; |
||||
private AdaptiveGridListener adaptiveGridListener; |
||||
private FormDesigner designer; |
||||
|
||||
public NewFormDesignerGridUI(FormDesigner designer, int resolution) { |
||||
super(resolution); |
||||
this.designer = designer; |
||||
this.setCellElementPainter(new AdaptiveCellElementPainter()); |
||||
} |
||||
|
||||
public void setCellElementPainter(CellElementPainter elementPainter) { |
||||
this.painter = elementPainter; |
||||
} |
||||
|
||||
public void paint(Graphics g, JComponent c) { |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
Grid grid = (Grid) c; |
||||
// 取得ElementCasePane.ElementCase
|
||||
ElementCasePane elementCasePane = grid.getElementCasePane(); |
||||
final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); |
||||
|
||||
super.paint(g, c); |
||||
|
||||
if (!(elementCase instanceof FormElementCase)) { |
||||
return; |
||||
} |
||||
final Rectangle rectangle = getBoundsLineRect(elementCase, grid); |
||||
int width = getScaleWidth(rectangle.width) - columnWidthList.getRangeValue(0, horizontalValue).toPixI(resolution); |
||||
int height = getScaleHeight(rectangle.height) - rowHeightList.getRangeValue(0, verticalValue).toPixI(resolution); |
||||
drawBoundsLine(g2d, width, height); |
||||
addListener(grid, elementCasePane, width, height, rectangle.width, rectangle.height); |
||||
} |
||||
|
||||
private int getScaleWidth(int width) { |
||||
return width * resolution / DesignerUIModeConfig.getInstance().getScreenResolution(); |
||||
|
||||
} |
||||
|
||||
private int getScaleHeight(int height) { |
||||
return height * resolution / DesignerUIModeConfig.getInstance().getScreenResolution(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取需要画线的矩形大小 |
||||
*/ |
||||
private Rectangle getBoundsLineRect(TemplateElementCase elementCase, Grid grid) { |
||||
final Rectangle rectangle = new Rectangle(); |
||||
XElementCase xElementCase = FormDesignerUtil.getXelementCase(designer.getRootComponent(), (FormElementCase) elementCase); |
||||
if (xElementCase != null) { |
||||
rectangle.setBounds(xElementCase.getBounds()); |
||||
|
||||
//减去内边距的宽和高
|
||||
Insets insets = xElementCase.getInsets(); |
||||
rectangle.width -= insets.left + insets.right; |
||||
rectangle.height -= insets.top + insets.bottom; |
||||
|
||||
} |
||||
return rectangle; |
||||
} |
||||
|
||||
|
||||
private void addListener(Grid grid, ElementCasePane elementCasePane, int width, int height, int actualWidth, int actualHeight) { |
||||
addGridColumnListener(elementCasePane.getGridColumn(), width); |
||||
addGridRowListener(elementCasePane.getGridRow(), height); |
||||
addMouseListener(grid, width, height, actualWidth, actualHeight); |
||||
} |
||||
|
||||
|
||||
private void drawBoundsLine(Graphics2D g2d, int width, int height) { |
||||
g2d.setPaint(Color.black); |
||||
g2d.setStroke(GraphDrawHelper.getStroke(Constants.LINE_DASH_DOT)); |
||||
g2d.drawLine(0, height, width, height); |
||||
g2d.drawLine(width, 0, width, height); |
||||
} |
||||
|
||||
private void removeGridColumnListener(GridColumn column) { |
||||
MouseMotionListener[] mouseMotionListeners = column.getMouseMotionListeners(); |
||||
for (MouseMotionListener mouseMotionListener : mouseMotionListeners) { |
||||
if (mouseMotionListener instanceof com.fr.grid.GridColumnMouseHandler || mouseMotionListener instanceof GridLimitColumnMouseHandler) { |
||||
column.removeMouseMotionListener(mouseMotionListener); |
||||
} |
||||
} |
||||
MouseListener[] mouseListeners = column.getMouseListeners(); |
||||
for (MouseListener motionListener : mouseListeners) { |
||||
if (motionListener instanceof com.fr.grid.GridColumnMouseHandler || motionListener instanceof GridLimitColumnMouseHandler) { |
||||
column.removeMouseListener(motionListener); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void removeGridRowListener(GridRow row) { |
||||
MouseMotionListener[] mouseMotionListeners = row.getMouseMotionListeners(); |
||||
for (MouseMotionListener mouseMotionListener : mouseMotionListeners) { |
||||
if (mouseMotionListener instanceof com.fr.grid.GridRowMouseHandler || mouseMotionListener instanceof GridLimitRowMouseHandler) { |
||||
row.removeMouseMotionListener(mouseMotionListener); |
||||
} |
||||
} |
||||
MouseListener[] mouseListeners = row.getMouseListeners(); |
||||
for (MouseListener motionListener : mouseListeners) { |
||||
if (motionListener instanceof com.fr.grid.GridRowMouseHandler || motionListener instanceof GridLimitRowMouseHandler) { |
||||
row.removeMouseListener(motionListener); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void removeGridListener(Grid grid) { |
||||
MouseMotionListener[] mouseMotionListeners = grid.getMouseMotionListeners(); |
||||
for (MouseMotionListener mouseMotionListener : mouseMotionListeners) { |
||||
if (mouseMotionListener instanceof AdaptiveGridListener) { |
||||
grid.removeMouseMotionListener(mouseMotionListener); |
||||
break; |
||||
} |
||||
} |
||||
MouseListener[] mouseListeners = grid.getMouseListeners(); |
||||
for (MouseListener motionListener : mouseListeners) { |
||||
if (motionListener instanceof AdaptiveGridListener) { |
||||
grid.removeMouseListener(motionListener); |
||||
break; |
||||
} |
||||
} |
||||
MouseWheelListener[] mouseWheelListeners = grid.getMouseWheelListeners(); |
||||
for (MouseWheelListener mouseWheelListener : mouseWheelListeners) { |
||||
if (mouseWheelListener instanceof AdaptiveGridListener) { |
||||
grid.removeMouseWheelListener(mouseWheelListener); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void addGridColumnListener(GridColumn column, int width) { |
||||
if (gridColumnMouseHandler != null) { |
||||
gridColumnMouseHandler.setLimit(width); |
||||
return; |
||||
} |
||||
removeGridColumnListener(column); |
||||
gridColumnMouseHandler = new GridLimitColumnMouseHandler(column, width); |
||||
column.addMouseListener(gridColumnMouseHandler); |
||||
column.addMouseMotionListener(gridColumnMouseHandler); |
||||
} |
||||
|
||||
|
||||
private void addGridRowListener(GridRow row, int height) { |
||||
if (gridRowMouseHandler != null) { |
||||
gridRowMouseHandler.setLimit(height); |
||||
return; |
||||
} |
||||
removeGridRowListener(row); |
||||
gridRowMouseHandler = new GridLimitRowMouseHandler(row, height); |
||||
row.addMouseMotionListener(gridRowMouseHandler); |
||||
row.addMouseListener(gridRowMouseHandler); |
||||
} |
||||
|
||||
|
||||
private void addMouseListener(Grid grid, int width, int height, int actualWidth, int actualHeight) { |
||||
if (adaptiveGridListener != null) { |
||||
adaptiveGridListener.resetBoundInfo(width, height, actualWidth, actualHeight); |
||||
return; |
||||
} |
||||
removeGridListener(grid); |
||||
adaptiveGridListener = new AdaptiveGridListener(grid, width, height, actualWidth, actualHeight); |
||||
grid.addMouseMotionListener(adaptiveGridListener); |
||||
grid.addMouseListener(adaptiveGridListener); |
||||
grid.addMouseWheelListener(adaptiveGridListener); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.design.sort.celldscolumn; |
||||
|
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.design.sort.common.AbstractSortGroupPane; |
||||
import com.fr.design.sort.common.AbstractSortItemPane; |
||||
import com.fr.report.cell.cellattr.core.group.DSColumn; |
||||
import com.fr.report.core.sort.sortexpression.SortExpression; |
||||
|
||||
public class CellDSColumnSortGroupPane extends AbstractSortGroupPane { |
||||
DSColumn dsColumn; |
||||
|
||||
public CellDSColumnSortGroupPane(int sortGroupPaneWidth, int sortGroupPaneRightWidth) { |
||||
super(sortGroupPaneWidth, sortGroupPaneRightWidth); |
||||
} |
||||
|
||||
public void populateDsColumn(DSColumn dsColumn) { |
||||
this.dsColumn = dsColumn; |
||||
} |
||||
|
||||
@Override |
||||
protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) { |
||||
CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane(sortItemPaneWidth, sortItemPaneRightWidth); |
||||
java.util.Map<String, TableDataWrapper> tableDataWrapperMap = |
||||
DesignTableDataManager.getAllEditingDataSet(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); |
||||
TableDataWrapper tableDataWrapper = tableDataWrapperMap.get(dsColumn.getDSName()); |
||||
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; |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.design.sort.celldscolumn; |
||||
|
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.sort.common.AbstractSortItemPane; |
||||
import com.fr.design.sort.common.AbstractSortPane; |
||||
import com.fr.report.core.sort.sortexpression.SortExpression; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
|
||||
public class CellDSColumnSortItemPane extends AbstractSortItemPane { |
||||
|
||||
UIComboBox sortAreaUiComboBox; |
||||
|
||||
public CellDSColumnSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth) { |
||||
super(sortItemPaneWidth, sortItemPaneRightWidth); |
||||
} |
||||
|
||||
@Override |
||||
public void initMainSortAreaPane(JPanel sortAreaPane) { |
||||
sortAreaUiComboBox = new UIComboBox(new String[0]); |
||||
sortAreaUiComboBox.setPreferredSize(new Dimension(sortItemPaneRightWidth, AbstractSortPane.PANE_COMPONENT_HEIGHT)); |
||||
sortAreaPane.add(sortAreaUiComboBox); |
||||
} |
||||
|
||||
public void populateBean(SortExpression sortExpression) { |
||||
sortAreaUiComboBox.setSelectedItem(sortExpression.getSortArea()); |
||||
super.populateBean(sortExpression); |
||||
} |
||||
|
||||
public SortExpression updateBean() { |
||||
SortExpression sortExpression = super.updateBean(); |
||||
if (sortExpression != null) { |
||||
sortExpression.setSortArea(sortAreaUiComboBox.getSelectedItem().toString()); |
||||
} |
||||
return sortExpression; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,59 @@
|
||||
package com.fr.design.sort.celldscolumn; |
||||
|
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.sort.common.AbstractSortPane; |
||||
import com.fr.general.data.TableDataColumn; |
||||
import com.fr.report.cell.TemplateCellElement; |
||||
import com.fr.report.cell.cellattr.core.group.DSColumn; |
||||
import com.fr.report.core.sort.common.CellSortAttr; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
|
||||
public class CellDSColumnSortPane extends AbstractSortPane { |
||||
|
||||
public CellDSColumnSortPane() { |
||||
super(220, 150); |
||||
//this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
} |
||||
|
||||
@Override |
||||
protected void initSortGroupPane() { |
||||
sortGroupPane = new CellDSColumnSortGroupPane(sortPaneWidth, sortPaneRightWidth); |
||||
this.add(sortGroupPane); |
||||
} |
||||
|
||||
@Override |
||||
protected CellSortAttr getCellSortAttr(TemplateCellElement cellElement) { |
||||
if (cellElement.getValue() instanceof DSColumn) { |
||||
DSColumn dsColumn = ((DSColumn) cellElement.getValue()); |
||||
if (dsColumn.getCellSortAttr() == null) { |
||||
dsColumn.setCellSortAttr(new CellSortAttr()); |
||||
} |
||||
return dsColumn.getCellSortAttr(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
protected void populateSortArea(TemplateCellElement cellElement) { |
||||
super.populateSortArea(cellElement); |
||||
if (cellElement.getValue() instanceof DSColumn) { |
||||
DSColumn dsColumn = ((DSColumn) cellElement.getValue()); |
||||
TableDataColumn tableDataColumn = dsColumn.getColumn(); |
||||
if (tableDataColumn instanceof TableDataColumn) { |
||||
selfSortArea = TableDataColumn.getColumnName(tableDataColumn); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void populateBean(TemplateCellElement cellElement) { |
||||
if (cellElement.getValue() instanceof DSColumn) { |
||||
DSColumn dsColumn = ((DSColumn) cellElement.getValue()); |
||||
if (sortGroupPane != null) { |
||||
((CellDSColumnSortGroupPane) sortGroupPane).populateDsColumn(dsColumn); |
||||
} |
||||
} |
||||
super.populateBean(cellElement); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.fr.design.sort.cellexpand; |
||||
|
||||
import com.fr.design.sort.common.AbstractSortGroupPane; |
||||
import com.fr.design.sort.common.AbstractSortItemPane; |
||||
import com.fr.report.core.sort.sortexpression.SortExpression; |
||||
|
||||
public class CellExpandSortGroupPane extends AbstractSortGroupPane { |
||||
|
||||
public CellExpandSortGroupPane(int sortGroupPaneWidth, int sortGroupPaneRightWidth) { |
||||
super(sortGroupPaneWidth, sortGroupPaneRightWidth); |
||||
} |
||||
|
||||
@Override |
||||
protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) { |
||||
AbstractSortItemPane abstractSortItemPane = new CellExpandSortItemPane( sortItemPaneWidth, sortItemPaneRightWidth); |
||||
abstractSortItemPane.populateBean(sortExpression); |
||||
return abstractSortItemPane; |
||||
} |
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.fr.design.sort.cellexpand; |
||||
|
||||
import com.fr.design.sort.common.AbstractSortPane; |
||||
import com.fr.design.sort.common.SortColumnRowPane; |
||||
import com.fr.design.sort.common.AbstractSortItemPane; |
||||
import com.fr.report.core.sort.sortexpression.SortExpression; |
||||
import com.fr.stable.ColumnRow; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
public class CellExpandSortItemPane extends AbstractSortItemPane { |
||||
SortColumnRowPane columnRowPane; |
||||
|
||||
public CellExpandSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth) { |
||||
super(sortItemPaneWidth, sortItemPaneRightWidth); |
||||
} |
||||
|
||||
@Override |
||||
public void initMainSortAreaPane(JPanel sortAreaPane) { |
||||
columnRowPane = new SortColumnRowPane(sortItemPaneRightWidth + 4, AbstractSortPane.PANE_COMPONENT_HEIGHT); |
||||
sortAreaPane.add(columnRowPane); |
||||
} |
||||
|
||||
public void populateBean(SortExpression sortExpression) { |
||||
columnRowPane.populateBean(ColumnRow.valueOf(sortExpression.getSortArea())); |
||||
super.populateBean(sortExpression); |
||||
} |
||||
|
||||
public SortExpression updateBean() { |
||||
SortExpression sortExpression = super.updateBean(); |
||||
if (sortExpression != null) { |
||||
ColumnRow columnRow = columnRowPane.updateBean(); |
||||
sortExpression.setSortArea(columnRow == null ? null : columnRow.toString()); |
||||
} |
||||
return sortExpression; |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue