|
|
@ -122,19 +122,13 @@ import java.util.Set; |
|
|
|
* @since 2012-3-29下午1:50:53 |
|
|
|
* @since 2012-3-29下午1:50:53 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
private final static String CONFIRM_DIALOG_TITLE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"); |
|
|
|
|
|
|
|
public static final int DEFUAL_FOMULA_LENGTH = 103; |
|
|
|
public static final int DEFUAL_FOMULA_LENGTH = 103; |
|
|
|
public static final String ELLIPSIS = "..."; |
|
|
|
public static final String ELLIPSIS = "..."; |
|
|
|
public static final int KEY_CODE_A = 64; |
|
|
|
public static final int KEY_CODE_A = 64; |
|
|
|
public static final int KEY_CODE_Z = 91; |
|
|
|
public static final int KEY_CODE_Z = 91; |
|
|
|
public static final String CHECK_RESULT = Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Result"); |
|
|
|
|
|
|
|
public static final String CONTINUE = Toolkit.i18nText("Fine-Design_Basic_Formula_Continue"); |
|
|
|
|
|
|
|
public static final String CAL_RESULT = Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result"); |
|
|
|
|
|
|
|
public static final String NEWLINE = "\n"; |
|
|
|
public static final String NEWLINE = "\n"; |
|
|
|
public static final String ERROR_POSITION = Toolkit.i18nText("Fine-Design_Basic_Formula_Error_Position"); |
|
|
|
|
|
|
|
public static final String FORMULA_ICON = "/com/fr/design/images/m_file/formula.png"; |
|
|
|
public static final String FORMULA_ICON = "/com/fr/design/images/m_file/formula.png"; |
|
|
|
public static final String PARAM_ICON = "/com/fr/design/images/m_file/param.png"; |
|
|
|
public static final String PARAM_ICON = "/com/fr/design/images/m_file/param.png"; |
|
|
|
public static final int KEY_CODE_$ = 515; |
|
|
|
|
|
|
|
private VariableTreeAndDescriptionArea variableTreeAndDescriptionArea; |
|
|
|
private VariableTreeAndDescriptionArea variableTreeAndDescriptionArea; |
|
|
|
private RSyntaxTextArea formulaTextArea; |
|
|
|
private RSyntaxTextArea formulaTextArea; |
|
|
|
private UITextField keyWordTextField = new UITextField(18); |
|
|
|
private UITextField keyWordTextField = new UITextField(18); |
|
|
@ -152,7 +146,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
private JList functionNameList; |
|
|
|
private JList functionNameList; |
|
|
|
private UITableEditorPane<ParameterProvider> editor4CalPane; |
|
|
|
private UITableEditorPane<ParameterProvider> editor4CalPane; |
|
|
|
private FormulaPaneAutoCompletion autoCompletion; |
|
|
|
private FormulaPaneAutoCompletion autoCompletion; |
|
|
|
private static DefaultCompletionProvider COMPLETION_PROVIDER = null; |
|
|
|
private DefaultCompletionProvider completionProvider; |
|
|
|
private static final Map<String, String> PARAM_PREFIX_MAP = new HashMap<>(); |
|
|
|
private static final Map<String, String> PARAM_PREFIX_MAP = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
public FormulaPane() { |
|
|
|
public FormulaPane() { |
|
|
@ -353,11 +347,11 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private CompletionProvider createCompletionProvider() { |
|
|
|
private CompletionProvider createCompletionProvider() { |
|
|
|
if (COMPLETION_PROVIDER == null) { |
|
|
|
if (completionProvider == null) { |
|
|
|
COMPLETION_PROVIDER = new DefaultCompletionProvider(); |
|
|
|
completionProvider = new DefaultCompletionProvider(); |
|
|
|
NameAndDescription[] nameAndDescriptions = FunctionConstants.ALL.getDescriptions(); |
|
|
|
NameAndDescription[] nameAndDescriptions = FunctionConstants.ALL.getDescriptions(); |
|
|
|
for (NameAndDescription nameAndDescription : nameAndDescriptions) { |
|
|
|
for (NameAndDescription nameAndDescription : nameAndDescriptions) { |
|
|
|
COMPLETION_PROVIDER.addCompletion(new FormulaCompletion(COMPLETION_PROVIDER, nameAndDescription.getName(), BaseUtils.readIcon(FORMULA_ICON))); |
|
|
|
completionProvider.addCompletion(new FormulaCompletion(completionProvider, nameAndDescription.getName(), BaseUtils.readIcon(FORMULA_ICON))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
VariableResolver variableResolver = VariableResolver.DEFAULT; |
|
|
|
VariableResolver variableResolver = VariableResolver.DEFAULT; |
|
|
@ -381,13 +375,13 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
paramWithoutPre = parameter; |
|
|
|
paramWithoutPre = parameter; |
|
|
|
PARAM_PREFIX_MAP.put(paramWithoutPre, StringUtils.EMPTY); |
|
|
|
PARAM_PREFIX_MAP.put(paramWithoutPre, StringUtils.EMPTY); |
|
|
|
} |
|
|
|
} |
|
|
|
COMPLETION_PROVIDER.addCompletion(new FormulaCompletion(COMPLETION_PROVIDER, paramWithoutPre, BaseUtils.readIcon(PARAM_ICON))); |
|
|
|
completionProvider.addCompletion(new FormulaCompletion(completionProvider, paramWithoutPre, BaseUtils.readIcon(PARAM_ICON))); |
|
|
|
} |
|
|
|
} |
|
|
|
COMPLETION_PROVIDER.addCompletion(new FormulaCompletion(COMPLETION_PROVIDER, "$$$", BaseUtils.readIcon(PARAM_ICON))); |
|
|
|
completionProvider.addCompletion(new FormulaCompletion(completionProvider, "$$$", BaseUtils.readIcon(PARAM_ICON))); |
|
|
|
|
|
|
|
|
|
|
|
return COMPLETION_PROVIDER; |
|
|
|
return completionProvider; |
|
|
|
} |
|
|
|
} |
|
|
|
return COMPLETION_PROVIDER; |
|
|
|
return completionProvider; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean containsParam(String param) { |
|
|
|
public static boolean containsParam(String param) { |
|
|
@ -821,7 +815,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
String objectToString = EssentialUtils.objectToString(value); |
|
|
|
String objectToString = EssentialUtils.objectToString(value); |
|
|
|
String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ? |
|
|
|
String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ? |
|
|
|
objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString; |
|
|
|
objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString; |
|
|
|
messageTips = messageTips + CAL_RESULT + ":" + result; |
|
|
|
messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result; |
|
|
|
FineLoggerFactory.getLogger().info("value:{}", value); |
|
|
|
FineLoggerFactory.getLogger().info("value:{}", value); |
|
|
|
} catch (UtilEvalError utilEvalError) { |
|
|
|
} catch (UtilEvalError utilEvalError) { |
|
|
|
FineLoggerFactory.getLogger().error(utilEvalError.getMessage(), utilEvalError); |
|
|
|
FineLoggerFactory.getLogger().error(utilEvalError.getMessage(), utilEvalError); |
|
|
@ -843,13 +837,13 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
int confirmDialog = FineJOptionPane.showConfirmDialog( |
|
|
|
int confirmDialog = FineJOptionPane.showConfirmDialog( |
|
|
|
FormulaPane.this, |
|
|
|
FormulaPane.this, |
|
|
|
checkResult.getTips() + ", " + ERROR_POSITION + ":" + (checkResult.getFormulaCoordinates().getColumns()) + ".", |
|
|
|
checkResult.getTips() + ", " + Toolkit.i18nText("Fine-Design_Basic_Formula_Error_Position") + ":" + (checkResult.getFormulaCoordinates().getColumns()) + ".", |
|
|
|
CONFIRM_DIALOG_TITLE, |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), |
|
|
|
JOptionPane.YES_NO_OPTION, |
|
|
|
JOptionPane.YES_NO_OPTION, |
|
|
|
JOptionPane.WARNING_MESSAGE, |
|
|
|
JOptionPane.WARNING_MESSAGE, |
|
|
|
null, |
|
|
|
null, |
|
|
|
new String[]{CHECK_RESULT, CONTINUE}, |
|
|
|
new String[]{Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Result"), Toolkit.i18nText("Fine-Design_Basic_Formula_Continue")}, |
|
|
|
CHECK_RESULT); |
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Result")); |
|
|
|
if (confirmDialog == 0) { |
|
|
|
if (confirmDialog == 0) { |
|
|
|
formulaTextArea.setCaretPosition(checkResult.getFormulaCoordinates().getColumns()); |
|
|
|
formulaTextArea.setCaretPosition(checkResult.getFormulaCoordinates().getColumns()); |
|
|
|
formulaTextArea.requestFocus(); |
|
|
|
formulaTextArea.requestFocus(); |
|
|
|