Package org.chromium.debug.ui.DialogUtils

Examples of org.chromium.debug.ui.DialogUtils.Message


     * Builds PreviewContext from what was passed from the action. Takes into account
     * various problems that are returned as error value of {@link Optional}.
     */
    static Optional<PreviewContext> build(Value uiValue) {
      if (uiValue == null) {
        return createErrorOptional(new Message(Messages.LogicImpl_VALUE_IS_NOT_AVAILABLE,
                MessagePriority.BLOCKING_PROBLEM));
      }
      JsValue jsValue = uiValue.getJsValue();
      JsObject jsObject = jsValue.asObject();
      if (jsObject == null) {
        return createErrorOptional(
            new Message(Messages.LogicImpl_NOT_FOR_PRIMITIVE, MessagePriority.BLOCKING_PROBLEM));
      }

      DebugContext debugContext = uiValue.getSuspendedState().getDebugContext();
      // Unsafe asynchronous check.
      if (uiValue.getSuspendedState().isDismissed()) {
        return createErrorOptional(
            new Message(Messages.LogicImpl_CONTEXT_DISMISSED, MessagePriority.BLOCKING_PROBLEM));
      }
      JsEvaluateContext globalEvaluateContext = debugContext.getGlobalEvaluateContext();

      return createOptional(new PreviewContext(globalEvaluateContext, jsObject));
    }
