You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
235 lines
8.2 KiB
235 lines
8.2 KiB
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.base.mode.DesignModeContext; |
|
import com.fr.design.event.TargetModifiedEvent; |
|
import com.fr.design.event.TargetModifiedListener; |
|
import com.fr.design.file.HistoryTemplateListCache; |
|
import com.fr.design.fit.NewUIModeCellElementPainter; |
|
import com.fr.design.gui.frpane.HyperlinkGroupPane; |
|
import com.fr.design.mainframe.*; |
|
import com.fr.design.mainframe.cell.QuickEditorRegion; |
|
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; |
|
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.design.utils.gui.AdjustWorkBookDefaultStyleUtils; |
|
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.cell.DefaultTemplateCellElement; |
|
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.Rectangle; |
|
|
|
/** |
|
*/ |
|
public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase>{ |
|
|
|
public FormElementCasePaneDelegate(FormElementCase sheet, Form form) { |
|
this(sheet, form.getFormMobileAttr().isMobileOnly(), LightTool.containNewFormFlag(form)); |
|
} |
|
|
|
public FormElementCasePaneDelegate(FormElementCase sheet, boolean isMobileOnly, boolean isNewForm) { |
|
super(sheet); |
|
this.getGrid().setPaginateLineShowType(isMobileOnly |
|
? Grid.SINGLE_HORIZONTAL_PAGINATE_LINE |
|
: Grid.NO_PAGINATE_LINE); |
|
if (isNewForm){ |
|
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); |
|
} |
|
} |
|
}); |
|
|
|
// fvs根据主题样式创建默认单元格 |
|
if (DesignModeContext.isDuchampMode()) { |
|
sheet.setDefaultCellElementSupplier(() -> { |
|
DefaultTemplateCellElement defaultTemplateCellElement = DefaultThemedTemplateCellElementCase.createInstance(); |
|
// fvs调整单元格默认样式 |
|
AdjustWorkBookDefaultStyleUtils.adjustCellElement(defaultTemplateCellElement); |
|
return defaultTemplateCellElement; |
|
}); |
|
} |
|
} |
|
|
|
private Rectangle getBoundsLineRect(TemplateElementCase elementCase) { |
|
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
if (!(template instanceof JDashboard)) { |
|
return new Rectangle(); |
|
} |
|
try { |
|
return ((JDashboard)template).getElementCaseRectangle((FormElementCase)elementCase); |
|
} catch (Throwable e) { |
|
// 兼容旧插件 |
|
return new 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(); |
|
} |
|
|
|
} |