|
|
|
package com.fr.design.mainframe.form;
|
|
|
|
|
|
|
|
import com.fr.design.DesignState;
|
|
|
|
import com.fr.design.actions.UpdateAction;
|
|
|
|
import com.fr.design.actions.core.ActionFactory;
|
|
|
|
import com.fr.design.actions.form.FormECBackgroundAction;
|
|
|
|
import com.fr.design.actions.form.FormECColumnsAction;
|
|
|
|
import com.fr.design.actions.form.FormECFrozenAction;
|
|
|
|
import com.fr.design.designer.creator.XElementCase;
|
|
|
|
import com.fr.design.event.TargetModifiedEvent;
|
|
|
|
import com.fr.design.event.TargetModifiedListener;
|
|
|
|
import com.fr.design.fit.NewUIModeCellElementPainter;
|
|
|
|
import com.fr.design.fit.common.FormDesignerUtil;
|
|
|
|
import com.fr.design.gui.frpane.HyperlinkGroupPane;
|
|
|
|
import com.fr.design.mainframe.*;
|
|
|
|
import com.fr.design.mainframe.cell.QuickEditorRegion;
|
|
|
|
import com.fr.design.menu.KeySetUtils;
|
|
|
|
import com.fr.design.menu.MenuDef;
|
|
|
|
import com.fr.design.menu.ShortCut;
|
|
|
|
import com.fr.design.menu.ToolBarDef;
|
|
|
|
import com.fr.design.present.ConditionAttributesGroupPane;
|
|
|
|
import com.fr.form.fit.common.LightTool;
|
|
|
|
import com.fr.form.main.Form;
|
|
|
|
import com.fr.grid.Grid;
|
|
|
|
import com.fr.grid.GridColumn;
|
|
|
|
import com.fr.grid.GridCorner;
|
|
|
|
import com.fr.grid.GridRow;
|
|
|
|
import com.fr.page.ReportSettingsProvider;
|
|
|
|
import com.fr.report.elementcase.TemplateElementCase;
|
|
|
|
import com.fr.report.worksheet.FormElementCase;
|
|
|
|
import com.fr.design.selection.SelectionEvent;
|
|
|
|
import com.fr.design.selection.SelectionListener;
|
|
|
|
|
|
|
|
import javax.swing.JComponent;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import java.awt.Insets;
|
|
|
|
import java.awt.Rectangle;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase>{
|
|
|
|
|
|
|
|
|
|
|
|
public FormElementCasePaneDelegate(FormElementCase sheet, Form form) {
|
|
|
|
super(sheet);
|
|
|
|
this.getGrid().setPaginateLineShowType(form.getFormMobileAttr().isMobileOnly()
|
|
|
|
? Grid.SINGLE_HORIZONTAL_PAGINATE_LINE
|
|
|
|
: Grid.NO_PAGINATE_LINE);
|
|
|
|
if (LightTool.containNewFormFlag(form)){
|
|
|
|
this.getGrid().setCellElementPainter(new NewUIModeCellElementPainter());
|
|
|
|
}
|
|
|
|
this.addSelectionChangeListener(new SelectionListener() {
|
|
|
|
@Override
|
|
|
|
public void selectionChanged(SelectionEvent e) {
|
|
|
|
refreshPropertyPanes();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.addTargetModifiedListener(new TargetModifiedListener() {
|
|
|
|
@Override
|
|
|
|
public void targetModified(TargetModifiedEvent e) {
|
|
|
|
if (DesignerContext.isRefreshOnTargetModifiedEnabled()) {
|
|
|
|
refreshPropertyPanes();
|
|
|
|
} else {
|
|
|
|
CellElementPropertyPane.getInstance().populate(FormElementCasePaneDelegate.this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private Rectangle getBoundsLineRect(TemplateElementCase elementCase) {
|
|
|
|
FormDesigner designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void initGridComponent() {
|
|
|
|
Rectangle adsorbRec = getBoundsLineRect(this.getEditingElementCase());
|
|
|
|
// Components
|
|
|
|
if (this.grid == null) {
|
|
|
|
this.grid = new Grid(this.getResolution(), adsorbRec.width, adsorbRec.height);
|
|
|
|
this.grid.setAdsorbWidth(adsorbRec.width);
|
|
|
|
this.grid.setAdsorbHeight(adsorbRec.height);
|
|
|
|
}
|
|
|
|
if (this.gridColumn == null) {
|
|
|
|
this.gridColumn = new GridColumn(this.getResolution(), adsorbRec.width);
|
|
|
|
}
|
|
|
|
if (this.gridRow == null) {
|
|
|
|
this.gridRow = new GridRow(this.getResolution(), adsorbRec.height);
|
|
|
|
}
|
|
|
|
if (this.gridCorner == null) {
|
|
|
|
this.gridCorner = new GridCorner();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void refreshPropertyPanes() {
|
|
|
|
CellElementPropertyPane.getInstance().populate(FormElementCasePaneDelegate.this);
|
|
|
|
QuickEditorRegion.getInstance().populate(getCurrentEditor());
|
|
|
|
// 超级链接
|
|
|
|
HyperlinkGroupPane hyperlinkGroupPane = DesignerContext.getDesignerFrame().getSelectedJTemplate().
|
|
|
|
getHyperLinkPane(HyperlinkGroupPaneActionImpl.getInstance());
|
|
|
|
hyperlinkGroupPane.populate(FormElementCasePaneDelegate.this);
|
|
|
|
// 条件属性
|
|
|
|
ConditionAttributesGroupPane conditionAttributesGroupPane = ConditionAttributesGroupPane.getInstance();
|
|
|
|
conditionAttributesGroupPane.populate(FormElementCasePaneDelegate.this);
|
|
|
|
|
|
|
|
EastRegionContainerPane.getInstance().updateCellElementState(isSelectedOneCell());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void afterPasteAction() {
|
|
|
|
refreshPropertyPanes();
|
|
|
|
fireTargetModified();
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean supportRepeatedHeaderFooter() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 选中目标的 对应Menu
|
|
|
|
*
|
|
|
|
* @return 返回MenuDef数组.
|
|
|
|
*/
|
|
|
|
public MenuDef[] menus4Target() {
|
|
|
|
return new MenuDef[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 报表块工具栏 快捷键菜单按钮 包括分页冻结
|
|
|
|
*
|
|
|
|
* @return 返回工具栏数组.
|
|
|
|
*/
|
|
|
|
public ToolBarDef[] toolbars4Target() {
|
|
|
|
return new ToolBarDef[]{
|
|
|
|
createFontToolBar(),
|
|
|
|
createAlignmentToolBar(),
|
|
|
|
createStyleToolBar(),
|
|
|
|
createCellToolBar(),
|
|
|
|
createInsertToolBar(),
|
|
|
|
createFrozenColumnsToolBar()};
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getMenuState() {
|
|
|
|
return DesignState.WORK_SHEET;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 表单的报表块的工具按钮
|
|
|
|
* @return 工具按钮
|
|
|
|
*/
|
|
|
|
public JComponent[] toolBarButton4Form() {
|
|
|
|
return new JComponent[]{
|
|
|
|
formatBrush };
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 是否必须为可见范围.
|
|
|
|
*
|
|
|
|
* @return 不是必须在可见范围.
|
|
|
|
*/
|
|
|
|
public boolean mustInVisibleRange() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 模板菜单
|
|
|
|
* @return 模板菜单
|
|
|
|
*/
|
|
|
|
public MenuDef createTemplateShortCuts() {
|
|
|
|
MenuDef menuDef = new MenuDef(KeySetUtils.TEMPLATE.getMenuKeySetName(), KeySetUtils.TEMPLATE.getMnemonic());
|
|
|
|
menuDef.addShortCut(new FormECBackgroundAction(this));
|
|
|
|
menuDef.addShortCut(new FormECFrozenAction(this));
|
|
|
|
menuDef.addShortCut(new FormECColumnsAction(this));
|
|
|
|
return menuDef;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected ToolBarDef createInsertToolBar() {
|
|
|
|
UpdateAction[] cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, this);
|
|
|
|
ShortCut[] shortCuts = new ShortCut[cellInsertActions.length];
|
|
|
|
System.arraycopy(cellInsertActions, 0, shortCuts, 0, cellInsertActions.length);
|
|
|
|
return ShortCut.asToolBarDef(shortCuts);
|
|
|
|
}
|
|
|
|
|
|
|
|
private ToolBarDef createFrozenColumnsToolBar() {
|
|
|
|
return ShortCut.asToolBarDef(new ShortCut[]{
|
|
|
|
new FormECFrozenAction(this),
|
|
|
|
new FormECColumnsAction(this),});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JPanel getEastUpPane() {
|
|
|
|
QuickEditorRegion.getInstance().populate(getCurrentEditor());
|
|
|
|
return QuickEditorRegion.getInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public JPanel getEastDownPane() {
|
|
|
|
CellElementPropertyPane.getInstance().populate(FormElementCasePaneDelegate.this);
|
|
|
|
return CellElementPropertyPane.getInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ReportSettingsProvider getReportSettings() {
|
|
|
|
return this.getTarget().getReportSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|