コード例 #1
0
ファイル: DialogLogic.java プロジェクト: dgolovin/cdt-java
    /** @return immediately calculated value or null if async calculation has been started */
    private String calculateValue(final int requestNumber) {
      Optional<DialogLogic.PreviewContext> evaluatorOptional = previewContextValue.getValue();
      if (!evaluatorOptional.isNormal()) {
        return ""; //$NON-NLS-1$
      }
      DialogLogic.PreviewContext previewContext = evaluatorOptional.getNormal();
      Optional<DialogLogic.Expression> expressionOptional = parsedExpressionValue.getValue();
      if (!expressionOptional.isNormal()) {
        return ""; //$NON-NLS-1$
      }
      DialogLogic.Expression expression = expressionOptional.getNormal();
      Expression.PreviewCallback callback =
          new Expression.PreviewCallback() {
            @Override
            public void done(String message, String additionalWarning) {
              synchronized (monitor) {
                if (monitor.requestId != requestNumber) {
                  return;
                }
                monitor.currentValue = message;
                monitor.additionalWarning = additionalWarning;

                updater.reportChanged(CheckerResultProcessor.this);
                updater.reportChanged(warningSource);
                updater.updateAsync();
              }
            }
          };
      expression.doPreview(previewContext, callback);
      return null;
    }
コード例 #2
0
ファイル: DialogLogic.java プロジェクト: dgolovin/cdt-java
    @Override
    public void run() {
      Expression.SetCallback callback =
          new Expression.SetCallback() {
            @Override
            public void done(final String errorMessage) {
              if (errorMessage == null) {
                if (addWatchExpression) {
                  IExpressionManager expressionManager =
                      DebugPlugin.getDefault().getExpressionManager();
                  IWatchExpression watchExpression =
                      expressionManager.newWatchExpression(expression.getWatchExpression());
                  expressionManager.addExpression(watchExpression);
                }
              } else {
                parentShell
                    .getDisplay()
                    .asyncExec(
                        new Runnable() {
                          @Override
                          public void run() {
                            MessageBox messageBox = new MessageBox(parentShell);
                            messageBox.setText(Messages.LogicImpl_RESULT_FAILURE_TITLE);
                            messageBox.setMessage(errorMessage);
                            messageBox.open();
                          }
                        });
              }
            }
          };

      expression.execute(previewContext, callback);
    }