forked from fanruan/design
25 changed files with 544 additions and 239 deletions
@ -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); |
||||
|
||||
} |
@ -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; |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.design.formula; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import static junit.framework.Assert.fail; |
||||
import static junit.framework.TestCase.assertEquals; |
||||
import static junit.framework.TestCase.assertTrue; |
||||
|
||||
/** |
||||
* Created by plough on 2018/12/7. |
||||
*/ |
||||
public class FunctionConstantsTest { |
||||
@Test |
||||
public void testNewInstanceFail() throws Exception { |
||||
try { |
||||
FunctionConstants.class.newInstance(); |
||||
fail("Not allowed to instantiate FunctionConstants!"); |
||||
} catch (IllegalAccessException e) { |
||||
assertTrue(true); |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
public void testEmbedFuntionsAfterStaticInit() { |
||||
NameAndTypeAndFunctionList[] embFunctionLists = FunctionConstants.EMBFUNCTIONS; |
||||
// 一共有 8 个分类
|
||||
assertEquals(8, embFunctionLists.length); |
||||
for (NameAndTypeAndFunctionList embFunctionsList : embFunctionLists) { |
||||
// 每个分类下都有函数
|
||||
NameAndDescription[] nameAndDescriptions = embFunctionsList.getDescriptions(); |
||||
assertTrue(nameAndDescriptions.length > 0); |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
public void testCommonFuntionsAfterStaticInit() { |
||||
NameAndFunctionList commonFunctionList = FunctionConstants.COMMON; |
||||
assertEquals(9, commonFunctionList.getDescriptions().length); |
||||
} |
||||
} |
Loading…
Reference in new issue