Browse Source

REPORT-13018 大赛后续开两个接口 ,右键菜单接口同步10.0

bugfix/10.0
zack 6 years ago
parent
commit
8559c8ee12
  1. 55
      designer-base/src/main/java/com/fr/design/fun/RightSelectionHandlerProvider.java
  2. 45
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractRightSelectionHandlerProvider.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  4. 8
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  5. 29
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  6. 2
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  7. 48
      designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java
  8. 2
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  9. 27
      designer-realize/src/main/java/com/fr/grid/selection/Selection.java

55
designer-base/src/main/java/com/fr/design/fun/RightSelectionHandlerProvider.java

@ -0,0 +1,55 @@
package com.fr.design.fun;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.BaseFormDesigner;
import com.fr.design.selection.SelectableElement;
import com.fr.stable.fun.mark.Mutable;
import java.util.List;
/**
* 设计器右键菜单接口
*/
public interface RightSelectionHandlerProvider extends Mutable {
int CURRENT_LEVEL = 1;
String XML_TAG = "RightSelectionHandlerProvider";
/**
* 对单元格或者悬浮元素的右键菜单项进行增删改
*
* @param ePane 选择的元素
* @param popupMenu 右键主菜单
*/
void dmlMenu(TargetComponent ePane, UIPopupMenu popupMenu);
/**
* 当前实现是否可以作用于当前元素
*
* @param selectableElement 当前选中元素分为CellSelection和FloatSelection(单元格和悬浮元素)
* @return
*/
boolean accept(SelectableElement selectableElement);
/**
* 对表单,参数面板内置的右键选项进行增删改处理
*
* @param actions 默认的action集合 注意:主体代码要求这边的action必须是UndoableAction 的子类而非updateAction
*/
void dmlUpdateActions(BaseFormDesigner formDesigner, List<UpdateAction> actions);
/**
* 当前实现是否可以作用于当前元素
*
* @param formDesigner 当前选中元素分为表单编辑器和参数面板(表单组件元素以及各种控件)
* @return
*/
boolean accept(BaseFormDesigner formDesigner);
}

45
designer-base/src/main/java/com/fr/design/fun/impl/AbstractRightSelectionHandlerProvider.java

@ -0,0 +1,45 @@
package com.fr.design.fun.impl;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.TargetComponent;
import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.BaseFormDesigner;
import com.fr.design.selection.SelectableElement;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
import java.util.List;
@API(level = RightSelectionHandlerProvider.CURRENT_LEVEL)
public abstract class AbstractRightSelectionHandlerProvider extends AbstractProvider implements RightSelectionHandlerProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public void dmlUpdateActions(BaseFormDesigner formDesigner, List<UpdateAction> actions) {
}
@Override
public boolean accept(BaseFormDesigner formDesigner) {
return false;
}
@Override
public void dmlMenu(TargetComponent ePane, UIPopupMenu popupMenu) {
}
@Override
public boolean accept(SelectableElement selectableElement) {
return false;
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -419,7 +419,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
fireSuperTargetModified();
}
protected boolean accept(Object o) {
public boolean accept(Object o) {
return true;
}

8
designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java

@ -11,6 +11,7 @@ import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.BorderFactory;
@ -324,10 +325,11 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
*/
public UpdateAction[] getActions() {
if (designerActions == null) {
designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)};
designerActions = new ArrayList<UpdateAction>(Arrays.asList(new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)}));
dmlActions(designerActions);
}
return designerActions;
return designerActions.toArray(new UpdateAction[designerActions.size()]);
}
private boolean searchQueryCreators(XLayoutContainer rootContainer) {

29
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1,9 +1,11 @@
package com.fr.design.mainframe;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.TargetComponent;
@ -39,6 +41,7 @@ import com.fr.design.designer.properties.FormWidgetAuthorityEditPane;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
@ -89,6 +92,7 @@ import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
/**
* 设计界面组件该组件是界面设计工具的核心主要负责的是被设计界面的显示界面设计操作状态的 显示编辑状态的显示等等
@ -132,7 +136,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
private int resolution = ScreenResolution.getScreenResolution();
// 编辑状态的事件表
private CreatorEventListenerTable edit;
protected UpdateAction[] designerActions;
protected List<UpdateAction> designerActions;
private FormDesignerModeForSpecial<?> desigerMode;
private Action switchAction;
private FormElementCaseContainerProvider elementCaseContainer;
@ -1180,11 +1184,28 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
*/
public UpdateAction[] getActions() {
if (designerActions == null) {
designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
designerActions = new ArrayList<UpdateAction>(Arrays.asList(new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this), new MoveToTopAction(this), new MoveToBottomAction(this),
new MoveUpAction(this), new MoveDownAction(this)};
new MoveUpAction(this), new MoveDownAction(this)}));
dmlActions(designerActions);
}
return designerActions.toArray(new UpdateAction[designerActions.size()]);
}
/**
* 扩展菜单项
* @param actions
*/
public void dmlActions(List<UpdateAction> actions) {
try {
Set<RightSelectionHandlerProvider> selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG);
for (RightSelectionHandlerProvider handler : selectionHandlerProviders) {
if (handler.accept(this)) {
handler.dmlUpdateActions(this,actions);
}
}
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
return designerActions;
}
// 当前选中控件可以上移一层吗?

