Browse Source

添加单元格元素接口和示例

master
richie 9 years ago
parent
commit
f5b76e1218
  1. 4
      designer/src/com/fr/design/actions/cell/BorderAction.java
  2. 4
      designer/src/com/fr/design/actions/cell/style/ReportFontForegroundAction.java
  3. 4
      designer/src/com/fr/design/actions/cell/style/StyleBackgroundAction.java
  4. 3
      designer/src/com/fr/design/actions/insert/cell/BiasCellAction.java
  5. 7
      designer/src/com/fr/design/actions/insert/cell/ChartCellAction.java
  6. 3
      designer/src/com/fr/design/actions/insert/cell/DSColumnCellAction.java
  7. 3
      designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java
  8. 3
      designer/src/com/fr/design/actions/insert/cell/GeneralCellAction.java
  9. 3
      designer/src/com/fr/design/actions/insert/cell/ImageCellAction.java
  10. 3
      designer/src/com/fr/design/actions/insert/cell/RichTextCellAction.java
  11. 13
      designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java
  12. 9
      designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java
  13. 49
      designer/src/com/fr/design/mainframe/ElementCasePane.java
  14. 4
      designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java
  15. 2
      designer/src/com/fr/design/mainframe/JWorkBook.java
  16. 4
      designer/src/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java
  17. 700
      designer/src/com/fr/design/module/DesignerModule.java
  18. 4
      designer/src/com/fr/grid/selection/CellSelection.java
  19. 4
      designer/src/com/fr/grid/selection/FloatSelection.java
  20. 4
      designer/src/com/fr/poly/creator/ECBlockPane.java
  21. 6
      designer/src/com/fr/start/Designer.java
  22. 19
      designer_base/src/com/fr/design/ExtraDesignClassManager.java
  23. 4
      designer_base/src/com/fr/design/actions/UpdateAction.java
  24. 216
      designer_base/src/com/fr/design/actions/core/ActionFactory.java
  25. 202
      designer_base/src/com/fr/design/actions/core/ActionUtils.java
  26. 7
      designer_base/src/com/fr/design/actions/core/WorkBookSupportable.java
  27. 26
      designer_base/src/com/fr/design/fun/ElementUIProvider.java
  28. 20
      designer_base/src/com/fr/design/fun/impl/AbstractElementUIProvider.java
  29. 5
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  30. 44
      designer_base/src/com/fr/design/module/DesignModule.java
  31. 4
      designer_base/src/com/fr/design/utils/gui/GUICoreUtils.java
  32. 2
      designer_chart/src/com/fr/design/module/ChartDesignerModule.java
  33. 5
      designer_form/src/com/fr/design/mainframe/JForm.java

4
designer/src/com/fr/design/actions/cell/BorderAction.java

@ -10,7 +10,7 @@ import javax.swing.event.ChangeListener;
import com.fr.base.BaseUtils;
import com.fr.base.CellBorderStyle;
import com.fr.design.actions.ElementCaseAction;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.style.BorderUtils;
import com.fr.general.Inter;
import com.fr.design.mainframe.ElementCasePane;
@ -56,7 +56,7 @@ public class BorderAction extends ElementCaseAction implements ChangeListener {
borderStylePane.setEnabled(this.isEnabled());
borderStylePane.set4Toolbar();
// peter:产生tooltip
borderStylePane.setToolTipText(ActionUtils.createButtonToolTipText(this));
borderStylePane.setToolTipText(ActionFactory.createButtonToolTipText(this));
borderStylePane.setCellBorderStyle(new CellBorderStyle());
borderStylePane.addStyleChangeListener(this);
return borderStylePane;

4
designer/src/com/fr/design/actions/cell/style/ReportFontForegroundAction.java

@ -12,7 +12,7 @@ import javax.swing.event.ChangeListener;
import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.base.core.StyleUtils;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.design.mainframe.ElementCasePane;
@ -59,7 +59,7 @@ public class ReportFontForegroundAction extends AbstractStyleAction implements C
tbButton.addColorChangeListener(this);
//peter:产生tooltip
tbButton.setToolTipText(ActionUtils.createButtonToolTipText(this));
tbButton.setToolTipText(ActionFactory.createButtonToolTipText(this));
return tbButton;
}

4
designer/src/com/fr/design/actions/cell/style/StyleBackgroundAction.java

@ -12,7 +12,7 @@ import javax.swing.event.ChangeListener;
import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.base.background.ColorBackground;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.design.mainframe.ElementCasePane;
@ -68,7 +68,7 @@ public class StyleBackgroundAction extends AbstractStyleAction implements Change
tbButton.addColorChangeListener(this);
//peter:产生tooltip
tbButton.setToolTipText(ActionUtils.createButtonToolTipText(this));
tbButton.setToolTipText(ActionFactory.createButtonToolTipText(this));
return tbButton;
}

3
designer/src/com/fr/design/actions/insert/cell/BiasCellAction.java

