You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.4 KiB
83 lines
2.4 KiB
package com.fr.solution.plugin.design.formula.ui.type.impl; |
|
|
|
import com.fr.base.Parameter; |
|
import com.fr.base.ParameterHelper; |
|
import com.fr.base.ScriptFormula; |
|
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea; |
|
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; |
|
import com.fr.general.Inter; |
|
import com.fr.script.Calculator; |
|
import com.fr.solution.plugin.design.formula.ui.type.BaseFormulaPane; |
|
import com.fr.stable.StringUtils; |
|
|
|
public class ScriptFormulaPane extends BaseFormulaPane<ScriptFormula> { |
|
|
|
@Override |
|
protected RSyntaxTextArea createContentEditor() { |
|
RSyntaxTextArea formulaTextArea = new RSyntaxTextArea(); |
|
formulaTextArea.setCloseCurlyBraces(true); |
|
formulaTextArea.setLineWrap(true); |
|
formulaTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT); |
|
formulaTextArea.setCodeFoldingEnabled(true); |
|
formulaTextArea.setAntiAliasingEnabled(true); |
|
return formulaTextArea; |
|
} |
|
|
|
@Override |
|
public boolean accept(Object ob) { |
|
return ob instanceof ScriptFormula; |
|
} |
|
|
|
@Override |
|
public void reset() { |
|
|
|
} |
|
|
|
@Override |
|
public void populateBean(ScriptFormula formula) { |
|
if (formula != null) { |
|
String content = formula.getContent(); |
|
fixContent(content); |
|
} |
|
} |
|
|
|
@Override |
|
protected ScriptFormula createFormula(String content) { |
|
ScriptFormula formula; |
|
if (StringUtils.isEmpty(content) || content.trim().charAt(0) == '=') { |
|
formula = new ScriptFormula(content); |
|
} else { |
|
formula = new ScriptFormula("=" + content); |
|
} |
|
return formula; |
|
} |
|
|
|
@Override |
|
protected ScriptFormula createWrittenFormula(String content) { |
|
return createFormula(content); |
|
} |
|
|
|
@Override |
|
public void onDoubleClick(String currentLineContent) { |
|
|
|
} |
|
|
|
@Override |
|
protected String wrapText(String text) { |
|
return "'${" + text + "}'"; |
|
} |
|
|
|
@Override |
|
public Parameter[] analyze4Parameters(Calculator calculator) { |
|
ScriptFormula scriptFormula = updateBean(); |
|
if (scriptFormula == null) { |
|
return new Parameter[0]; |
|
} |
|
return ParameterHelper.analyze4Parameters(scriptFormula.getContent(), true); |
|
} |
|
|
|
@Override |
|
public String title4PopupWindow() { |
|
return Inter.getLocText("Plugin-Design_Group_Formula_Script_Title"); |
|
} |
|
}
|
|
|