Browse Source

为自定义函数进行分组【一次引入一组公式用,比如财务主题公式】

master
hugh 8 years ago
parent
commit
5fa2691e8d
  1. 30
      designer_base/src/com/fr/design/formula/AbstractFunctionGroup.java
  2. 12
      designer_base/src/com/fr/design/formula/FormulaPane.java
  3. 10
      designer_base/src/com/fr/design/formula/FunctionConstants.java
  4. 12
      designer_base/src/com/fr/design/formula/FunctionGroupDefineProvider.java

30
designer_base/src/com/fr/design/formula/AbstractFunctionGroup.java

@ -0,0 +1,30 @@
package com.fr.design.formula;
import com.fr.stable.fun.mark.API;
import com.fr.stable.script.FunctionDef;
@API(level = FunctionGroupDefineProvider.CURRENT_LEVEL)
public abstract class AbstractFunctionGroup implements FunctionGroupDefineProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public NameAndDescription[] getDescriptions() {
FunctionDef[] funcs = getFunctionDefs();
int count = funcs.length;
FunctionDefNAD[] nads = new FunctionDefNAD[count];
for (int i = 0; i < count; i ++) {
nads[i] = new FunctionDefNAD(funcs[i]);
}
return nads;
}
}

12
designer_base/src/com/fr/design/formula/FormulaPane.java

@ -22,8 +22,10 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.parser.FRLexer; import com.fr.parser.FRLexer;
import com.fr.parser.FRParser; import com.fr.parser.FRParser;
import com.fr.plugin.ExtraClassManager;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.Expression; import com.fr.stable.script.Expression;
import javax.swing.*; import javax.swing.*;
@ -32,10 +34,12 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener; import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.*; import javax.swing.tree.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.io.*; import java.io.*;
import java.util.Locale; import java.util.Locale;
import java.util.Set;
/** /**
* 公式编辑面板 * 公式编辑面板
* @editor zhou * @editor zhou
@ -581,7 +585,13 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
functionTypeListModel.addElement(FunctionConstants.ALL); functionTypeListModel.addElement(FunctionConstants.ALL);
functionTypeListModel.addElement(FunctionConstants.CUSTOM); functionTypeListModel.addElement(FunctionConstants.CUSTOM);
functionTypeListModel.addElement(FunctionConstants.PLUGIN); functionTypeListModel.addElement(FunctionConstants.PLUGIN);
//hugh:自定义函数分组
Set<Mutable> groups = ExtraClassManager.getInstance().getArray(FunctionGroupDefineProvider.MARK_STRING);
if(!groups.isEmpty()){
for(Mutable group : groups){
functionTypeListModel.addElement(group);
}
}
functionTypeList.addListSelectionListener(new ListSelectionListener() { functionTypeList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) { public void valueChanged(ListSelectionEvent evt) {

10
designer_base/src/com/fr/design/formula/FunctionConstants.java

@ -11,6 +11,8 @@ import com.fr.stable.EncodeConstants;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.fun.FunctionGroupDefineProvider;
import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.Function; import com.fr.stable.script.Function;
import com.fr.stable.script.FunctionDef; import com.fr.stable.script.FunctionDef;
@ -96,7 +98,13 @@ public abstract class FunctionConstants {
} }
Collections.addAll(all, PLUGIN.getDescriptions()); Collections.addAll(all, PLUGIN.getDescriptions());
Collections.addAll(all, CUSTOM.getDescriptions()); Collections.addAll(all, CUSTOM.getDescriptions());
//hugh:自定义函数分组
Set<Mutable> groups = ExtraClassManager.getInstance().getArray(FunctionGroupDefineProvider.MARK_STRING);
if(!groups.isEmpty()){
for(Mutable group : groups){
Collections.addAll(all, ((FunctionGroup)group).getDescriptions());
}
}
java.util.Collections.sort(all, NameAndDescriptionComparator); java.util.Collections.sort(all, NameAndDescriptionComparator);
return all.toArray(new NameAndDescription[all.size()]); return all.toArray(new NameAndDescription[all.size()]);

12
designer_base/src/com/fr/design/formula/FunctionGroupDefineProvider.java

@ -0,0 +1,12 @@
package com.fr.design.formula;
import com.fr.design.formula.FunctionGroup;
import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.FunctionDef;
public interface FunctionGroupDefineProvider extends Mutable,FunctionGroup{
int CURRENT_LEVEL = 1;
String MARK_STRING = "FunctionGroupDefineProvider";
public FunctionDef[] getFunctionDefs();
}
Loading…
Cancel
Save