View Full Code Here


   * It may be not very accurate working as JavaScript lexer.
   */
  private static class DotSeparatedExpression extends DialogLogic.Expression {
    static Optional<DialogLogic.Expression> parse(String string) {
      if (string.length() == 0) {
        return createErrorOptional(new Message(Messages.LogicImpl_ENTER_EXPRESSION,
            MessagePriority.BLOCKING_PROBLEM));
      }

      List<String> parts = new ArrayList<String>();
      int pos = 0;
      while (true) {
        if (pos >= string.length() || string.charAt(pos) != '.') {
          return createErrorOptional(new Message(Messages.LogicImpl_DOT_EXPECTED,
              MessagePriority.BLOCKING_PROBLEM));
        }
        pos++;
        int partStartPos = pos;
        if (pos >= string.length()) {
          return createErrorOptional(
              new Message(Messages.LogicImpl_ENTER_AFTER_DOT, MessagePriority.BLOCKING_INFO));
        }
        if (!Character.isJavaIdentifierStart(string.codePointAt(pos))) {
          return createErrorOptional(new Message(Messages.LogicImpl_INVALID_COMPONENT_START,
              MessagePriority.BLOCKING_PROBLEM));
        }
        pos = string.offsetByCodePoints(pos, 1);
        while (pos < string.length() && string.charAt(pos) != '.') {
          if (!Character.isJavaIdentifierPart(string.codePointAt(pos))) {
            return createErrorOptional(new Message(Messages.LogicImpl_INVALID_COMPONENT_CHAR,
                MessagePriority.BLOCKING_PROBLEM));
          }
          pos = string.offsetByCodePoints(pos, 1);
        }
        parts.add(string.substring(partStartPos, pos));
View Full Code Here

          try {
            PushChangesPlan plan = PushChangesPlan.create(mapping);
            optionalPlan = createOptional(plan);
          } catch (RuntimeException e) {
            // TODO: have more specific exception types to catch.
            optionalPlan = createErrorOptional(new Message(
                Messages.WizardLogicBuilder_FAILED_TO_GET,
                MessagePriority.BLOCKING_PROBLEM));
          }
          result.add(optionalPlan);
        }
        return result;
      }
    });
    updater.addSource(scope, selectedChangePlansValue);
    updater.addConsumer(scope, selectedChangePlansValue);
    updater.addDependency(selectedChangePlansValue, selectedVmInput);


    // A derived value of selected VMs list; the list is non-empty or the value is error.
    final ValueProcessor<? extends Optional<List<PushChangesPlan>>> nonEmptySelectedPlansValue =
        createProcessor(new Gettable<Optional<List<PushChangesPlan>>>() {
      public Optional<List<PushChangesPlan>> getValue() {
        List<Optional<PushChangesPlan>> planList = selectedChangePlansValue.getValue();
        if (planList.isEmpty()) {
          return createErrorOptional(
              new Message(Messages.WizardLogicBuilder_CHOOSE_VM, MessagePriority.BLOCKING_INFO));
        }
        List<Message> errorMessages = new LinkedList<Message>();
        List<PushChangesPlan> result = new ArrayList<PushChangesPlan>(planList.size());
        for (Optional<PushChangesPlan> optionalPlan : planList) {
          if (optionalPlan.isNormal()) {
View Full Code Here

                    } catch (RuntimeException e) {
                      ChromiumDebugPlugin.log(e);
                      String messageText =
                          NLS.bind(Messages.WizardLogicBuilder_ERROR_GETTING_PREVIEW, e.toString());
                      return createErrorOptional(
                          new Message(messageText, MessagePriority.WARNING));
                    }
                  }
                }

                @Override
                public Optional<Input> visitCompileError(CompileErrorFailure compileError) {
                  LiveEditDiffViewer.Input viewerInput =
                      PushResultParser.createCompileErrorViewerInput(compileError, changesPlan,
                          true);
                  return createOptional(viewerInput);
                }
              });
            }
            @DependencyGetter
            public ValueSource<Optional<PreviewLoader.Data>>
                previewRawResultValueSource() {
              return previewRawResultValue;
            }
          }));



    updater.addConsumer(scope, previewValue);
    updater.addSource(scope, previewValue);
    updater.addDependency(previewValue, previewRawResultValue);
    updater.addDependency(previewValue, singlePlanValue);

    // A simple consumer that sets preview data to the viewer.
    ValueConsumer v8PreviewInputSetter = new ValueConsumer() {
      public void update(Updater updater) {
        Optional<? extends LiveEditDiffViewer.Input> previewOptional = previewValue.getValue();
        LiveEditDiffViewer.Input viewerInput;
        if (previewOptional.isNormal()) {
          viewerInput = previewOptional.getNormal();
        } else {
          viewerInput = null;
        }
        v8PreviewPage.getPageElements().getPreviewViewer().setInput(viewerInput);
      }
    };
    updater.addConsumer(scope, v8PreviewInputSetter);
    updater.addDependency(v8PreviewInputSetter, previewValue);

    // A warning generator that collects them from v8 preview loader.
    final ValueProcessor<Optional<Void>> warningValue = createProcessor(
        new Gettable<Optional<Void>>() {
      public Optional<Void> getValue() {
        Optional<PreviewLoader.Data> previewResult = previewRawResultValue.getValue();
        if (previewResult.isNormal()) {
          PreviewLoader.Data data = previewResult.getNormal();
          return data.accept(new PreviewLoader.Data.Visitor<Optional<Void>>() {
            @Override public Optional<Void> visitSuccess(ChangeDescription changeDescription) {
              return createOptional(null);
            }
            @Override
            public Optional<Void> visitCompileError(CompileErrorFailure compileError) {
              TextStreamPosition start = compileError.getStartPosition();
              String messageString = NLS.bind(Messages.WizardLogicBuilder_COMPILE_ERROR_AT,
                  new Object[] { compileError.getCompilerMessage(),
                  start.getLine(), start.getColumn() });
              return createErrorOptional(
                  new Message(messageString, MessagePriority.BLOCKING_PROBLEM));
            }
          });
        } else {
          return createErrorOptional(previewResult.errorMessages());
        }
View Full Code Here

        Optional<Data> result = failure.accept(
            new UpdatableScript.Failure.Visitor<Optional<Data>>() {
          @Override
          public Optional<Data> visitUnspecified() {
            return createErrorOptional(
                new Message(NLS.bind(Messages.PreviewLoader_FAILED_TO_GET, message),
                    MessagePriority.WARNING));
          }

          @Override
          public Optional<Data> visitCompileError(final CompileErrorFailure compileError) {
View Full Code Here

        finisher = finisherValue.getValue().getNormal();
      } else {
        finisher = null;
        messages.addAll(finisherValue.getValue().errorMessages());
      }
      Message message = DialogUtils.chooseImportantMessage(messages);
      wizardImpl.setWizardFinisher(finisher, message);
    }
View Full Code Here

          try {
            PushChangesPlan plan = PushChangesPlan.create(mapping);
            optionalPlan = createOptional(plan);
          } catch (RuntimeException e) {
            // TODO: have more specific exception types to catch.
            optionalPlan = createErrorOptional(new Message(
                "Failed to get script source from a file. See log for details.",
                MessagePriority.BLOCKING_PROBLEM));
          }
          result.add(optionalPlan);
        }
        return result;
      }
    });
    updater.addSource(scope, selectedChangePlansValue);
    updater.addConsumer(scope, selectedChangePlansValue);
    updater.addDependency(selectedChangePlansValue, selectedVmInput);


    // A derived value of selected VMs list; the list is non-empty or the value is error.
    final ValueProcessor<? extends Optional<List<PushChangesPlan>>> nonEmptySelectedPlansValue =
        createProcessor(new Gettable<Optional<List<PushChangesPlan>>>() {
      public Optional<List<PushChangesPlan>> getValue() {
        List<Optional<PushChangesPlan>> planList = selectedChangePlansValue.getValue();
        if (planList.isEmpty()) {
          return createErrorOptional(
              new Message("Choose at least one VM", MessagePriority.BLOCKING_INFO));
        }
        List<Message> errorMessages = new LinkedList<Message>();
        List<PushChangesPlan> result = new ArrayList<PushChangesPlan>(planList.size());
        for (Optional<PushChangesPlan> optionalPlan : planList) {
          if (optionalPlan.isNormal()) {
View Full Code Here

                  LiveEditDiffViewer.Input viewerInput =
                      PushResultParser.createViewerInput(changeDescription, changesPlan, true);
                  result = createOptional(viewerInput);
                } catch (RuntimeException e) {
                  ChromiumDebugPlugin.log(e);
                  result = createErrorOptional(new Message(
                      "Error in getting preview: " + e.toString(), MessagePriority.WARNING));
                }
              }
              return result;
            }
View Full Code Here

      @Override
      protected Optional<String> calculateNormal() {
        String prefix = prefixEditor.getValue();
        Optional<String> result;
        if (prefix == null || prefix.length() == 0) {
          return createErrorOptional(new Message(
              Messages.SourceNameMapperContainerDialog_ENTER_PREFIX,
              MessagePriority.BLOCKING_INFO));
        } else {
          return createOptional(prefix);
        }
      }
    };
    updater.addSource(rootScope, prefixValue);
    updater.addConsumer(rootScope, prefixValue);
    updater.addDependency(prefixValue, prefixEditor);

    // Represents possible warning about prefix value having no trailing slash.
    ValueProcessor<String> noSlashWarning = new ValueProcessor<String>() {
      public void update(Updater updater) {
        Optional<String> prefix = prefixValue.getValue();
        String result;
        if (prefix.isNormal() && !prefix.getNormal().endsWith("/")) { //$NON-NLS-1$
          result = Messages.SourceNameMapperContainerDialog_PREFIX_NORMALLY_ENDS;
        } else {
          result = null;
        }
        setCurrentValue(result);
        updater.reportChanged(this);
      }
    };
    updater.addSource(rootScope, noSlashWarning);
    updater.addConsumer(rootScope, noSlashWarning);
    updater.addDependency(noSlashWarning, prefixValue);
    warningSources.add(noSlashWarning);

    // Represents prefix rule example printer.
    ValueConsumer prefixExample = new ValueConsumer() {
      public void update(Updater updater) {
        Optional<String> prefix = prefixValue.getValue();
        String line1;
        String line2;
        if (prefix.isNormal()) {
          String sampleFileName = Messages.SourceNameMapperContainerDialog_SAMPLE_FILE_NAME;
          line1 = NLS.bind(Messages.SourceNameMapperContainerDialog_EXAMPLE_1,
              prefix.getNormal() + sampleFileName);
          line2 = NLS.bind(Messages.SourceNameMapperContainerDialog_EXAMPLE_2, sampleFileName);
        } else {
          line1 = ""; //$NON-NLS-1$
          line2 = ""; //$NON-NLS-1$
        }
        elements.getPrefixExampleLine1Label().setText(line1);
        elements.getPrefixExampleLine2Label().setText(line2);
      }
    };
    updater.addConsumer(rootScope, prefixExample);
    updater.addDependency(prefixExample, prefixValue);

    // Represents container type combo box.
    final ValueSource<ISourceContainerType> selectedTypeValue =
        new ValueSource<ISourceContainerType>() {
      public ISourceContainerType getValue() {
        return elements.getContainerTypeCombo().getSelected();
      }
      {
        if (initialParams != null) {
          ISourceContainerType type = initialParams.getContainer().getType();
          elements.getContainerTypeCombo().setSelected(type);
        }
        final ValueSource<ISourceContainerType> updatableThis = this;
        SelectionListener listener = new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            updater.reportChanged(updatableThis);
            updater.update();
          }
        };
        elements.getContainerTypeCombo().addSelectionListener(listener);
      }
    };
    updater.addSource(rootScope, selectedTypeValue);

    // Represents "Configure" button that acts like a container factory.
    final ValueProcessor<ISourceContainer> containerFactoryButtonValue =
        new ValueProcessor<ISourceContainer>() {
      private ConfigureButtonAction preparedAction = null;
      {
        if (initialParams != null) {
          setCurrentValue(initialParams.getContainer());
        }
        final ValueSource<ISourceContainer> valueSourceThis = this;
        elements.getConfigureButton().addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (preparedAction != null) {
              ISourceContainer value = preparedAction.run(elements.getShell());
              if (value != null) {
                setCurrentValue(value);
              }
              updater.reportChanged(valueSourceThis);
              updater.update();
              updateAction();
            }
          }
        });
      }
      public void update(Updater updater) {
        if (getValue() != null && !getValue().getType().equals(selectedTypeValue.getValue())) {
          setCurrentValue(null);
          updater.reportChanged(this);
        }
        updateAction();
      }
      private void updateAction() {
        preparedAction = SourceNameMapperContainerDialog.prepareConfigureAction(
            selectedTypeValue.getValue(), getValue(), director);
        elements.getConfigureButton().setEnabled(preparedAction != null);
      }
    };
    updater.addSource(rootScope, containerFactoryButtonValue);
    updater.addConsumer(rootScope, containerFactoryButtonValue);
    updater.addDependency(containerFactoryButtonValue, selectedTypeValue);

    // Represents printer that shows type and name of the created container.
    ValueConsumer showContainerTypeValue = new ValueConsumer() {
      public void update(Updater updater) {
        ISourceContainer container = containerFactoryButtonValue.getValue();
        String status;
        Image image;
        String name;
        boolean enabled;
        if (container == null) {
          status = Messages.SourceNameMapperContainerDialog_NOTHING_CONFIGURED;
          name = ""; //$NON-NLS-1$
          image = null;
          enabled = false;
        } else {
          status = Messages.SourceNameMapperContainerDialog_CONFIGURED_CONTAINER;
          ISourceContainerType type = container.getType();
          name = container.getName();
          image = DebugUITools.getSourceContainerImage(type.getId());
          enabled = true;
        }
        ContainerStatusGroup group = elements.getContainerStatusGroup();
        group.getStatusLabel().setText(status);
        group.getTypeImageLabel().setImage(image);
        group.getContainerNameLabel().setText(name);
        group.setEnabled(enabled);
        group.layout();
      }
    };
    updater.addConsumer(rootScope, showContainerTypeValue);
    updater.addDependency(showContainerTypeValue, containerFactoryButtonValue);

    // Represents possible warning about unsupported container.
    ValueProcessor<String> unsupportedContainerWarning = createProcessor(new Gettable<String>() {
      @Override
      public String getValue() {
        ISourceContainer container = containerFactoryButtonValue.getValue();
        if (container == null) {
          return null;
        }
        if (ReverseSourceLookup.isGoodTargetContainer(container)) {
          return null;
        }
        return Messages.SourceNameMapperContainerDialogLogic_TARGET_CONTAINER_NOT_SUPPORTED0;
      }
    });
    updater.addSource(rootScope, unsupportedContainerWarning);
    updater.addConsumer(rootScope, unsupportedContainerWarning);
    updater.addDependency(unsupportedContainerWarning, containerFactoryButtonValue);
    warningSources.add(unsupportedContainerWarning);

    // Represents expression that constructs dialog window result.
    final ValueProcessor<? extends Optional<Result>> resultValue =
        new ExpressionProcessor<Result>(
            Arrays.<ValueSource<? extends Optional<?>>>asList(prefixValue) ) {
          @Override
          protected Optional<Result> calculateNormal() {
            final String prefix = prefixValue.getValue().getNormal();
            final ISourceContainer container = containerFactoryButtonValue.getValue();
            if (container == null) {
              return createErrorOptional(
                  new Message(Messages.SourceNameMapperContainerDialog_CONFIGURE_TARGET_CONTAINER,
                      MessagePriority.BLOCKING_INFO));
            }
            Result result = new Result() {
              public ISourceContainer getResultContainer() {
                return container;
View Full Code Here

    updater.reportChanged(this);

    UpdatableScript.UpdateCallback callback = new UpdatableScript.UpdateCallback() {
      public void failure(String message) {
        Optional<Data> error = createErrorOptional(
            new Message(NLS.bind(Messages.PreviewLoader_FAILED_TO_GET, message),
                MessagePriority.WARNING));
        done(error);
      }
      public void success(Object report,
          final UpdatableScript.ChangeDescription changeDescription) {
View Full Code Here

TOP

Related Classes of org.chromium.debug.ui.DialogUtils.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.