public static void tryCreateVar(@Nonnull final Context context) {
   final CalculatorDisplay display = Locator.getInstance().getDisplay();
   final CalculatorDisplayViewState viewState = display.getViewState();
   if (viewState.isValid()) {
     final String varValue = viewState.getText();
     if (!Strings.isEmpty(varValue)) {
       if (CalculatorVarsFragment.isValidValue(varValue)) {
         if (context instanceof SherlockFragmentActivity) {
           VarEditDialogFragment.showDialog(
               VarEditDialogFragment.Input.newFromValue(varValue),
               ((SherlockFragmentActivity) context).getSupportFragmentManager());
         } else {
           final Intent intent = new Intent(context, CalculatorVarsActivity.class);
           intent.putExtra(CalculatorVarsFragment.CREATE_VAR_EXTRA_STRING, varValue);
           Android.addIntentFlags(intent, false, context);
           context.startActivity(intent);
         }
       } else {
         getNotifier().showMessage(R.string.c_value_is_not_a_number, MessageType.error);
       }
     } else {
       getNotifier().showMessage(R.string.empty_var_error, MessageType.error);
     }
   } else {
     getNotifier().showMessage(R.string.not_valid_result, MessageType.error);
   }
 }
  public static void tryPlot() {
    final CalculatorPlotter plotter = Locator.getInstance().getPlotter();
    final CalculatorDisplay display = Locator.getInstance().getDisplay();
    final CalculatorDisplayViewState viewState = display.getViewState();

    if (viewState.isValid()) {
      final String functionValue = viewState.getText();
      final Generic expression = viewState.getResult();
      if (!Strings.isEmpty(functionValue) && expression != null) {
        if (plotter.isPlotPossibleFor(expression)) {
          plotter.plot(expression);
        } else {
          getNotifier().showMessage(R.string.cpp_plot_too_many_variables, MessageType.error);
        }
      } else {
        getNotifier().showMessage(R.string.cpp_plot_empty_function_error, MessageType.error);
      }
    } else {
      getNotifier().showMessage(R.string.not_valid_result, MessageType.error);
    }
  }
  public static void tryCreateFunction(@Nonnull final Context context) {
    final CalculatorDisplay display = Locator.getInstance().getDisplay();
    final CalculatorDisplayViewState viewState = display.getViewState();

    if (viewState.isValid()) {
      final String functionValue = viewState.getText();
      if (!Strings.isEmpty(functionValue)) {

        FunctionEditDialogFragment.showDialog(
            FunctionEditDialogFragment.Input.newFromDisplay(viewState), context);

      } else {
        getNotifier().showMessage(R.string.empty_function_error, MessageType.error);
      }
    } else {
      getNotifier().showMessage(R.string.not_valid_result, MessageType.error);
    }
  }
 @Nonnull
 private static CalculatorNotifier getNotifier() {
   return Locator.getInstance().getNotifier();
 }