2
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -160,7 +160,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
}
@Override
protected boolean accept(Object o) {
public boolean accept(Object o) {
return !(o instanceof FloatElementsProvider);
}

48
designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java

@ -3,9 +3,6 @@
*/
package com.fr.design.cell.clipboard;
import java.util.Arrays;
import java.util.Iterator;
import com.fr.base.FRContext;
import com.fr.grid.selection.CellSelection;
import com.fr.report.cell.CellElement;
@ -15,6 +12,9 @@ import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.StringUtils;
import com.fr.stable.unit.FU;
import java.util.Arrays;
import java.util.Iterator;
/**
* The clip of CellElement.
*/
@ -39,7 +39,47 @@ public class CellElementsClip implements Cloneable, java.io.Serializable {
this.clips = clips;
}
public String compateExcelPaste() {
public int getColumnSpan() {
return columnSpan;
}
public void setColumnSpan(int columnSpan) {
this.columnSpan = columnSpan;
}
public int getRowSpan() {
return rowSpan;
}
public void setRowSpan(int rowSpan) {
this.rowSpan = rowSpan;
}
public FU[] getColumnWidth() {
return columnWidth;
}
public void setColumnWidth(FU[] columnWidth) {
this.columnWidth = columnWidth;
}
public FU[] getRowHeight() {
return rowHeight;
}
public void setRowHeight(FU[] rowHeight) {
this.rowHeight = rowHeight;
}
public TemplateCellElement[] getClips() {
return clips;
}
public void setClips(TemplateCellElement[] clips) {
this.clips = clips;
}
public String compateExcelPaste() {
Arrays.sort(this.clips, CellElementComparator.getRowFirstComparator());
// 排序

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

@ -663,7 +663,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
}
}
private Object getClipObject() {
public Object getClipObject() {
// 需要检查是否可以编辑。
Clipboard clipboard = DesignerContext.getClipboard(this.getGrid());
Transferable clipData = clipboard.getContents(this);

27
designer-realize/src/main/java/com/fr/grid/selection/Selection.java

@ -1,19 +1,22 @@
package com.fr.grid.selection;
import java.io.Serializable;
import javax.swing.JPopupMenu;
import com.fr.base.FRContext;
import com.fr.design.ExtraDesignClassManager;
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.fun.RightSelectionHandlerProvider;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.design.selection.SelectableElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow;
import com.fr.stable.FCloneable;
import javax.swing.JPopupMenu;
import java.io.Serializable;
import java.util.Set;
/*
* TODO ALEX_SEP Selection是跟ElementCasePane绑定的,能不能把ElementCasePane保存在Selection里面呢?
*
@ -65,6 +68,20 @@ public abstract class Selection implements FCloneable, Serializable , Selectable
// ///////////////////////////////popup////////////////////////////////
public abstract JPopupMenu createPopupMenu(ElementCasePane ePane);
/**
* 添加插件菜单(增删改都可以)
* @param ePane
* @param popupMenu
*/
public void addExtraMenu(ElementCasePane ePane, UIPopupMenu popupMenu) {
Set<RightSelectionHandlerProvider> selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG);
for (RightSelectionHandlerProvider handler : selectionHandlerProviders) {
if (handler.accept(this)) {
handler.dmlMenu(ePane, popupMenu);
}
}
}
// ///////////////////////////////clear////////////////////////////////
public abstract boolean clear(ElementCasePane.Clear type, ElementCasePane ePane);

Loading…
Cancel
Save