@ -6,6 +6,7 @@ package com.fr.design.actions.insert.cell;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
@ -14,7 +15,7 @@ import com.fr.report.cell.painter.BiasTextPainter;
/**
* Bias
*/
public class BiasCellAction extends AbstractCellAction {
public class BiasCellAction extends AbstractCellAction implements WorkBookSupportable {
public BiasCellAction(ElementCasePane t) {
super(t);
this.setMenuKeySet(INSERT_SLOPE_LINE);

7
designer/src/com/fr/design/actions/insert/cell/ChartCellAction.java

@ -4,7 +4,8 @@
package com.fr.design.actions.insert.cell;
import com.fr.base.BaseUtils;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
@ -14,7 +15,7 @@ import javax.swing.*;
/**
* .
*/
public class ChartCellAction extends AbstractCellAction {
public class ChartCellAction extends AbstractCellAction implements WorkBookSupportable {
public ChartCellAction(ElementCasePane t) {
super(t);
this.setMenuKeySet(INSERT_CHART);
@ -43,6 +44,6 @@ public class ChartCellAction extends AbstractCellAction {
@Override
public Class getCellValueClass() {
return ActionUtils.getChartCollectionClass();
return ActionFactory.getChartCollectionClass();
}
}

3
designer/src/com/fr/design/actions/insert/cell/DSColumnCellAction.java

@ -1,11 +1,12 @@
package com.fr.design.actions.insert.cell;
import com.fr.base.BaseUtils;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.report.cell.cellattr.core.group.DSColumn;
public class DSColumnCellAction extends AbstractCellAction {
public class DSColumnCellAction extends AbstractCellAction implements WorkBookSupportable {
public DSColumnCellAction(ElementCasePane t) {
super(t);
this.setMenuKeySet(KeySetUtils.INSERT_DATA_COLUMN);

3
designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java

@ -5,13 +5,14 @@ package com.fr.design.actions.insert.cell;
import com.fr.base.BaseUtils;
import com.fr.base.Formula;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import javax.swing.*;
public class FormulaCellAction extends AbstractCellAction {
public class FormulaCellAction extends AbstractCellAction implements WorkBookSupportable {
public FormulaCellAction(ElementCasePane t) {
super(t);
this.setMenuKeySet(INSERT_FORMULA);

3
designer/src/com/fr/design/actions/insert/cell/GeneralCellAction.java

@ -4,6 +4,7 @@
package com.fr.design.actions.insert.cell;
import com.fr.base.BaseUtils;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
@ -13,7 +14,7 @@ import javax.swing.*;
/**
*
*/
public class GeneralCellAction extends AbstractCellAction {
public class GeneralCellAction extends AbstractCellAction implements WorkBookSupportable {
public GeneralCellAction(ElementCasePane t) {
super(t);
this.setMenuKeySet(INSERT_TEXT);

3
designer/src/com/fr/design/actions/insert/cell/ImageCellAction.java

@ -4,6 +4,7 @@
package com.fr.design.actions.insert.cell;
import com.fr.base.BaseUtils;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
@ -14,7 +15,7 @@ import java.awt.*;
/**
* Image
*/
public class ImageCellAction extends AbstractCellAction {
public class ImageCellAction extends AbstractCellAction implements WorkBookSupportable {
public ImageCellAction(ElementCasePane t) {
super(t);
this.setMenuKeySet(INSERT_IMAGE);

3
designer/src/com/fr/design/actions/insert/cell/RichTextCellAction.java

@ -3,13 +3,14 @@ package com.fr.design.actions.insert.cell;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.report.cell.cellattr.core.RichText;
public class RichTextCellAction extends AbstractCellAction {
public class RichTextCellAction extends AbstractCellAction implements WorkBookSupportable {
public RichTextCellAction(ElementCasePane t) {
super(t);

13
designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java

@ -15,11 +15,11 @@ import java.awt.event.ActionEvent;
/**
* Insert textbox.
*/
public class TextBoxFloatAction extends AbstractShapeAction {
public TextBoxFloatAction(ElementCasePane t) {
super(t);
public class TextBoxFloatAction extends AbstractShapeAction {
public TextBoxFloatAction(ElementCasePane t) {
super(t);
this.setMenuKeySet(FLOAT_INSERT_TEXT);
this.setName(getMenuKeySet().getMenuKeySetName()+ "...");
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/text.png"));
}
@ -44,10 +44,11 @@ public class TextBoxFloatAction extends AbstractShapeAction {
/**
* 动作
*
* @param e 动作
*/
public void actionPerformed(ActionEvent e) {
ElementCasePane jws = getEditingComponent();
public void actionPerformed(ActionEvent e) {
ElementCasePane jws = getEditingComponent();
if (jws == null) {
return;
}

9
designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java

@ -8,7 +8,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.cell.NewPresentAction;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.edit.clear.*;
import com.fr.design.actions.edit.order.BringFloatElementForwardAction;
import com.fr.design.actions.edit.order.BringFloatElementToFrontAction;
@ -92,10 +92,11 @@ public class DeprecatedActionManager {
final MenuDef subMenuDef = new MenuDef(KeySetUtils.CELL_ELEMENT.getMenuName());
subMenuDef.setIconPath("/com/fr/design/images/m_insert/cell.png");
UpdateAction[] actions = ActionUtils.createCellInsertAction(ElementCasePane.class, ePane);
for (int i = 0; i < actions.length; i++) {
subMenuDef.addShortCut(actions[i]);
UpdateAction[] actions = ActionFactory.createCellInsertAction(ElementCasePane.class, ePane);
for (UpdateAction action : actions) {
subMenuDef.addShortCut(action);
}
ePane.addSelectionChangeListener(new SelectionListener() {
@Override

49
designer/src/com/fr/design/mainframe/ElementCasePane.java

@ -17,6 +17,7 @@ import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.lang.reflect.Constructor;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
@ -36,6 +37,7 @@ import com.fr.base.ScreenResolution;
import com.fr.base.Style;
import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction;
import com.fr.design.actions.ExitAuthorityEditAction;
import com.fr.design.actions.UpdateAction;
@ -65,7 +67,7 @@ import com.fr.design.actions.columnrow.ResetColumnHideAction;
import com.fr.design.actions.columnrow.ResetRowHideAction;
import com.fr.design.actions.columnrow.RowHeightAction;
import com.fr.design.actions.columnrow.RowHideAction;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.edit.CopyAction;
import com.fr.design.actions.edit.CutAction;
import com.fr.design.actions.edit.PasteAction;
@ -75,20 +77,12 @@ import com.fr.design.cell.bar.DynamicScrollBar;
import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.cell.editor.BiasTextPainterCellEditor;
import com.fr.design.cell.editor.ChartCellEditor;
import com.fr.design.cell.editor.ChartFloatEditor;
import com.fr.design.cell.editor.DSColumnCellEditor;
import com.fr.design.cell.editor.FormulaCellEditor;
import com.fr.design.cell.editor.FormulaFloatEditor;
import com.fr.design.cell.editor.ImageCellEditor;
import com.fr.design.cell.editor.ImageFloatEditor;
import com.fr.design.cell.editor.RichTextCellEditor;
import com.fr.design.cell.editor.SubReportCellEditor;
import com.fr.design.cell.editor.*;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.EditingState;
import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fun.ElementUIProvider;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.cell.QuickEditorRegion;
@ -103,6 +97,7 @@ import com.fr.design.selection.Selectedable;
import com.fr.design.selection.SelectionEvent;
import com.fr.design.selection.SelectionListener;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.grid.Grid;
import com.fr.grid.GridColumn;
@ -372,19 +367,45 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
grid.setDefaultCellEditor(Image.class, new ImageCellEditor(this));
grid.setDefaultCellEditor(SubReport.class, new SubReportCellEditor(this));
Class chartClass = ActionUtils.getChartCollectionClass();
Class chartClass = ActionFactory.getChartCollectionClass();
if (chartClass != null) {
grid.setDefaultCellEditor(chartClass, new ChartCellEditor(this));
grid.setDefaultFloatEditor(chartClass, new ChartFloatEditor());
}
addExtraCellEditor(grid);
grid.setDefaultFloatEditor(Formula.class, new FormulaFloatEditor());
grid.setDefaultFloatEditor(Image.class, new ImageFloatEditor());
DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager();
grid.setGridLineColor(designerEnvManager.getGridLineColor());
grid.setPaginationLineColor(designerEnvManager.getPaginationLineColor());
}
private void addExtraCellEditor(Grid grid) {
ElementUIProvider[] providers = ExtraDesignClassManager.getInstance().getElementUIProviders();
for (ElementUIProvider provider : providers) {
CellEditor editor = null;
Class<?> clazz = provider.targetCellEditorClass();
Constructor<?> c;
try {
c = clazz.getConstructor();
editor = (CellEditor) c.newInstance();
} catch (NoSuchMethodException e) {
try {
c = clazz.getConstructor(ElementCase.class);
editor = (CellEditor) c.newInstance(this);
} catch (Exception e1) {
FRLogger.getLogger().error(e1.getMessage(), e1);
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
grid.setDefaultCellEditor(provider.targetObjectClass(), editor);
}
}
/**
* 返回当前正在编辑的模板单元格组件
*/
@ -1263,11 +1284,11 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
insertFloatMenu.setTooltip(Inter.getLocText("T_Insert-Float"));
insertFloatMenu.setIconPath("/com/fr/design/images/m_insert/floatPop.png");
UpdateAction[] actions = ActionUtils.createFloatInsertAction(ElementCasePane.class, this);
UpdateAction[] actions = ActionFactory.createFloatInsertAction(ElementCasePane.class, this);
for (int i = 0; i < actions.length; i++) {
insertFloatMenu.addShortCut(actions[i]);
}
UpdateAction[] cellInsertActions = ActionUtils.createCellInsertAction(ElementCasePane.class, this);
UpdateAction[] cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, this);
ShortCut[] shortCuts = new ShortCut[cellInsertActions.length];
System.arraycopy(cellInsertActions, 0, shortCuts, 0, cellInsertActions.length);
return ShortCut.asToolBarDef((ShortCut[]) ArrayUtils.add(shortCuts, insertFloatMenu));

4
designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java

@ -10,7 +10,7 @@ import com.fr.design.DesignState;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.cell.*;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.edit.HyperlinkAction;
import com.fr.design.actions.edit.merge.MergeCellAction;
import com.fr.design.actions.edit.merge.UnmergeCellAction;
@ -131,7 +131,7 @@ public class ElementCasePaneDelegate extends ElementCasePane<WorkSheet> {
MenuDef subMenuDef = new MenuDef(KeySetUtils.INSERT_FLOAT.getMenuName());
subMenuDef.setIconPath("/com/fr/design/images/m_insert/float.png");
menuDef.addShortCut(subMenuDef);
UpdateAction[] actions = ActionUtils.createFloatInsertAction(ElementCasePane.class, this);
UpdateAction[] actions = ActionFactory.createFloatInsertAction(ElementCasePane.class, this);
for (int i = 0; i < actions.length; i++) {
subMenuDef.addShortCut(actions[i]);
}

2
designer/src/com/fr/design/mainframe/JWorkBook.java

@ -7,6 +7,7 @@ import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction;
import com.fr.design.actions.ExitAuthorityEditAction;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.actions.file.export.*;
import com.fr.design.actions.report.ReportExportAttrAction;
@ -896,5 +897,4 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
//产品想要重新设计下, 1现在的分享多列数据集很麻烦, 2想做成自动上传附件.
// return new UIButton[]{new ShareButton()};
}
}

4
designer/src/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java

@ -5,7 +5,7 @@ import javax.swing.JPanel;
import com.fr.design.DesignState;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.core.ActionUtils;
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;
@ -108,7 +108,7 @@ public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase
}
protected ToolBarDef createInsertToolBar() {
UpdateAction[] cellInsertActions = ActionUtils.createCellInsertAction(ElementCasePane.class, this);
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);

700
designer/src/com/fr/design/module/DesignerModule.java

@ -1,31 +1,19 @@
package com.fr.design.module;
import com.fr.base.BaseUtils;
import com.fr.base.ConfigManager;
import com.fr.base.FRContext;
import com.fr.base.Formula;
import com.fr.base.MultiFieldParameter;
import com.fr.base.Style;
import com.fr.base.TempNameStyle;
import com.fr.base.*;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.base.process.ProcessOperator;
import com.fr.base.remote.RemoteDeziConstants;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.insert.cell.BiasCellAction;
import com.fr.design.actions.insert.cell.ChartCellAction;
import com.fr.design.actions.insert.cell.DSColumnCellAction;
import com.fr.design.actions.insert.cell.FormulaCellAction;
import com.fr.design.actions.insert.cell.GeneralCellAction;
import com.fr.design.actions.insert.cell.ImageCellAction;
import com.fr.design.actions.insert.cell.RichTextCellAction;
import com.fr.design.actions.insert.cell.SubReportCellAction;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.*;
import com.fr.design.actions.insert.flot.ChartFloatAction;
import com.fr.design.actions.insert.flot.FormulaFloatAction;
import com.fr.design.actions.insert.flot.ImageFloatAction;
import com.fr.design.actions.insert.flot.TextBoxFloatAction;
import com.fr.design.actions.server.StyleListAction;
import com.fr.design.fun.ElementUIProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.ibutton.UIButton;
@ -36,11 +24,7 @@ import com.fr.design.javascript.EmailPane;
import com.fr.design.javascript.JavaScriptImplPane;
import com.fr.design.javascript.ParameterJavaScriptPane;
import com.fr.design.javascript.ProcessTransitionAdapter;
import com.fr.design.mainframe.App;
import com.fr.design.mainframe.DecodeDialog;
import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.bbs.BBSGuestPane;
import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider;
@ -50,28 +34,15 @@ import com.fr.design.mainframe.loghandler.DesignerLogImpl;
import com.fr.design.parameter.WorkBookParameterReader;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FILE;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.ModuleContext;
import com.fr.general.*;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.io.importer.Excel2007ReportImporter;
import com.fr.io.importer.ExcelReportImporter;
import com.fr.js.EmailJavaScript;
import com.fr.js.JavaScriptImpl;
import com.fr.js.ParameterJavaScript;
import com.fr.js.ReportletHyperlink;
import com.fr.js.WebHyperlink;
import com.fr.js.*;
import com.fr.main.impl.WorkBook;
import com.fr.plugin.ExtraClassManager;
import com.fr.quickeditor.ChartQuickEditor;
import com.fr.quickeditor.cellquick.CellBiasTextPainterEditor;
import com.fr.quickeditor.cellquick.CellDScolumnEditor;
import com.fr.quickeditor.cellquick.CellImageQuickEditor;
import com.fr.quickeditor.cellquick.CellRichTextEditor;
import com.fr.quickeditor.cellquick.CellStringQuickEditor;
import com.fr.quickeditor.cellquick.CellSubReportEditor;
import com.fr.quickeditor.cellquick.*;
import com.fr.quickeditor.floatquick.FloatImageQuickEditor;
import com.fr.quickeditor.floatquick.FloatStringQuickEditor;
import com.fr.report.cell.CellElementValueConverter;
@ -79,6 +50,7 @@ import com.fr.report.cell.cellattr.core.RichText;
import com.fr.report.cell.cellattr.core.SubReport;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.painter.BiasTextPainter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
@ -100,357 +72,327 @@ import java.util.Iterator;
public class DesignerModule extends DesignModule {
/**
* 启动设计器模块
*/
public void start() {
super.start();
/**
* 启动设计器模块
*/
public void start() {
super.start();
justStartModules4Engine();
justStartModules4Designer();
justStartModules4Engine();
justStartModules4Designer();
CalculatorProviderContext.setValueConverter(valueConverter());
GeneralXMLTools.Object_Tokenizer = startXMLReadObjectTokenizer();
GeneralXMLTools.Object_XML_Writer_Finder = startObjectXMLWriterFinder();
addAdapterForPlate();
generateInsertActionClasses();
CalculatorProviderContext.setValueConverter(valueConverter());
GeneralXMLTools.Object_Tokenizer = startXMLReadObjectTokenizer();
GeneralXMLTools.Object_XML_Writer_Finder = startObjectXMLWriterFinder();
addAdapterForPlate();
registerHyperlink();
registerCellEditor();
registerFloatEditor();
registerData4Form();
registerOtherPane();
registerCellEditor();
registerFloatEditor();
registerData4Form();
registerOtherPane();
InformationCollector.getInstance().collectStartTime();
InformationCollector.getInstance().collectStartTime();
ExtraDesignClassManager.getInstance().getFeedback().didFeedback();
ExtraDesignClassManager.getInstance().getFeedback().didFeedback();
ExtraClassManager.getInstance().addLogProvider(DesignerLogImpl.getInstance());
}
private void registerOtherPane(){
StableFactory.registerMarkedClass(BBSGuestPaneProvider.XML_TAG, BBSGuestPane.class);
}
/**
* kunsnat:注册单元格选中Editor
*/
private void registerCellEditor() {
ActionUtils.registerCellEditor(String.class, CellStringQuickEditor.getInstance());
ActionUtils.registerCellEditor(Number.class, CellStringQuickEditor.getInstance());
ActionUtils.registerCellEditor(Formula.class, CellStringQuickEditor.getInstance());
ActionUtils.registerCellEditor(SubReport.class, CellSubReportEditor.getInstance());
ActionUtils.registerCellEditor(RichText.class, CellRichTextEditor.getInstance());
ActionUtils.registerCellEditor(DSColumn.class, CellDScolumnEditor.getInstance());
ActionUtils.registerCellEditor(Image.class, CellImageQuickEditor.getInstance());
ActionUtils.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor());
ActionUtils.registerCellEditor(BufferedImage.class, CellImageQuickEditor.getInstance());
if (ModuleContext.isModuleStarted(Module.CHART_MODULE)) {
ActionUtils.registerChartCellEditorInEditor(ChartQuickEditor.getInstance());
}
}
public String getInterNationalName(){
}
private void registerOtherPane() {
StableFactory.registerMarkedClass(BBSGuestPaneProvider.XML_TAG, BBSGuestPane.class);
}
/**
* kunsnat:注册单元格选中Editor
*/
private void registerCellEditor() {
ActionFactory.registerCellEditor(String.class, CellStringQuickEditor.getInstance());
ActionFactory.registerCellEditor(Number.class, CellStringQuickEditor.getInstance());
ActionFactory.registerCellEditor(Formula.class, CellStringQuickEditor.getInstance());
ActionFactory.registerCellEditor(SubReport.class, CellSubReportEditor.getInstance());
ActionFactory.registerCellEditor(RichText.class, CellRichTextEditor.getInstance());
ActionFactory.registerCellEditor(DSColumn.class, CellDScolumnEditor.getInstance());
ActionFactory.registerCellEditor(Image.class, CellImageQuickEditor.getInstance());
ActionFactory.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor());
ActionFactory.registerCellEditor(BufferedImage.class, CellImageQuickEditor.getInstance());
ActionFactory.registerChartCellEditorInEditor(ChartQuickEditor.getInstance());
ElementUIProvider[] providers = ExtraDesignClassManager.getInstance().getElementUIProviders();
for (ElementUIProvider provider : providers) {
ActionFactory.registerCellEditor(provider.targetObjectClass(), provider.quickEditor());
}
}
public String getInterNationalName() {
return Inter.getLocText("FR-Module_Designer");
}
/**
* kunnat: 注册悬浮选中Editor
*/
private void registerFloatEditor() {
FloatStringQuickEditor floatStringQuickEditor = new FloatStringQuickEditor();
ActionUtils.registerFloatEditor(String.class, floatStringQuickEditor);
ActionUtils.registerFloatEditor(Formula.class, floatStringQuickEditor);
FloatImageQuickEditor floatImageQuickEditor = new FloatImageQuickEditor();
ActionUtils.registerFloatEditor(Image.class, floatImageQuickEditor);
ActionUtils.registerFloatEditor(BufferedImage.class, floatImageQuickEditor);
if (ModuleContext.isModuleStarted(Module.CHART_MODULE)) {
ActionUtils.registerChartFloatEditorInEditor(ChartQuickEditor.getInstance());
}
}
/**
* kunsnat: 一些模块信息 必须跟随设计器启动,
* 比如 读取CC.XML, 设计器启动之后, 马上会读取XML, 需要Chart_Module中的注册信息
*/
private void justStartModules4Engine() {
ModuleContext.startModule(ENGINE_MODULE);
}
private void justStartModules4Designer() {
ModuleContext.startModule(CHART_DESIGNER_MODULE);
ModuleContext.startModule(FORM_DESIGNER_MODULE);
}
/**
* CellElementValueConverter用来处理设计器格子里的值将公式/数组/其他元素转换成对应的值
*
* @return 返回处理格子值的转换器
*/
public ValueConverter valueConverter() {
return new CellElementValueConverter();
}
@Override
/**
* 针对不同的对象在读取Object对象的xml的时候需要使用不同的对象生成器
* @return 返回对象生成器
*/
public ObjectTokenizer startXMLReadObjectTokenizer() {
return new ReportXMLUtils.ReportObjectTokenizer();
}
/**
* 针对不同的对象在写对象的XML时需要使用不同的XML生成器
*
* @return 返回xml生成器
*/
@Override
public ObjectXMLWriterFinder startObjectXMLWriterFinder() {
return new ReportXMLUtils.ReportObjectXMLWriterFinder();
}
//wei:fs的模块中可能有需要设计器界面做设置的地方,在这边添加
private void addAdapterForPlate() {
ProcessTransitionAdapter.setProcessTransitionAdapter(new ProcessTransitionAdapter() {
@Override
protected String[] getTransitionNamesByBook(String book) {
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getTransitionNamesByBook(book);
}
@Override
protected String[] getParaNames(String book) {
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getParaNames(book);
}
@Override
protected ParameterProvider[] getParas(String book) {
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getParas(book);
}
protected MultiFieldParameter[] getAllMultiFieldParas(String book) {
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getAllMultiFieldParas(book);
}
});
}
private static abstract class AbstractWorkBookApp implements App<WorkBook>{
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public JTemplate<WorkBook, ?> openTemplate(FILE tplFile) {
return new JWorkBook(asIOFile(tplFile), tplFile);
}
}
@Override
/**
* 返回设计器能打开的模板类型的一个数组列表
* @return 可以打开的模板类型的数组
*/
public App[] apps4TemplateOpener() {
return new App[]{getCptApp(), getXlsApp(), getXlsxApp()};
}
private AbstractWorkBookApp getXlsxApp() {
return new AbstractWorkBookApp() {
@Override
public String[] defaultExtentions() {
return new String[]{"xlsx"};
}
@Override
public WorkBook asIOFile(FILE tplFile) {
WorkBook workbook = null;
try {
workbook = new Excel2007ReportImporter().generateWorkBookByStream(tplFile.asInputStream());
} catch (Exception exp) {
FRContext.getLogger().error("Failed to generate xlsx from " + tplFile, exp);
}
return workbook;
}
};
}
private AbstractWorkBookApp getXlsApp() {
return new AbstractWorkBookApp() {
@Override
public String[] defaultExtentions() {
return new String[]{"xls"};
}
@Override
public WorkBook asIOFile(FILE tplFile) {
WorkBook workbook = null;
try {
workbook = new ExcelReportImporter().generateWorkBookByStream(tplFile.asInputStream());
} catch (Exception exp) {
FRContext.getLogger().error("Failed to generate xls from " + tplFile, exp);
}
return workbook;
}
};
}
private AbstractWorkBookApp getCptApp() {
return new AbstractWorkBookApp() {
public String[] defaultExtentions() {
return new String[]{"cpt"};
}
public WorkBook asIOFile(FILE file) {
if(XMLEncryptUtils.isCptEncoded() &&
!XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())){
if(!new DecodeDialog(file).isPwdRight()){
FRContext.getLogger().error(Inter.getLocText("ECP-error_pwd"));
return new WorkBook();
}
}
WorkBook tpl = new WorkBook();
// richer:打开报表通知
FRContext.getLogger().info(Inter.getLocText(new String[]{"LOG-Is_Being_Openned", "LOG-Please_Wait"}, new String[]{"\"" + file.getName() + "\"" + ",", "..."}));
TempNameStyle namestyle = TempNameStyle.getInstance();
namestyle.clear();
String checkStr = StringUtils.EMPTY;
try {
checkStr = IOUtils.inputStream2String(file.asInputStream());
tpl.readStream(file.asInputStream());
} catch (Exception exp) {
String errorMessage = StringUtils.EMPTY;
errorMessage = ComparatorUtils.equals(RemoteDeziConstants.INVALID_USER, checkStr) ? Inter.getLocText("FR-Designer_No-Privilege")
: Inter.getLocText("NS-exception_readError");
FRContext.getLogger().error(errorMessage + file, exp);
}
checkNameStyle(namestyle);
return tpl;
}
};
}
private static void checkNameStyle(TempNameStyle namestyle) {
Iterator it = namestyle.getIterator();
ArrayList<String> al = new ArrayList<String>();
while (it.hasNext()) {
al.add((String) it.next());
}
if (!al.isEmpty()) {
showConfirmDialog(al);
}
}
private static void showConfirmDialog(final ArrayList<String> namelist) {
final JDialog jd = new JDialog();
// 模态一下,因为可能会多个样式丢失
// jd.setModal(true);
jd.setAlwaysOnTop(true);
jd.setSize(450, 150);
jd.setResizable(false);
jd.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
String message = namelist.toString().replaceAll("\\[", "").replaceAll("\\]", "");
UILabel jl = new UILabel(Inter.getLocText(new String[]{"Current_custom_global", "Has_been_gone"}, new String[]{message}));
jl.setHorizontalAlignment(SwingConstants.CENTER);
jd.add(jl, BorderLayout.CENTER);
JPanel jp = new JPanel();
// ”是“按钮,点击之后将生成一个全局样式,并写入xml
UIButton confirmButton = new UIButton(Inter.getLocText("FR-Designer_Yes"));
confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
for (int i = 0; i < namelist.size(); i++) {
ConfigManager.getProviderInstance().putStyle(namelist.get(i), Style.DEFAULT_STYLE);
FRContext.getCurrentEnv().writeResource(ConfigManager.getProviderInstance());
}
} catch (Exception ex) {
FRLogger.getLogger().error(ex.getMessage());
}
jd.dispose();
new StyleListAction().actionPerformed(e);// 弹窗
}
});
UIButton noButton = new UIButton(Inter.getLocText("FR-Designer_No"));
noButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jd.dispose();
}
});
jp.add(confirmButton);
jp.add(noButton);
jd.setTitle(Inter.getLocText("FR-Custom_styles_lost"));
jd.add(jp, BorderLayout.SOUTH);
GUICoreUtils.centerWindow(jd);
jd.setVisible(true);
}
private void generateInsertActionClasses() {
if (ModuleContext.isModuleStarted(CHART_MODULE)) {
ActionUtils.registerCellInsertActionClass(new Class[]{
DSColumnCellAction.class,
GeneralCellAction.class,
RichTextCellAction.class,
FormulaCellAction.class,
ChartCellAction.class,
ImageCellAction.class,
BiasCellAction.class,
SubReportCellAction.class
});
ActionUtils.registerFloatInsertActionClass(new Class[]{
TextBoxFloatAction.class,
FormulaFloatAction.class,
ChartFloatAction.class,
ImageFloatAction.class
});
} else {
ActionUtils.registerCellInsertActionClass(new Class[]{
DSColumnCellAction.class,
GeneralCellAction.class,
FormulaCellAction.class,
ImageCellAction.class,
BiasCellAction.class,
SubReportCellAction.class
});
ActionUtils.registerFloatInsertActionClass(new Class[]{
TextBoxFloatAction.class,
FormulaFloatAction.class,
ImageFloatAction.class
});
}
}
private void registerHyperlink() {
if (ModuleContext.isModuleStarted(Module.CHART_MODULE)) {
DesignModuleFactory.registerCreators4Hyperlink(new NameableCreator[]{
new NameObjectCreator(Inter.getLocText("FR-Hyperlink_Reportlet"), ReportletHyperlink.class, ReportletHyperlinkPane.CHART_NO_RENAME.class),
new NameObjectCreator(Inter.getLocText("FR-Designer_Email"), EmailJavaScript.class, EmailPane.class),
new NameObjectCreator(Inter.getLocText("Hyperlink-Web_link"), WebHyperlink.class, WebHyperlinkPane.CHART_NO_RENAME.class),
new NameObjectCreator(Inter.getLocText("JavaScript-Dynamic_Parameters"), ParameterJavaScript.class, ParameterJavaScriptPane.CHART_NO_RENAME.class),
new NameObjectCreator("JavaScript", JavaScriptImpl.class, JavaScriptImplPane.CHART_NO_RENAME.class)
});
} else {
DesignModuleFactory.registerCreators4Hyperlink(new NameableCreator[]{
new NameObjectCreator(Inter.getLocText("FR-Hyperlink_Reportlet"), ReportletHyperlink.class, ReportletHyperlinkPane.class),
new NameObjectCreator(Inter.getLocText("FR-Designer_Email"), EmailJavaScript.class, EmailPane.class),
new NameObjectCreator(Inter.getLocText("Hyperlink-Web_link"), WebHyperlink.class, WebHyperlinkPane.class),
new NameObjectCreator(Inter.getLocText("JavaScript-Dynamic_Parameters"), ParameterJavaScript.class, ParameterJavaScriptPane.class),
new NameObjectCreator("JavaScript", JavaScriptImpl.class, JavaScriptImplPane.class)
});
}
}
private void registerData4Form() {
StableFactory.registerMarkedClass(FormECDesignerProvider.XML_TAG, FormElementCaseDesigner.class);
StableFactory.registerMarkedClass(FormECCompositeProvider.XML_TAG, FormReportComponentComposite.class);
/**
* kunnat: 注册悬浮选中Editor
*/
private void registerFloatEditor() {
FloatStringQuickEditor floatStringQuickEditor = new FloatStringQuickEditor();
ActionFactory.registerFloatEditor(String.class, floatStringQuickEditor);
ActionFactory.registerFloatEditor(Formula.class, floatStringQuickEditor);
FloatImageQuickEditor floatImageQuickEditor = new FloatImageQuickEditor();
ActionFactory.registerFloatEditor(Image.class, floatImageQuickEditor);
ActionFactory.registerFloatEditor(BufferedImage.class, floatImageQuickEditor);
ActionFactory.registerChartFloatEditorInEditor(ChartQuickEditor.getInstance());
}
/**
* kunsnat: 一些模块信息 必须跟随设计器启动,
* 比如 读取CC.XML, 设计器启动之后, 马上会读取XML, 需要Chart_Module中的注册信息
*/
private void justStartModules4Engine() {
ModuleContext.startModule(ENGINE_MODULE);
}
private void justStartModules4Designer() {
ModuleContext.startModule(CHART_DESIGNER_MODULE);
ModuleContext.startModule(FORM_DESIGNER_MODULE);
}
/**
* CellElementValueConverter用来处理设计器格子里的值将公式/数组/其他元素转换成对应的值
*
* @return 返回处理格子值的转换器
*/
public ValueConverter valueConverter() {
return new CellElementValueConverter();
}
@Override
/**
* 针对不同的对象在读取Object对象的xml的时候需要使用不同的对象生成器
* @return 返回对象生成器
*/
public ObjectTokenizer startXMLReadObjectTokenizer() {
return new ReportXMLUtils.ReportObjectTokenizer();
}
/**
* 针对不同的对象在写对象的XML时需要使用不同的XML生成器
*
* @return 返回xml生成器
*/
@Override
public ObjectXMLWriterFinder startObjectXMLWriterFinder() {
return new ReportXMLUtils.ReportObjectXMLWriterFinder();
}
//wei:fs的模块中可能有需要设计器界面做设置的地方,在这边添加
private void addAdapterForPlate() {
ProcessTransitionAdapter.setProcessTransitionAdapter(new ProcessTransitionAdapter() {
@Override
protected String[] getTransitionNamesByBook(String book) {
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getTransitionNamesByBook(book);
}
@Override
protected String[] getParaNames(String book) {
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getParaNames(book);
}
@Override
protected ParameterProvider[] getParas(String book) {
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getParas(book);
}
protected MultiFieldParameter[] getAllMultiFieldParas(String book) {
return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getAllMultiFieldParas(book);
}
});
}
private static abstract class AbstractWorkBookApp implements App<WorkBook> {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public JTemplate<WorkBook, ?> openTemplate(FILE tplFile) {
return new JWorkBook(asIOFile(tplFile), tplFile);
}
}
@Override
/**
* 返回设计器能打开的模板类型的一个数组列表
* @return 可以打开的模板类型的数组
*/
public App[] apps4TemplateOpener() {
return new App[]{getCptApp(), getXlsApp(), getXlsxApp()};
}
private AbstractWorkBookApp getXlsxApp() {
return new AbstractWorkBookApp() {
@Override
public String[] defaultExtentions() {
return new String[]{"xlsx"};
}
@Override
public WorkBook asIOFile(FILE tplFile) {
WorkBook workbook = null;
try {
workbook = new Excel2007ReportImporter().generateWorkBookByStream(tplFile.asInputStream());
} catch (Exception exp) {
FRContext.getLogger().error("Failed to generate xlsx from " + tplFile, exp);
}
return workbook;
}
};
}
private AbstractWorkBookApp getXlsApp() {
return new AbstractWorkBookApp() {
@Override
public String[] defaultExtentions() {
return new String[]{"xls"};
}
@Override
public WorkBook asIOFile(FILE tplFile) {
WorkBook workbook = null;
try {
workbook = new ExcelReportImporter().generateWorkBookByStream(tplFile.asInputStream());
} catch (Exception exp) {
FRContext.getLogger().error("Failed to generate xls from " + tplFile, exp);
}
return workbook;
}
};
}
private AbstractWorkBookApp getCptApp() {
return new AbstractWorkBookApp() {
public String[] defaultExtentions() {
return new String[]{"cpt"};
}
public WorkBook asIOFile(FILE file) {
if (XMLEncryptUtils.isCptEncoded() &&
!XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) {
if (!new DecodeDialog(file).isPwdRight()) {
FRContext.getLogger().error(Inter.getLocText("ECP-error_pwd"));
return new WorkBook();
}
}
WorkBook tpl = new WorkBook();
// richer:打开报表通知
FRContext.getLogger().info(Inter.getLocText(new String[]{"LOG-Is_Being_Openned", "LOG-Please_Wait"}, new String[]{"\"" + file.getName() + "\"" + ",", "..."}));
TempNameStyle namestyle = TempNameStyle.getInstance();
namestyle.clear();
String checkStr = StringUtils.EMPTY;
try {
checkStr = IOUtils.inputStream2String(file.asInputStream());
tpl.readStream(file.asInputStream());
} catch (Exception exp) {
String errorMessage = StringUtils.EMPTY;
errorMessage = ComparatorUtils.equals(RemoteDeziConstants.INVALID_USER, checkStr) ? Inter.getLocText("FR-Designer_No-Privilege")
: Inter.getLocText("NS-exception_readError");
FRContext.getLogger().error(errorMessage + file, exp);
}
checkNameStyle(namestyle);
return tpl;
}
};
}
private static void checkNameStyle(TempNameStyle namestyle) {
Iterator it = namestyle.getIterator();
ArrayList<String> al = new ArrayList<String>();
while (it.hasNext()) {
al.add((String) it.next());
}
if (!al.isEmpty()) {
showConfirmDialog(al);
}
}
private static void showConfirmDialog(final ArrayList<String> namelist) {
final JDialog jd = new JDialog();
// 模态一下,因为可能会多个样式丢失
// jd.setModal(true);
jd.setAlwaysOnTop(true);
jd.setSize(450, 150);
jd.setResizable(false);
jd.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
String message = namelist.toString().replaceAll("\\[", "").replaceAll("\\]", "");
UILabel jl = new UILabel(Inter.getLocText(new String[]{"Current_custom_global", "Has_been_gone"}, new String[]{message}));
jl.setHorizontalAlignment(SwingConstants.CENTER);
jd.add(jl, BorderLayout.CENTER);
JPanel jp = new JPanel();
// ”是“按钮,点击之后将生成一个全局样式,并写入xml
UIButton confirmButton = new UIButton(Inter.getLocText("FR-Designer_Yes"));
confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
for (int i = 0; i < namelist.size(); i++) {
ConfigManager.getProviderInstance().putStyle(namelist.get(i), Style.DEFAULT_STYLE);
FRContext.getCurrentEnv().writeResource(ConfigManager.getProviderInstance());
}
} catch (Exception ex) {
FRLogger.getLogger().error(ex.getMessage());
}
jd.dispose();
new StyleListAction().actionPerformed(e);// 弹窗
}
});
UIButton noButton = new UIButton(Inter.getLocText("FR-Designer_No"));
noButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jd.dispose();
}
});
jp.add(confirmButton);
jp.add(noButton);
jd.setTitle(Inter.getLocText("FR-Custom_styles_lost"));
jd.add(jp, BorderLayout.SOUTH);
GUICoreUtils.centerWindow(jd);
jd.setVisible(true);
}
public Class<?>[] actionsForInsertCellElement() {
return (Class<?>[])ArrayUtils.addAll(new Class<?>[]{
DSColumnCellAction.class,
GeneralCellAction.class,
RichTextCellAction.class,
FormulaCellAction.class,
ChartCellAction.class,
ImageCellAction.class,
BiasCellAction.class,
SubReportCellAction.class
}, super.actionsForInsertCellElement());
}
public Class<?>[] actionsForInsertFloatElement() {
return (Class<?>[]) ArrayUtils.addAll(new Class<?>[]{
TextBoxFloatAction.class,
FormulaFloatAction.class,
ChartFloatAction.class,
ImageFloatAction.class
}, super.actionsForInsertFloatElement());
}
private void registerData4Form() {
StableFactory.registerMarkedClass(FormECDesignerProvider.XML_TAG, FormElementCaseDesigner.class);
StableFactory.registerMarkedClass(FormECCompositeProvider.XML_TAG, FormReportComponentComposite.class);
DesignModuleFactory.registerParameterReader(new WorkBookParameterReader());
}
}
}

4
designer/src/com/fr/grid/selection/CellSelection.java

@ -5,7 +5,7 @@ import com.fr.cache.list.IntList;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.cell.*;
import com.fr.design.actions.cell.GlobalStyleMenuDef.GlobalStyleSelection;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.edit.CopyAction;
import com.fr.design.actions.edit.CutAction;
import com.fr.design.actions.edit.HyperlinkAction;
@ -669,7 +669,7 @@ public class CellSelection extends Selection {
}
value = value == null ? "" : value;
//之前是少了个bigInteger,刚kunsnat又发现少了个bigDecimal,数字类型的都用stringEditor,没必要那个样子
QuickEditor editor = ActionUtils.getCellEditor((value instanceof Number) ? (Number.class) : (value.getClass()));
QuickEditor editor = ActionFactory.getCellEditor((value instanceof Number) ? (Number.class) : (value.getClass()));
if (editor == null) {
return null;
}

4
designer/src/com/fr/grid/selection/FloatSelection.java

@ -8,7 +8,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.actions.cell.CleanAuthorityAction;
import com.fr.design.actions.cell.FloatStyleAction;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.edit.CopyAction;
import com.fr.design.actions.edit.CutAction;
import com.fr.design.actions.edit.DeleteAction;
@ -226,7 +226,7 @@ public class FloatSelection extends Selection {
Object value = selectedFloat.getValue();
value = value == null ? "" : value;
value = value instanceof Number ? value.toString() : value;
QuickEditor editor = ActionUtils.getFloatEditor(value.getClass());
QuickEditor editor = ActionFactory.getFloatEditor(value.getClass());
editor.populate(tc);
return editor;
}

4
designer/src/com/fr/poly/creator/ECBlockPane.java

@ -9,7 +9,7 @@ import com.fr.general.Inter;
import com.fr.page.ReportSettingsProvider;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.cell.*;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.edit.HyperlinkAction;
import com.fr.design.actions.edit.merge.MergeCellAction;
import com.fr.design.actions.edit.merge.UnmergeCellAction;
@ -130,7 +130,7 @@ public class ECBlockPane extends PolyElementCasePane {
MenuDef subMenuDef = new MenuDef(KeySetUtils.INSERT_FLOAT.getMenuKeySetName());
subMenuDef.setIconPath("/com/fr/design/images/m_insert/float.png");
menuDef.addShortCut(subMenuDef);
UpdateAction[] actions = ActionUtils.createFloatInsertAction(ElementCasePane.class, this);
UpdateAction[] actions = ActionFactory.createFloatInsertAction(ElementCasePane.class, this);
for (int i = 0; i < actions.length; i++) {
subMenuDef.addShortCut(actions[i]);
}

6
designer/src/com/fr/start/Designer.java

@ -3,7 +3,7 @@ package com.fr.start;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.actions.file.newReport.NewPolyReportAction;
import com.fr.design.actions.file.newReport.NewWorkBookAction;
@ -111,8 +111,8 @@ public class Designer extends BaseDesigner {
if (FRContext.getCurrentEnv().isRoot()) {
menuDef.addShortCut(new ServerConfigManagerAction(), new StyleListAction(), new WidgetManagerAction());
if (ActionUtils.getChartPreStyleAction() != null) {
menuDef.addShortCut(ActionUtils.getChartPreStyleAction());
if (ActionFactory.getChartPreStyleAction() != null) {
menuDef.addShortCut(ActionFactory.getChartPreStyleAction());
}
}

19
designer_base/src/com/fr/design/ExtraDesignClassManager.java

@ -128,6 +128,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi
private TableDataTreePaneProcessor tableDataTreePaneProcessor;
private Set<ElementUIProvider> elementUIProviders;
public TableDataTreePaneProcessor getTableDataTreePaneProcessor() {
return tableDataTreePaneProcessor;
}
@ -719,6 +721,21 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi
cellAttributeProvider = (CellAttributeProvider) level;
}
public ElementUIProvider[] getElementUIProviders() {
if (elementUIProviders == null) {
return new ElementUIProvider[0];
}
return elementUIProviders.toArray(new ElementUIProvider[elementUIProviders.size()]);
}
public void addElementUIProvider(Level level, PluginSimplify simplify) throws Exception {
if (elementUIProviders == null) {
elementUIProviders = new HashSet<ElementUIProvider>();
}
validAPILevel(level, ElementUIProvider.CURRENT_LEVEL, simplify.getPluginName());
elementUIProviders.add((ElementUIProvider) level);
}
/**
* 文件名
*
@ -809,6 +826,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi
setEnvProcessor(impl, simplify);
} else if (tagName.equals(TableDataTreePaneProcessor.XML_TAG)) {
setTableDataSourceOPProcessor(impl, simplify);
} else if (tagName.equals(ElementUIProvider.MARK_STRING)) {
addElementUIProvider(impl, simplify);
}
} catch (PluginInvalidLevelException e) {
PluginMessage.remindUpdate(e.getMessage());

4
designer_base/src/com/fr/design/actions/UpdateAction.java

@ -7,7 +7,7 @@ import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution;
import com.fr.base.Style;
import com.fr.design.constants.UIConstants;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UICheckBoxMenuItem;
import com.fr.design.gui.imenu.UIMenuItem;
@ -272,7 +272,7 @@ public abstract class UpdateAction extends ShortCut implements Action {
button.setEnabled(this.isEnabled());
//peter:产生tooltip
button.setToolTipText(ActionUtils.createButtonToolTipText(this));
button.setToolTipText(ActionFactory.createButtonToolTipText(this));
object = button;
}

216
designer_base/src/com/fr/design/actions/core/ActionFactory.java

@ -0,0 +1,216 @@
package com.fr.design.actions.core;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.selection.QuickEditor;
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.lang.reflect.Constructor;
import java.util.*;
/**
* 插入单元格元素和插入悬浮元素的一些集合方法
*/
public class ActionFactory {
private static LinkedHashSet<Class<?>> actionClasses = new LinkedHashSet<>();
private static LinkedHashSet<Class<?>> floatActionClasses = new LinkedHashSet<>();
private ActionFactory() {
}
private static Map<Class, QuickEditor> floatEditor = new HashMap<Class, QuickEditor>();
private static Class chartCollectionClass = null;
private static Map<Class, QuickEditor> cellEditor = new HashMap<Class, QuickEditor>();
private static UpdateAction chartPreStyleAction = null;
/**
* 待说明
*
* @param clazz 待说明
* @param editor 待说明
*/
public static void registerCellEditor(Class clazz, QuickEditor editor) {
cellEditor.put(clazz, editor);
}
/**
* 待说明
*
* @param clazz 待说明
* @param editor 待说明
*/
public static void registerFloatEditor(Class clazz, QuickEditor editor) {
floatEditor.put(clazz, editor);
}
/**
* 注册图表的 预定义样式.
*
* @param action 注册的图表预定义样式action
*/
public static void registerChartPreStyleAction(UpdateAction action) {
chartPreStyleAction = action;
}
/**
* 返回 图表预定义样式Action
*/
public static UpdateAction getChartPreStyleAction() {
return chartPreStyleAction;
}
/**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
*
* @param clazz 待说明
*/
public static void registerChartCollection(Class clazz) {
chartCollectionClass = clazz;
}
public static Class getChartCollectionClass() {
return chartCollectionClass;
}
/**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
*
* @param editor 待说明
*/
public static void registerChartFloatEditorInEditor(QuickEditor editor) {
if (chartCollectionClass != null) {
floatEditor.put(chartCollectionClass, editor);
}
}
/**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
*
* @param editor 待说明
*/
public static void registerChartCellEditorInEditor(QuickEditor editor) {
if (chartCollectionClass != null) {
cellEditor.put(chartCollectionClass, editor);
}
}
/**
* 返回 悬浮元素选中的Editor
*/
public static QuickEditor getFloatEditor(Class clazz) {
return floatEditor.get(clazz);
}
public static QuickEditor getCellEditor(Class clazz) {
return cellEditor.get(clazz);
}
/**
* peter:从Action来产生ToolTipText.
*
* @param action 动作
* @return 字符
*/
public static String createButtonToolTipText(Action action) {
StringBuffer buttonToolTipTextBuf = new StringBuffer();
//peter:把中文后面的(U),alt 快捷键的括号去掉,这个方法是临时的做法.
String actionName = (String) action.getValue(Action.NAME);
if (actionName.lastIndexOf("(") != -1) {
buttonToolTipTextBuf.append(actionName.substring(0, actionName.lastIndexOf("(")));
} else {
buttonToolTipTextBuf.append(actionName);
}
//peter:产生快捷键的ToolTip.
KeyStroke keyStroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
if (keyStroke != null) {
buttonToolTipTextBuf.append(" (");
buttonToolTipTextBuf.append(KeyEvent.getKeyModifiersText(keyStroke.getModifiers()));
buttonToolTipTextBuf.append('+');
buttonToolTipTextBuf.append(KeyEvent.getKeyText(keyStroke.getKeyCode()));
buttonToolTipTextBuf.append(')');
}
return Utils.objectToString(buttonToolTipTextBuf);
}
/**
* 纪录插入元素的种类
*
* @param cls 类型数组
*/
public static void registerCellInsertActionClass(Class<?>[] cls) {
if (cls != null) {
Collections.addAll(actionClasses, cls);
}
}
/**
* 生成单元格插入相关的Action
* 表单中报表块编辑需要屏蔽掉"插入子报表"
*
* @param cls 构造函数参数类型
* @param obj 构造函数参数值
* @return 相关Action组成的一个数组
*/
public static UpdateAction[] createCellInsertAction(Class cls, Object obj) {
List<UpdateAction> actions = new ArrayList<>();
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
for (Class<?> clazz : actionClasses) {
if (clazz == null) {
continue;
}
if (jTemplate.acceptToolbarItem(clazz)) {
try {
Constructor<? extends UpdateAction> c = (Constructor<? extends UpdateAction>)clazz.getConstructor(cls);
actions.add(c.newInstance(obj));
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
}
return actions.toArray(new UpdateAction[actions.size()]);
}
/**
* 登记悬浮元素插入类型
*
* @param cls 插入类型数组
*/
public static void registerFloatInsertActionClass(Class<?>[] cls) {
if (cls != null) {
Collections.addAll(floatActionClasses, cls);
}
}
/**
* 生成悬浮元素插入相关的Action
*
* @param cls 构造函数参数类型
* @param obj 构造函数参数值
* @return 相关Action组成的一个数组
*/
public static UpdateAction[] createFloatInsertAction(Class cls, Object obj) {
List<UpdateAction> actions = new ArrayList<>();
for (Class<?> clazz : floatActionClasses) {
if (clazz == null) {
continue;
}
try {
Constructor<? extends UpdateAction> c = (Constructor<? extends UpdateAction>)clazz.getConstructor(cls);
actions.add(c.newInstance(obj));
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
return actions.toArray(new UpdateAction[actions.size()]);
}
}

202
designer_base/src/com/fr/design/actions/core/ActionUtils.java

@ -1,202 +0,0 @@
package com.fr.design.actions.core;
import java.awt.event.KeyEvent;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
import javax.swing.Action;
import javax.swing.KeyStroke;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.selection.QuickEditor;
/**
* 一些ActionUtils
*/
public class ActionUtils {
private static Class<UpdateAction>[] actionClasses;
private static Class<UpdateAction>[] floatActionClasses;
private ActionUtils() {
}
private static Map<Class, QuickEditor> floatEditor = new HashMap<Class, QuickEditor>();
private static Class chartCollectionClass = null;
private static Map<Class, QuickEditor> cellEditor = new HashMap<Class, QuickEditor>();
private static UpdateAction chartPreStyleAction = null;
/**
* 待说明
* @param clzz 待说明
* @param editor 待说明
*/
public static void registerCellEditor(Class clzz, QuickEditor editor) {
cellEditor.put(clzz, editor);
}
/**
* 待说明
* @param clzz 待说明
* @param editor 待说明
*/
public static void registerFloatEditor(Class clzz, QuickEditor editor) {
floatEditor.put(clzz, editor);
}
/**
* 注册图表的 预定义样式.
* @param action 注册的图表预定义样式action
*/
public static void registerChartPreStyleAction(UpdateAction action) {
chartPreStyleAction = action;
}
/**
* 返回 图表预定义样式Action
*/
public static UpdateAction getChartPreStyleAction() {
return chartPreStyleAction;
}
/**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* @param clzz 待说明
*/
public static void registerChartCollection(Class clzz) {
chartCollectionClass = clzz;
}
public static Class getChartCollectionClass() {
return chartCollectionClass;
}
/**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* @param editor 待说明
*/
public static void registerChartFloatEditorInEditor(QuickEditor editor) {
if(chartCollectionClass != null) {
floatEditor.put(chartCollectionClass, editor);
}
}
/**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* @param editor 待说明
*/
public static void registerChartCellEditorInEditor(QuickEditor editor) {
if(chartCollectionClass != null) {
cellEditor.put(chartCollectionClass, editor);
}
}
/**
* 返回 悬浮元素选中的Editor
*/
public static QuickEditor getFloatEditor(Class clazz) {
return floatEditor.get(clazz);
}
public static QuickEditor getCellEditor(Class clazz) {
return cellEditor.get(clazz);
}
/**
* peter:从Action来产生ToolTipText.
* @param action 动作
* @return 字符
*/
public static String createButtonToolTipText(Action action) {
StringBuffer buttonToolTipTextBuf = new StringBuffer();
//peter:把中文后面的(U),alt 快捷键的括号去掉,这个方法是临时的做法.
String actionName = (String) action.getValue(Action.NAME);
if (actionName.lastIndexOf("(") != -1) {
buttonToolTipTextBuf.append(actionName.substring(0, actionName.lastIndexOf("(")));
} else {
buttonToolTipTextBuf.append(actionName);
}
//peter:产生快捷键的ToolTip.
KeyStroke keyStroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
if (keyStroke != null) {
buttonToolTipTextBuf.append(" (");
buttonToolTipTextBuf.append(KeyEvent.getKeyModifiersText(keyStroke.getModifiers()));
buttonToolTipTextBuf.append('+');
buttonToolTipTextBuf.append(KeyEvent.getKeyText(keyStroke.getKeyCode()));
buttonToolTipTextBuf.append(')');
}
return Utils.objectToString(buttonToolTipTextBuf);
}
/**
* 纪录插入元素的种类
*
* @param cls 类型数组
*/
public static void registerCellInsertActionClass(Class<UpdateAction>[] cls) {
actionClasses = cls;
}
/**
* 生成单元格插入相关的Action
*
* @param cls 构造函数参数类型
* @param obj 构造函数参数值
* @return 相关Action组成的一个数组
*/
public static UpdateAction[] createCellInsertAction(Class cls, Object obj) {
int length = 0;
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
//表单中报表块编辑屏蔽掉 插入子报表
length = jTemplate.isJWorkBook()? actionClasses.length : actionClasses.length - 1;
UpdateAction[] actions = new UpdateAction[length];
for (int i = 0; i < length; i++) {
try {
Constructor<UpdateAction> c = actionClasses[i].getConstructor(cls);
actions[i] = c.newInstance(obj);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
return actions;
}
/**
* 登记悬浮元素插入类型
*
* @param cls 插入类型数组
*/
public static void registerFloatInsertActionClass(Class<UpdateAction>[] cls) {
floatActionClasses = cls;
}
/**
* 生成悬浮元素插入相关的Action
*
* @param cls 构造函数参数类型
* @param obj 构造函数参数值
* @return 相关Action组成的一个数组
*/
public static UpdateAction[] createFloatInsertAction(Class cls, Object obj) {
UpdateAction[] actions = new UpdateAction[floatActionClasses.length];
for (int i = 0; i < floatActionClasses.length; i++) {
try {
Constructor<UpdateAction> c = floatActionClasses[i].getConstructor(cls);
actions[i] = c.newInstance(obj);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
return actions;
}
}

7
designer_base/src/com/fr/design/actions/core/WorkBookSupportable.java

@ -0,0 +1,7 @@
package com.fr.design.actions.core;
/**
* Created by richie on 16/4/25.
*/
public interface WorkBookSupportable {
}

26
designer_base/src/com/fr/design/fun/ElementUIProvider.java

@ -0,0 +1,26 @@
package com.fr.design.fun;
import com.fr.design.actions.UpdateAction;
import com.fr.design.selection.QuickEditor;
import com.fr.stable.fun.Level;
/**
* Created by richie on 16/4/25.
*/
public interface ElementUIProvider extends Level {
String MARK_STRING = "ElementUIProvider";
int CURRENT_LEVEL = 1;
Class<?> targetCellEditorClass();
Class<?> targetObjectClass();
QuickEditor<?> quickEditor();
Class<? extends UpdateAction> actionForInsertCellElement();
Class<? extends UpdateAction> actionForInsertFloatElement();
}

20
designer_base/src/com/fr/design/fun/impl/AbstractElementUIProvider.java

@ -0,0 +1,20 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.ElementUIProvider;
import com.fr.stable.fun.impl.AbstractProvider;
/**
* Created by richie on 16/4/25.
*/
public abstract class AbstractElementUIProvider extends AbstractProvider implements ElementUIProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return this.getClass().getName();
}
}

5
designer_base/src/com/fr/design/mainframe/JTemplate.java

@ -9,6 +9,7 @@ import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.TableDataSourceAction;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.edit.RedoAction;
import com.fr.design.actions.edit.UndoAction;
import com.fr.design.actions.file.SaveAsTemplateAction;
@ -952,4 +953,8 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
}
return pp;
}
public boolean acceptToolbarItem(Class clazz) {
return true;
}
}

44
designer_base/src/com/fr/design/module/DesignModule.java

@ -1,14 +1,28 @@
package com.fr.design.module;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.fun.ElementUIProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.hyperlink.ReportletHyperlinkPane;
import com.fr.design.hyperlink.WebHyperlinkPane;
import com.fr.design.javascript.EmailPane;
import com.fr.design.javascript.JavaScriptImplPane;
import com.fr.design.javascript.ParameterJavaScriptPane;
import com.fr.design.mainframe.App;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.general.Inter;
import com.fr.general.ModuleContext;
import com.fr.js.*;
import com.fr.module.TopModule;
import com.fr.stable.ArrayUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.stable.plugin.ExtraDesignClassManagerProvider;
import java.util.ArrayList;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* Author : Richer
@ -26,6 +40,9 @@ public abstract class DesignModule extends TopModule {
}
ModuleContext.registerStartedModule(DesignModule.class.getName(), this);
StableFactory.registerMarkedClass(ExtraDesignClassManagerProvider.XML_TAG, ExtraDesignClassManager.class);
ActionFactory.registerCellInsertActionClass(actionsForInsertCellElement());
ActionFactory.registerFloatInsertActionClass(actionsForInsertFloatElement());
DesignModuleFactory.registerCreators4Hyperlink(hyperlinkTypes());
}
public boolean isStarted() {
@ -47,5 +64,32 @@ public abstract class DesignModule extends TopModule {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
public Class<?>[] actionsForInsertCellElement() {
List<Class<?>> classes = new ArrayList<>();
ElementUIProvider[] providers = ExtraDesignClassManager.getInstance().getElementUIProviders();
for (ElementUIProvider provider : providers) {
classes.add(provider.actionForInsertCellElement());
}
return classes.toArray(new Class<?>[classes.size()]);
}
public Class<?>[] actionsForInsertFloatElement() {
List<Class<?>> classes = new ArrayList<>();
ElementUIProvider[] providers = ExtraDesignClassManager.getInstance().getElementUIProviders();
for (ElementUIProvider provider : providers) {
classes.add(provider.actionForInsertFloatElement());
}
return classes.toArray(new Class<?>[classes.size()]);
}
public NameableCreator[] hyperlinkTypes() {
return new NameableCreator[]{
new NameObjectCreator(Inter.getLocText("FR-Hyperlink_Reportlet"), ReportletHyperlink.class, ReportletHyperlinkPane.CHART_NO_RENAME.class),
new NameObjectCreator(Inter.getLocText("FR-Designer_Email"), EmailJavaScript.class, EmailPane.class),
new NameObjectCreator(Inter.getLocText("Hyperlink-Web_link"), WebHyperlink.class, WebHyperlinkPane.CHART_NO_RENAME.class),
new NameObjectCreator(Inter.getLocText("JavaScript-Dynamic_Parameters"), ParameterJavaScript.class, ParameterJavaScriptPane.CHART_NO_RENAME.class),
new NameObjectCreator("JavaScript", JavaScriptImpl.class, JavaScriptImplPane.CHART_NO_RENAME.class)
};
}
}

4
designer_base/src/com/fr/design/utils/gui/GUICoreUtils.java

@ -8,7 +8,7 @@ import com.fr.base.Style;
import com.fr.base.background.ColorBackground;
import com.fr.data.util.function.*;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIToggleButton;
@ -214,7 +214,7 @@ public abstract class GUICoreUtils{
button.setText(StringUtils.EMPTY);
button.setEnabled(updateAction.isEnabled());
button.setToolTipText(ActionUtils.createButtonToolTipText(updateAction));
button.setToolTipText(ActionFactory.createButtonToolTipText(updateAction));
object = button;
}

2
designer_chart/src/com/fr/design/module/ChartDesignerModule.java

@ -1 +1 @@
package com.fr.design.module; import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.actions.core.ActionUtils; import com.fr.design.chart.ChartDialog; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.gui.core.WidgetOption; import com.fr.design.mainframe.App; import com.fr.design.mainframe.ChartAndWidgetPropertyPane; import com.fr.design.mainframe.ChartPropertyPane; import com.fr.form.ui.ChartEditor; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.stable.plugin.PluginReadListener; import javax.swing.*; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 13-7-8 * Time: 上午9:13 */ public class ChartDesignerModule extends DesignModule { public void start() { super.start(); dealBeforeRegister(); register(); registerFloatEditor(); } protected void dealBeforeRegister(){ StableFactory.registerMarkedClass(ExtraChartDesignClassManagerProvider.XML_TAG, ChartTypeInterfaceManager.class); } private void register(){ DesignModuleFactory.registerHyperlinkGroupType(new ChartHyperlinkGroup()); GeneralContext.addPluginReadListener(new PluginReadListener() { @Override public void success() { DesignModuleFactory.registerExtraWidgetOptions(options4Show()); } }); DesignModuleFactory.registerChartEditorClass(ChartEditor.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartAndWidgetPropertyPane(ChartAndWidgetPropertyPane.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); ActionUtils.registerChartPreStyleAction(new ChartPreStyleAction()); } protected void registerFloatEditor() { ActionUtils.registerChartCollection(ChartCollection.class); } /** * 返回设计器能打开的模板类型的一个数组列表 * * @return 可以打开的模板类型的数组 */ public App<?>[] apps4TemplateOpener() { return new App[0]; } protected WidgetOption[] options4Show() { ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; for (int i = 0; i < typeName.length; i++) { String plotID = typeName[i].getPlotID(); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); Icon icon = IOUtils.readIcon(iconPath); child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); } return child; } public String getInterNationalName() { return Inter.getLocText("FR-Chart-Design_ChartModule"); } }
package com.fr.design.module; import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.actions.core.ActionFactory; import com.fr.design.chart.ChartDialog; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.gui.core.WidgetOption; import com.fr.design.mainframe.App; import com.fr.design.mainframe.ChartAndWidgetPropertyPane; import com.fr.design.mainframe.ChartPropertyPane; import com.fr.form.ui.ChartEditor; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.stable.plugin.PluginReadListener; import javax.swing.*; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 13-7-8 * Time: 上午9:13 */ public class ChartDesignerModule extends DesignModule { public void start() { super.start(); dealBeforeRegister(); register(); registerFloatEditor(); } protected void dealBeforeRegister(){ StableFactory.registerMarkedClass(ExtraChartDesignClassManagerProvider.XML_TAG, ChartTypeInterfaceManager.class); } private void register(){ DesignModuleFactory.registerHyperlinkGroupType(new ChartHyperlinkGroup()); GeneralContext.addPluginReadListener(new PluginReadListener() { @Override public void success() { DesignModuleFactory.registerExtraWidgetOptions(options4Show()); } }); DesignModuleFactory.registerChartEditorClass(ChartEditor.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartAndWidgetPropertyPane(ChartAndWidgetPropertyPane.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); } protected void registerFloatEditor() { ActionFactory.registerChartCollection(ChartCollection.class); } /** * 返回设计器能打开的模板类型的一个数组列表 * * @return 可以打开的模板类型的数组 */ public App<?>[] apps4TemplateOpener() { return new App[0]; } protected WidgetOption[] options4Show() { ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; for (int i = 0; i < typeName.length; i++) { String plotID = typeName[i].getPlotID(); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); Icon icon = IOUtils.readIcon(iconPath); child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); } return child; } public String getInterNationalName() { return Inter.getLocText("FR-Chart-Design_ChartModule"); } }

5
designer_form/src/com/fr/design/mainframe/JForm.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.design.DesignState;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.cell.FloatElementsProvider;
import com.fr.design.constants.UIConstants;
@ -742,4 +743,8 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return BaseUtils.readIcon("/com/fr/web/images/form/new_form3.png");
}
@Override
public boolean acceptToolbarItem(Class clazz) {
return WorkBookSupportable.class.isAssignableFrom(clazz);
}
}
Loading…
Cancel
Save