Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.debug.ui.liveedit; | 5 package org.chromium.debug.ui.liveedit; |
| 6 | 6 |
| 7 import static org.chromium.debug.ui.DialogUtils.createConstant; | 7 import static org.chromium.debug.ui.DialogUtils.createConstant; |
| 8 import static org.chromium.debug.ui.DialogUtils.createErrorOptional; | 8 import static org.chromium.debug.ui.DialogUtils.createErrorOptional; |
| 9 import static org.chromium.debug.ui.DialogUtils.createOptional; | 9 import static org.chromium.debug.ui.DialogUtils.createOptional; |
| 10 import static org.chromium.debug.ui.DialogUtils.createProcessor; | 10 import static org.chromium.debug.ui.DialogUtils.createProcessor; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 import org.chromium.debug.ui.DialogUtils.ValueSource; | 34 import org.chromium.debug.ui.DialogUtils.ValueSource; |
| 35 import org.chromium.debug.ui.WizardUtils.LogicBasedWizard; | 35 import org.chromium.debug.ui.WizardUtils.LogicBasedWizard; |
| 36 import org.chromium.debug.ui.WizardUtils.NextPageEnabler; | 36 import org.chromium.debug.ui.WizardUtils.NextPageEnabler; |
| 37 import org.chromium.debug.ui.WizardUtils.PageElements; | 37 import org.chromium.debug.ui.WizardUtils.PageElements; |
| 38 import org.chromium.debug.ui.WizardUtils.PageImpl; | 38 import org.chromium.debug.ui.WizardUtils.PageImpl; |
| 39 import org.chromium.debug.ui.WizardUtils.PageListener; | 39 import org.chromium.debug.ui.WizardUtils.PageListener; |
| 40 import org.chromium.debug.ui.WizardUtils.WizardFinishController; | 40 import org.chromium.debug.ui.WizardUtils.WizardFinishController; |
| 41 import org.chromium.debug.ui.WizardUtils.WizardFinisher; | 41 import org.chromium.debug.ui.WizardUtils.WizardFinisher; |
| 42 import org.chromium.debug.ui.WizardUtils.WizardLogic; | 42 import org.chromium.debug.ui.WizardUtils.WizardLogic; |
| 43 import org.chromium.debug.ui.actions.ChooseVmControl; | 43 import org.chromium.debug.ui.actions.ChooseVmControl; |
| 44 import org.chromium.debug.ui.liveedit.LiveEditDiffViewer.Input; | |
| 44 import org.chromium.debug.ui.liveedit.PushChangesWizard.FinisherDelegate; | 45 import org.chromium.debug.ui.liveedit.PushChangesWizard.FinisherDelegate; |
| 46 import org.chromium.sdk.TextStreamPosition; | |
| 45 import org.chromium.sdk.UpdatableScript.ChangeDescription; | 47 import org.chromium.sdk.UpdatableScript.ChangeDescription; |
| 48 import org.chromium.sdk.UpdatableScript.CompileErrorFailure; | |
| 49 import org.eclipse.osgi.util.NLS; | |
| 46 | 50 |
| 47 /** | 51 /** |
| 48 * Creates Updater-based logic implementation of the wizard. It is responsible f or proper data | 52 * Creates Updater-based logic implementation of the wizard. It is responsible f or proper data |
| 49 * manipulation and view control updates. | 53 * manipulation and view control updates. |
| 50 * <p> | 54 * <p> |
| 51 * The wizard pages are arranged in graph with one fork:<br> | 55 * The wizard pages are arranged in graph with one fork:<br> |
| 52 * 'choose vm' -> | 56 * 'choose vm' -> |
| 53 * <ul> | 57 * <ul> |
| 54 * <li>[single vm path] -> 'textual preview' -> 'v8 preview' | 58 * <li>[single vm path] -> 'textual preview' -> 'v8 preview' |
| 55 * <li>[multiple vm path] -> 'multiple vm stub' | 59 * <li>[multiple vm path] -> 'multiple vm stub' |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 }); | 280 }); |
| 277 | 281 |
| 278 // Parses raw preview value and converts it into a form suitable for the vie wer; also handles | 282 // Parses raw preview value and converts it into a form suitable for the vie wer; also handles |
| 279 // errors that become warnings. | 283 // errors that become warnings. |
| 280 final ValueProcessor<Optional<? extends LiveEditDiffViewer.Input>> previewVa lue = | 284 final ValueProcessor<Optional<? extends LiveEditDiffViewer.Input>> previewVa lue = |
| 281 createProcessor(handleErrors( | 285 createProcessor(handleErrors( |
| 282 new NormalExpression<LiveEditDiffViewer.Input>() { | 286 new NormalExpression<LiveEditDiffViewer.Input>() { |
| 283 @Calculate | 287 @Calculate |
| 284 public Optional<? extends LiveEditDiffViewer.Input> calculate( | 288 public Optional<? extends LiveEditDiffViewer.Input> calculate( |
| 285 PreviewLoader.Data previewRawResultParam) { | 289 PreviewLoader.Data previewRawResultParam) { |
| 286 PushChangesPlan changesPlan = singlePlanValue.getValue(); | 290 final PushChangesPlan changesPlan = singlePlanValue.getValue(); |
| 287 ChangeDescription changeDescription = previewRawResultParam.getCha ngeDescription(); | 291 |
| 288 Optional<LiveEditDiffViewer.Input> result; | 292 return previewRawResultParam.accept( |
| 289 if (changeDescription == null) { | 293 new PreviewLoader.Data.Visitor<Optional<LiveEditDiffViewer.Inp ut>>() { |
| 290 result = createOptional(null); | 294 @Override |
| 291 } else { | 295 public Optional<LiveEditDiffViewer.Input> visitSuccess( |
| 292 try { | 296 ChangeDescription changeDescription) { |
| 297 if (changeDescription == null) { | |
| 298 return createOptional(null); | |
| 299 } else { | |
| 300 try { | |
| 301 LiveEditDiffViewer.Input viewerInput = | |
| 302 PushResultParser.createViewerInput(changeDescription, changesPlan, true); | |
| 303 return createOptional(viewerInput); | |
| 304 } catch (RuntimeException e) { | |
| 305 ChromiumDebugPlugin.log(e); | |
| 306 return createErrorOptional(new Message( | |
| 307 "Error in getting preview: " + e.toString(), MessagePr iority.WARNING)); | |
|
apavlov
2013/01/24 13:06:27
"Failed to create preview". Don't you want to i18n
Peter Rybin
2013/01/24 14:08:22
Done.
| |
| 308 } | |
| 309 } | |
| 310 } | |
| 311 | |
| 312 @Override | |
| 313 public Optional<Input> visitCompileError(CompileErrorFailure com pileError) { | |
| 293 LiveEditDiffViewer.Input viewerInput = | 314 LiveEditDiffViewer.Input viewerInput = |
| 294 PushResultParser.createViewerInput(changeDescription, chan gesPlan, true); | 315 PushResultParser.createCompileErrorViewerInput(compileErro r, changesPlan, |
| 295 result = createOptional(viewerInput); | 316 true); |
| 296 } catch (RuntimeException e) { | 317 return createOptional(viewerInput); |
| 297 ChromiumDebugPlugin.log(e); | |
| 298 result = createErrorOptional(new Message( | |
| 299 "Error in getting preview: " + e.toString(), MessagePriori ty.WARNING)); | |
| 300 } | 318 } |
| 301 } | 319 }); |
| 302 return result; | |
| 303 } | 320 } |
| 304 @DependencyGetter | 321 @DependencyGetter |
| 305 public ValueSource<Optional<PreviewLoader.Data>> | 322 public ValueSource<Optional<PreviewLoader.Data>> |
| 306 previewRawResultValueSource() { | 323 previewRawResultValueSource() { |
| 307 return previewRawResultValue; | 324 return previewRawResultValue; |
| 308 } | 325 } |
| 309 })); | 326 })); |
| 310 | 327 |
| 311 | 328 |
| 312 | 329 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 328 v8PreviewPage.getPageElements().getPreviewViewer().setInput(viewerInput) ; | 345 v8PreviewPage.getPageElements().getPreviewViewer().setInput(viewerInput) ; |
| 329 } | 346 } |
| 330 }; | 347 }; |
| 331 updater.addConsumer(scope, v8PreviewInputSetter); | 348 updater.addConsumer(scope, v8PreviewInputSetter); |
| 332 updater.addDependency(v8PreviewInputSetter, previewValue); | 349 updater.addDependency(v8PreviewInputSetter, previewValue); |
| 333 | 350 |
| 334 // A warning generator that collects them from v8 preview loader. | 351 // A warning generator that collects them from v8 preview loader. |
| 335 final ValueProcessor<Optional<Void>> warningValue = createProcessor( | 352 final ValueProcessor<Optional<Void>> warningValue = createProcessor( |
| 336 new Gettable<Optional<Void>>() { | 353 new Gettable<Optional<Void>>() { |
| 337 public Optional<Void> getValue() { | 354 public Optional<Void> getValue() { |
| 338 Optional<?> previewResult = previewValue.getValue(); | 355 Optional<PreviewLoader.Data> previewResult = previewRawResultValue.getVa lue(); |
| 339 if (previewResult.isNormal()) { | 356 if (previewResult.isNormal()) { |
| 340 return createOptional(null); | 357 PreviewLoader.Data data = previewResult.getNormal(); |
| 358 return data.accept(new PreviewLoader.Data.Visitor<Optional<Void>>() { | |
| 359 @Override public Optional<Void> visitSuccess(ChangeDescription chang eDescription) { | |
| 360 return createOptional(null); | |
| 361 } | |
| 362 @Override | |
| 363 public Optional<Void> visitCompileError(CompileErrorFailure compileE rror) { | |
| 364 TextStreamPosition start = compileError.getStartPosition(); | |
| 365 String messageString = NLS.bind("Compile error: {0} ({1}:{2})", | |
| 366 new Object[] { compileError.getCompilerMessage(), | |
| 367 start.getLine(), start.getColumn() }); | |
| 368 return createErrorOptional( | |
| 369 new Message (messageString, MessagePriority.BLOCKING_PROBLEM)) ; | |
|
apavlov
2013/01/24 13:06:27
stray whitespace before '('
Peter Rybin
2013/01/24 14:08:22
Done.
| |
| 370 } | |
| 371 }); | |
| 341 } else { | 372 } else { |
| 342 return createErrorOptional(previewResult.errorMessages()); | 373 return createErrorOptional(previewResult.errorMessages()); |
| 343 } | 374 } |
| 344 } | 375 } |
| 345 }); | 376 }); |
| 346 updater.addConsumer(scope, warningValue); | 377 updater.addConsumer(scope, warningValue); |
| 347 updater.addSource(scope, warningValue); | 378 updater.addSource(scope, warningValue); |
| 348 updater.addDependency(warningValue, previewValue); | 379 updater.addDependency(warningValue, previewRawResultValue); |
| 349 | 380 |
| 350 // A finisher delegate source, that does not actually depend on most of the code above. | 381 // A finisher delegate source, that does not actually depend on most of the code above. |
| 351 final ValueProcessor<? extends Optional<FinisherDelegate>> wizardFinisher = | 382 final ValueProcessor<? extends Optional<FinisherDelegate>> wizardFinisher = |
| 352 createProcessor(( | 383 createProcessor(( |
| 353 new Gettable<Optional<FinisherDelegate>>() { | 384 new Gettable<Optional<FinisherDelegate>>() { |
| 354 public Optional<FinisherDelegate> getValue() { | 385 public Optional<FinisherDelegate> getValue() { |
| 355 FinisherDelegate finisher = | 386 FinisherDelegate finisher = |
| 356 new PushChangesWizard.SingleVmFinisher(singlePlanValue.getValue( )); | 387 new PushChangesWizard.SingleVmFinisher(singlePlanValue.getValue( )); |
| 357 return createOptional(finisher); | 388 return createOptional(finisher); |
| 358 } | 389 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 public ValueSource<? extends Optional<? extends FinisherDelegate>> | 442 public ValueSource<? extends Optional<? extends FinisherDelegate>> |
| 412 getFinisherDelegateValue() { | 443 getFinisherDelegateValue() { |
| 413 return wizardFinisher; | 444 return wizardFinisher; |
| 414 } | 445 } |
| 415 public ValueSource<Optional<Void>> getWarningValue() { | 446 public ValueSource<Optional<Void>> getWarningValue() { |
| 416 return warningValue; | 447 return warningValue; |
| 417 } | 448 } |
| 418 }; | 449 }; |
| 419 } | 450 } |
| 420 } | 451 } |
| OLD | NEW |